32 #if defined(USE_X11) && defined(USE_OPENGL)
37 PRAGMA48(GCC diagnostic ignored
"-Wshadow")
38 #include <SDL_events.h>
39 #include <SDL_syswm.h>
47 SDL_Rect *
const *
const modes = SDL_ListModes(
nullptr,
48 SDL_FULLSCREEN | SDL_HWSURFACE);
51 const std::string modeString =
54 logger->
log(
"support mode: " + modeString);
55 modeList.push_back(modeString);
60 if (modes ==
static_cast<SDL_Rect **
>(
nullptr))
65 else if (modes ==
reinterpret_cast<SDL_Rect **
>(-1))
72 for (
int i = 0; modes[i] !=
nullptr; ++ i)
74 const std::string modeString =
77 logger->
log(
"support mode: " + modeString);
78 modeList.push_back(modeString);
86 const char *
const title)
88 SDL_WM_SetCaption(title,
nullptr);
92 SDL_Surface *
const icon)
94 SDL_WM_SetIcon(icon,
nullptr);
99 SDL_WM_GrabInput(grab ? SDL_GRAB_ON : SDL_GRAB_OFF);
104 SDL_SetGamma(gamma, gamma, gamma);
109 SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, val);
113 SDL_SysWMinfo *
const info)
115 return SDL_GetWMInfo(
info) != 0;
122 return SDL_CreateThread(fn,
data);
125 #if defined(USE_X11) && defined(USE_OPENGL)
132 SDL_VERSION(&
info.version)
133 SDL_GetWMInfo(&
info);
134 void *context = GlxHelper::createContext(
info.
info.x11.window,
135 info.
info.x11.display, major, minor, profile);
136 if (!context && (major > 3 || (major == 3 && minor > 3)))
138 logger->
log(
"Try fallback to OpenGL 3.3 core context");
139 context = GlxHelper::createContext(
info.info.x11.window,
140 info.info.x11.display, 3, 3, profile);
141 if (!context && profile == 0x01)
143 logger->
log(
"Try fallback to OpenGL 3.3 compatibility context");
144 context = GlxHelper::createContext(
info.info.x11.window,
145 info.info.x11.display, 3, 3, 0x02);
148 if (!context && (major > 3 || (major == 3 && minor > 0)))
150 logger->
log(
"Try fallback to OpenGL 3.0 core context");
151 context = GlxHelper::createContext(
info.info.x11.window,
152 info.info.x11.display, 3, 0, profile);
154 if (!context && (major > 2 || (major == 2 && minor > 1)))
156 logger->
log(
"Try fallback to OpenGL 2.1 compatibility context");
157 context = GlxHelper::createContext(
info.info.x11.window,
158 info.info.x11.display, 2, 1, 0x02);
166 SDL_VERSION(&
info.version)
167 SDL_GetWMInfo(&
info);
168 GlxHelper::makeCurrent(
info.
info.x11.window,
197 if (thread !=
nullptr && SDL_GetThreadID(thread) != 0U)
198 SDL_WaitThread(thread,
nullptr);
204 return SDL_PeepEvents(event,
213 setEnv(
"SDL_VIDEO_ALLOW_SCREENSAVER",
"1");
215 setEnv(
"SDL_VIDEO_ALLOW_SCREENSAVER",
"0");
void log(const char *const log_text,...)
void log1(const char *const log_text)
void setEnv(const char *const name, const char *const value)
bool info(InputEvent &event)
std::string toString(T const &value)
converts any type to a string
SDL_Thread * createThread(int(*fn)(void *), const char *const name, void *const data)
void SetWindowTitle(const SDL_Surface *const window, const char *const title)
void WaitThread(SDL_Thread *const thread)
bool PollEvent(SDL_Event *event)
bool getWindowWMInfo(const SDL_Surface *const window, SDL_SysWMinfo *const info)
void setLogLevel(const int level)
void SetWindowIcon(const SDL_Surface *const window, SDL_Surface *const icon)
void makeCurrentContext(void *const context)
void grabInput(const SDL_Surface *const window, const bool grab)
void setGamma(const SDL_Surface *const window, const float gamma)
void setVsync(const int val)
bool getAllVideoModes(StringVect &modeList)
void allowScreenSaver(const bool allow)
void * createGLContext(SDL_Surface *const window, const int major, const int minor, const int profile)
std::vector< std::string > StringVect