mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-10 22:33:58 +00:00
[client] opengl: added preventBuffer option
This commit is contained in:
parent
f4b95eeda9
commit
133d8ec21f
2 changed files with 64 additions and 20 deletions
|
@ -45,6 +45,7 @@ struct Options
|
|||
{
|
||||
bool mipmap;
|
||||
bool vsync;
|
||||
bool preventBuffer;
|
||||
bool splitMouse;
|
||||
};
|
||||
|
||||
|
@ -52,6 +53,7 @@ static struct Options defaultOptions =
|
|||
{
|
||||
.mipmap = true,
|
||||
.vsync = true,
|
||||
.preventBuffer = true,
|
||||
.splitMouse = false
|
||||
};
|
||||
|
||||
|
@ -700,6 +702,8 @@ bool lgr_opengl_basic_render(void * opaque)
|
|||
if (this->fpsTexture)
|
||||
glCallList(this->fpsList);
|
||||
|
||||
if (this->opt.preventBuffer)
|
||||
{
|
||||
unsigned int before, after;
|
||||
glXGetVideoSyncSGI(&before);
|
||||
SDL_GL_SwapWindow(this->sdlWindow);
|
||||
|
@ -708,6 +712,9 @@ bool lgr_opengl_basic_render(void * opaque)
|
|||
glXGetVideoSyncSGI(&after);
|
||||
if (before == after)
|
||||
glXWaitVideoSyncSGI(1, 0, &before);
|
||||
}
|
||||
else
|
||||
SDL_GL_SwapWindow(this->sdlWindow);
|
||||
|
||||
++this->frameCount;
|
||||
const uint64_t t = nanotime();
|
||||
|
@ -738,6 +745,15 @@ static void handle_opt_vsync(void * opaque, const char *value)
|
|||
this->opt.vsync = LG_RendererValueToBool(value);
|
||||
}
|
||||
|
||||
static void handle_opt_prevent_buffer(void * opaque, const char *value)
|
||||
{
|
||||
struct LGR_OpenGLBasic * this = (struct LGR_OpenGLBasic *)opaque;
|
||||
if (!this)
|
||||
return;
|
||||
|
||||
this->opt.preventBuffer = LG_RendererValueToBool(value);
|
||||
}
|
||||
|
||||
static void handle_opt_split_mouse(void * opaque, const char *value)
|
||||
{
|
||||
struct LGR_OpenGLBasic * this = (struct LGR_OpenGLBasic *)opaque;
|
||||
|
@ -761,6 +777,12 @@ static LG_RendererOpt lgr_opengl_basic_options[] =
|
|||
.validator = LG_RendererValidatorBool,
|
||||
.handler = handle_opt_vsync
|
||||
},
|
||||
{
|
||||
.name = "preventBuffer",
|
||||
.desc = "Prevent the driver from buffering frames [default: enabled]",
|
||||
.validator = LG_RendererValidatorBool,
|
||||
.handler = handle_opt_prevent_buffer
|
||||
},
|
||||
{
|
||||
.name = "splitMouse",
|
||||
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
|
||||
|
|
|
@ -47,6 +47,7 @@ struct Options
|
|||
{
|
||||
bool mipmap;
|
||||
bool vsync;
|
||||
bool preventBuffer;
|
||||
bool splitMouse;
|
||||
};
|
||||
|
||||
|
@ -54,6 +55,7 @@ static struct Options defaultOptions =
|
|||
{
|
||||
.mipmap = true,
|
||||
.vsync = true,
|
||||
.preventBuffer = true,
|
||||
.splitMouse = false
|
||||
};
|
||||
|
||||
|
@ -764,14 +766,19 @@ bool lgr_opengl_render(void * opaque)
|
|||
if (this->fpsTexture)
|
||||
glCallList(this->fpsList);
|
||||
|
||||
if (this->opt.preventBuffer)
|
||||
{
|
||||
unsigned int before, after;
|
||||
glXGetVideoSyncSGI(&before);
|
||||
SDL_GL_SwapWindow(this->sdlWindow);
|
||||
|
||||
// wait for the swap to happen to ensure we dont buffer frames
|
||||
// wait for the swap to happen to ensure we dont buffer frames //
|
||||
glXGetVideoSyncSGI(&after);
|
||||
if (before == after)
|
||||
glXWaitVideoSyncSGI(1, 0, &before);
|
||||
}
|
||||
else
|
||||
SDL_GL_SwapWindow(this->sdlWindow);
|
||||
|
||||
++this->frameCount;
|
||||
const uint64_t t = nanotime();
|
||||
|
@ -802,6 +809,15 @@ static void handle_opt_vsync(void * opaque, const char *value)
|
|||
this->opt.vsync = LG_RendererValueToBool(value);
|
||||
}
|
||||
|
||||
static void handle_opt_prevent_buffer(void * opaque, const char *value)
|
||||
{
|
||||
struct LGR_OpenGL * this = (struct LGR_OpenGL *)opaque;
|
||||
if (!this)
|
||||
return;
|
||||
|
||||
this->opt.preventBuffer = LG_RendererValueToBool(value);
|
||||
}
|
||||
|
||||
static void handle_opt_split_mouse(void * opaque, const char *value)
|
||||
{
|
||||
struct LGR_OpenGL * this = (struct LGR_OpenGL *)opaque;
|
||||
|
@ -825,6 +841,12 @@ static LG_RendererOpt lgr_opengl_options[] =
|
|||
.validator = LG_RendererValidatorBool,
|
||||
.handler = handle_opt_vsync
|
||||
},
|
||||
{
|
||||
.name = "preventBuffer",
|
||||
.desc = "Prevent the driver from buffering frames [default: enabled]",
|
||||
.validator = LG_RendererValidatorBool,
|
||||
.handler = handle_opt_prevent_buffer
|
||||
},
|
||||
{
|
||||
.name = "splitMouse",
|
||||
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
|
||||
|
|
Loading…
Reference in a new issue