| Summary: | Can't create a dialog box with OpenGL active | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Sam Lantinga <slouken> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 1.2 | ||
| Hardware: | x86 | ||
| OS: | Windows (All) | ||
| Attachments: |
Test case
fixes for Windows based backends |
||
|
Description
Sam Lantinga
2006-03-13 19:15:32 UTC
Created attachment 78 [details]
Test case
(In reply to comment #0) > FlushMessageQueue() after the DestroyWindow() call at the end of > Init_WGL_ARB_extensions(). This is probably the best approach. > Is there any good reason NOT to just use this existing DC? Yes, once you've set an OpenGL context on the window in some drivers, you can't re-set different basic attributes of the context. (In reply to comment #2) > > > Is there any good reason NOT to just use this existing DC? > > Yes, once you've set an OpenGL context on the window in some drivers, you can't > re-set different basic attributes of the context. > OK, I didn't know that - thanks. I have traced this sample code on MSVC and found out the cause of the issue. I noticed, that the SDL window was not being displayed until MessageBox() had been called. What this means is, although SDL called CreateWindow() to open the main app window, it doesn't actually do it until something runs the message loop. In this case, it happens to be the message loop inside MessageBox(), which is task modal and therefore runs its own message loop. This obviously dislikes having to handle SDL's message stuff, and fails. Modify the sample so that it calls SDL_PumpEvents() after SDL_SetVideoMode(). Then the second assert appears just fine. The fix is that every time SDL calls functions to do with window opening/closing or any function that will result in window messages being generated, it needs to run the message loop to actually make them happen. In the SDL_dx5video.c code, there is a FlushMessageQueue() function which does just that. It's being called when the window is destroyed but not when it's been created. Similar patches will be needed in the windib driver. I will try and add these but please bear with me - I don't really know how to use CVS and diff as I'm 90% a Windows guy who doesn't touch these tools. Created attachment 79 [details]
fixes for Windows based backends
Some patches that should fix the issues
Your fix (slightly tweaked) is in CVS, thanks! (In reply to comment #6) > Your fix (slightly tweaked) is in CVS, thanks! > I've just tested CVS on my set of machines - works great! My evil FlushMessageQueue() function will one day rule the earth! Ha-Ha! There was already FlushMessageQueue() in the SDL drivers. It was being called when a window was destroyed, presumably someone found that if you don't do a message queue pump, it doesnt close the window and Bad Things Happen. The same applies when you open a window or change its settings, these all cause window messages to be issued and *none* of them will execute until the message loop runs. So therefore, the message loop needs to be pumped after extensive window wrangling has taken place when initing/changing video mode |