Advertisement

When REcreating OpenGL, SetPixelFormat fails

Started by February 11, 2001 11:56 PM
2 comments, last by CGameProgrammer 24 years ago
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.
The NeHe tutorials works this way. Perhaps are you forgetting to destroy something?
Advertisement
Try to destroy DC (Device context) and obtain new one befor Pixelformat setup
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( ); 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