diff --git a/src/wx-sdl2-video-gl3.c b/src/wx-sdl2-video-gl3.c index 248432d..14907cb 100644 --- a/src/wx-sdl2-video-gl3.c +++ b/src/wx-sdl2-video-gl3.c @@ -769,6 +769,12 @@ int gl3_init(SDL_Window* window, sdl_render_driver requested_render_driver, SDL_ strcpy(current_render_driver_name, requested_render_driver.name); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); +#ifdef __APPLE__ + // without an explicit request for the core profile 3.0 macOS falls back to default ancient 2.1 + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); +#endif context = SDL_GL_CreateContext(window); @@ -1637,12 +1643,21 @@ int gl3_renderer_available(struct sdl_render_driver* driver) if (available < 0) { available = 0; + + // GL SetAttribute should be done *before* window creation for the attributes to apply on + // context creation (seems to depend on OpenGL impl. but it souldn't hurt other platforms + // to do it here (earlier than before) + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + +#ifdef __APPLE__ + // without an explicit request for the core profile 3.0 macOS falls back to default ancient 2.1 + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); +#endif + SDL_Window* window = SDL_CreateWindow("GL3 test", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1, 1, SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL); if (window) { - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); - SDL_GLContext context = SDL_GL_CreateContext(window); if (context) {