summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client.cpp14
-rw-r--r--src/utils/sdl2helper.cpp10
-rw-r--r--src/utils/sdl2helper.h4
-rw-r--r--src/utils/sdlhelper.cpp10
-rw-r--r--src/utils/sdlhelper.h4
5 files changed, 31 insertions, 11 deletions
diff --git a/src/client.cpp b/src/client.cpp
index f7fd72094..b191e443d 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -2824,12 +2824,8 @@ void Client::applyGamma()
if (config.getFloatValue("enableGamma"))
{
const float val = config.getFloatValue("gamma");
-#ifdef USE_SDL2
- if (mainGraphics)
- SDL_SetWindowBrightness(mainGraphics->getWindow(), val);
-#else
- SDL_SetGamma(val, val, val);
-#endif
+ SDL::setGamma(mainGraphics->getWindow(),
+ config.getFloatValue("gamma"));
}
}
@@ -2837,11 +2833,7 @@ void Client::applyVSync()
{
const int val = config.getIntValue("vsync");
if (val > 0 && val < 2)
-#ifdef USE_SDL2
- SDL_GL_SetSwapInterval(val);
-#else
- SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val);
-#endif
+ SDL::setVsync(val);
}
void Client::applyKeyRepeat()
diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp
index 442d40990..33a88cc8a 100644
--- a/src/utils/sdl2helper.cpp
+++ b/src/utils/sdl2helper.cpp
@@ -52,4 +52,14 @@ void SDL::grabInput(SDL_Window *const window, const bool grab)
SDL_SetWindowGrab(window, grab ? SDL_TRUE : SDL_FALSE);
}
+void SDL::setGamma(SDL_Window *const window, const float gamma)
+{
+ SDL_SetWindowBrightness(window, gamma);
+}
+
+void SDL::setVsync(const int val)
+{
+ SDL_GL_SetSwapInterval(val);
+}
+
#endif // USE_SDL2
diff --git a/src/utils/sdl2helper.h b/src/utils/sdl2helper.h
index 956a63ff8..3e7b20651 100644
--- a/src/utils/sdl2helper.h
+++ b/src/utils/sdl2helper.h
@@ -38,6 +38,10 @@ namespace SDL
void SetWindowIcon(SDL_Window *const window, SDL_Surface *const icon);
void grabInput(SDL_Window *const window, const bool grab);
+
+ void setGamma(SDL_Window *const window, const float gamma);
+
+ void setVsync(const int val);
} // namespace SDL
#endif // USE_SDL2
diff --git a/src/utils/sdlhelper.cpp b/src/utils/sdlhelper.cpp
index a470ce927..2690554be 100644
--- a/src/utils/sdlhelper.cpp
+++ b/src/utils/sdlhelper.cpp
@@ -78,4 +78,14 @@ void SDL::grabInput(SDL_Surface *const window A_UNUSED, const bool grab)
SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
}
+void SDL::setGamma(SDL_Surface *const window A_UNUSED, const float gamma)
+{
+ SDL_SetGamma(gamma, gamma, gamma)
+}
+
+void SDL::setVsync(const int val)
+{
+ SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val);
+}
+
#endif // USE_SDL2
diff --git a/src/utils/sdlhelper.h b/src/utils/sdlhelper.h
index 912528a29..acaf7111b 100644
--- a/src/utils/sdlhelper.h
+++ b/src/utils/sdlhelper.h
@@ -42,6 +42,10 @@ namespace SDL
SDL_Surface *const icon);
void grabInput(SDL_Surface *const window A_UNUSED, const bool grab);
+
+ void setGamma(SDL_Surface *const window A_UNUSED, const float gamma);
+
+ void setVsync(const int val);
} // namespace SDL
#endif // USE_SDL2