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

Commit

Permalink
- Restructured threads and application structure.
Browse files Browse the repository at this point in the history
- Moved to SurfaceView instead of GLSurfaceView
- Moved to C++ for the android library
  • Loading branch information
bieh committed Jun 28, 2010
1 parent 1948658 commit 877d51d
Show file tree
Hide file tree
Showing 6 changed files with 258 additions and 217 deletions.
4 changes: 2 additions & 2 deletions android/testproject/jni/Android.mk
Expand Up @@ -11,8 +11,8 @@ LOCAL_CFLAGS := -DANDROID_NDK \
-I$(SDL)/include

LOCAL_SRC_FILES := \
importgl.c \
app-android.c \
importgl.cpp \
app-android.cpp \
lesson05.c \

LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lSDL -lEGL -lgcc -L$(SDL) -L$(SDL)/build-scripts/android_libs/
Expand Down
183 changes: 0 additions & 183 deletions android/testproject/jni/app-android.c

This file was deleted.

101 changes: 101 additions & 0 deletions android/testproject/jni/app-android.cpp
@@ -0,0 +1,101 @@
/*******************************************************************************
Headers
*******************************************************************************/
#include <jni.h>
#include <sys/time.h>
#include <time.h>
#include <android/log.h>
#include <stdint.h>

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#include <pthread.h>

#include "importgl.h"
#include "egl.h"

/*******************************************************************************
Globals
*******************************************************************************/
static long _getTime(void){
struct timeval now;
gettimeofday(&now, NULL);
return (long)(now.tv_sec*1000 + now.tv_usec/1000);
}

JNIEnv* mEnv = NULL;
JavaVM* mVM = NULL;

//Main activity
jclass mActivityInstance;

//method signatures
jmethodID midCreateGLContext;
jmethodID midFlipBuffers;

extern "C" int SDL_main();

/*******************************************************************************
Functions called by JNI
*******************************************************************************/

extern "C" void Java_org_libsdl_android_TestActivity_nativeInit( JNIEnv* env, jobject obj )
{
__android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: NativeInit");

mEnv = env;

SDL_main();
}

extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
JNIEnv* env = NULL;
jint result = -1;

if (vm->GetEnv((void**) &env, JNI_VERSION_1_4) != JNI_OK) {
return result;
}

mEnv = env;

__android_log_print(ANDROID_LOG_INFO, "SDL", "JNI: OnLoad");

jclass cls = mEnv->FindClass ("org/libsdl/android/TestActivity");
mActivityInstance = cls;
midCreateGLContext = mEnv->GetStaticMethodID(cls,"createGLContext","()V");
midFlipBuffers = mEnv->GetStaticMethodID(cls,"flipBuffers","()V");

if(!midCreateGLContext || !midFlipBuffers){
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: Bad mids\n");
}else{
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: Good mids\n");
}

return JNI_VERSION_1_4;
}



/*******************************************************************************
Functions called by SDL
*******************************************************************************/
extern "C" void sdl_create_context(){
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: sdl_create_context()\n");

mEnv->CallStaticVoidMethod(mActivityInstance, midCreateGLContext );
__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: sdl_create_context() return\n");

// exit(1);
}

extern "C" void sdl_render(){

//When we get here, we've accumulated a full frame
//__android_log_print(ANDROID_LOG_INFO, "SDL", "SDL: sdl_render()");

mEnv->CallStaticVoidMethod(mActivityInstance, midFlipBuffers );
}

File renamed without changes.

0 comments on commit 877d51d

Please sign in to comment.