Fix fullscreen resizing. It wasn't working properly.

This commit is contained in:
The Dax 2014-05-02 17:46:24 -04:00
parent f5b62ae364
commit 8ada7de18a

View file

@ -54,6 +54,9 @@ static SDL_Surface* g_Screen = NULL;
static bool g_ToggleFullScreenNextFrame = false; static bool g_ToggleFullScreenNextFrame = false;
static int g_QuitRequested = 0; static int g_QuitRequested = 0;
static int g_DesktopWidth = 0;
static int g_DesktopHeight = 0;
#if defined(MAEMO) || defined(PANDORA) #if defined(MAEMO) || defined(PANDORA)
#define EGL #define EGL
#include "EGL/egl.h" #include "EGL/egl.h"
@ -371,14 +374,21 @@ void ToggleFullScreenIfFlagSet() {
g_ToggleFullScreenNextFrame = false; g_ToggleFullScreenNextFrame = false;
#if 1 #if 1
pixel_xres = g_DesktopWidth;
pixel_yres = g_DesktopHeight;
dp_xres = (float)pixel_xres;
dp_yres = (float)pixel_yres;
int flags = g_Screen->flags; // Save the current flags in case toggling fails int flags = g_Screen->flags; // Save the current flags in case toggling fails
g_Screen = SDL_SetVideoMode(0, 0, 0, g_Screen->flags ^ SDL_FULLSCREEN); // Toggles FullScreen Mode g_Screen = SDL_SetVideoMode(g_DesktopWidth, g_DesktopHeight, 0, g_Screen->flags ^ SDL_FULLSCREEN); // Toggles FullScreen Mode
if (g_Screen == NULL) { if (g_Screen == NULL) {
g_Screen = SDL_SetVideoMode(0, 0, 0, flags); // If toggle FullScreen failed, then switch back g_Screen = SDL_SetVideoMode(0, 0, 0, flags); // If toggle FullScreen failed, then switch back
} }
if (g_Screen == NULL) { if (g_Screen == NULL) {
exit(1); // If you can't switch back for some reason, then epic fail exit(1); // If you can't switch back for some reason, then epic fail
} }
NativeResized();
#endif #endif
} }
} }
@ -420,6 +430,11 @@ int main(int argc, char *argv[]) {
return 1; return 1;
#endif #endif
// Get the video info before doing anything else, so we don't get skewed resolution results.
const SDL_VideoInfo* desktopVideoInfo = SDL_GetVideoInfo();
g_DesktopWidth = desktopVideoInfo->current_w;
g_DesktopHeight = desktopVideoInfo->current_h;
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);