🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

SDL_SetWindowDisplayMode problem

Started by
0 comments, last by howie_007 9 years, 6 months ago

I'm builing an engine around SLD2 and I've been working on the code to allow for changing the resolution and full screen mode. Everything works fine except for changing the resolution while in full screen mode. It seems like SDL_SetWindowDisplayMode doesn't works unless it is done in combination with a change to full screen mode.

*I can make this work if I force it back out of full screen mode and then back in again and the resolution change while in full screen then works. This is an odd way to handle it.


if( resChanged )
{
    if( oldFullScreenState && fullScreenState )
        CDevice::Instance().SetFullScreen( 0 );

    if( fullScreenState )
    {
        SDL_DisplayMode mode;
        SDL_GetCurrentDisplayMode(0, &mode);

        mode.w = CSettings::Instance().GetSize().GetW();
        mode.h = CSettings::Instance().GetSize().GetH();

        if( SDL_SetWindowDisplayMode( CDevice::Instance().GetWindow(), &mode ) < 0 )
            NGenFunc::PostDebugMsg( boost::str( boost::format("Warning: Unable to set display mode! SDL GL Error: %s\n") % SDL_GetError() ) );
    }
    else
    {
        SDL_SetWindowSize(
            CDevice::Instance().GetWindow(),
            CSettings::Instance().GetSize().GetW(),
            CSettings::Instance().GetSize().GetH() );

        SDL_SetWindowPosition(
            CDevice::Instance().GetWindow(),
            SDL_WINDOWPOS_CENTERED,
            SDL_WINDOWPOS_CENTERED );
    }

    if( fullScreenChanged || fullScreenState )
        CDevice::Instance().SetFullScreen( fullScreenState );

    // Reset the world transform to recalculate mouse collision
    CMenuManager::Instance().ResetWorldTransform();

    // Need to reset the view port the changing the resolution
    glViewport(0, 0, CSettings::Instance().GetSize().GetW(), CSettings::Instance().GetSize().GetH());
}
Advertisement

Never mind. I just learned SDL doesn't allow resolution change while in full screen mode. Bah!

This topic is closed to new replies.

Advertisement