mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-06 06:43:36 +00:00
Merge pull request #140 from urzuline/dev
finish the fps uncap changes and remove the testing patch
This commit is contained in:
commit
f2ae9a509f
|
|
@ -70,6 +70,9 @@ static void onFramebufferResize(int w, int h)
|
|||
::glViewport(0, 0, w, h);
|
||||
}
|
||||
|
||||
// V-Sync
|
||||
|
||||
|
||||
// Initialize OpenGL & The SDL window.
|
||||
void C4JRender::Initialise()
|
||||
{
|
||||
|
|
@ -121,8 +124,14 @@ void C4JRender::Initialise()
|
|||
SDL_Quit();
|
||||
return;
|
||||
}
|
||||
SDL_GL_SetSwapInterval(0); // V-Sync Off Please.
|
||||
|
||||
// 4JCraft VSync/V-Sync
|
||||
#ifdef ENABLE_VSYNC
|
||||
SDL_GL_SetSwapInterval(1); // V-Sync On Please.
|
||||
#else
|
||||
SDL_GL_SetSwapInterval(0); // V-Sync Off Please.
|
||||
#endif
|
||||
|
||||
int fw, fh; SDL_GetWindowSize(s_window, &fw, &fh); onFramebufferResize(fw, fh);
|
||||
|
||||
// We initialize the OpenGL states. Touching those values makes some funny artifacts appear.
|
||||
|
|
|
|||
|
|
@ -116,7 +116,13 @@ void Options::init()
|
|||
bobView = true;
|
||||
anaglyph3d = false;
|
||||
advancedOpengl = false;
|
||||
|
||||
//4JCRAFT V-Sync / VSync
|
||||
#ifdef ENABLE_VSYNC
|
||||
framerateLimit = 2;
|
||||
#else
|
||||
framerateLimit = 3;
|
||||
#endif
|
||||
fancyGraphics = true;
|
||||
ambientOcclusion = true;
|
||||
renderClouds = true;
|
||||
|
|
@ -522,4 +528,4 @@ void Options::save()
|
|||
bool Options::isCloudsOn()
|
||||
{
|
||||
return viewDistance < 2 && renderClouds;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2189,6 +2189,9 @@ int GameRenderer::getFpsCap(int option)
|
|||
int maxFps = 200;
|
||||
if (option == 1) maxFps = 120;
|
||||
if (option == 2) maxFps = 35;
|
||||
#ifndef ENABLE_VSYNC
|
||||
if (option == 3) maxFps = 0;
|
||||
#endif
|
||||
return maxFps;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,6 +37,12 @@ global_cpp_defs = [
|
|||
'-DDEBUG',
|
||||
]
|
||||
|
||||
if get_option('enable_vsync')
|
||||
global_cpp_defs += '-DENABLE_VSYNC'
|
||||
message('v-sync enabled')
|
||||
endif
|
||||
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
global_cpp_defs += [
|
||||
'-Dlinux',
|
||||
|
|
|
|||
4
meson.options
Normal file
4
meson.options
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
option('enable_vsync',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
description : 'Toggles weather V-Sync will be toggle on or off.')
|
||||
Loading…
Reference in a new issue