Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Last test version with GLSurface
Browse files Browse the repository at this point in the history
  • Loading branch information
bieh committed Jun 28, 2010
1 parent 5c40435 commit 1948658
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
37 changes: 32 additions & 5 deletions android/testproject/jni/app-android.c
Expand Up @@ -55,6 +55,7 @@ void* sdlThreadProc(void* args){
__android_log_print(ANDROID_LOG_INFO, "SDL", "Couldn't make current: 0x%x", eglGetError());
return NULL;
}


return (void *)SDL_main();
}
Expand Down Expand Up @@ -143,14 +144,40 @@ void Java_org_libsdl_android_TestGLSurfaceView_nativePause( JNIEnv* env )
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){
;
}

pthread_mutex_lock(&mSDLRenderMutex);
pthread_cond_signal(&mSDLRenderCondition); //wake up the SDL thread
pthread_mutex_unlock(&mSDLRenderMutex);
__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", "Unlocked");
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: BeginRender");

frames++;

while(startSDL == 0){
;
}
startSDL = 0;

__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: EndRender");
}

4 changes: 3 additions & 1 deletion android/testproject/jni/lesson05.c
Expand Up @@ -236,7 +236,7 @@ int drawGLScene( GLvoid )

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);
Expand Down Expand Up @@ -335,6 +335,8 @@ int drawGLScene( GLvoid )
}
}



return( TRUE );
}

Expand Down
2 changes: 2 additions & 0 deletions android/testproject/src/org/libsdl/android/TestActivity.java
Expand Up @@ -41,6 +41,8 @@ public TestGLSurfaceView(Context context) {
super(context);
mRenderer = new TestRenderer();
setRenderer(mRenderer);

//setRenderMode(RENDERMODE_WHEN_DIRTY);
}

public boolean onTouchEvent(final MotionEvent event) {
Expand Down
5 changes: 4 additions & 1 deletion src/video/android/SDL_androidgl.c
Expand Up @@ -43,6 +43,7 @@ These things are in the JNI android support
*/
extern pthread_mutex_t mSDLRenderMutex;
extern pthread_cond_t mSDLRenderCondition;
extern void sdl_render();

/* GL functions */
int Android_GL_LoadLibrary(_THIS, const char *path){
Expand Down Expand Up @@ -89,12 +90,14 @@ int Android_GL_GetSwapInterval(_THIS){

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();

}

Expand Down

0 comments on commit 1948658

Please sign in to comment.