View Full Version : how to use several ogl control?
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.
03-02-2007, 04:34 AM
You need to call wglMakeCurrent(..) to set the control you want to render to. Google it :)
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.
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.
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.
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.
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.