Rendering context over multiple display settings

Suppose I create a window with an opengl rendering context in the usual way that you can find in almost every win32 opengl tutorial: create window, choose pixel format, set pixel format, create opengl rendering context, make it current. Suppose I now make a call to the win32 function ChangeDisplaySettings and change my display settings to something with say, a different color depth than before. Will the opengl graphics still display properly?

The reason I ask this question is because I did a small test where I enumerated the pixel formats of a single device context under two different display settings, and discovered that both the total count and types of pixel formats were different. This seems to indicate that pixel formats are dependent on display settings, and a questionable potential situation arises: it may be that I’ve set the pixel format of a device context to be a pixel format which, under different display settings, is no longer enumerated as a valid pixel format of that device context. Sounds like a bad situation.

After reading discussions on similar topics it seems the common answer is that win32 may “mess up things” when passing through some types of display changes. A common solution I see used is to simply destroy the entire window and recreate it whenever display settings change. However, through much reading of the win32 documentation, I haven’t found anything that discusses this issue at all, so I’m somewhat skeptical of “things might get messed up”. From my own (very simple) tests it appears to work fine, but of course this isn’t at all an indicator of behaviour across multiple systems.

Any help with this would be greatly appreciated.

You should destroy your rendering context and create new (and find new pixel format) after you changed display settings.
That also means you reload all textures and other resources. No workaround for this AFAIK.

Is there any possibility that wglShareLists can help avoid reloading all textures ?

Is there any possibility that wglShareLists can help avoid reloading all textures
I don’t think so.
First context is not valid anymore (or at least not reliable) after a call to ChangeDisplaySettings and you can’t create the other context before that call so there’s actually no point in time where both contexts exist and are valid.

(Edit: LOL - I just hit a round number of posts - 0x300, hehe)

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