Android video mode and screen blits

On a real android device (EVO) the SDLActivity has surfaceChanged called with width/height parameters set to 800x405. Eventually those parameters get passed all the way down to SDL/src/render/opengles2/SDL_render_gles2.c:


glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL);

Which will fail if the w, h arguments are not powers of 2. I hacked SDL to set the screen size to 1024x512 just to get this to work and it does.

Now my game runs but the screen doesn’t update. I see a lot of


E/libEGL ( 6763): called unimplemented OpenGL ES API

Presumably caused by SDL trying to blit the screen. I am using the compat library 1.2.14 interface, in case it matters. I’m not sure how to resolve this issue.

I have tested my game in the emulator running with 2.2 (which is what the EVO has) and it works there, so my only guess is that the EVO manufacturer put in some opengles library that doesn’t implement some functionality.

JFYI, its easier to use the hints mechanism to force the opengles renderer so the SDL code itself doesn’t need to change.


SDL_SetHint(SDL_HINT_RENDER_DRIVER, “opengles”);

Thanks to a post on stackoverflow I was inspired to force SDL to use the opengl es renderer instead of opengl es 2. This works, even with non-power of 2 window sizes.

Specifically I edited SDL/src/render/SDL_render.c and swapped these items in the render_drivers array.


// make GLES renderer first, normally GLES2 is first