SDL on android

I’m a long time lurker, although that was with a different email address
than this. I haven’t been reading the list for quite a while…

I am curious how well SDL 1.3 is working with android? I have done a lot
of research since the end of December and I am using 1.3.0-6150 in my
builds for android. I am seeing quite different results depending on the
android version and device. I am doing some simple blitting using textures.

Two devices (emulator android v 2.1 and samsung I5801 v 2.2) show a
flickering background, one device (LG Ally v 2.2.2) shows a bit of a
mess, with parts of the textures enlarged, one device (LG GT 540 v 2.1
update 1) has its window moved a bit to the left, in such a way that the
bliting is mirrored on the other side.

In all cases the textures that are being blitted (I probably should say
rendered) are rendered ok. It’s just stuff around it messes up a bit.

Is this a known problem or am I doing something wrong?
I am using the below (abbreviated) code to load and render the textures.

Is there anything I did wrong that may cause these diverse problems?

if (SDL_GetCurrentDisplayMode(0, &mode)==0)
{
/* I read that android ignores these so you can just as well set
them to 0 */
XRES=mode.w;
YRES=mode.h;
}

window=SDL_CreateWindow(“example”, SDL_WINDOWPOS_CENTERED,
SDL_WINDOWPOS_CENTERED, XRES, YRES, SDL_WINDOW_SHOWN|SDL_WINDOW_FULLSCREEN);

renderer=SDL_CreateRenderer(window, -1, 0);

/* i include image in source file couldnt get assets folder to work */
temp=IMG_ReadXPMFromArray(shape_);
SDL_SetColorKey(temp,SDL_SRCCOLORKEY,SDL_MapRGB(temp->format,255,255,255));
shape=SDL_CreateTextureFromSurface(renderer, temp);

SDL_RenderCopy(renderer, shape, NULL, &destrect)
SDL_RenderPresent(renderer);

Thanks,
Jeroen–
Earthquake Magnitude: 5.4
Date: Thursday, January 12, 2012 22:31:00 UTC
Location: Tonga
Latitude: -16.5277; Longitude: -173.3909
Depth: 79.50 km

2012/1/13 Jeroen van Aart

I’m a long time lurker, although that was with a different email address
than this. I haven’t been reading the list for quite a while…

I am curious how well SDL 1.3 is working with android? I have done a lot
of research since the end of December and I am using 1.3.0-6150 in my
builds for android. I am seeing quite different results depending on the
android version and device. I am doing some simple blitting using textures.

I use an Asus Transformer, a Tegra 2 device with Honeycomb, it works
flawlessly with OpenGL ES 1.1 and 2.0

Is there anything I did wrong that may cause these diverse problems?

How do you construct dstrect? As you point out in one of your comments, SDL
in Android ignores the window size you request and sets it to the whatever
means full screen in your device. What I usually do after creating the
renderer is using SDL_GetWindowSize to see what I’m dealing with. I would
try constructing dstrect based on that and see what you get.–
Gabriel.

Gabriel Jacobo wrote:

I use an Asus Transformer, a Tegra 2 device with Honeycomb, it works
flawlessly with OpenGL ES 1.1 and 2.0

Actually I had to disable OpenGL2.0 in the SDL build files or it would
segfault. So It’s using 1.1.

How do you construct dstrect? As you point out in one of your comments, SDL
in Android ignores the window size you request and sets it to the whatever
means full screen in your device. What I usually do after creating the
renderer is using SDL_GetWindowSize to see what I’m dealing with. I would

Yes I do use SDL_GetWindowSize to get the actual size and base the
dstrect on that. The texture (called shape in my example) is actually
drawn correctly and moves fine over the screen.

Greetings,
Jeroen–
Earthquake Magnitude: 4.7
Date: Friday, January 13, 2012 19:46:09 UTC
Location: Queen Charlotte Islands, Canada region
Latitude: 51.2617; Longitude: -130.3610
Depth: 15.00 km

