View Full Version : OpenGL/MFC: Losing dialog controls?

06-25-2003, 09:59 AM

I am attempting to render an OpenGL scene into an object in a dialog box. However, as you may well know, by default this only renders the scene once, making animation impossible.

The workaround that was suggested to me first was Invalidate(FALSE) along with returning a TRUE value in the OnEraseBkgnd() handler. While this method does animate my 3D scene correctly, it causes my dialog controls (currently just a few buttons) to not be rendered on resize or restore.

There are several other methods that I've read about to do what I need...some use counters, others seem to rely on ShowWindow(SW_SHOW).

What method would you suggest, and how can I implement it? How exactly would I use a counter in an event-based system?


06-25-2003, 08:46 PM
I don't know much about MFC.But basically,once you can use getDC() to get the hdc of that dialog handle.then use wglMakeCurrent to register this hdc (maybe you need to do some other registration stuff,check out the red book and nehe tutorial for more detail , and start a thread include a loop like while(true) to draw gl scene ,you might include swapbuffer something.

[This message has been edited by RunningRabbit (edited 06-25-2003).]

06-26-2003, 03:17 AM
Wouldn't that prevent any other messages from getting through, though?

06-26-2003, 03:53 AM
You could use a timer...

06-26-2003, 06:28 AM
Ok, I used SetTimer(1,1,NULL) and in OnTimer I call Invalidate(FALSE).

It seems to be working. Are there any negative effects of using this method that anyone can think of (other than a theoretical limit on max FPS; ~30fps should be fine for my application).

06-26-2003, 06:20 PM
Invalidate(NULL) pull down the performance a lot.

In MFC ,every application has OnIdle() method which is called in the winmain message loop.
CWinApp::OnIdle(). Overload this method and repaint the GLscene in this method

[This message has been edited by RunningRabbit (edited 06-27-2003).]