Jump to content
  • Advertisement
Sign in to follow this  
exorcist_bob

OpenGL switching between fullscreen and windowed

This topic is 4349 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, How can I switch between these two modes? The only way that I know of is destroy/recreate the window, since opengl requires some prelim stuff before window creation. Thanks, exorcist_bob

Share this post


Link to post
Share on other sites
Advertisement
Hmmmmm,Have you read the first Nehe tutorial? It has code that allows you to switch mode.

http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=01

Share this post


Link to post
Share on other sites
Quote:
Original post by exorcist_bob
At runtime. For instance I have it in windowed mode, and when I press F2, it switches to fullscreen and vice-versa.


That is what lesson one does, just take a look in the game loop and you would have seen it, because what it does is inside the gameloop it destroys the current window and creates a new one fast while switching screenmodes. After this the game continues with the new hDC/hGLRC. So you do have to kill your window first, but it switches immediately to the new fullscreen window.


if (keys[VK_F1]) // Is F1 Being Pressed?
{
keys[VK_F1]=FALSE; // If So Make Key FALSE
KillGLWindow(); // Kill Our Current Window
fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode

// Recreate Our OpenGL Window
if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
{
return 0; // Quit If Window Was Not Created
}
}


Greetings.

Share this post


Link to post
Share on other sites
if you are using Win32 for your windowing code and you don't change resolution you can just call the SetScreenMode() function (iirc, you might want to check that, it's in the NeHe code), you might want to change and update the window's style as well to gain/lose the window dectorations

Share this post


Link to post
Share on other sites
Quote:
Original post by Limitz
Quote:
Original post by exorcist_bob
At runtime. For instance I have it in windowed mode, and when I press F2, it switches to fullscreen and vice-versa.


That is what lesson one does, just take a look in the game loop and you would have seen it, because what it does is inside the gameloop it destroys the current window and creates a new one fast while switching screenmodes. After this the game continues with the new hDC/hGLRC. So you do have to kill your window first, but it switches immediately to the new fullscreen window.


if (keys[VK_F1]) // Is F1 Being Pressed?
{
keys[VK_F1]=FALSE; // If So Make Key FALSE
KillGLWindow(); // Kill Our Current Window
fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode

// Recreate Our OpenGL Window
if (!CreateGLWindow("NeHe's OpenGL Framework",640,480,16,fullscreen))
{
return 0; // Quit If Window Was Not Created
}
}


Greetings.


Whoa, I didn't even see that there. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!