OpenGL/MFC: Losing dialog controls?


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?


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).]

Wouldn’t that prevent any other messages from getting through, though?

You could use a timer…

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).

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).]