Last test version with GLSurface
authorPaul Hunkin
Mon, 28 Jun 2010 21:35:28 +1200
changeset 4710aeac51289991
parent 4709 6dc26b9d8368
child 4711 ed040b480a9f
Last test version with GLSurface
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
     1.1 --- a/android/testproject/jni/app-android.c	Fri Jun 18 01:29:14 2010 +1200
     1.2 +++ b/android/testproject/jni/app-android.c	Mon Jun 28 21:35:28 2010 +1200
     1.3 @@ -55,6 +55,7 @@
     1.4  		__android_log_print(ANDROID_LOG_INFO, "SDL", "Couldn't make current: 0x%x", eglGetError());
     1.5  		return NULL;
     1.6  	}
     1.7 +
     1.8  	
     1.9  	return (void *)SDL_main();
    1.10  }
    1.11 @@ -143,14 +144,40 @@
    1.12                       Render the next frame
    1.13  *******************************************************************************/
    1.14  
    1.15 +volatile int frames = 0;
    1.16 +volatile int startSDL = 0;
    1.17 +
    1.18 +//eglSwapBuffers(mDisplay, mDraw);
    1.19 +	
    1.20  void Java_org_libsdl_android_TestRenderer_nativeRender( JNIEnv*  env )
    1.21  {    
    1.22 -	//TODO: Render here
    1.23 +	__android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: BeginRender");
    1.24 +
    1.25 +    //Let the SDL thread do an entire run
    1.26 +    int lastFrames = frames;
    1.27 +    startSDL = 1;
    1.28 +
    1.29 +    //wait for it to finish
    1.30 +    while(lastFrames == frames){
    1.31 +        ;   
    1.32 +    }
    1.33 +
    1.34 +	__android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: EndRender");
    1.35 +}
    1.36  
    1.37 -	pthread_mutex_lock(&mSDLRenderMutex);
    1.38 -	pthread_cond_signal(&mSDLRenderCondition); //wake up the SDL thread
    1.39 -	pthread_mutex_unlock(&mSDLRenderMutex);
    1.40 +void sdl_render(){
    1.41 +
    1.42 +    //When we get here, we've accumulated a full frame
    1.43 +
    1.44 +    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: BeginRender");
    1.45 +    
    1.46 +    frames++;
    1.47  
    1.48 -	//__android_log_print(ANDROID_LOG_INFO, "SDL", "Unlocked");
    1.49 +    while(startSDL == 0){
    1.50 +        ;
    1.51 +    }
    1.52 +    startSDL = 0;
    1.53  
    1.54 +    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: EndRender");
    1.55  }
    1.56 +
     2.1 --- a/android/testproject/jni/lesson05.c	Fri Jun 18 01:29:14 2010 +1200
     2.2 +++ b/android/testproject/jni/lesson05.c	Mon Jun 28 21:35:28 2010 +1200
     2.3 @@ -236,7 +236,7 @@
     2.4  	
     2.5      glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
     2.6  
     2.7 -    glClearColorx(0,0,Frames,255);
     2.8 +    glClearColorx(0,0,0,255);
     2.9      glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    2.10  
    2.11      glMatrixMode(GL_PROJECTION);
    2.12 @@ -335,6 +335,8 @@
    2.13  	}
    2.14      }
    2.15  
    2.16 +   
    2.17 +
    2.18      return( TRUE );
    2.19  }
    2.20  
     3.1 --- a/android/testproject/src/org/libsdl/android/TestActivity.java	Fri Jun 18 01:29:14 2010 +1200
     3.2 +++ b/android/testproject/src/org/libsdl/android/TestActivity.java	Mon Jun 28 21:35:28 2010 +1200
     3.3 @@ -41,6 +41,8 @@
     3.4          super(context);
     3.5          mRenderer = new TestRenderer();
     3.6          setRenderer(mRenderer);
     3.7 +
     3.8 +        //setRenderMode(RENDERMODE_WHEN_DIRTY);
     3.9      }
    3.10  
    3.11      public boolean onTouchEvent(final MotionEvent event) {
     4.1 --- a/src/video/android/SDL_androidgl.c	Fri Jun 18 01:29:14 2010 +1200
     4.2 +++ b/src/video/android/SDL_androidgl.c	Mon Jun 28 21:35:28 2010 +1200
     4.3 @@ -43,6 +43,7 @@
     4.4  */
     4.5  extern pthread_mutex_t mSDLRenderMutex;
     4.6  extern pthread_cond_t mSDLRenderCondition;
     4.7 +extern void sdl_render();
     4.8  
     4.9  /* GL functions */
    4.10  int Android_GL_LoadLibrary(_THIS, const char *path){
    4.11 @@ -89,12 +90,14 @@
    4.12  
    4.13  void Android_GL_SwapWindow(_THIS, SDL_Window * window){
    4.14  
    4.15 +/*
    4.16  	pthread_mutex_lock(&mSDLRenderMutex);
    4.17  	pthread_cond_wait(&mSDLRenderCondition, &mSDLRenderMutex);
    4.18  	pthread_mutex_unlock(&mSDLRenderMutex);
    4.19 -	
    4.20 +*/	
    4.21  	
    4.22  	//__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SwapWindow\n");
    4.23 +	sdl_render();
    4.24  
    4.25  }
    4.26