Changing video mode/driver on Android?

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.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)

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)
-------------- next part --------------
A non-text attachment was scrubbed…
Name: sample.c
Type: text/x-csrc
Size: 3192 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20130308/ffb60874/attachment-0001.c

Hi again,

About 3 months ago I asked here if it’s possible to change the “video
mode” of a running Android app. I mean here if, say, it’s possible to use
a software renderer first, then an OpenGL ES renderer and finally OpenGL
ES directly; All without restarting the app.

I had some problems with that on Android. Only recently I have found out
it’s a matter of changing a few lines of Java code, at least according to
a few local tests here.
As a consequence, I have opened a bug report with a patch and a minor
update to the sample program I originally posted on the list:
https://bugzilla.libsdl.org/show_bug.cgi?id=1889

For the ones reading this via the mailing list, here is a link to the
original post in the forums (although I think there isn’t a lot to see
there): http://forums.libsdl.org/viewtopic.php?t=8895
Note that I currently don’t see any attachment on the forums, but you can
simply check the bug report for a minor update to the sample code.

Again thanks!