Android,ndk, SDL2 problems with screen

Hi
I am a developer and I am trying to port an sdl game from ipad to android.
I am stuck on a weird thing that you may know how to go around.

I use windows 7, 64bit. Eclipse 3.7.2.
Latest android SDK and NDK r8b.
I use the android example by latest SDL HG.
I do this on Android 2.2.

The example works ok but:

The problem is that ‘SDL_CreateWindow’ always gives a 16bit color context
and I need 32bit.
Its pixel format RGB_565 which is the default I heard.
I need pixel format RGBA_8888 but it doesnt switch.

I tried in c++:
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
with no change.

I tried in SDLActivity.java in ‘onCreate’ before 'setContentView’
getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
no change at all.

It keeps choosing: ‘PixelFormat.RGB_565’ in ‘surfaceChanged’.

Can you help me?
Can that change to RGBA_8888?
Or is RGB_565 hard-coded somewhere inside the SDL code?

Thanks a lot,
George

Hi
I am a developer and I am trying to port an sdl game from ipad to android.
I am stuck on a weird thing that you may know how to go around.

I use windows 7, 64bit. Eclipse 3.7.2.
Latest android SDK and NDK r8b.
I use the android example by latest SDL HG.
I do this on Android 2.2.

The example works ok but:

The problem is that ‘SDL_CreateWindow’ always gives a 16bit color context
and I need 32bit.
Its pixel format RGB_565 which is the default I heard.
I need pixel format RGBA_8888 but it doesnt switch.

I tried in c++:
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
with no change.

I tried in SDLActivity.java in ‘onCreate’ before 'setContentView’
getWindow().setFormat(PixelFormat.RGBA_8888);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);
no change at all.

It keeps choosing: ‘PixelFormat.RGB_565’ in ‘surfaceChanged’.

Can you help me?
Can that change to RGBA_8888?
Or is RGB_565 hard-coded somewhere inside the SDL code?

Thanks a lot,
George

Hi there,

I use the latest build of SDL HG and SDL2_mixer.
I made a library ‘libSDL2_mixer.so’ and a ‘libtremor.a’ with the SDL
example in android.
I target 2.2 android.
I read the ogg vorbis file from the SD card.

When I play an OGG vorbis music file on my Nexus One phone (running 2.3
android) it works ok.

When I play the same file on my Samsung Galaxy II tablet (running ICS
4.0.3 android) it plays fine but when I exit the app (with java’s
’finish()’) and relead the game I hear the music distorted like echoing.
This does not happen all the time. Half times it does and half not.

Where is the problem? How can I fix it?

Both devices open up this:
09-25 12:05:36.862: V/SDL(1441): SDL audio: opening device
09-25 12:05:36.862: V/SDL(1441): SDL audio: wanted stereo 16-bit 44.1kHz,
1024 frames buffer
09-25 12:05:36.870: V/SDL(1441): SDL audio: got stereo 16-bit 44.1kHz,
4096 frames buffer

Thanks,
Giorgos

Hi again,
Can anyone help me out with this SDL_mixer issue in android?

I use the latest build of SDL HG and SDL2_mixer.
I made a library ‘libSDL2_mixer.so’ and a ‘libtremor.a’ with the SDL
example in android.
I target 2.2 android.
I read the ogg vorbis file from the SD card.

When I play an OGG vorbis music file on my Nexus One phone (running 2.3
android) it works ok.

When I play the same file on my Samsung Galaxy II tablet (running ICS
4.0.3 android) it plays fine but when I exit the app (with java’s
’finish()’) and relead the game I hear the music distorted like echoing
(Its like a helicopter sound!!). This does not happen all the time. Half
times it does and half not.

Where is the problem?
Do you have any clue?

Both devices open up this:
09-25 12:05:36.862: V/SDL(1441): SDL audio: opening device
09-25 12:05:36.862: V/SDL(1441): SDL audio: wanted stereo 16-bit 44.1kHz,
1024 frames buffer
09-25 12:05:36.870: V/SDL(1441): SDL audio: got stereo 16-bit 44.1kHz,
4096 frames buffer

Thanks,
Giorgos

It looks like the OpenGL context is created in initEGL in the Java activity
and doesn’t respect the parameters set in the SDL API.

I would expect to see something like this there:

int attribs[] = {
EGL10.EGL_RED_SIZE, mRedSize,
EGL10.EGL_GREEN_SIZE, mGreenSize,
EGL10.EGL_BLUE_SIZE, mBlueSize,
EGL10.EGL_ALPHA_SIZE, mAlphaSize,
EGL10.EGL_DEPTH_SIZE, mDepthSize,
EGL10.EGL_SAMPLE_BUFFERS, mSampleBuffers,
EGL10.EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
EGL10.EGL_NONE
};

Feel free to take a crack at it if you want!On Sun, Sep 23, 2012 at 2:40 AM, Giorgos Sarris wrote:

Hi

I am a developer and I am trying to port an sdl game from ipad to android.
I am stuck on a weird thing that you may know how to go around.

I use windows 7, 64bit. Eclipse 3.7.2.
Latest android SDK and NDK r8b.
I use the android example by latest SDL HG.
I do this on Android 2.2.

The example works ok but:

The problem is that ‘SDL_CreateWindow’ always gives a *16bit color context

  • and I need 32bit.
    Its pixel format RGB_565 which is the default I heard.
    I need pixel format RGBA_8888 but it doesnt switch.

I tried in c++:

  • SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);**
    ** SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);**
    ** SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);**
    ** SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8);**
    ** SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);**
    ** SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);*
    with no change.

I tried in SDLActivity.java in ‘onCreate’ before ‘setContentView’

  •    getWindow().setFormat(PixelFormat.RGBA_8888);**
    

** getWindow().addFlags(WindowManager.LayoutParams.FLAG_DITHER);*
no change at all.

It keeps choosing: ‘PixelFormat.RGB_565’ in ‘surfaceChanged’.

Can you help me?
Can that change to RGBA_8888?
Or is RGB_565 hard-coded somewhere inside the SDL code?

Thanks a lot,
George


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org