mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 18:50:47 +00:00
Support for turning vsync on and off
git-svn-id: https://svn.eduke32.com/eduke32@889 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
0f607b70dd
commit
d8ae04d773
9 changed files with 70 additions and 5 deletions
|
@ -16,6 +16,8 @@ extern const char **_buildargv;
|
|||
|
||||
extern char quitevent, appactive;
|
||||
|
||||
extern int vsync;
|
||||
|
||||
// NOTE: these are implemented in game-land so they may be overridden in game specific ways
|
||||
extern int startwin_open(void);
|
||||
extern int startwin_close(void);
|
||||
|
@ -55,9 +57,11 @@ struct glinfo {
|
|||
char multitex;
|
||||
char envcombine;
|
||||
char vbos;
|
||||
char vsync;
|
||||
char dumped;
|
||||
};
|
||||
extern struct glinfo glinfo;
|
||||
extern void setvsync(int sync);
|
||||
#endif
|
||||
|
||||
extern char inputdevices;
|
||||
|
|
|
@ -220,6 +220,7 @@ extern int (WINAPI * bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR*);
|
|||
extern int (WINAPI * bwglDescribePixelFormat)(HDC,int,UINT,LPPIXELFORMATDESCRIPTOR);
|
||||
extern int (WINAPI * bwglGetPixelFormat)(HDC);
|
||||
extern BOOL (WINAPI * bwglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*);
|
||||
extern BOOL (WINAPI * bwglSwapIntervalEXT)(int);
|
||||
#endif
|
||||
|
||||
#endif //USE_OPENGL
|
||||
|
|
|
@ -42,6 +42,7 @@ struct glinfo glinfo =
|
|||
0, // multitexturing
|
||||
0, // env_combine
|
||||
0, // Vertex Buffer Objects
|
||||
0, // VSync support
|
||||
0, // GL info dumped
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -186,6 +186,7 @@ int (WINAPI * bwglChoosePixelFormat)(HDC,CONST PIXELFORMATDESCRIPTOR*);
|
|||
int (WINAPI * bwglDescribePixelFormat)(HDC,int,UINT,LPPIXELFORMATDESCRIPTOR);
|
||||
int (WINAPI * bwglGetPixelFormat)(HDC);
|
||||
BOOL (WINAPI * bwglSetPixelFormat)(HDC,int,const PIXELFORMATDESCRIPTOR*);
|
||||
BOOL (WINAPI * bwglSwapIntervalEXT)(int);
|
||||
|
||||
static HANDLE hGLDLL, hGLUDLL;
|
||||
#else
|
||||
|
@ -423,6 +424,9 @@ int loadglextensions(void)
|
|||
bglGetQueryObjectivARB = GETPROCEXTSOFT("glGetQueryObjectivARB");
|
||||
bglGetQueryObjectuivARB = GETPROCEXTSOFT("glGetQueryObjectuivARB");
|
||||
|
||||
#ifdef RENDERTYPEWIN
|
||||
bwglSwapIntervalEXT = GETPROCEXTSOFT("wglSwapIntervalEXT");
|
||||
#endif
|
||||
return err;
|
||||
}
|
||||
|
||||
|
@ -586,6 +590,7 @@ int unloadgldriver(void)
|
|||
bwglDescribePixelFormat = NULL;
|
||||
bwglGetPixelFormat = NULL;
|
||||
bwglSetPixelFormat = NULL;
|
||||
bwglSwapIntervalEXT = NULL;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -177,7 +177,7 @@ int r_parallaxskypanning = 0;
|
|||
// line of sight checks before mddraw()
|
||||
int r_cullobstructedmodels = 0;
|
||||
#define CULL_DELAY 5
|
||||
#define CULL_OFFSET 256
|
||||
#define CULL_OFFSET 384
|
||||
|
||||
// fullbright cvar
|
||||
int r_fullbrights = 1;
|
||||
|
@ -5974,6 +5974,12 @@ static int osdcmd_polymostvars(const osdfuncparm_t *parm)
|
|||
else r_fullbrights = (val != 0);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
else if (!Bstrcasecmp(parm->name, "r_swapinterval"))
|
||||
{
|
||||
if (showval) { OSD_Printf("r_swapinterval is %d\n", vsync); }
|
||||
else vsync = (val != 0);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
#endif
|
||||
return OSDCMD_SHOWHELP;
|
||||
}
|
||||
|
@ -6026,6 +6032,7 @@ void polymost_initosdfuncs(void)
|
|||
OSD_RegisterFunction("r_polygonmode","r_polygonmode: debugging feature",osdcmd_polymostvars); //FUK
|
||||
OSD_RegisterFunction("r_redbluemode","r_redbluemode: enable/disable experimental OpenGL red-blue glasses mode",osdcmd_polymostvars);
|
||||
OSD_RegisterFunction("r_shadescale","r_shadescale: multiplier for lighting",osdcmd_polymostvars);
|
||||
OSD_RegisterFunction("r_swapinterval","r_swapinterval: sets the GL swap interval (VSync)",osdcmd_polymostvars);
|
||||
OSD_RegisterFunction("r_texcachecompression","r_texcachecompression: enable/disable compression of files in the OpenGL compressed texture cache",osdcmd_polymostvars);
|
||||
OSD_RegisterFunction("r_texcache","r_texcache: enable/disable OpenGL compressed texture cache",osdcmd_polymostvars);
|
||||
OSD_RegisterFunction("r_texcompr","r_texcompr: enable/disable OpenGL texture compression",osdcmd_polymostvars);
|
||||
|
|
|
@ -61,6 +61,7 @@ extern int curbrightness, gammabrightness;
|
|||
// OpenGL stuff
|
||||
static char nogl=0;
|
||||
#endif
|
||||
int vsync=1;
|
||||
|
||||
// input
|
||||
char inputdevices=0;
|
||||
|
@ -205,6 +206,15 @@ int main(int argc, char *argv[])
|
|||
return r;
|
||||
}
|
||||
|
||||
#if defined(USE_OPENGL) && defined(POLYMOST)
|
||||
void setvsync(int sync)
|
||||
{
|
||||
vsync = sync;
|
||||
resetvideomode();
|
||||
if (setgamemode(fullscreen,xdim,ydim,bpp))
|
||||
OSD_Printf("restartvid: Reset failed...\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// initsystem() -- init SDL systems
|
||||
|
@ -967,6 +977,8 @@ int setvideomode(int x, int y, int c, int fs)
|
|||
SDL_GL_SetAttribute(attributes[i].attr, j);
|
||||
}
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, vsync);
|
||||
|
||||
sdl_surface = SDL_SetVideoMode(x, y, c, SDL_OPENGL | ((fs&1)?SDL_FULLSCREEN:0));
|
||||
if (!sdl_surface)
|
||||
{
|
||||
|
|
|
@ -116,7 +116,7 @@ char offscreenrendering=0;
|
|||
int glcolourdepth=32;
|
||||
char videomodereset = 0;
|
||||
char silentvideomodeswitch = 0;
|
||||
|
||||
int vsync=1;
|
||||
// input and events
|
||||
char inputdevices=0;
|
||||
char quitevent=0, appactive=1, realfs=0, regrabmouse=0;
|
||||
|
@ -2065,6 +2065,11 @@ int checkvideomode(int *x, int *y, int c, int fs, int forced)
|
|||
//
|
||||
// setvideomode() -- set the video mode
|
||||
//
|
||||
|
||||
#if defined(USE_OPENGL) && defined(POLYMOST)
|
||||
static HWND hGLWindow = NULL;
|
||||
#endif
|
||||
|
||||
int setvideomode(int x, int y, int c, int fs)
|
||||
{
|
||||
char i,inp[NUM_INPUTS];
|
||||
|
@ -2109,6 +2114,9 @@ int setvideomode(int x, int y, int c, int fs)
|
|||
if (gammabrightness && setgamma() < 0) gammabrightness = 0;
|
||||
}
|
||||
|
||||
#if defined(USE_OPENGL) && defined(POLYMOST)
|
||||
if (hGLWindow && glinfo.vsync) bwglSwapIntervalEXT(vsync);
|
||||
#endif
|
||||
for (i=0;i<NUM_INPUTS;i++) if (inp[i]) AcquireInputDevices(1,i);
|
||||
modechange=1;
|
||||
videomodereset = 0;
|
||||
|
@ -2135,6 +2143,17 @@ int setvideomode(int x, int y, int c, int fs)
|
|||
#define CHECK(w,h) if ((w < maxx) && (h < maxy))
|
||||
|
||||
#if defined(USE_OPENGL) && defined(POLYMOST)
|
||||
void setvsync(int sync)
|
||||
{
|
||||
if (!glinfo.vsync)
|
||||
{
|
||||
vsync = 0;
|
||||
return;
|
||||
}
|
||||
vsync = sync;
|
||||
bwglSwapIntervalEXT(sync);
|
||||
}
|
||||
|
||||
static void cdsenummodes(void)
|
||||
{
|
||||
DEVMODE dm;
|
||||
|
@ -3108,8 +3127,6 @@ static int SetupDIB(int width, int height)
|
|||
// ReleaseOpenGL() -- cleans up OpenGL rendering stuff
|
||||
//
|
||||
|
||||
static HWND hGLWindow = NULL;
|
||||
|
||||
static void ReleaseOpenGL(void)
|
||||
{
|
||||
if (hGLRC)
|
||||
|
@ -3324,6 +3341,10 @@ static int SetupOpenGL(int width, int height, int bitspp)
|
|||
{
|
||||
glinfo.vbos = 1;
|
||||
}
|
||||
else if (!Bstrcmp((char *)p2, "WGL_EXT_swap_control"))
|
||||
{
|
||||
glinfo.vsync = 1;
|
||||
}
|
||||
}
|
||||
Bfree(p);
|
||||
}
|
||||
|
|
|
@ -692,6 +692,8 @@ int32 CONFIG_ReadSetup(void)
|
|||
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", &r_vbos);
|
||||
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", &r_vbocount);
|
||||
|
||||
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLVSync", &vsync);
|
||||
|
||||
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing", &r_animsmoothing);
|
||||
|
||||
SCRIPT_GetNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping", &r_parallaxskyclamping);
|
||||
|
@ -902,6 +904,8 @@ void CONFIG_WriteSetup(void)
|
|||
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOs", r_vbos,false,false);
|
||||
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVBOCount", r_vbocount,false,false);
|
||||
|
||||
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLVSync", vsync,false,false);
|
||||
|
||||
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLAnimationSmoothing",r_animsmoothing,false,false);
|
||||
|
||||
SCRIPT_PutNumber(ud.config.scripthandle, "Screen Setup", "GLParallaxSkyClamping",r_parallaxskyclamping,false,false);
|
||||
|
|
|
@ -2441,7 +2441,7 @@ cheat_for_port_credits:
|
|||
"Use models",
|
||||
"Blend model animations",
|
||||
"-",
|
||||
"-",
|
||||
"Enable VSync",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -2551,6 +2551,16 @@ cheat_for_port_credits:
|
|||
if (enabled) modval(0,1,(int *)&r_animsmoothing,1,probey==io);
|
||||
mgametextpal(d,yy, r_animsmoothing && enabled ? "Yes" : "No", enabled?MENUHIGHLIGHT(io):DISABLEDMENUSHADE, 0);
|
||||
break;
|
||||
case 11:
|
||||
{
|
||||
int ovsync = vsync;
|
||||
if (x==io) vsync = !vsync;
|
||||
modval(0,1,(int *)&vsync,1,probey==io);
|
||||
mgametextpal(d,yy, vsync? "Yes" : "No", MENUHIGHLIGHT(io), 0);
|
||||
if (vsync != ovsync)
|
||||
setvsync(vsync);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue