Search
lxdream.org :: lxdream/src/gui_android.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/gui_android.c
changeset 1275:83b15705cdde
prev1253:5aa14eeaad5a
next1277:f727227cc4f8
author nkeynes
date Tue Mar 20 08:29:38 2012 +1000 (12 years ago)
permissions -rw-r--r--
last change More android WIP
- Implement onPause/onResume (although resume is not actually working yet)
- Implement BGRA => RGBA texture conversion (BGRA doesn't seem to work on the TFP)

Boot swirl is now displayed, albeit depth buffering seems to be broken.
file annotate diff log raw
1.1 --- a/src/gui_android.c Sun Mar 04 20:47:14 2012 +1000
1.2 +++ b/src/gui_android.c Tue Mar 20 08:29:38 2012 +1000
1.3 @@ -45,7 +45,7 @@
1.4 int width, height, format;
1.5 };
1.6
1.7 -static struct surface_info current_surface;
1.8 +static struct surface_info current_surface = { NULL, 0, 0, 0 };
1.9 static const char *appHome = NULL;
1.10
1.11 /**
1.12 @@ -89,14 +89,30 @@
1.13 return 0;
1.14 }
1.15
1.16 +int android_do_pause(void *data)
1.17 +{
1.18 + if( dreamcast_is_running() ) {
1.19 + dreamcast_stop();
1.20 + }
1.21 + video_egl_clear_window();
1.22 + INFO( "Paused" );
1.23 + return 0;
1.24 +}
1.25 +
1.26 +int android_do_resume(void *data)
1.27 +{
1.28 + struct surface_info *surface = (struct surface_info *)data;
1.29 + if( surface->win != NULL )
1.30 + video_egl_set_window(surface->win, surface->width, surface->height, surface->format);
1.31 + INFO( "Resumed" );
1.32 + return 0;
1.33 +}
1.34 +
1.35 int android_clear_surface(void *data)
1.36 {
1.37 struct surface_info *surface = (struct surface_info *)data;
1.38
1.39 - if( dreamcast_is_running() ) {
1.40 - dreamcast_stop();
1.41 - }
1.42 - video_egl_clear_window();
1.43 + android_do_pause(data); /* If we haven't already stopped, stop now */
1.44 ANativeWindow_release(surface->win);
1.45 surface->win = NULL;
1.46 return 0;
1.47 @@ -287,6 +303,17 @@
1.48 tqueue_send_message( android_callback_wrapper, dreamcast_stop );
1.49 }
1.50
1.51 +JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_onAppPause(JNIEnv * env, jclass obj)
1.52 +{
1.53 + /* Need to make sure this completely shuts down before we return */
1.54 + tqueue_send_message( android_do_pause, &current_surface );
1.55 +}
1.56 +
1.57 +JNIEXPORT void JNICALL Java_org_lxdream_Dreamcast_onAppResume(JNIEnv * env, jclass obj)
1.58 +{
1.59 + tqueue_post_message( android_do_resume, &current_surface );
1.60 +}
1.61 +
1.62 JNIEXPORT jboolean JNICALL Java_org_lxdream_Dreamcast_isRunning(JNIEnv *env, jclass obj)
1.63 {
1.64 return dreamcast_is_running();
1.65 @@ -322,6 +349,7 @@
1.66 } else {
1.67 current_surface.format = COLFMT_RGB888;
1.68 }
1.69 + INFO( "Setting surface" );
1.70 tqueue_post_message( android_set_surface, &current_surface );
1.71 }
1.72
.