[client] opengl: add splitmouse option

This feature was previously hardcoded enabled, it is now optional as
some hardware pipelines stall with the excessive flushes resulting in a
jumpy cursor. Default is disabled and may be re-enabled with
`-o opengl:splitmouse=1` or `-o opengl-basic:splitmouse=1` depending on
the renderer selected.
This commit is contained in:
Geoffrey McRae 2017-12-19 10:19:12 +11:00
parent 1f004472cc
commit c38e38d43d
2 changed files with 86 additions and 47 deletions

View File

@ -45,12 +45,14 @@ struct Options
{
bool mipmap;
bool vsync;
bool splitMouse;
};
static struct Options defaultOptions =
{
.mipmap = true,
.vsync = true
.vsync = true,
.splitMouse = false
};
struct LGR_OpenGLBasic
@ -659,6 +661,8 @@ bool lgr_opengl_basic_render(void * opaque)
}
if (this->opt.splitMouse)
{
if (!this->frameUpdate)
{
if (!this->mouseUpdate)
@ -685,6 +689,7 @@ bool lgr_opengl_basic_render(void * opaque)
this->lastMouseDraw = nanotime();
return true;
}
}
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
@ -733,6 +738,15 @@ static void handle_opt_vsync(void * opaque, const char *value)
this->opt.vsync = LG_RendererValueToBool(value);
}
static void handle_opt_split_mouse(void * opaque, const char *value)
{
struct LGR_OpenGLBasic * this = (struct LGR_OpenGLBasic *)opaque;
if (!this)
return;
this->opt.splitMouse = LG_RendererValueToBool(value);
}
static LG_RendererOpt lgr_opengl_basic_options[] =
{
{
@ -746,6 +760,12 @@ static LG_RendererOpt lgr_opengl_basic_options[] =
.desc ="Enable or disable vsync [default: enabled]",
.validator = LG_RendererValidatorBool,
.handler = handle_opt_vsync
},
{
.name = "splitMouse",
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
.validator = LG_RendererValidatorBool,
.handler = handle_opt_split_mouse
}
};

View File

@ -47,12 +47,14 @@ struct Options
{
bool mipmap;
bool vsync;
bool splitMouse;
};
static struct Options defaultOptions =
{
.mipmap = true,
.vsync = true
.vsync = true,
.splitMouse = false
};
struct LGR_OpenGL
@ -723,7 +725,8 @@ bool lgr_opengl_render(void * opaque)
this->resizeWindow = false;
}
if (this->opt.splitMouse)
{
if (!this->frameUpdate)
{
if (!this->mouseUpdate)
@ -750,6 +753,7 @@ bool lgr_opengl_render(void * opaque)
this->lastMouseDraw = nanotime();
return true;
}
}
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT);
@ -798,6 +802,15 @@ static void handle_opt_vsync(void * opaque, const char *value)
this->opt.vsync = LG_RendererValueToBool(value);
}
static void handle_opt_split_mouse(void * opaque, const char *value)
{
struct LGR_OpenGL * this = (struct LGR_OpenGL *)opaque;
if (!this)
return;
this->opt.splitMouse = LG_RendererValueToBool(value);
}
static LG_RendererOpt lgr_opengl_options[] =
{
{
@ -811,6 +824,12 @@ static LG_RendererOpt lgr_opengl_options[] =
.desc ="Enable or disable vsync [default: enabled]",
.validator = LG_RendererValidatorBool,
.handler = handle_opt_vsync
},
{
.name = "splitMouse",
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
.validator = LG_RendererValidatorBool,
.handler = handle_opt_split_mouse
}
};