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 2204 - Regression: cannot create GLES2 context on Android since 2.0.1
Summary: Regression: cannot create GLES2 context on Android since 2.0.1
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.1
Hardware: ARM Android (All)
: P2 major
Assignee: Gabriel Jacobo
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-03 01:36 UTC by dnschneid
Modified: 2013-11-27 06:20 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dnschneid 2013-11-03 01:36:37 UTC
Since upgrading to SDL 2.0.1 (confirmed still to be an issue in mercurial), creating a GLES2 context on Android 4.1.2 (Spyder) is broken.  The following code (error handling removed) worked in 2.0.0:


SDL_InitSubSystem(SDL_INIT_VIDEO);
_window = SDL_CreateWindow(PROJ_NAME,
            SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
            _width, _height, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
_context = SDL_GL_CreateContext(_window);


In 2.0.1/mercurial, _context returns NULL, and eglGetError returns EGL_BAD_CONFIG after the eglCreateContext call in the implementation.
Comment 1 Gabriel Jacobo 2013-11-04 12:56:25 UTC
Can you add 

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);

before creating the context and let me know if that solves the problem?

Thanks!
Comment 2 dnschneid 2013-11-12 04:59:35 UTC
Sorry for the delay. Updated to latest mercurial and tried both with and without setting the profile mask; still fails to create the context.

eglGetError returns EGL_BAD_CONFIG after the eglCreateContext call, so it's definitely taking the EGL codepath; it's just not initializing something in the same way as it used to in the Java code.
Comment 3 dnschneid 2013-11-12 05:07:09 UTC
I just tested on my Nexus 7 and it works fine, so it's either due to 4.1.2 or something with Spyder.  But the old SDL 2.0.0 java-based initialization code worked...
Comment 4 dnschneid 2013-11-12 06:07:14 UTC
Random observation: SDL_EGL_LoadLibrary ignores the return value of SDL_EGL_ChooseConfig; shouldn't it pass it up? (changing this did not change the point of failure)

I can't find any significant differences with the java version, unless one of the EGL10 functions isn't just a dumb wrapper.  Some basic behavior matching vs. the old java code, like always prividing default values for the config attributes doesn't help.  Not that I fully understand both sources, so I'm sure I'm overlooking the subtle difference that causes the issue at hand.
Comment 5 Gabriel Jacobo 2013-11-13 11:57:56 UTC
Can you give testrendercopyex a try? There's a handy script in build-scripts/androidbuild.sh to make this easy to try, you just need to remember to copy the test/sample.bmp file manually into the Android assets folder before building the apk.
Comment 6 Gabriel Jacobo 2013-11-14 23:16:20 UTC
SDL_EGL_ChooseConfig return value being ignored is fixed here: https://hg.libsdl.org/SDL/rev/ffb7bf531644
Comment 7 Gabriel Jacobo 2013-11-19 14:12:02 UTC
I updated the SDL_EGL_ChooseConfig to match what the old Java code used to do in terms of finding the best config available. Let me know if this helps.
Comment 8 dnschneid 2013-11-27 06:20:59 UTC
That seems to have done the trick!  Latest hg works fine.
Thanks for tracking this down.