[SDL] Changing video mode/driver on Android?

NY00123 ny00 at outlook.com
Fri Mar 8 04:41:26 PST 2013


Hi all,

I would like to ask if there is a way of changing video driver within an 
SDL 2.0 Android app without restarting the app, as done by many games on 
desktop environments. If it's impossible, is that a known limitation of 
the Android platform?

To avoid further confusions, I refer to one of a few ways to display 
graphics: Using OpenGL directly (at least on desktops), some 
implementation of an SDL_Renderer (like OpenGL ES 1.0 and Software) or 
an SDL_Surface returned by SDL_GetWindowSurface.

For reference, I have attached a minor test app, along with an 
Android.mk file that should reside in the exact same location 
(android-project-path/jni/src).
Android.mk is taken right off a modification of the SDL 2.0 Android 
project template (about 1 month old), and the app has been tested using 
a recent revision of SDL itself. I have used "ndk-build" and "ant" for 
the construction of an Android package.

A GNU/Linux desktop executable can also be constructed (at least on 
Ubuntu 12.04, x86_64), using a command like this:

gcc sample.c -o sample `sdl2-config --cflags --libs`

The various calls of the form "SDL_Delay(1000);" exist for simplistic 
debugging purposes. I've just had some troubles with ndk-gdb and the 
delay commands help at the moment. So far it looks like the app crashes 
for me on an Android device as it attempts to create a renderer for the 
second time. I have also attempted to use the exact same window, but 
with different renderers (so only the first renderer is destroyed, not 
the window); It has similarly failed.

Maybe I should accept that a manual app restart is required?

To finish, if someone spots a bug in the attached source file by chance, 
please inform if you can.

Thanks,
NY
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.c
Type: text/x-csrc
Size: 3243 bytes
Desc: not available
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130308/abc63cb9/attachment-0008.c>
-------------- next part --------------
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE := main

SDL_PATH := ../SDL

LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include

# Add your application source files here...
LOCAL_SRC_FILES := $(SDL_PATH)/src/main/android/SDL_android_main.cpp \
	sample.c

LOCAL_SHARED_LIBRARIES := SDL2

LOCAL_LDLIBS := -lGLESv1_CM -llog

include $(BUILD_SHARED_LIBRARY)


More information about the SDL mailing list