summaryrefslogtreecommitdiff
path: root/src/utils/sdl2helper.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-09-13 21:54:39 +0300
committerAndrei Karas <akaras@inbox.ru>2017-09-13 21:54:39 +0300
commit86b19d64c2692665aba33e44ee5db6cbf36b6342 (patch)
tree93d91c84258f9b76ab29ab51119bbc0044d729a4 /src/utils/sdl2helper.cpp
parenta45303dc06c74735389607e5b281bb69543547ed (diff)
downloadplus-86b19d64c2692665aba33e44ee5db6cbf36b6342.tar.gz
plus-86b19d64c2692665aba33e44ee5db6cbf36b6342.tar.bz2
plus-86b19d64c2692665aba33e44ee5db6cbf36b6342.tar.xz
plus-86b19d64c2692665aba33e44ee5db6cbf36b6342.zip
Add option to select any existing SDL renderer drivers for SDL2 default mode.
Diffstat (limited to 'src/utils/sdl2helper.cpp')
-rw-r--r--src/utils/sdl2helper.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/utils/sdl2helper.cpp b/src/utils/sdl2helper.cpp
index da86d2b41..ad559b0e6 100644
--- a/src/utils/sdl2helper.cpp
+++ b/src/utils/sdl2helper.cpp
@@ -28,10 +28,13 @@
#include "utils/sdl2logger.h"
#include "utils/stringutils.h"
+#include <algorithm>
+
PRAGMA48(GCC diagnostic push)
PRAGMA48(GCC diagnostic ignored "-Wshadow")
#include <SDL_events.h>
#include <SDL_hints.h>
+#include <SDL_render.h>
#include <SDL_syswm.h>
PRAGMA48(GCC diagnostic pop)
@@ -225,4 +228,40 @@ void SDL::allowScreenSaver(const bool allow)
}
}
+void SDL::getRenderers(StringVect &list,
+ const std::string &currentRenderer)
+{
+ SDL_RendererInfo info;
+ const int num = SDL_GetNumRenderDrivers();
+ for (int f = 0; f < num; f ++)
+ {
+ if (!SDL_GetRenderDriverInfo(f, &info))
+ list.push_back(info.name);
+ }
+ if (!currentRenderer.empty())
+ {
+ bool found(false);
+ FOR_EACH (StringVectCIter, it, list)
+ {
+ if (*it == currentRenderer)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ list.push_back(currentRenderer);
+ }
+ std::sort(list.begin(), list.end());
+}
+
+void SDL::setRendererHint(const std::string &driver)
+{
+ if (!driver.empty())
+ {
+ SDL_SetHint(SDL_HINT_RENDER_DRIVER,
+ driver.c_str());
+ }
+}
+
#endif // USE_SDL2