PDA

View Full Version : Switching res on the fly w/ OpenGL on a PC



DJ Tricky S
09-29-2000, 07:15 PM
I am finishing up an OpenGL game (runs full screen) which allows the user to change the resolution in-game. There is a problem though; after switching resolutions, a couple of my textures appear to be corrupted. While you might think "of course they are, they are getting kicked around during the switch", I am taking every precaution to make sure that won't happen, and can't understand what is wrong. What I do when the user picks a new display setting is:

- destroy my gl render context and display context
- change the display setting via ChangeDisplaySettings()
- create a new display context from my enlarged window, and then a new render context from that
- set the current context
- delete all my textures via glDeleteTextures
- reload all textures from scratch
- continue on my merry way

It seems like this should work, but there will always be one or two textures that end up looking hosed after doing this. Does anyone have any ideas on what I might be doing wrong, or some sample code on a sure-fire way to switch resolutions on the fly?

mcraighead
09-29-2000, 10:16 PM
I'm not entirely clear on what you're doing...

You say you create a new context after the mode switch, but then you delete all the textures. However, because you deleted your original context, all your old textures were already deleted; you should just respecify them all.

You actually don't need to rebuild your context on a mode switch. This is the responsibility of the driver. You also don't need to respecify your textures. It still is a good idea in many cases to tear everything down, since it's the safest way to go about things, but it is by no means a requirement.

- Matt

DFrey
09-30-2000, 05:04 AM
I definately would destroy the old context when changing modes. Especially if the colordepth is to be changed. I know with my TNT, if I don't do that, all OpenGL functions appear to cease working and instead return immediately.

drakaza
09-30-2000, 04:37 PM
So basically you would only destroy the context if you want compatibility with the older cards, is that right?

I don't destroy it at all....I just resize the window and update my opengl dimension var's and do a ChangeDisplaySettings( ) and everything is fine on my TNT2 and Voodoo2. Takes about 250ms to do it....

But then again, if it causes problems on some cards...it would be worth the extra effort

DJ Tricky S
09-30-2000, 05:58 PM
This is what I ran into; switching without deleting & rebuilding my contexts, etc. would work on most newer cards but I found it didn't work on some older cards, so I'm trying to play it as safe as possible.