MessageBox won't work with OpenGL

For some reason, I have been unable to get any kind of standard message/dialog box to work with my OpenGL windowed app. The application is a straight Win32 API application (no GLUT, SDL, etc). Any time I try to bring up any kind of common dialog (MessageBox, ChooseColor, assert(false), etc), I get "First Chance Exception"s (several of them), no dialog appears, and basically the program is hosed and has to be terminated.

Any ideas? They would be greatly appreciated!
Mac

When you display any window in front of your GL window the pixels under the message box will fail the pixel ownership test. However, I have only seen it create problems when using glReadPixels on the “inactive” framebuffer. Are you using glReadPixels?

As a general rule, do not draw to or read the framebuffer when the window is inactive. If this is unacceptable to you, use an off-screen buffer(pbuffer).

Many, many thank you’s!

I am not using glReadPixels, but rendering to an inactive window was my problem. I have animations running in the background (driven either by timers or by sound buffers completing), and that meant that I was rendering to inactive windows. I didn’t realize that was a problem.

I’ve protected the render code with a “is window active” check, and the dialogs are working fine now.

Thanks again!
Mac

Hi!

I have another question about Messageboxes that are displayed in front of the rendering window. I must say, that I am a beginner and didn’t find any solution on the net: When I display a messagebox in front of the main window, where I render the scene, and move the messagebox, the messagebox is drawn again and again as I move it and covers the content of the background window. What do I have to do to prevent this? Currently I am using no MFC, just WIN32.

thanks,
Steve

Originally posted by steve_j:
[b]Hi!

the messagebox is drawn again and again as I move it and covers the content of the background window. [/b]
If you’re not updating the background window it will get “overwritten”. And updating an inactive window is not recommended as I explained in the previous post.

It also appears that using the CS_OWNDC class style (used in RegisterClass – not a window style used in CreateWindow) helps this problem.

I found an update to the OpenGL SuperBible that talked about the importance of using CS_OWNDC, so I tried it out. The update mentioned that some OpenGL drivers behaved incorrectly if the window did not have this style set (Win32 OpenGL was originally for Windows NT, and it is apparently impossible to make a window under Windows NT that doesn’t use CS_OWNDC). After I had included the CS_OWNDC flag, I was able to open dialogs just fine.

I think it may have improved my framerate by around 10% as well, but I could just be mis-remembering the “before” speed…

Mac

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.