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 mipmap;
|
||||||
bool vsync;
|
bool vsync;
|
||||||
|
bool preventBuffer;
|
||||||
bool splitMouse;
|
bool splitMouse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ static struct Options defaultOptions =
|
||||||
{
|
{
|
||||||
.mipmap = true,
|
.mipmap = true,
|
||||||
.vsync = true,
|
.vsync = true,
|
||||||
|
.preventBuffer = true,
|
||||||
.splitMouse = false
|
.splitMouse = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -700,6 +702,8 @@ bool lgr_opengl_basic_render(void * opaque)
|
||||||
if (this->fpsTexture)
|
if (this->fpsTexture)
|
||||||
glCallList(this->fpsList);
|
glCallList(this->fpsList);
|
||||||
|
|
||||||
|
if (this->opt.preventBuffer)
|
||||||
|
{
|
||||||
unsigned int before, after;
|
unsigned int before, after;
|
||||||
glXGetVideoSyncSGI(&before);
|
glXGetVideoSyncSGI(&before);
|
||||||
SDL_GL_SwapWindow(this->sdlWindow);
|
SDL_GL_SwapWindow(this->sdlWindow);
|
||||||
|
@ -708,6 +712,9 @@ bool lgr_opengl_basic_render(void * opaque)
|
||||||
glXGetVideoSyncSGI(&after);
|
glXGetVideoSyncSGI(&after);
|
||||||
if (before == after)
|
if (before == after)
|
||||||
glXWaitVideoSyncSGI(1, 0, &before);
|
glXWaitVideoSyncSGI(1, 0, &before);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SDL_GL_SwapWindow(this->sdlWindow);
|
||||||
|
|
||||||
++this->frameCount;
|
++this->frameCount;
|
||||||
const uint64_t t = nanotime();
|
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);
|
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)
|
static void handle_opt_split_mouse(void * opaque, const char *value)
|
||||||
{
|
{
|
||||||
struct LGR_OpenGLBasic * this = (struct LGR_OpenGLBasic *)opaque;
|
struct LGR_OpenGLBasic * this = (struct LGR_OpenGLBasic *)opaque;
|
||||||
|
@ -761,6 +777,12 @@ static LG_RendererOpt lgr_opengl_basic_options[] =
|
||||||
.validator = LG_RendererValidatorBool,
|
.validator = LG_RendererValidatorBool,
|
||||||
.handler = handle_opt_vsync
|
.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",
|
.name = "splitMouse",
|
||||||
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
|
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
|
||||||
|
|
|
@ -47,6 +47,7 @@ struct Options
|
||||||
{
|
{
|
||||||
bool mipmap;
|
bool mipmap;
|
||||||
bool vsync;
|
bool vsync;
|
||||||
|
bool preventBuffer;
|
||||||
bool splitMouse;
|
bool splitMouse;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -54,6 +55,7 @@ static struct Options defaultOptions =
|
||||||
{
|
{
|
||||||
.mipmap = true,
|
.mipmap = true,
|
||||||
.vsync = true,
|
.vsync = true,
|
||||||
|
.preventBuffer = true,
|
||||||
.splitMouse = false
|
.splitMouse = false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -764,14 +766,19 @@ bool lgr_opengl_render(void * opaque)
|
||||||
if (this->fpsTexture)
|
if (this->fpsTexture)
|
||||||
glCallList(this->fpsList);
|
glCallList(this->fpsList);
|
||||||
|
|
||||||
|
if (this->opt.preventBuffer)
|
||||||
|
{
|
||||||
unsigned int before, after;
|
unsigned int before, after;
|
||||||
glXGetVideoSyncSGI(&before);
|
glXGetVideoSyncSGI(&before);
|
||||||
SDL_GL_SwapWindow(this->sdlWindow);
|
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);
|
glXGetVideoSyncSGI(&after);
|
||||||
if (before == after)
|
if (before == after)
|
||||||
glXWaitVideoSyncSGI(1, 0, &before);
|
glXWaitVideoSyncSGI(1, 0, &before);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SDL_GL_SwapWindow(this->sdlWindow);
|
||||||
|
|
||||||
++this->frameCount;
|
++this->frameCount;
|
||||||
const uint64_t t = nanotime();
|
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);
|
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)
|
static void handle_opt_split_mouse(void * opaque, const char *value)
|
||||||
{
|
{
|
||||||
struct LGR_OpenGL * this = (struct LGR_OpenGL *)opaque;
|
struct LGR_OpenGL * this = (struct LGR_OpenGL *)opaque;
|
||||||
|
@ -825,6 +841,12 @@ static LG_RendererOpt lgr_opengl_options[] =
|
||||||
.validator = LG_RendererValidatorBool,
|
.validator = LG_RendererValidatorBool,
|
||||||
.handler = handle_opt_vsync
|
.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",
|
.name = "splitMouse",
|
||||||
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
|
.desc = "Draw mouse updates directly to the front buffer [default: disabled]",
|
||||||
|
|
Loading…
Reference in a new issue