PBuffer and Fullscreen switching

Hi all,

i used Nehe “Class Basecode” to begin an application, then included my Pbuffer class, and what a surprise, all content of pbuffer is lost after switching to fullscreen, or rolling back… in fact app runs, but screen becoms white, and i’m sure i didnt loose OpenGl Context… have u the same problem ?

I tried to shutdown my pbuffer and recreate it after the switch, but it’s the same !

I dont understand what happen when switching to fullscreen…

thanx !

You switched resolutions while you have OpenGL running? That is generally not safe to do, although it might work in some implementations.
Switch your resolution before you choose/enumerate the pixelformat and back after you’ve destoyed the window. This guarantees that you never have selected pixelformats which may not be the ones available in the “other” resolution.

To do resolution switching without destroying to context,window and etc. is extremely dangerous and might have undefined results…

OpenGL garantuees the survival of certain objects across resolution switches, such as textures and display lists. PBuffers however is not garantueed to survive, that’s why there’s a query to check whether the PBuffer was lost. If it’s lost, you need to recreate it.

We switch resolution while having active GL context/contexts. We also use pbuffers. Aside from miscellaneous driver bugs (from many vendors), it works fine. We do lose the buffers, and use the query to know when to re-establish the buffer.

If you want to save the data out of the buffer across a context switch, use ReadPixels or CopyTexSubImage, as appropriate.

From the extension registry (ie. As Jon said…)

  1. The pixel buffer might be lost if a display mode change occurs. A query is provided that can be called after a display mode change to determine the state of the pixel buffer.


The frame buffer resources that are associated with a pbuffer are also static and are deallocated when the pbuffer is destroyed or possibly when a display mode change occurs.

Basically shutting down your pbuffer after the switch would cause you problems (because it doesn’t exist) - you need to query it’s existence and recreate it if it’s been lost.

[This message has been edited by rgpc (edited 04-30-2003).]

Ok, thanks a lot guys,

i’m doing right things in correct order now i think

But there is still another problem: I use simultaneously 2 Pbuffers. All is ok in 20482048, but when i use 10241024 (or 20481024 and not in 10242048), all is ok in windowed mode, but “random” parts of screen are not refreshed in fullscreen mode ! I think it depends on Zbuffer because refresh of those stranges parts depends on depth of current pixel, and all works well when Zbuffer is switched off…

i use 32 bpp, 16b zbuffer… and when i come back to windowed mode (same init, just a flag is changed) all works well again…

strange no ?