Commit 3ad2c1bd authored by Paul Hunkin's avatar Paul Hunkin

Last test version with GLSurface

parent 904e7b45
...@@ -56,6 +56,7 @@ void* sdlThreadProc(void* args){ ...@@ -56,6 +56,7 @@ void* sdlThreadProc(void* args){
return NULL; return NULL;
} }
return (void *)SDL_main(); return (void *)SDL_main();
} }
...@@ -143,14 +144,40 @@ void Java_org_libsdl_android_TestGLSurfaceView_nativePause( JNIEnv* env ) ...@@ -143,14 +144,40 @@ void Java_org_libsdl_android_TestGLSurfaceView_nativePause( JNIEnv* env )
Render the next frame Render the next frame
*******************************************************************************/ *******************************************************************************/
volatile int frames = 0;
volatile int startSDL = 0;
//eglSwapBuffers(mDisplay, mDraw);
void Java_org_libsdl_android_TestRenderer_nativeRender( JNIEnv* env ) void Java_org_libsdl_android_TestRenderer_nativeRender( JNIEnv* env )
{ {
//TODO: Render here __android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: BeginRender");
pthread_mutex_lock(&mSDLRenderMutex); //Let the SDL thread do an entire run
pthread_cond_signal(&mSDLRenderCondition); //wake up the SDL thread int lastFrames = frames;
pthread_mutex_unlock(&mSDLRenderMutex); startSDL = 1;
//__android_log_print(ANDROID_LOG_INFO, "SDL", "Unlocked"); //wait for it to finish
while(lastFrames == frames){
;
}
__android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: EndRender");
} }
void sdl_render(){
//When we get here, we've accumulated a full frame
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: BeginRender");
frames++;
while(startSDL == 0){
;
}
startSDL = 0;
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: EndRender");
}
...@@ -236,7 +236,7 @@ int drawGLScene( GLvoid ) ...@@ -236,7 +236,7 @@ int drawGLScene( GLvoid )
glViewport(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); 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); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
...@@ -335,6 +335,8 @@ int drawGLScene( GLvoid ) ...@@ -335,6 +335,8 @@ int drawGLScene( GLvoid )
} }
} }
return( TRUE ); return( TRUE );
} }
......
...@@ -41,6 +41,8 @@ class TestGLSurfaceView extends GLSurfaceView { ...@@ -41,6 +41,8 @@ class TestGLSurfaceView extends GLSurfaceView {
super(context); super(context);
mRenderer = new TestRenderer(); mRenderer = new TestRenderer();
setRenderer(mRenderer); setRenderer(mRenderer);
//setRenderMode(RENDERMODE_WHEN_DIRTY);
} }
public boolean onTouchEvent(final MotionEvent event) { public boolean onTouchEvent(final MotionEvent event) {
......
...@@ -43,6 +43,7 @@ These things are in the JNI android support ...@@ -43,6 +43,7 @@ These things are in the JNI android support
*/ */
extern pthread_mutex_t mSDLRenderMutex; extern pthread_mutex_t mSDLRenderMutex;
extern pthread_cond_t mSDLRenderCondition; extern pthread_cond_t mSDLRenderCondition;
extern void sdl_render();
/* GL functions */ /* GL functions */
int Android_GL_LoadLibrary(_THIS, const char *path){ int Android_GL_LoadLibrary(_THIS, const char *path){
...@@ -89,12 +90,14 @@ int Android_GL_GetSwapInterval(_THIS){ ...@@ -89,12 +90,14 @@ int Android_GL_GetSwapInterval(_THIS){
void Android_GL_SwapWindow(_THIS, SDL_Window * window){ void Android_GL_SwapWindow(_THIS, SDL_Window * window){
/*
pthread_mutex_lock(&mSDLRenderMutex); pthread_mutex_lock(&mSDLRenderMutex);
pthread_cond_wait(&mSDLRenderCondition, &mSDLRenderMutex); pthread_cond_wait(&mSDLRenderCondition, &mSDLRenderMutex);
pthread_mutex_unlock(&mSDLRenderMutex); pthread_mutex_unlock(&mSDLRenderMutex);
*/
//__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SwapWindow\n"); //__android_log_print(ANDROID_LOG_INFO, "SDL", "[STUB] GL_SwapWindow\n");
sdl_render();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment