View Full Version : MessageBox won't work with OpenGL
03-10-2004, 07:05 PM
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!
03-12-2004, 02:38 PM
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).
03-12-2004, 03:34 PM
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.
03-24-2004, 09:41 AM
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.
03-24-2004, 01:41 PM
Originally posted by steve_j:
the messagebox is drawn again and again as I move it and covers the content of the background window. 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.
04-09-2004, 10:37 AM
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...
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.