When REcreating OpenGL, SetPixelFormat fails
To switch screen modes or rendering APIs in my engine, the entire window is destroyed and OpenGL/Direct3D uninitialized. Then a new window is created, and OpenGL or Direct3D is initialized with the new display settings.
However, I cannot recreate OpenGL because SetPixelFormat returns FALSE. The DC is retrieved from the newly created window, so it is not the problem. And SetPixelFormat fails even if the pixel format is exactly the same as before -- recreating OpenGL without changing the display mode still prevents SetPixelFormat from succeeding.
I can initialize and re-initialize Direct3D as many times as I like, but not OpenGL, not even if I use OpenGL, switch to Direct3D, then try to go back to OpenGL. Any ideas why this is happening?
~CGameProgrammer( );
~CGameProgrammer( );
Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
February 12, 2001 02:21 PM
The NeHe tutorials works this way. Perhaps are you forgetting to destroy something?
February 16, 2001 05:11 PM
Try to destroy DC (Device context) and obtain new one befor Pixelformat setup
![](wink.gif)
I did that. Actually, I finally solved the problem, and it had nothing to do with OpenGL or Windows at all, but simply had to do with class destructors. My OpenGL class was derived from a base Renderer class, and since creating an instance of a class calls both its parent''s constructor and its own, I assumed the same was true of destructors. But apparently it isn''t; I needed to make the destructor virtual.
~CGameProgrammer( );
~CGameProgrammer( );
~CGameProgrammer( );
Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement