if (RequestFullScreen)
{
if (!IsFullScreen)
{
Result=SDL_SetWindowFullscreen(Window,VideoFlags);
if (Result != 0)
debugf( TEXT("SDL2: Couldn't switch into fullscreen mode (%ix%i): %s\n"), NewX, NewY,appFromAnsi(SDL_GetError()) );
else debugf( TEXT("SDL2: Switched into fullscreen mode (%ix%i)"), NewX, NewY);
}
Result=SDL_SetWindowDisplayMode(Window, &NewMode);
if (Result != 0)
debugf( TEXT("SDL2: Couldn't set resolution of (%ix%i): %s\n"), NewX, NewY,appFromAnsi(SDL_GetError()) );
else debugf( TEXT("SDL2: Set resolution of (%ix%i)"), NewX, NewY );
}
I also intend to make use of SDL_WINDOW_FULLSCREEN_DESKTOP because I am aware about the problems with fullscreen resolution changes, especially in Linux. Still I think a game needs the ability to change the resolution, so this would be nice if it would be working. Current problem with that is, that the resolution is virtually changed, so its running at requested resolution (like 1920x1080) but the real screen solution is unchanged like 1440x1050, in other words, I am only getting a virtual resolution of 1920 (I hope you know what I mean). To combine it with SDL_SetWindowSize didn't make any visible difference as well.
To change windowed size I am doing the following:
Code:
if (IsFullScreen)
{
Result=SDL_SetWindowFullscreen(Window,0);
if (Result != 0)
debugf( TEXT("SDL2: Couldn't switch into windowed mode (%ix%i): %s\n"), NewX, NewY,appFromAnsi(SDL_GetError()) );
else debugf( TEXT("SDL2: Switched into windowed mode (%ix%i): %s\n"), NewX, NewY,appFromAnsi(SDL_GetError()) );
}
SDL_SetWindowSize(Window,NewX,NewY);
debugf( TEXT("SDL2: Switched windowed mode to (%ix%i): %s\n"), NewX, NewY );
It changes the window size, but it doesn't resize the window. I am getting a window inside the previous window, so if I switch from lets say 1280x1024 to 1024x768 I am getting a 1024 window inside the former frame of 1280.
The code above is what I think the docs say how it works, but I changed this maybe a dozen of times already in various orders and variations without a single successful result.
Now I read about that SDL2 is having a couple of fullscreen problems, so I tried at first to update from 2.0.3 which I was still running to 2.0.4 stable.
However, in Linux 2.0.4 fails to create an OpenGL context entirely with 2.0.4 and in Windows I am still getting a context, but the resolution changes are not working anyway.
context creation looks like this currently:
Code:
if (SDL_GL_LoadLibrary(NULL) == -1)
{
appErrorf(TEXT("SDL_GL_LoadLibrary failed: %s"),appFromAnsi(SDL_GetError()));
}
As said, this works in Linux (OpenSuSE13.2 currently) with 2.0.3 flawlessly in 2.0.4 it fails creating a context. Doesn't matter if taking a prebuild package or building myself. Also tried various combinations and versions of context creation without any success.
When I switched to 2.0.4 latest dev version from mercurial it fails to init video mode directly, not even coming so far to fail with context creation.
Additionally to all these problems gamma settings fail entirely with
Quote:
Window doesn't have DirectColor visual
when trying to use SDL_SetWindowGammaRamp(Window, Ramp.red, Ramp.green, Ramp.blue ); and this code was working on some point definitely too with an older release (unfortunately didn't keep the old stuff, so can't say exactly which version).