OpenGL in a portion of a dialog box
-
I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?
-
I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?
I would create a picture control inside the dialog and assign a CStatic control variable to it, say m_cPic. Then in OnInitDialog you can get a DC for the picture control and assign this DC to the OpenGL rendering context. Something like HDC hdc = m_cPic.GetDC()->GetSafeHdc(); wglMakeCurrent(hdc, hGLRC); // hGLRC is handle to the OpenGL rendering context This approach worked for me before.
-
I would create a picture control inside the dialog and assign a CStatic control variable to it, say m_cPic. Then in OnInitDialog you can get a DC for the picture control and assign this DC to the OpenGL rendering context. Something like HDC hdc = m_cPic.GetDC()->GetSafeHdc(); wglMakeCurrent(hdc, hGLRC); // hGLRC is handle to the OpenGL rendering context This approach worked for me before.
Thanks I'll give it a go. Is any special cleanup necessary if you use this approach?
-
Thanks I'll give it a go. Is any special cleanup necessary if you use this approach?
You should release the device context hdc using ::ReleaseDC API function
-
I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?
ComboController wrote: A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC? You window gets its OnPaint() first because its at the back of the TAB or window order. The OK/Cancel buttons gets theirs after the dialogs OnPaint(), so they would appear over your scene. On a second not, when your added your own OnPaint() function for your dialog, you would have seen a comment such as:
// DO NOT CALL base Class OnPaint()
This is a bad thing to do, as the CDC parameter passed through to the OnPaint() handler gets setup in some way by the system, so what your doing could crash/corrupt things. If you can, see if you can avoid calling the base class function in this way. Roger Allen Sonork 100.10016 Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003 -
I have created a dialog that is rendered into by an OpenGL RC. Now that I have that going I'd like to be able to add a few control variables. What I'd like to do is set OpenGL to only render into a portion of the dialog..... I was wondering how I'd go about this, do I have to create another window in the dialog? If so, what type is appropriate, I'm only getting started with MFC. A quick aside, in my OnPaint() I call the base OnPaint() function and THEN render my scene, yet the OK and CANCEL buttons still get painted. Shouldn't they be painted over by RC?
There is a lot of stuff in there to help you. http://pws.prserv.net/mfcogl/ Mykel Everything's beautiful if you look at it long enough...