[Change] Use desktops resolution if fullscreen mode is set without specifying dimensions.

This commit is contained in:
Allanis 2014-03-04 02:25:08 +00:00
parent 169e9da1aa
commit a4b17c561c
3 changed files with 26 additions and 3 deletions

View File

@ -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;

View File

@ -1,5 +1,6 @@
#include <SDL/SDL.h>
#include <SDL/SDL_image.h>
#include "SDL_version.h"
#include <png.h>
#include <ft2build.h>
#include <freetype/freetype.h>
@ -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");

View File

@ -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. */
/**