summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-02-27 18:51:20 +0100
committerGitHub <noreply@github.com>2021-02-27 18:51:20 +0100
commit1b5d1d074ef1a65634830cbfa7ff412f8a9906bd (patch)
tree6cc3e76450aeebbc73e503bd8fd0ac9329f06c80 /src/video
parentdfa141818be5c6ac91adaebfd2641f23b3bbbf39 (diff)
downloadopenttd-1b5d1d074ef1a65634830cbfa7ff412f8a9906bd.tar.xz
Fix: [SDL2] set GL attributes to get the best GL context possible (#8759)
Diffstat (limited to 'src/video')
-rw-r--r--src/video/sdl2_opengl_v.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/video/sdl2_opengl_v.cpp b/src/video/sdl2_opengl_v.cpp
index 9c9a9c6fa..87a8bb9b3 100644
--- a/src/video/sdl2_opengl_v.cpp
+++ b/src/video/sdl2_opengl_v.cpp
@@ -94,6 +94,17 @@ void VideoDriver_SDL_OpenGL::DestroyContext()
const char *VideoDriver_SDL_OpenGL::AllocateContext()
{
+ SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
+ SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0);
+ SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1);
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
+
+ if (_debug_driver_level >= 8) {
+ SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);
+ }
+
this->gl_context = SDL_GL_CreateContext(this->sdl_window);
if (this->gl_context == nullptr) return "SDL2: Can't active GL context";