I am trying to use SDL2 in my new Android application, it should work well:
http://wilbefast.com/2011/11/11/recent-sdl-android-goodies/
It compiles without a single problem and there is a sample project so it is quite easy to start using it. I compiled the library and started with my application, created an event loop – as in SDL 1.2 and tried to push some events into it by function:
int SDL_PushEvent(SDL_Event * event);
However, it always fails with error value -1. I just defined SDL_main function for this source file:
http://hg.libsdl.org/SDL/file/6bb657898f55/src/main/android/SDL_android_main.cpp
My SDL_main function contains simple event loop:
SDL_Event event;
for (;;)
{
SDL_WaitEvent(&event);
switch (event.type)
{
case SDL_QUIT:
return;
case SOME_EVENT:
break;
default:
break;
}
}
and that’s all, no threads, no mutexes, no waits, just a simple main function. I noticed that my event loop process some events, their event.type equals to 2151293988, It looks their source is SDLSurface instance, which is created in the Java code: http://hg.libsdl.org/SDL/file/6bb657898f55/android-project/src/org/libsdl/app/SDLActivity.java
Why SDL_PushEvent function doesn’t work? Has anybody an idea what could be wrong?
SDL queue does not start automatically after init, it must be started explicitly by calling
SDL_StartEventLoop();