Gabriel Jacobo wrote:

I use an Asus Transformer, a Tegra 2 device with Honeycomb, it works
flawlessly with OpenGL ES 1.1 and 2.0

Actually I had to disable OpenGL2.0 in the SDL build files or it would
segfault. So It’s using 1.1.

How old is the SDL version you are using? The OpenGL ES 2.0 bug was fixed a
couple of month ago IIRC.–
Gabriel.

Gabriel Jacobo wrote:

How old is the SDL version you are using?

SDL-1.3.0-6150

The OpenGL ES 2.0 bug was fixed a
couple of month ago IIRC.

I thought so too, but maybe it’s just something specific to my set up.
Using 1.1. is fine to me so I didn’t bother looking into it more.

Greetings,
Jeroen–
Earthquake Magnitude: 3.3
Date: Saturday, January 14, 2012 01:42:10 UTC
Location: Central California
Latitude: 36.6587; Longitude: -121.2768
Depth: 4.30 km

Jeroen van Aart wrote:

Gabriel Jacobo wrote:

How old is the SDL version you are using?

SDL-1.3.0-6150

The OpenGL ES 2.0 bug was fixed a
couple of month ago IIRC.

I thought so too, but maybe it’s just something specific to my set up.
Using 1.1. is fine to me so I didn’t bother looking into it more.

Actually I was wrong, I don’t think it segfaults anymore. I get the
following in logcat when trying to run with GLES2:

V/SDL (18260): pixel format unknown -1
I/SDL (18260): SDL_Android_Init()
I/SDL (18260): SDL_Android_Init() finished!
V/SDL (18260): Starting up OpenGL ES 2.0
I/SDL (18260): [STUB] GL_SetSwapInterval
I/SDL (18260): [STUB] GL_GetSwapInterval
E/libEGL (18260): called unimplemented OpenGL ES API
E/libEGL (18260): called unimplemented OpenGL ES API
I/example (18260): Couldn’t load image: Texture creation failed.

My android api level is android-7 in this case.

I’m actually using the jan 13 release and I now get this error with GLES1:
I/example (18460): Couldn’t load image: Video driver doesn’t support
changing display mode.

Caused by this code:
temp=IMG_ReadXPMFromArray(shape_);
SDL_SetColorKey(temp,SDL_SRCCOLORKEY,SDL_MapRGB(temp->format,255,255,255));
shape=SDL_CreateTextureFromSurface(renderer, temp);

Anyways, I understand the UNDER_CONSTRUCTION.txt text. Could anyone
recommend a revision that may work with android?

Thanks,
Jeroen–
Earthquake Magnitude: 5.0
Date: Saturday, January 14, 2012 11:35:00 UTC
Location: South Sandwich Islands region
Latitude: -60.7226; Longitude: -26.1261
Depth: 34.70 km

Actually I was wrong, I don’t think it segfaults anymore. I get the
following in logcat when trying to run with GLES2:

V/SDL (18260): pixel format unknown -1
I/SDL (18260): SDL_Android_Init()
I/SDL (18260): SDL_Android_Init() finished!
V/SDL (18260): Starting up OpenGL ES 2.0
I/SDL (18260): [STUB] GL_SetSwapInterval
I/SDL (18260): [STUB] GL_GetSwapInterval
E/libEGL (18260): called unimplemented OpenGL ES API
E/libEGL (18260): called unimplemented OpenGL ES API
I/example (18260): Couldn’t load image: Texture creation failed.

My android api level is android-7 in this case.

This was reported before, see here…
http://forums.libsdl.org/viewtopic.php?t=7654 , it’s not in the bug tracker
AFAICT.

I’m not sure if this is an Android bug or something we are not doing
correctly in the Java Activity…can you try adding a “case -1” under the
"case PixelFormat.RGB_565" in onSurfaceChanged and see if that works?–
Gabriel.