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 - GL_CreateRenderer forces 2.1 context
Summary: GL_CreateRenderer forces 2.1 context
Status: RESOLVED WONTFIX
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: HG 2.0
Hardware: x86 All
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-08-25 08:32 UTC by Angelo
Modified: 2016-10-01 21:38 UTC (History)
1 user (show)

See Also:


Attachments
Test case (824 bytes, text/plain)
2015-08-25 10:04 UTC, Angelo
Details

Note You need to log in before you can comment on or make changes to this bug.
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.