Jelajahi Sumber

TODO: fix 1M undefined reference building crown shared library

mikymod 13 tahun lalu
induk
melakukan
91e748a54e

+ 11 - 2
android/jni/Android.mk

@@ -32,6 +32,8 @@ LOCAL_SRC_FILES :=\
 	core/math/Vec2.cpp\
 	core/math/Vec3.cpp\
 	core/math/Vec4.cpp\
+	core/mem/MallocAllocator.cpp\
+	core/streams/File.cpp\
 	core/streams/FileStream.cpp\
 	core/streams/MemoryStream.cpp\
 	core/streams/Stream.cpp\
@@ -105,8 +107,15 @@ LOCAL_C_INCLUDES	:=\
 LOCAL_CPPFLAGS	:= -g -fexceptions
 LOCAL_LDLIBS	:= -llog -landroid -lEGL -lGLESv1_CM
 LOCAL_STATIC_LIBRARIES := android_native_app_glue
-include $(BUILD_STATIC_LIBRARY)
-include $(CLEAR_VARS)
+include $(BUILD_SHARED_LIBRARY)
+
+#include $(CLEAR_VARS)
+
+#LOCAL_CPPFLAGS	:= -g -fexceptions
+#LOCAL_LDLIBS	:= -llog -landroid -lEGL -lGLESv1_CM
+#LOCAL_STATIC_LIBRARIES := android_native_app_glue
+#include $(BUILD_STATIC_LIBRARY)
+#include $(CLEAR_VARS)
 
 #LOCAL_MODULE    := simple
 #LOCAL_SRC_FILES :=	tests/chainsawbuffet/maain.cpp\

+ 35 - 0
android/src/crown/android/CrownActivity.java

@@ -2,6 +2,7 @@ package crown.android;
 
 import android.app.Activity;
 import android.os.Bundle;
+import android.widget.Toast;
 
 public class CrownActivity extends Activity
 {
@@ -11,5 +12,39 @@ public class CrownActivity extends Activity
     {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.main);
+		CrownLib.create();
+		Toast.makeText(this, "EGL window created", Toast.LENGTH_SHORT).show();
     }
+
+	public void onStart()
+	{
+		super.onStart();
+	}
+	
+	public void onRestart()
+	{
+		super.onRestart();
+	}
+
+	public void onResume()
+	{
+		super.onResume();
+	}
+
+	public void onPause()
+	{
+		super.onPause();
+	}
+
+	public void onStop()
+	{
+		super.onStop();
+	}
+
+	public void onDestroy()
+	{
+		super.onDestroy();
+		CrownLib.destroy();
+		Toast.makeText(this, "EGL window destroyed", Toast.LENGTH_SHORT).show();
+	}
 }

+ 12 - 0
android/src/crown/android/CrownLib.java

@@ -0,0 +1,12 @@
+package crown.android;
+
+public class CrownLib
+{
+	static 
+	{
+		System.loadLibrary("crown");
+	}
+
+	public static native boolean create();
+	public static native void destroy();
+}

+ 28 - 2
src/os/android/AndroidRenderWindow.cpp

@@ -29,18 +29,21 @@ OTHER DEALINGS IN THE SOFTWARE.
 #include "Config.h"
 #include <EGL/egl.h>
 #include <android_native_app_glue.h>
+#include <jni.h>
 
 namespace crown
 {
 namespace os
 {
 
+EGLint w;
+EGLint h;
 EGLDisplay display;
 EGLSurface surface;
 EGLContext context;
 android_app* application;
 
-bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint32_t depth, bool /*fullscreen*/)
+bool create_render_window()
 {
 	assert(width != 0 && height != 0);
 
@@ -80,7 +83,8 @@ bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t heigh
 
 	EGLint ctxattr[] =
 	{
-		EGL_CONTEXT_CLIENT_VERSION, 1,
+		EGL_CONTEXT_CLIENT_VERSION, 
+		1,
 		EGL_NONE
 	};
 
@@ -89,6 +93,9 @@ bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t heigh
 
 	assert(eglMakeCurrent(display, surface, surface, context) != EGL_NO_CONTEXT);
 
+	eglQuerySurface(display, surface, EGL_WIDTH, &w);
+    eglQuerySurface(display, surface, EGL_HEIGHT, &h);
+
 	return true;
 }
 
@@ -127,6 +134,25 @@ void swap_buffers()
 	eglSwapBuffers(display, surface);
 }
 
+
+// JNI definitions - just tmp
+extern "C"
+{
+	JNIEXPORT bool JNICALL Java_crown_android_CrownLib_create(JNIEnv* env, jobject obj);
+	JNIEXPORT void JNICALL Java_crown_android_CrownLib_destroy(JNIEnv* env, jobject obj);
+}
+
+JNIEXPORT bool JNICALL Java_crown_android_CrownLib_create(JNIEnv* env, jobject obj)
+{
+	return create_render_window();
+}
+
+JNIEXPORT void JNICALL Java_crown_android_CrownLib_destroy(JNIEnv* env, jobject obj)
+{
+	destroy_render_window();
+}
+
+
 } // namespace os
 } // namespace crown