mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-13 07:58:04 +00:00
Fix the vsync menu option so that it actually works.
Variables at global scope which share a name tend to actually be the same variable. Not good when you pass such a variable to function that immediately returns if the passed parameter (the variable) equals said variable (itself). git-svn-id: https://svn.eduke32.com/eduke32@4090 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4bc5f5cbc7
commit
d738fb7ad5
7 changed files with 43 additions and 11 deletions
|
@ -102,6 +102,7 @@ extern int32_t qsetmode;
|
||||||
|
|
||||||
int32_t initsystem(void);
|
int32_t initsystem(void);
|
||||||
void uninitsystem(void);
|
void uninitsystem(void);
|
||||||
|
void system_getcvars(void);
|
||||||
|
|
||||||
extern int32_t flushlogwindow;
|
extern int32_t flushlogwindow;
|
||||||
void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2)));
|
void initprintf(const char *, ...) ATTRIBUTE((format(printf,1,2)));
|
||||||
|
|
|
@ -686,6 +686,8 @@ int32_t app_main(int32_t argc, const char **argv)
|
||||||
// executed once per init, but after setgamemode so that OSD has the right width
|
// executed once per init, but after setgamemode so that OSD has the right width
|
||||||
OSD_Exec("m32_autoexec.cfg");
|
OSD_Exec("m32_autoexec.cfg");
|
||||||
|
|
||||||
|
system_getcvars();
|
||||||
|
|
||||||
overheadeditor();
|
overheadeditor();
|
||||||
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
keystatus[buildkeys[BK_MODE2D_3D]] = 0;
|
||||||
|
|
||||||
|
@ -710,6 +712,8 @@ int32_t app_main(int32_t argc, const char **argv)
|
||||||
// executed once per init, but after setgamemode so that OSD has the right width
|
// executed once per init, but after setgamemode so that OSD has the right width
|
||||||
OSD_Exec("m32_autoexec.cfg");
|
OSD_Exec("m32_autoexec.cfg");
|
||||||
|
|
||||||
|
system_getcvars();
|
||||||
|
|
||||||
setbrightness(GAMMA_CALC,0,0);
|
setbrightness(GAMMA_CALC,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10036,6 +10036,8 @@ skip_reading_mapbin:
|
||||||
append_ext_UNSAFE(fn, ".cfg");
|
append_ext_UNSAFE(fn, ".cfg");
|
||||||
|
|
||||||
OSD_Exec(fn);
|
OSD_Exec(fn);
|
||||||
|
|
||||||
|
system_getcvars();
|
||||||
}
|
}
|
||||||
|
|
||||||
return finish_loadboard(dapos, dacursectnum, numsprites, myflags);
|
return finish_loadboard(dapos, dacursectnum, numsprites, myflags);
|
||||||
|
|
|
@ -91,6 +91,7 @@ extern char textfont[2048], smalltextfont[2048];
|
||||||
|
|
||||||
int32_t rendmode=0;
|
int32_t rendmode=0;
|
||||||
int32_t usemodels=1, usehightile=1;
|
int32_t usemodels=1, usehightile=1;
|
||||||
|
int32_t vsync=0;
|
||||||
|
|
||||||
#include <math.h> //<-important!
|
#include <math.h> //<-important!
|
||||||
typedef struct { float x, cy[2], fy[2]; int32_t tag; int16_t n, p, ctag, ftag; } vsptyp;
|
typedef struct { float x, cy[2], fy[2]; int32_t tag; int16_t n, p, ctag, ftag; } vsptyp;
|
||||||
|
|
|
@ -89,7 +89,7 @@ extern int32_t curbrightness, gammabrightness;
|
||||||
// OpenGL stuff
|
// OpenGL stuff
|
||||||
char nogl=0;
|
char nogl=0;
|
||||||
#endif
|
#endif
|
||||||
int32_t vsync=0;
|
static int32_t vsync_render=0;
|
||||||
|
|
||||||
// last gamma, contrast, brightness
|
// last gamma, contrast, brightness
|
||||||
static float lastvidgcb[3];
|
static float lastvidgcb[3];
|
||||||
|
@ -273,11 +273,16 @@ int32_t main(int32_t argc, char *argv[])
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
void setvsync(int32_t sync)
|
void setvsync(int32_t sync)
|
||||||
{
|
{
|
||||||
if (vsync == sync) return;
|
if (vsync_render == sync) return;
|
||||||
vsync = sync;
|
vsync_render = sync;
|
||||||
|
# if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
|
||||||
resetvideomode();
|
resetvideomode();
|
||||||
if (setgamemode(fullscreen,xdim,ydim,bpp))
|
if (setgamemode(fullscreen,xdim,ydim,bpp))
|
||||||
OSD_Printf("restartvid: Reset failed...\n");
|
OSD_Printf("restartvid: Reset failed...\n");
|
||||||
|
# else
|
||||||
|
if (sdl_context)
|
||||||
|
SDL_GL_SetSwapInterval(vsync_render);
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -472,6 +477,15 @@ void uninitsystem(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// system_getcvars() -- propagate any cvars that are read post-initialization
|
||||||
|
//
|
||||||
|
void system_getcvars(void)
|
||||||
|
{
|
||||||
|
setvsync(vsync);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// initprintf() -- prints a string to the intitialization window
|
// initprintf() -- prints a string to the intitialization window
|
||||||
//
|
//
|
||||||
|
@ -1337,7 +1351,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
{ SDL_GL_MULTISAMPLESAMPLES, glmultisample },
|
{ SDL_GL_MULTISAMPLESAMPLES, glmultisample },
|
||||||
{ SDL_GL_STENCIL_SIZE, 1 },
|
{ SDL_GL_STENCIL_SIZE, 1 },
|
||||||
# if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
|
# if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
|
||||||
{ SDL_GL_SWAP_CONTROL, vsync },
|
{ SDL_GL_SWAP_CONTROL, vsync_render },
|
||||||
# endif
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1368,7 +1382,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
so we have to create a new surface in a different format first
|
so we have to create a new surface in a different format first
|
||||||
to force the surface we WANT to be recreated instead of reused. */
|
to force the surface we WANT to be recreated instead of reused. */
|
||||||
# if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
|
# if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
|
||||||
if (vsync != ovsync)
|
if (vsync_render != ovsync)
|
||||||
{
|
{
|
||||||
if (sdl_surface)
|
if (sdl_surface)
|
||||||
{
|
{
|
||||||
|
@ -1376,7 +1390,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
sdl_surface = SDL_SetVideoMode(1, 1, 8, SDL_NOFRAME | SURFACE_FLAGS | ((fs&1)?SDL_FULLSCREEN:0));
|
sdl_surface = SDL_SetVideoMode(1, 1, 8, SDL_NOFRAME | SURFACE_FLAGS | ((fs&1)?SDL_FULLSCREEN:0));
|
||||||
SDL_FreeSurface(sdl_surface);
|
SDL_FreeSurface(sdl_surface);
|
||||||
}
|
}
|
||||||
ovsync = vsync;
|
ovsync = vsync_render;
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
|
@ -1411,7 +1425,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
destroy_window_resources();
|
destroy_window_resources();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
SDL_GL_SetSwapInterval(vsync);
|
SDL_GL_SetSwapInterval(vsync_render);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
|
@ -144,7 +144,7 @@ int32_t bpp=0;
|
||||||
int32_t bytesperline=0;
|
int32_t bytesperline=0;
|
||||||
int32_t lockcount=0;
|
int32_t lockcount=0;
|
||||||
int32_t glcolourdepth=32;
|
int32_t glcolourdepth=32;
|
||||||
int32_t vsync=0;
|
static int32_t vsync_render=0;
|
||||||
uint32_t maxrefreshfreq=60;
|
uint32_t maxrefreshfreq=60;
|
||||||
intptr_t frameplace=0;
|
intptr_t frameplace=0;
|
||||||
char modechange=1;
|
char modechange=1;
|
||||||
|
@ -615,6 +615,14 @@ void uninitsystem(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// system_getcvars() -- propagate any cvars that are read post-initialization
|
||||||
|
//
|
||||||
|
void system_getcvars(void)
|
||||||
|
{
|
||||||
|
setvsync(vsync);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// initprintf() -- prints a string to the intitialization window
|
// initprintf() -- prints a string to the intitialization window
|
||||||
//
|
//
|
||||||
|
@ -1703,7 +1711,7 @@ int32_t setvideomode(int32_t x, int32_t y, int32_t c, int32_t fs)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
if (hGLWindow && glinfo.vsync) bwglSwapIntervalEXT(vsync);
|
if (hGLWindow && glinfo.vsync) bwglSwapIntervalEXT(vsync_render);
|
||||||
#endif
|
#endif
|
||||||
if (inp) AcquireInputDevices(1);
|
if (inp) AcquireInputDevices(1);
|
||||||
modechange=1;
|
modechange=1;
|
||||||
|
@ -1735,10 +1743,10 @@ void setvsync(int32_t sync)
|
||||||
{
|
{
|
||||||
if (!glinfo.vsync)
|
if (!glinfo.vsync)
|
||||||
{
|
{
|
||||||
vsync = 0;
|
vsync_render = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
vsync = sync;
|
vsync_render = sync;
|
||||||
bwglSwapIntervalEXT(sync);
|
bwglSwapIntervalEXT(sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11643,6 +11643,8 @@ int32_t app_main(int32_t argc, const char **argv)
|
||||||
|
|
||||||
OSD_Exec("autoexec.cfg");
|
OSD_Exec("autoexec.cfg");
|
||||||
|
|
||||||
|
system_getcvars();
|
||||||
|
|
||||||
if (g_networkMode != NET_DEDICATED_SERVER)
|
if (g_networkMode != NET_DEDICATED_SERVER)
|
||||||
{
|
{
|
||||||
if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0)
|
if (setgamemode(ud.config.ScreenMode,ud.config.ScreenWidth,ud.config.ScreenHeight,ud.config.ScreenBPP) < 0)
|
||||||
|
|
Loading…
Reference in a new issue