Jump to content
  • Advertisement
Sign in to follow this  
Milquetoasty

Toggling Window/Fullscreen For W32 OGL App

This topic is 4311 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

I am making a method to toggle fullscreen/windowed mode. Right now I am doing something like:
change window/extended window style [setwindowlongptr]

if changing to fullscreen
       find appropriate display settings [enumdisplaysettings]
       change to appropriate display setting [changedisplaysettings]
otherwise
       revert to previous display settings

frame changed [setwindowpos - framechanged]
set foreground window [setforegroundwindow]
This does not appear to be working, though none of the API's fail. It changes the device, but my window seems 'dead', in that it's on the taskbar but I can't click it or make it show. So, is this method even reasonable? Do I have to recreate the window, rendering contexts, pixel format, etc. like as NeHe's does?

Share this post


Link to post
Share on other sites
Advertisement
Your plan seems okay, but your actual implementation may be the problem. Please post the relevant code so we can see what's going on a little better. Thanks.

Share this post


Link to post
Share on other sites
I know this is funky but I'm gonna post a repo-link to a small compilable test project ;)

svn co https://pokepong.svn.sourceforge.net/svnroot/pokepong/checkitoutlocalcheckitout
http://pokepong.svn.sourceforge.net/viewvc/pokepong/checkitout/COpenGLWindow.cpp?revision=44&view=markup

Main content includes makeFullscreen (and related, initialize and destroy), which seems to not actually change the window to fullscreen. Right now, I just create and destroy the rendering context, and device context before and after changing to fullscreen.

I could simplify it more if you anybody wants, and takes the effort to say it.

Share this post


Link to post
Share on other sites
Update: program can now go from starting in fullscreen mode to windowed mode, however, it can not go from windowed mode to fullscreen mode properly.

svn co https://pokepong.svn.sourceforge.net/svnroot/pokepong/checkitout localcheckitout
http://pokepong.svn.sourceforge.net/viewvc/pokepong/checkitout/

Share this post


Link to post
Share on other sites
Basically, here's a dialog I have with my program.

// Hey program you should start up.

CWindowClassEx::CWindowClassEx // RegisterClass
CWindow::CWindow // Initializes members. Calls setup
CWindow::setup // CreateWindow
COpenGLWindow::COpenGLWindow // Initializes members, base

COpenGLWindow::makeFullscreen // Works this first time it is called!
CWindow::destroy // DestroyWindow
// Enum/ChangeDisplaySettings
CWindow::setup // CreateWindow
COpenGLWindow::setup // GetDC, Choose/SetPixelFormat, wglCreateContext/wglMakeCurrent, glClearColor, glClearDepth

COpenGLWindow::toggleFullscreen // I now go to windowed mode
COpenGLWindow::killFullscreen // Works going into windowed mode!
COpenGLWindow::destroy // wglMakeCurrent/wglDeleteContext, ReleaseDC
CWindow::destroy // DestroyWindow
CWindow::setup // CreateWindow
COpenGLWindow::setup // GetDC, Choose/SetPixelFormat, wglCreateContext/wglMakeCurrent, glClearColor, glClearDepth

COpenGLWindow::toggleFullscreen // I now go to fullscreen from windowed mode
COpenGLWindow::makeFullscreen // Does not work, changes resolution, but is not a black opengl screen I can draw to
COpenGLWindow::destroy // wglMakeCurrent/wglDeleteContext, ReleaseDC
CWindow::destroy // DestroyWindow
CWindow::setup // CreateWindow
COpenGLWindow::setup // GetDC, Choose/SetPixelFormat, wglCreateContext/wglMakeCurrent, glClearColor, glClearDepth

COpenGLWindow::~COpenGLWindow
COpenGLWindow::killFullscreen
COpenGLWindow::destroy
CWindow::~CWindow
CWindow::destroy
CWindowClassEx::~CWindowClassEx


It should be noted that I extensively error check like, everything, so I don't know what is going wrong. This problem is so confusing.

http://pokepong.svn.sourceforge.net/viewvc/pokepong/checkitout/
svn co https://pokepong.svn.sourceforge.net/svnroot/pokepong/checkitout localcheckitout

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!