Last test version with GLSurface
This commit is contained in:
parent
904e7b4511
commit
3ad2c1bdbf
4 changed files with 41 additions and 7 deletions
|
@ -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();
|
||||
}
|
||||
|
@ -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");
|
||||
|
||||
pthread_mutex_lock(&mSDLRenderMutex);
|
||||
pthread_cond_signal(&mSDLRenderCondition); //wake up the SDL thread
|
||||
pthread_mutex_unlock(&mSDLRenderMutex);
|
||||
//Let the SDL thread do an entire run
|
||||
int lastFrames = frames;
|
||||
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 )
|
|||
|
||||
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 @@ int drawGLScene( GLvoid )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return( TRUE );
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@ class TestGLSurfaceView extends GLSurfaceView {
|
|||
super(context);
|
||||
mRenderer = new TestRenderer();
|
||||
setRenderer(mRenderer);
|
||||
|
||||
//setRenderMode(RENDERMODE_WHEN_DIRTY);
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(final MotionEvent event) {
|
||||
|
|
|
@ -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){
|
||||
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue