Răsfoiți Sursa

AndroidRenderer first implementation done, jni declaration separated from jni definitions

mikymod 13 ani în urmă
părinte
comite
5a6f2cc6fe

+ 1 - 1
android/jni/Android.mk

@@ -46,8 +46,8 @@ LOCAL_SRC_FILES :=\
 \
 	os/OS.cpp\
 	os/android/AndroidOS.cpp\
-	os/android/AndroidRenderWindow.cpp\
 	os/android/AndroidInput.cpp\
+	os/android/AndroidRenderer.cpp\
 	os/android/File.cpp\
 \
 	Filesystem.cpp\

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

@@ -8,8 +8,16 @@ public class CrownLib
 	{
 		System.loadLibrary("crown");
 	}
+	
+	// Device functions
 
+	// AssetManager functions
 	public static native void initAssetManager(AssetManager assetManager);
 
+	// InputManager functions
 	public static native void pushEvent(int type, int a, int b, int c, int d);
+
+	// Renderer functions
+	public static native void beginFrame();
+	public static native void endFrame();
 }

+ 12 - 1
src/os/android/AndroidInput.cpp

@@ -16,30 +16,41 @@ JNIEXPORT void JNICALL Java_crown_android_CrownLib_pushEvent(JNIEnv * env, jobje
 	push_event((OSEventType)type, a, b, c, d);
 }
 
-
+//-----------------------------------------------------------------------------
 void init_input()
 {
 	// FIXME
 }
 
+//-----------------------------------------------------------------------------
+void event_loop()
+{
+	// not necessary
+}
+
+//-----------------------------------------------------------------------------
 void get_cursor_xy(int32_t& x, int32_t& y)
 {
 	// not necessary
 }
 
+//-----------------------------------------------------------------------------
 void set_cursor_xy(int32_t x, int32_t y)
 {
 	// not necessary
 }
 
+//-----------------------------------------------------------------------------
 void hide_cursor()
 {
 	// not necessary
 }
 
+//-----------------------------------------------------------------------------
 void show_cursor()
 {
 	// not necessary
 }
+
 } // namespace os
 } // namespace crown

+ 32 - 8
src/os/android/AndroidOS.cpp

@@ -23,19 +23,19 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-#include "OS.h"
 #include <android/log.h>
 #include <cstdio>
 #include <cstdarg>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <sys/types.h>
 #include <dirent.h>
 #include <cstdlib>
 #include <sys/time.h>
 #include <time.h>
 #include <android/asset_manager_jni.h>
-#include <jni.h>
+
+#include "OS.h"
+#include "AndroidOS.h"
 
 #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "crown", __VA_ARGS__))
 #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "crown", __VA_ARGS__))
@@ -47,6 +47,12 @@ namespace crown
 namespace os
 {
 
+extern "C" 
+{
+	// This is sadly necessary in order to get the asset manager from java...
+    JNIEXPORT void JNICALL Java_crown_android_CrownLib_initAssetManager(JNIEnv* env, jobject obj, jobject assetManager);
+};
+
 static timespec			base_time;
 static AAssetManager*	asset_manager = NULL;
 
@@ -242,13 +248,31 @@ AAssetManager* get_android_asset_manager()
 }
 
 //-----------------------------------------------------------------------------
-extern "C" 
+bool create_render_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height, bool fullscreen)
 {
-	// This is sadly necessary in order to get the asset manager from java...
-    JNIEXPORT void JNICALL Java_crown_android_CrownLib_initAssetManager(JNIEnv * env, jobject obj, jobject assetManager);
-};
+	// not necessary
+}
 
-JNIEXPORT void JNICALL Java_crown_android_CrownLib_initAssetManager(JNIEnv * env, jobject obj, jobject assetManager)
+//-----------------------------------------------------------------------------
+bool destroy_render_window()
+{
+	// not necessary
+}
+
+//-----------------------------------------------------------------------------
+void get_render_window_metrics(uint32_t& width, uint32_t& height)
+{
+	// not necessary
+}
+
+//-----------------------------------------------------------------------------
+void swap_buffers()
+{
+	// not necessary
+}
+
+//-----------------------------------------------------------------------------
+JNIEXPORT void JNICALL Java_crown_android_CrownLib_initAssetManager(JNIEnv* env, jobject obj, jobject assetManager)
 {
 	asset_manager = AAssetManager_fromJava(env, assetManager);
 }

+ 18 - 0
src/os/android/AndroidRenderer.cpp

@@ -0,0 +1,18 @@
+#include "AndroidRenderer.h"
+#include "Device.h"
+#include "Renderer.h"
+
+namespace crown
+{
+
+JNIEXPORT void JNICALL Java_crown_android_CrownLib_beginFrame(JNIEnv* env, jobject obj)
+{
+	GetDevice()->GetRenderer()->_BeginFrame();
+}
+
+JNIEXPORT void JNICALL Java_crown_android_CrownLib_endFrame(JNIEnv* env, jobject obj)
+{
+	GetDevice()->GetRenderer()->_EndFrame();
+}
+
+} // namespace crown

+ 14 - 0
src/os/android/AndroidRenderer.h

@@ -0,0 +1,14 @@
+#include <jni.h>
+#include <sys/types.h>
+
+namespace crown
+{
+
+extern "C" 
+{
+	// Renderer function...
+	JNIEXPORT void JNICALL Java_crown_android_CrownLib_beginFrame(JNIEnv* env, jobject obj);
+	JNIEXPORT void JNICALL Java_crown_android_CrownLib_endFrame(JNIEnv* env, jobject obj);
+};
+
+} // namespace crown