[Change] Use desktops resolution if fullscreen mode is set without specifying dimensions.
This commit is contained in:
parent
169e9da1aa
commit
a4b17c561c
17
src/conf.c
17
src/conf.c
@ -100,6 +100,7 @@ int conf_loadConfig(const char* file) {
|
|||||||
double d = 0.;
|
double d = 0.;
|
||||||
char* str, *mod;
|
char* str, *mod;
|
||||||
int type, key, reverse;
|
int type, key, reverse;
|
||||||
|
int w, h;
|
||||||
SDLMod m;
|
SDLMod m;
|
||||||
|
|
||||||
lua_State* L = llua_newState();
|
lua_State* L = llua_newState();
|
||||||
@ -109,8 +110,18 @@ int conf_loadConfig(const char* file) {
|
|||||||
conf_loadString("data", data);
|
conf_loadString("data", data);
|
||||||
|
|
||||||
/* OpenGL properties.. */
|
/* OpenGL properties.. */
|
||||||
conf_loadInt("width", gl_screen.w);
|
w = h = 0;
|
||||||
conf_loadInt("height", gl_screen.h);
|
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);
|
conf_loadBool("fullscreen", i);
|
||||||
if(i) { gl_screen.flags |= OPENGL_FULLSCREEN; i = 0; }
|
if(i) { gl_screen.flags |= OPENGL_FULLSCREEN; i = 0; }
|
||||||
conf_loadBool("aa", i);
|
conf_loadBool("aa", i);
|
||||||
@ -279,9 +290,11 @@ void conf_parseCLI(int argc, char** argv) {
|
|||||||
break;
|
break;
|
||||||
case 'W':
|
case 'W':
|
||||||
gl_screen.w = atoi(optarg);
|
gl_screen.w = atoi(optarg);
|
||||||
|
gl_screen.flags |= OPENGL_DIM_DEF;
|
||||||
break;
|
break;
|
||||||
case 'H':
|
case 'H':
|
||||||
gl_screen.h = atoi(optarg);
|
gl_screen.h = atoi(optarg);
|
||||||
|
gl_screen.flags |= OPENGL_DIM_DEF;
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
nosound = 1;
|
nosound = 1;
|
||||||
|
11
src/opengl.c
11
src/opengl.c
@ -1,5 +1,6 @@
|
|||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <SDL/SDL_image.h>
|
#include <SDL/SDL_image.h>
|
||||||
|
#include "SDL_version.h"
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include <freetype/freetype.h>
|
#include <freetype/freetype.h>
|
||||||
@ -874,8 +875,16 @@ int gl_init(void) {
|
|||||||
if(gl_has(OPENGL_VSYNC))
|
if(gl_has(OPENGL_VSYNC))
|
||||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
|
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, 1);
|
||||||
|
|
||||||
/* Get available fullscreen modes. */
|
|
||||||
if(gl_has(OPENGL_FULLSCREEN)) {
|
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);
|
modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
|
||||||
if(modes == NULL) { /* Could happen, but rare. */
|
if(modes == NULL) { /* Could happen, but rare. */
|
||||||
WARN("No fullscreen modes available");
|
WARN("No fullscreen modes available");
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#define OPENGL_VSYNC (1<<5) /**< Sync to monitor vertical refresh rate. */
|
#define OPENGL_VSYNC (1<<5) /**< Sync to monitor vertical refresh rate. */
|
||||||
#define OPENGL_FRAG_SHADER (1<<6) /**< Fragment shaders. */
|
#define OPENGL_FRAG_SHADER (1<<6) /**< Fragment shaders. */
|
||||||
#define OPENGL_VERT_SHADER (1<<7) /**< Vertex 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. */
|
#define gl_has(f) (gl_screen.flags & (f)) /**< Check for the flag. */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user