PDA

View Full Version : How to at any time change a OGL into fullscreen?



尘羽泯
08-07-2011, 05:31 AM
Sorry,I am a programmer who is a Chinese. I cannot speak English very well.I hope you can understand me.

My question is:In win32,How to at any time change a OGL into fullscreen?

I saw Nehe's lesson,use ChangeDisplaySettings to change window into fullscreen.But if need at any time to change it,need to killwindow then createwindow.But that result the texture cannot show.

This is Nehe's lesson code.


if (keys[VK_F1])
{
keys[VK_F1]=FALSE;
KillGLWindow();
fullscreen=!fullscreen;
if (!CreateGLWindow("Nehe's OpenGL ",640,480,16,fullscreen))
{
return 0;
}
}

Though it can at any time change a OGL into fullscreen,texture that created before killwindow cannot show in new window.

Have any other ways to at any time change a OGL into fullscreen,isn't have?

V-man
08-07-2011, 06:59 AM
But that result the texture cannot show.


Recreate the texture.

尘羽泯
08-07-2011, 07:05 AM
Bad idea...
Any other ways?..

BionicBytes
08-07-2011, 01:52 PM
Why is deleting and creating a new texture bad.
That is the only way.

Alfonse Reinheart
08-07-2011, 02:04 PM
Why is deleting and creating a new texture bad.

Is that a serious question? Are you seriously asking someone why they find having to reload all of their loaded assets bad?

In any case, the NeHe code does full-screening by destroying and rebuilding the window. It's entirely possible to simply resize and reposition the window, then use the DEVMODE stuff in the NeHe code to resize the screen.

mhagain
08-07-2011, 02:09 PM
Bad idea...
Any other ways?..

If you destroy the window you also destroy the OpenGL context that goes with it. Textures are a part of the context, so they must be recreated. The same goes for VBOs, display lists, program and shader objects, etc.

BionicBytes
08-07-2011, 04:08 PM
Is that a serious question? Are you seriously asking someone why they find having to reload all of their loaded assets bad?
Nobody mentioned tones of textures....only one. I was just asking why it was a problem for just 1 texture. If recreating the texture works and takes less time than researching the utopia solution then it's good enough. Time saved could be spent doing something more useful.

Alfonse Reinheart
08-07-2011, 05:56 PM
He never said it was just one texture. It's quite an assumption to assume that the only application he would ever write would use one texture. Remember: he's learning, so his initial applications aren't necessarily indicative of what he may eventually write.