We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3103

Summary: GL_CreateRenderer forces 2.1 context
Product: SDL Reporter: Angelo <spansjh>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED WONTFIX QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2 CC: amaranth72
Version: HG 2.0   
Hardware: x86   
OS: All   
Attachments: Test case

Description Angelo 2015-08-25 08:32:30 UTC
In src/render/opengl/SDL_render_gl.c on line 389 is GL_CreateRenderer, which upon calling, checks if the current context is a 2.1 context (using RENDERER_CONTEXT_MAJOR and RENDERER_CONTEXT_MINOR) and if the context is not 2.1, it creates a 2.1 context.

If I wanted to create a 3.2 context (for GLSL features and OSX compatibility), this code will create its own 2.1 context and I end up not being able to use the 3.2 features because there's a 2.1 context active.

Why is this necessary? Does SDL_Renderer not work with a newer OpenGL version?
Comment 1 Angelo 2015-08-25 10:04:23 UTC
Created attachment 2252 [details]
Test case

I ran a test compiling the given main.cpp against a version of SDL2 that doesn't create a 2.1 context and instead uses the currently active context. (In this case, a 3.2 core profile context)

With SDL2 itself, the window turns pink.

With SDL2 with the 2.1 context creation code in CreateRenderer removed, the window stays black. So my guess is that the 2.1 context is required, but why?
Comment 2 Angelo 2015-08-25 13:47:17 UTC
It appears like the reason the screen remains black is because glRect is not supported since OpenGL 3.0, which is used by SDL_Renderer.
Comment 3 Alex Szpakowski 2015-08-29 14:47:18 UTC
SDL_Render does not have a backend which uses Core Profile OpenGL 3+.

If you want to use OpenGL features directly in a program which uses SDL, I recommend just creating an OpenGL context with SDL_GL_CreateContext and dropping SDL_Render entirely. It's really easy to make things blow up when mixing SDL_Render with direct OpenGL.
Comment 4 Sam Lantinga 2016-10-01 21:38:00 UTC
Marking won't fix for now, since the SDL render API doesn't support Core Profile.