From a4b17c561ccccdfa06390291d4654aea7c37af7b Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 4 Mar 2014 02:25:08 +0000 Subject: [PATCH] [Change] Use desktops resolution if fullscreen mode is set without specifying dimensions. --- src/conf.c | 17 +++++++++++++++-- src/opengl.c | 11 ++++++++++- src/opengl.h | 1 + 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/conf.c b/src/conf.c index 7a9031c..e8ce061 100644 --- a/src/conf.c +++ b/src/conf.c @@ -100,6 +100,7 @@ int conf_loadConfig(const char* file) { double d = 0.; char* str, *mod; int type, key, reverse; + int w, h; SDLMod m; lua_State* L = llua_newState(); @@ -109,8 +110,18 @@ int conf_loadConfig(const char* file) { conf_loadString("data", data); /* OpenGL properties.. */ - conf_loadInt("width", gl_screen.w); - conf_loadInt("height", gl_screen.h); + w = h = 0; + conf_loadInt("width", w); + conf_loadInt("height", h); + if(w != 0) { + gl_screen.flags |= OPENGL_DIM_DEF; + gl_screen.w = w; + } + if(h != 0) { + gl_screen.flags |= OPENGL_DIM_DEF; + gl_screen.h = h; + } + conf_loadBool("fullscreen", i); if(i) { gl_screen.flags |= OPENGL_FULLSCREEN; i = 0; } conf_loadBool("aa", i); @@ -279,9 +290,11 @@ void conf_parseCLI(int argc, char** argv) { break; case 'W': gl_screen.w = atoi(optarg); + gl_screen.flags |= OPENGL_DIM_DEF; break; case 'H': gl_screen.h = atoi(optarg); + gl_screen.flags |= OPENGL_DIM_DEF; break; case 'M': nosound = 1; diff --git a/src/opengl.c b/src/opengl.c index d45e665..48d9aed 100644 --- a/src/opengl.c +++ b/src/opengl.c @@ -1,5 +1,6 @@ #include #include +#include "SDL_version.h" #include #include #include @@ -874,8 +875,16 @@ int gl_init(void) { if(gl_has(OPENGL_VSYNC)) SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1); - /* Get available fullscreen modes. */ if(gl_has(OPENGL_FULLSCREEN)) { + /* Try to use desktop resolution if nothing is specifically set. */ +#if SDL_VERSION_ATLEAST(1,2,10) + if(!gl_has(OPENGL_DIM_DEF)) { + const SDL_VideoInfo* vidinfo = SDL_GetVideoInfo(); + gl_screen.w = vidinfo->current_w; + gl_screen.h = vidinfo->current_h; + } +#endif + /* Get available modes and see what we can use. */ modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN); if(modes == NULL) { /* Could happen, but rare. */ WARN("No fullscreen modes available"); diff --git a/src/opengl.h b/src/opengl.h index 477e3c0..5da345f 100644 --- a/src/opengl.h +++ b/src/opengl.h @@ -28,6 +28,7 @@ #define OPENGL_VSYNC (1<<5) /**< Sync to monitor vertical refresh rate. */ #define OPENGL_FRAG_SHADER (1<<6) /**< Fragment shaders. */ #define OPENGL_VERT_SHADER (1<<7) /**< Vertex shaders. */ +#define OPENGL_DIM_DEF (1<<8) /**< Dimensions specifically defined. */ #define gl_has(f) (gl_screen.flags & (f)) /**< Check for the flag. */ /**