Reimplemented the 3 way 'F' toggle for psp size / double psp size / fullscreen in the SDL code path.

This commit is contained in:
wrenczes
2011-05-28 07:13:13 +00:00
parent 68cffde7de
commit 0476eaf5f3
+44 -14
View File
@@ -31,6 +31,15 @@
#define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT) #define ACTUAL_SCREEN_HEIGHT (SCREEN_HEIGHT)
#define ACTUAL_RATIO ((GLfloat)ACTUAL_SCREEN_WIDTH / (GLfloat)ACTUAL_SCREEN_HEIGHT) #define ACTUAL_RATIO ((GLfloat)ACTUAL_SCREEN_WIDTH / (GLfloat)ACTUAL_SCREEN_HEIGHT)
enum eDisplayMode
{
DisplayMode_lowRes = 0,
DisplayMode_hiRes,
DisplayMode_fullscreen
};
unsigned int gDisplayMode = DisplayMode_lowRes;
class SdlApp { class SdlApp {
public: /* For easy interfacing with JGE static functions */ public: /* For easy interfacing with JGE static functions */
bool Running; bool Running;
@@ -249,26 +258,47 @@ int JGEGetTime()
bool JGEToggleFullscreen() bool JGEToggleFullscreen()
{ {
//cycle between the display modes
++gDisplayMode;
if (gDisplayMode > DisplayMode_fullscreen)
gDisplayMode = DisplayMode_lowRes;
SDL_DisplayMode mode; SDL_DisplayMode mode;
SDL_GetCurrentDisplayMode(0, &mode); SDL_GetCurrentDisplayMode(0, &mode);
/* Do the physical mode switch */ int width = 0;
if (SDL_GetWindowFlags(g_SdlApp->window) & SDL_WINDOW_FULLSCREEN) { int height = 0;
if (SDL_SetWindowFullscreen(g_SdlApp->window, SDL_FALSE) < 0) {
return false; switch (gDisplayMode)
} {
// restore old position and size case DisplayMode_fullscreen:
SDL_SetWindowPosition(g_SdlApp->window, g_SdlApp->windowed_pos_x, g_SdlApp->windowed_pos_y);
SDL_SetWindowSize(g_SdlApp->window, g_SdlApp->windowed_w, g_SdlApp->windowed_h);
} else {
// backup old position and size
SDL_GetWindowSize(g_SdlApp->window, &g_SdlApp->windowed_w, &g_SdlApp->windowed_h);
SDL_GetWindowPosition(g_SdlApp->window, &g_SdlApp->windowed_pos_x, &g_SdlApp->windowed_pos_y);
SDL_SetWindowSize(g_SdlApp->window, mode.w, mode.h); SDL_SetWindowSize(g_SdlApp->window, mode.w, mode.h);
if (SDL_SetWindowFullscreen(g_SdlApp->window, SDL_TRUE) < 0) { return (SDL_SetWindowFullscreen(g_SdlApp->window, SDL_TRUE) == 0);
break;
case DisplayMode_hiRes:
width = SCREEN_WIDTH * 2;
height = SCREEN_HEIGHT * 2;
break;
case DisplayMode_lowRes:
default:
width = SCREEN_WIDTH;
height = SCREEN_HEIGHT;
break;
}
if (SDL_SetWindowFullscreen(g_SdlApp->window, SDL_FALSE) < 0)
{
return false; return false;
} }
}
int x = (mode.w - width) / 2;
int y = (mode.h - height) / 2;
SDL_SetWindowPosition(g_SdlApp->window, x, y);
SDL_SetWindowSize(g_SdlApp->window, width, height);
return true; return true;
} }