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 2994

Summary: OpenGL ES 3 context can't be created through EGL without the EGL_KHR_create_context extension
Product: SDL Reporter: Magnus Bjerke Vik <mbvett>
Component: videoAssignee: Alex Szpakowski <amaranth72>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: critical    
Priority: P2 CC: amaranth72, mbvett
Version: HG 2.0   
Hardware: All   
OS: All   

Description Magnus Bjerke Vik 2015-05-25 10:26:49 UTC
The current code uses EGL_KHR_create_context to create the context if GL major version is 3 or greater. If this extension is not available, it will fail with a message saying "Could not create EGL context (context attributes are not supported)".

My fix uses the EGL_CONTEXT_CLIENT_VERSION attribute, if EGL_KHR_create_context is not available, to set the major version. This attribute is part of the core EGL specification and should thus be safe to use. You can find the patch for the fix here: https://bitbucket.org/Gachapen/sdl/commits/38af96fc67e9fba7a8711fb2592453704c825c55/raw/

This was tested on a stock Google Nexus 5 (Android 5.1) device, using android-ndk-r10d, API level 18, on armeabi-v7a. I used a slightly modified SDL source code to support building for Android with CMake. You can find the changes here: https://bitbucket.org/Gachapen/sdl/commits/all
Comment 1 Alex Szpakowski 2015-05-25 16:11:12 UTC
FWIW, with your patch if a GLES 3.1 context is requested and EGL_KHR_create_context isn't supported, then a GLES 3.0 context will be created rather than no context being created.
Comment 2 Magnus Bjerke Vik 2015-05-25 16:18:57 UTC
(In reply to Alex Szpakowski from comment #1)
> FWIW, with your patch if a GLES 3.1 context is requested and
> EGL_KHR_create_context isn't supported, then a GLES 3.0 context will be
> created rather than no context being created.

I find it weird that the standard specification doesn't include a way to create a context with a minor version greater than 0.

Would it be better to make the code fail with an error message if a minor version > 0 is specified?
Comment 3 Alex Szpakowski 2015-05-25 16:24:50 UTC
(In reply to Magnus Bjerke Vik from comment #2)
> I find it weird that the standard specification doesn't include a way to
> create a context with a minor version greater than 0.

Well, it does – but only as of EGL 1.5 or the EGL_KHR_create_context extension (whose functionality was made part of EGL 1.5.)
Comment 4 Alex Szpakowski 2015-05-26 22:35:52 UTC
I believe I fixed the issue with this commit: https://hg.libsdl.org/SDL/rev/adf81fe554b9

Let me know if it works!
Comment 5 Magnus Bjerke Vik 2015-05-27 08:25:29 UTC
(In reply to Alex Szpakowski from comment #4)
> I believe I fixed the issue with this commit:
> https://hg.libsdl.org/SDL/rev/adf81fe554b9
> 
> Let me know if it works!

Great! Works as expected. Thank you.