1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 08:45:00 +01:00

Disable OpenGL vsync when uncap fps option is enabled

This commit is contained in:
Alexander Overvoorde
2016-07-23 22:12:17 +02:00
parent acb5c68eac
commit c56a683eed
6 changed files with 23 additions and 0 deletions

View File

@@ -41,6 +41,8 @@ interface IDrawingEngine
virtual void Resize(uint32 width, uint32 height) abstract;
virtual void SetPalette(SDL_Color * colours) abstract;
virtual void SetUncappedFrameRate(bool uncapped) abstract;
virtual void Invalidate(sint32 left, sint32 top, sint32 right, sint32 bottom) abstract;
virtual void Draw() abstract;
virtual void CopyRect(sint32 x, sint32 y, sint32 width, sint32 height, sint32 dx, sint32 dy) abstract;

View File

@@ -83,6 +83,7 @@ extern "C"
try
{
_drawingEngine->Initialise(gWindow);
_drawingEngine->SetUncappedFrameRate(gConfigGeneral.uncap_fps == 1);
}
catch (Exception ex)
{
@@ -164,6 +165,14 @@ extern "C"
}
}
void drawing_engine_set_fps_uncapped(bool uncapped)
{
if (_drawingEngine != nullptr)
{
_drawingEngine->SetUncappedFrameRate(uncapped);
}
}
void gfx_set_dirty_blocks(sint16 left, sint16 top, sint16 right, sint16 bottom)
{
if (_drawingEngine != nullptr)

View File

@@ -33,6 +33,7 @@ void drawing_engine_dispose();
rct_drawpixelinfo * drawing_engine_get_dpi();
bool drawing_engine_has_dirty_optimisations();
void drawing_engine_invalidate_image(uint32 image);
void drawing_engine_set_fps_uncapped(bool uncapped);
#ifdef __cplusplus
}

View File

@@ -327,6 +327,11 @@ public:
}
}
void SetUncappedFrameRate(bool uncapped)
{
// Not applicable for this engine
}
void Invalidate(sint32 left, sint32 top, sint32 right, sint32 bottom) override
{
left = Math::Max(left, 0);

View File

@@ -47,6 +47,7 @@ IDrawingEngine * DrawingEngineFactory::CreateOpenGL()
#include "../../IDrawingContext.h"
#include "../../IDrawingEngine.h"
#include "../../Rain.h"
#include "../../../config.h"
extern "C"
{
@@ -317,6 +318,10 @@ public:
_drawingContext->ResetPalette();
}
void SetUncappedFrameRate(bool uncapped) {
SDL_GL_SetSwapInterval(uncapped ? 0 : 1);
}
void Invalidate(sint32 left, sint32 top, sint32 right, sint32 bottom) override
{
}

View File

@@ -587,6 +587,7 @@ static void window_options_mouseup(rct_window *w, int widgetIndex)
switch (widgetIndex) {
case WIDX_UNCAP_FPS_CHECKBOX:
gConfigGeneral.uncap_fps ^= 1;
drawing_engine_set_fps_uncapped(gConfigGeneral.uncap_fps);
config_save_default();
window_invalidate(w);
break;