PDA

View Full Version : how to use several ogl control?



wexuv
03-01-2007, 05:33 PM
i make a static control use ogl to render in mfc,but when i add at least two controls on a form view,it doesn't work correctly,just the last control do.what's the matter and how to resolve it? thanks a lot.
BTW:diffrent control use diffrent hwnd and use diffrent hdc of course.it's no problem when i use d3d9 to make this control.

Mikkel Gjoel
03-02-2007, 04:34 AM
You need to call wglMakeCurrent(..) to set the control you want to render to. Google it :)

k_szczech
03-02-2007, 06:42 AM
Since each control has it's own HWND and HDC you have to create separate rendering contexts (HGLRC) for both of them, and switch with wglMakeCurrent as Mikkel suggested.

wexuv
03-03-2007, 01:12 AM
i create separate rendering contexts(HGLRC) and call the funtion of wglMakeCurrent(m_hDC,m_hRC) before clearbuffer to render. but it's the same problem.

Flavious
03-03-2007, 04:33 PM
For what it's worth, you can actually create a single context for multiple windows (just call SetPixelFormat with each DC). You will be limited to a single pixel format tho.

Cheers

wexuv
03-05-2007, 06:20 PM
i see,before any ogl fun is called,wglMakeCurrent must be called because any switch in diffirent contexts can make error.for example, creating texture,etc. that's ok.thanks.

Flavious
03-05-2007, 07:00 PM
That seems right. However you can call wglShareLists to share resources among your contexts, if that's the trouble you're having.

Cheers