changeset 4710:aeac51289991

Last test version with GLSurface
author Paul Hunkin <paul@bieh.net>
date Mon, 28 Jun 2010 21:35:28 +1200
parents 6dc26b9d8368
children ed040b480a9f
files android/testproject/jni/app-android.c android/testproject/jni/lesson05.c android/testproject/src/org/libsdl/android/TestActivity.java src/video/android/SDL_androidgl.c
diffstat 4 files changed, 41 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/android/testproject/jni/app-android.c	Fri Jun 18 01:29:14 2010 +1200
+++ b/android/testproject/jni/app-android.c	Mon Jun 28 21:35:28 2010 +1200
@@ -55,6 +55,7 @@
 		__android_log_print(ANDROID_LOG_INFO, "SDL", "Couldn't make current: 0x%x", eglGetError());
 		return NULL;
 	}
+
 	
 	return (void *)SDL_main();
 }
@@ -143,14 +144,40 @@
                      Render the next frame
 *******************************************************************************/
 
+volatile int frames = 0;
+volatile int startSDL = 0;
+
+//eglSwapBuffers(mDisplay, mDraw);
+	
 void Java_org_libsdl_android_TestRenderer_nativeRender( JNIEnv*  env )
 {    
-	//TODO: Render here
+	__android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: BeginRender");
+
+    //Let the SDL thread do an entire run
+    int lastFrames = frames;
+    startSDL = 1;
+
+    //wait for it to finish
+    while(lastFrames == frames){
+        ;   
+    }
+
+	__android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: EndRender");
+}
 
-	pthread_mutex_lock(&mSDLRenderMutex);
-	pthread_cond_signal(&mSDLRenderCondition); //wake up the SDL thread
-	pthread_mutex_unlock(&mSDLRenderMutex);
+void sdl_render(){
+
+    //When we get here, we've accumulated a full frame
+
+    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: BeginRender");
+    
+    frames++;
 
-	//__android_log_print(ANDROID_LOG_INFO, "SDL", "Unlocked");
+    while(startSDL == 0){
+        ;
+    }
+    startSDL = 0;
 
+    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: EndRender");
 }
+
--- a/android/testproject/jni/lesson05.c	Fri Jun 18 01:29:14 2010 +1200
+++ b/android/testproject/jni/lesson05.c	Mon Jun 28 21:35:28 2010 +1200
@@ -236,7 +236,7 @@
 	
     glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
 
-    glClearColorx(0,0,Frames,255);
+    glClearColorx(0,0,0,255);
     glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
 
     glMatrixMode(GL_PROJECTION);
@@ -335,6 +335,8 @@
 	}
     }
 
+   
+
     return( TRUE );
 }
 
--- a/android/testproject/src/org/libsdl/android/TestActivity.java	Fri Jun 18 01:29:14 2010 +1200
+++ b/android/testproject/src/org/libsdl/android/TestActivity.java	Mon Jun 28 21:35:28 2010 +1200
@@ -41,6 +41,8 @@
         super(context);
         mRenderer = new TestRenderer();
         setRenderer(mRenderer);
+
+        //setRenderMode(RENDERMODE_WHEN_DIRTY);
     }
 
     public boolean onTouchEvent(final MotionEvent event) {
--- a/src/video/android/SDL_androidgl.c	Fri Jun 18 01:29:14 2010 +1200
+++ b/src/video/android/SDL_androidgl.c	Mon Jun 28 21:35:28 2010 +1200
@@ -43,6 +43,7 @@
 */
 extern pthread_mutex_t mSDLRenderMutex;
 extern pthread_cond_t mSDLRenderCondition;
+extern void sdl_render();
 
 /* GL functions */
 int Android_GL_LoadLibrary(_THIS, const char *path){
@@ -89,12 +90,14 @@
 
 void Android_GL_SwapWindow(_THIS, SDL_Window * window){
 
+/*
 	pthread_mutex_lock(&mSDLRenderMutex);
 	pthread_cond_wait(&mSDLRenderCondition, &mSDLRenderMutex);
 	pthread_mutex_unlock(&mSDLRenderMutex);
-	
+*/	
 	
 	//__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SwapWindow\n");
+	sdl_render();
 
 }