From fd1c5f5cd4c3af4694c483ac8fee16cc7f83e891 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Thu, 30 Apr 2020 11:41:30 +0200 Subject: [PATCH] gpu: fix OpenGL context creation and shader patching on macOS Catalina. --- src/application/sdl-app.cpp | 3 +++ src/gpu/shader.cpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/application/sdl-app.cpp b/src/application/sdl-app.cpp index 6c6a6e27..eb6ce43b 100644 --- a/src/application/sdl-app.cpp +++ b/src/application/sdl-app.cpp @@ -56,6 +56,9 @@ sdl::app_display::app_display(char const *title, ivec2 res) // Ask for GL 3.2 at least SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); +#if __APPLE__ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); +#endif #if LOL_BUILD_DEBUG SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG); diff --git a/src/gpu/shader.cpp b/src/gpu/shader.cpp index 8cd46f4c..47563318 100644 --- a/src/gpu/shader.cpp +++ b/src/gpu/shader.cpp @@ -653,6 +653,10 @@ std::string ShaderData::Patch(std::string const &code, ShaderType type) /* Perform small replaces */ char const * const fast_replaces[] = { +#if __APPLE__ + "#version 130", "#version 150", + "texture2D", "texture", +#else "#version 130", "#version 120", "out vec4 out_color;", " ", "out_color =", "gl_FragColor =", @@ -664,6 +668,7 @@ std::string ShaderData::Patch(std::string const &code, ShaderType type) "out vec3", "varying vec3", "out vec4", "varying vec4", "out mat4", "varying mat4", +#endif nullptr };