[SDL] Android OpenGL ES 2 context creation bug and fix

Forest Hale havoc at ghdigital.com
Sat Jul 9 13:43:16 PDT 2011


On an OpenGL ES 2 capable device, it is not enough to pick a config that supports ES2, it is necessary to specify an EGL_CONTEXT_CLIENT_VERSION of 2 when one is wanted...  I have revised the 
eglCreateContext call as shown below in my local copy.

I also think the eglChooseConfig is busted, the first config reported on my device has EGL_DEPTH_SIZE 0 which makes it rather useless for a 3D game, I uncommented the request for EGL_DEPTH_SIZE 16 in 
my local copy for this purpose, the alternative would be to request a large number of configs (I got over 20 unique ones in testing...  so a larger number is required) and picking the "best matching" one.

This is just a bland snippet of revised code for android-project/src/org/libsdl/app/SDLActivity.java - sorry for any inconvenience with it not being a directly applyable patch.

             int EGL_CONTEXT_CLIENT_VERSION=0x3098;
             int contextAttrs[] = new int[]
             {
                 EGL_CONTEXT_CLIENT_VERSION, majorVersion,
                 EGL10.EGL_NONE
             };
             EGLContext ctx = egl.eglCreateContext(dpy, config, EGL10.EGL_NO_CONTEXT, contextAttrs);

-- 
LordHavoc
Author of DarkPlaces Quake1 engine - http://icculus.org/twilight/darkplaces
Co-designer of Nexuiz - http://alientrap.org/nexuiz
"War does not prove who is right, it proves who is left." - Unknown
"Any sufficiently advanced technology is indistinguishable from a rigged demo." - James Klass
"A game is a series of interesting choices." - Sid Meier




More information about the SDL mailing list