7 new commits in ogre:
https://bitbucket.org/sinbad/ogre/commits/218379cef9fd/
changeset: 218379cef9fd
branch: v1-9
user: wolf...@...
date: 2013-02-18 14:38:36
summary: First version og OGRE JNI binding
affected #: 11 files
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 CMake/Templates/Android.mk.in
--- a/CMake/Templates/Android.mk.in
+++ b/CMake/Templates/Android.mk.in
@@ -1,11 +1,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
- LOCAL_MODULE := OgreSampleBrowser
+ LOCAL_MODULE := @ANDROID_MOD_NAME@
LOCAL_LDLIBS := -landroid -lc -lm -ldl -llog -lEGL -lGLESv2
LOCAL_LDLIBS += -L@... -L@...@
- LOCAL_LDLIBS += -lSample_CameraTrack -lSample_CelShading -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_CubeMapping -lSample_DynTex
- LOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Fresnel -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_MeshLod -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke
+ @SAMPLE_LDLIBS@
LOCAL_LDLIBS += -lPlugin_ParticleFXStatic -lPlugin_OctreeSceneManagerStatic -lRenderSystem_GLES2Static -lOgreRTShaderSystemStatic -lOgreOverlayStatic -lOgreMainStatic
LOCAL_LDLIBS += -lzzip -lz -lFreeImage -lfreetype -lOIS @GLES_OPTIMISER@ @OGRE_BINARY_DIR@... @OGRE_BINARY_DIR@... @NDKOUT@...
LOCAL_STATIC_LIBRARIES := android_native_app_glue cpufeatures
@@ -16,9 +15,7 @@
LOCAL_CFLAGS += -I@... -I@... -I@...
LOCAL_CFLAGS += -fexceptions -frtti -x c++ -D___ANDROID___ -DANDROID -DZZIP_OMIT_CONFIG_H -DUSE_RTSHADER_SYSTEM=1
- LOCAL_PATH := @CMAKE_SOURCE_DIR@...
- LOCAL_SRC_FILES := SampleBrowser.cpp
-
+ @JNI_SRC@
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/cpufeatures)
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 CMake/Templates/AndroidGLES1.mk.in
--- a/CMake/Templates/AndroidGLES1.mk.in
+++ b/CMake/Templates/AndroidGLES1.mk.in
@@ -1,11 +1,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
- LOCAL_MODULE := OgreSampleBrowser
+ LOCAL_MODULE := @ANDROID_MOD_NAME@
LOCAL_LDLIBS := -landroid -lc -lm -ldl -llog -lEGL -lGLESv1_CM
LOCAL_LDLIBS += -L@... -L@...@
- LOCAL_LDLIBS += -lSample_CameraTrack -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_DynTex
- LOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke
+ @SAMPLE_LDLIBS@
LOCAL_LDLIBS += -lPlugin_ParticleFXStatic -lPlugin_OctreeSceneManagerStatic -lRenderSystem_GLESStatic -lOgreOverlayStatic -lOgreMainStatic
LOCAL_LDLIBS += -lzzip -lz -lFreeImage -lfreetype -lOIS @OGRE_BINARY_DIR@... @OGRE_BINARY_DIR@... @NDKOUT@...
LOCAL_STATIC_LIBRARIES := android_native_app_glue cpufeatures
@@ -16,9 +15,7 @@
LOCAL_CFLAGS += -I@... -I@... -I@...
LOCAL_CFLAGS += -fexceptions -frtti -x c++ -D___ANDROID___ -DANDROID -DZZIP_OMIT_CONFIG_H
- LOCAL_PATH := @CMAKE_SOURCE_DIR@...
- LOCAL_SRC_FILES := SampleBrowser.cpp
-
+ @JNI_SRC@
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/cpufeatures)
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 CMake/Templates/AndroidManifest_JNI.xml.in
--- /dev/null
+++ b/CMake/Templates/AndroidManifest_JNI.xml.in
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.ogre3d.jni"
+ android:versionCode="1"
+ android:versionName="1.0"
+ android:installLocation="auto">
+
+ <uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
+
+ <application android:label="@ANDROID_MOD_NAME@" android:hasCode="true">
+ <activity android:name="org.ogre3d.android.MainActivity"
+ android:label="@ANDROID_MOD_NAME@"
+ android:configChanges="orientation@..."
+ android:debuggable="true"
+ android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
\ No newline at end of file
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 CMake/toolchain/AndroidJNI.cmake
--- /dev/null
+++ b/CMake/toolchain/AndroidJNI.cmake
@@ -0,0 +1,98 @@
+#-------------------------------------------------------------------
+# This file is part of the CMake build system for OGRE
+# (Object-oriented Graphics Rendering Engine)
+# For the latest info, see http://www.ogre3d.org/
+#
+# The contents of this file are placed in the public domain. Feel
+# free to make use of it in any way you like.
+#-------------------------------------------------------------------
+
+if(ANDROID)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummyJNI.cpp "int x = 23;")
+ ADD_LIBRARY(OgreJNIDummy MODULE ${CMAKE_CURRENT_BINARY_DIR}/dummyJNI.cpp)
+
+ if(OGRE_BUILD_RENDERSYSTEM_GLES2)
+ add_dependencies(OgreJNIDummy OgreMain RenderSystem_GLES2)
+ else()
+ add_dependencies(OgreJNIDummy OgreMain RenderSystem_GLES)
+ endif()
+
+ if(APPLE OR WIN32)
+ SET(ANDROID_EXECUTABLE "android")
+ SET(NDK_BUILD_EXECUTABLE "ndk-build")
+ else()
+ SET(ANDROID_EXECUTABLE "$ENV{ANDROID_SDK}/tools/android")
+ SET(NDK_BUILD_EXECUTABLE "$ENV{ANDROID_NDK}/ndk-build")
+ endif()
+
+ SET(ANDROID_MOD_NAME "OgreJNI")
+ SET(JNI_SRC "LOCAL_PATH := @CMAKE_SOURCE_DIR@...")
+ SET(JNI_SRC "${JNI_SRC}\tLOCAL_SRC_FILES := OgreActivityJNI.cpp\n")
+ SET(ANT_EXECUTABLE "ant")
+
+ if(${ANDROID_NATIVE_API_LEVEL} LESS 14)
+ MATH(EXPR ANDROID_SDK_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}+1")
+ else()
+ SET(ANDROID_SDK_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}")
+ SET(SCREEN_SIZE "|screenSize")
+ endif()
+
+ if(OGRE_CONFIG_ENABLE_GLES2_GLSL_OPTIMISER)
+ SET(GLES_OPTIMISER "-lglsl_optimizer -lmesa -lglcpp-library")
+ endif()
+
+ SET(ANDROID_TARGET "android-${ANDROID_SDK_API_LEVEL}")
+
+ SET(NDKOUT "${CMAKE_BINARY_DIR}/OgreJNI")
+ file(MAKE_DIRECTORY "${NDKOUT}")
+ file(MAKE_DIRECTORY "${NDKOUT}/jni")
+ file(MAKE_DIRECTORY "${NDKOUT}/assets")
+ file(MAKE_DIRECTORY "${NDKOUT}/res")
+ file(MAKE_DIRECTORY "${NDKOUT}/src")
+ file(MAKE_DIRECTORY "${NDKOUT}/src/org")
+ file(MAKE_DIRECTORY "${NDKOUT}/src/org/ogre3d")
+ file(MAKE_DIRECTORY "${NDKOUT}/src/org/ogre3d/android")
+ file(COPY "@CMAKE_SOURCE_DIR@..." DESTINATION "${NDKOUT}/src/org/ogre3d/android")
+ file(COPY "@CMAKE_SOURCE_DIR@..." DESTINATION "${NDKOUT}/src/org/ogre3d/android")
+
+ file(WRITE "${NDKOUT}/default.properties" "target=${ANDROID_TARGET}")
+ file(WRITE "${NDKOUT}/jni/Application.mk" "APP_ABI := ${ANDROID_ABI}\nAPP_STL := gnustl_static ")
+ configure_file("${OGRE_TEMPLATES_DIR}/AndroidManifest_JNI.xml.in" "${NDKOUT}/AndroidManifest.xml" @ONLY)
+
+ if(NOT ANDROID_GLES_ONLY)
+ configure_file("${OGRE_TEMPLATES_DIR}/Android.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
+ else()
+ configure_file("${OGRE_TEMPLATES_DIR}/AndroidGLES1.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
+ endif()
+
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${ANDROID_EXECUTABLE} update project --target ${ANDROID_TARGET} --path "${NDKOUT}"
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+
+ if(DEBUG)
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${NDK_BUILD_EXECUTABLE} all -j2 V=1 NDK_DEBUG=1
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+ else()
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${NDK_BUILD_EXECUTABLE} all -j2
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+ endif()
+
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${ANT_EXECUTABLE} debug
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+
+endif()
\ No newline at end of file
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -476,6 +476,11 @@
# Setup samples
add_subdirectory(Samples)
+#Add android JNI binding
+if(ANDROID)
+ include(toolchain/AndroidJNI)
+endif()
+
# Setup command-line tools
if (OGRE_BUILD_TOOLS)
add_subdirectory(Tools)
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 OgreMain/src/Android/JNI/MainActivity.java
--- /dev/null
+++ b/OgreMain/src/Android/JNI/MainActivity.java
@@ -0,0 +1,130 @@
+package org.ogre3d.android;
+
+import org.ogre3d.android.OgreActivityJNI;
+
+import android.app.Activity;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.view.SurfaceHolder.Callback;
+import android.view.SurfaceView;
+
+public class MainActivity extends Activity implements SensorEventListener {
+ protected Handler handler = null;
+ protected SurfaceView surfaceView = null;
+ protected Surface lastSurface = null;
+
+ private Runnable renderer = null;
+ private boolean paused = false;
+ private boolean initOGRE = false;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ handler = new Handler();
+ sysInit();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ handler.removeCallbacks(renderer);
+ paused = true;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ paused = false;
+ handler.post(renderer);
+ }
+
+
+
+ private void sysInit() {
+ final Runnable initRunnable = new Runnable() {
+ public void run() {
+ if (!initOGRE) {
+ initOGRE = true;
+ OgreActivityJNI.create();
+
+ renderer = new Runnable() {
+ public void run() {
+
+ if (paused)
+ return;
+
+ if (!wndCreate && lastSurface != null) {
+ wndCreate = true;
+ OgreActivityJNI.initWindow(lastSurface);
+ handler.post(this);
+ return;
+ }
+
+ if (initOGRE && wndCreate)
+ OgreActivityJNI.renderOneFrame();
+
+ handler.post(this);
+ }
+ };
+
+ handler.post(renderer);
+ }
+ }
+
+ };
+
+ SurfaceView view = new SurfaceView(this);
+ SurfaceHolder holder = view.getHolder();
+ // holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
+ surfaceView = view;
+
+ holder.addCallback(new Callback() {
+ public void surfaceCreated(SurfaceHolder holder) {
+ if (holder.getSurface() != null
+ && holder.getSurface().isValid()) {
+ lastSurface = holder.getSurface();
+ handler.post(initRunnable);
+ }
+ }
+
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ if (initOGRE && wndCreate) {
+ wndCreate = false;
+ lastSurface = null;
+ handler.post(new Runnable() {
+ public void run() {
+ OgreActivityJNI.termWindow();
+ }
+ });
+ }
+ }
+
+ public void surfaceChanged(SurfaceHolder holder, int format,
+ int width, int height) {
+
+ }
+ });
+ setContentView(surfaceView);
+ }
+
+ boolean wndCreate = false;
+
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+
+ }
+
+ public void onSensorChanged(SensorEvent event) {
+ if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
+ }
+
+ }
+
+ static {
+ System.loadLibrary("OgreJNI");
+ }
+}
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 OgreMain/src/Android/JNI/OgreActivityJNI.cpp
--- /dev/null
+++ b/OgreMain/src/Android/JNI/OgreActivityJNI.cpp
@@ -0,0 +1,174 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+(Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2012 Torus Knot Software Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+
+#include <jni.h>
+#include <EGL/egl.h>
+#include <android/api-level.h>
+#include <android/native_window_jni.h>
+#include "OgrePlatform.h"
+#include "OgreRoot.h"
+#include "OgreRenderWindow.h"
+#include "Android/OgreAndroidEGLWindow.h"
+
+#include "OgreOctreePlugin.h"
+#include "OgreParticleFXPlugin.h"
+#include "OgreConfigFile.h"
+
+#ifdef OGRE_BUILD_RENDERSYSTEM_GLES2
+# include "OgreGLES2Plugin.h"
+# define GLESRS GLES2Plugin
+#else
+# include "OgreGLESPlugin.h"
+# define GLESRS GLESPlugin
+#endif
+
+using namespace Ogre;
+
+static bool gInit = false;
+static Ogre::Root* gRoot = NULL;
+static Ogre::RenderWindow* gRenderWnd = NULL;
+static Ogre::OctreePlugin* gOctreePlugin = NULL;
+static Ogre::ParticleFXPlugin* gParticleFXPlugin = NULL;
+static Ogre::GLESRS* gGLESPlugin = NULL;
+
+static Ogre::SceneManager* pSceneMgr = NULL;
+static Ogre::Camera* pCamera = NULL;
+static JavaVM* gVM = NULL;
+extern "C"
+{
+ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
+ {
+ JNIEnv *env;
+ jclass k;
+ jint r;
+
+ gVM = vm;
+ r = vm->GetEnv ((void **) &env, JNI_VERSION_1_4);
+ k = env->FindClass ("org/ogre3d/android/OgreActivityJNI");
+ return JNI_VERSION_1_4;
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_create(JNIEnv * env, jobject obj)
+ {
+ if(gInit)
+ return;
+
+ gRoot = new Ogre::Root();
+
+ gGLESPlugin = OGRE_NEW GLESRS();
+ gRoot->installPlugin(gGLESPlugin);
+
+ gOctreePlugin = OGRE_NEW OctreePlugin();
+ gRoot->installPlugin(gOctreePlugin);
+
+ gParticleFXPlugin = OGRE_NEW ParticleFXPlugin();
+ gRoot->installPlugin(gParticleFXPlugin);
+
+ gRoot->setRenderSystem(gRoot->getAvailableRenderers().at(0));
+ gRoot->initialise(false);
+ gInit = true;
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_destroy(JNIEnv * env, jobject obj)
+ {
+ if(!gInit)
+ return;
+
+ gInit = false;
+
+ OGRE_DELETE gRoot;
+ gRoot = NULL;
+ gRenderWnd = NULL;
+
+ OGRE_DELETE gParticleFXPlugin;
+ gParticleFXPlugin = NULL;
+
+ OGRE_DELETE gOctreePlugin;
+ gOctreePlugin = NULL;
+
+ OGRE_DELETE gGLESPlugin;
+ gGLESPlugin = NULL;
+ }
+
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_initWindow(JNIEnv * env, jobject obj, jobject surface)
+ {
+ if(surface)
+ {
+ ANativeWindow* nativeWnd = ANativeWindow_fromSurface(env, surface);
+ if (nativeWnd && gRoot)
+ {
+ if (!gRenderWnd)
+ {
+ Ogre::NameValuePairList opt;
+ opt["externalWindowHandle"] = Ogre::StringConverter::toString((int)nativeWnd);
+ gRenderWnd = Ogre::Root::getSingleton().createRenderWindow("OgreWindow", 0, 0, false, &opt);
+
+
+ if(pSceneMgr == NULL)
+ {
+ pSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);
+ pCamera = pSceneMgr->createCamera("MyCam");
+
+ Ogre::Viewport* vp = gRenderWnd->addViewport(pCamera);
+ vp->setBackgroundColour(Ogre::ColourValue(1,0,0));
+ }
+ }
+ else
+ {
+ static_cast<Ogre::AndroidEGLWindow*>(gRenderWnd)->_createInternalResources(nativeWnd, NULL);
+ }
+ }
+ }
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_termWindow(JNIEnv * env, jobject obj)
+ {
+ if(gRoot && gRenderWnd)
+ {
+ static_cast<Ogre::AndroidEGLWindow*>(gRenderWnd)->_destroyInternalResources();
+ }
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_renderOneFrame(JNIEnv * env, jobject obj)
+ {
+ if(gRenderWnd != NULL && gRenderWnd->isActive())
+ {
+ try
+ {
+ if(gVM->AttachCurrentThread(&env, NULL) < 0)
+ return;
+
+ gRenderWnd->windowMovedOrResized();
+ gRoot->renderOneFrame();
+
+ //gVM->DetachCurrentThread();
+ }catch(Ogre::RenderingAPIException ex) {}
+ }
+ }
+};
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 OgreMain/src/Android/JNI/OgreActivityJNI.java
--- /dev/null
+++ b/OgreMain/src/Android/JNI/OgreActivityJNI.java
@@ -0,0 +1,11 @@
+package org.ogre3d.android;
+
+import android.view.Surface;
+
+public class OgreActivityJNI {
+ public native static void create();
+ public native static void destroy();
+ public native static void initWindow(Surface surface);
+ public native static void termWindow();
+ public native static void renderOneFrame();
+}
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 RenderSystems/GLES/src/OgreGLESRenderSystem.cpp
--- a/RenderSystems/GLES/src/OgreGLESRenderSystem.cpp
+++ b/RenderSystems/GLES/src/OgreGLESRenderSystem.cpp
@@ -2931,9 +2931,8 @@
{
LogManager::getSingleton().logMessage("********************************************");
LogManager::getSingleton().logMessage("*** OpenGL ES 1.x Reset Renderer Started ***");
- LogManager::getSingleton().logMessage("********************************************");
+ LogManager::getSingleton().logMessage("********************************************");
- mStateCacheManager->clearCache();
initialiseContext(win);
mGLSupport->initialiseExtensions();
@@ -2952,6 +2951,7 @@
GLESRenderSystem::mResourceManager->notifyOnContextReset();
+ mStateCacheManager->clearCache();
_setViewport(NULL);
_setRenderTarget(win);
}
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
--- a/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
+++ b/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
@@ -2218,6 +2218,7 @@
GLES2RenderSystem::mResourceManager->notifyOnContextReset();
+ mStateCacheManager->clearCache();
_setViewport(NULL);
_setRenderTarget(win);
}
diff -r f07afef73acd04831dd5fa8015d8a3b923be94e2 -r 218379cef9fd57edcb3d38629754c8264dfe2d04 Samples/Browser/CMakeLists.txt
--- a/Samples/Browser/CMakeLists.txt
+++ b/Samples/Browser/CMakeLists.txt
@@ -90,13 +90,9 @@
if(APPLE OR WIN32)
SET(ANDROID_EXECUTABLE "android")
+ SET(NDK_BUILD_EXECUTABLE "ndk-build")
else()
SET(ANDROID_EXECUTABLE "$ENV{ANDROID_SDK}/tools/android")
- endif()
-
- if(APPLE OR WIN32)
- SET(NDK_BUILD_EXECUTABLE "ndk-build")
- else()
SET(NDK_BUILD_EXECUTABLE "$ENV{ANDROID_NDK}/ndk-build")
endif()
@@ -123,9 +119,17 @@
file(WRITE "${NDKOUT}/jni/Application.mk" "APP_ABI := ${ANDROID_ABI}\nAPP_STL := gnustl_static ")
configure_file("${OGRE_TEMPLATES_DIR}/AndroidManifest.xml.in" "${NDKOUT}/AndroidManifest.xml" @ONLY)
+ SET(ANDROID_MOD_NAME "OgreSampleBrowser")
+ SET(JNI_SRC "LOCAL_PATH := @CMAKE_SOURCE_DIR@...")
+ SET(JNI_SRC "${JNI_SRC}\tLOCAL_SRC_FILES := SampleBrowser.cpp\n")
+
if(NOT ANDROID_GLES_ONLY)
+ SET(SAMPLE_LDLIBS "LOCAL_LDLIBS += -lSample_CameraTrack -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_DynTex\n")
+ SET(SAMPLE_LDLIBS "${SAMPLE_LDLIBS}\tLOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke\n")
configure_file("${OGRE_TEMPLATES_DIR}/Android.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
else()
+ SET(SAMPLE_LDLIBS "LOCAL_LDLIBS += -lSample_CameraTrack -lSample_CelShading -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_CubeMapping -lSample_DynTex\n")
+ SET(SAMPLE_LDLIBS "${SAMPLE_LDLIBS}\tLOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Fresnel -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_MeshLod -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke\n")
configure_file("${OGRE_TEMPLATES_DIR}/AndroidGLES1.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
endif()
https://bitbucket.org/sinbad/ogre/commits/309e82d5832d/
changeset: 309e82d5832d
branch: v1-9
user: wolf...@...
date: 2013-02-21 09:50:23
summary: * Mixed up GLES1/GLES2 samples
affected #: 1 file
diff -r 218379cef9fd57edcb3d38629754c8264dfe2d04 -r 309e82d5832dd4f30c06f75c1fc558f198f7086a Samples/Browser/CMakeLists.txt
--- a/Samples/Browser/CMakeLists.txt
+++ b/Samples/Browser/CMakeLists.txt
@@ -124,12 +124,12 @@
SET(JNI_SRC "${JNI_SRC}\tLOCAL_SRC_FILES := SampleBrowser.cpp\n")
if(NOT ANDROID_GLES_ONLY)
- SET(SAMPLE_LDLIBS "LOCAL_LDLIBS += -lSample_CameraTrack -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_DynTex\n")
- SET(SAMPLE_LDLIBS "${SAMPLE_LDLIBS}\tLOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke\n")
- configure_file("${OGRE_TEMPLATES_DIR}/Android.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
- else()
SET(SAMPLE_LDLIBS "LOCAL_LDLIBS += -lSample_CameraTrack -lSample_CelShading -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_CubeMapping -lSample_DynTex\n")
SET(SAMPLE_LDLIBS "${SAMPLE_LDLIBS}\tLOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Fresnel -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_MeshLod -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke\n")
+ configure_file("${OGRE_TEMPLATES_DIR}/Android.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
+ else()
+ SET(SAMPLE_LDLIBS "LOCAL_LDLIBS += -lSample_CameraTrack -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_DynTex\n")
+ SET(SAMPLE_LDLIBS "${SAMPLE_LDLIBS}\tLOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke\n")
configure_file("${OGRE_TEMPLATES_DIR}/AndroidGLES1.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
endif()
https://bitbucket.org/sinbad/ogre/commits/8a828aa2e26f/
changeset: 8a828aa2e26f
branch: v1-9
user: wolf...@...
date: 2013-02-21 09:50:58
summary: Merge
affected #: 11 files
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d CMake/Templates/Android.mk.in
--- a/CMake/Templates/Android.mk.in
+++ b/CMake/Templates/Android.mk.in
@@ -1,11 +1,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
- LOCAL_MODULE := OgreSampleBrowser
+ LOCAL_MODULE := @ANDROID_MOD_NAME@
LOCAL_LDLIBS := -landroid -lc -lm -ldl -llog -lEGL -lGLESv2
LOCAL_LDLIBS += -L@... -L@...@
- LOCAL_LDLIBS += -lSample_CameraTrack -lSample_CelShading -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_CubeMapping -lSample_DynTex
- LOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Fresnel -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_MeshLod -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke
+ @SAMPLE_LDLIBS@
LOCAL_LDLIBS += -lPlugin_ParticleFXStatic -lPlugin_OctreeSceneManagerStatic -lRenderSystem_GLES2Static -lOgreRTShaderSystemStatic -lOgreOverlayStatic -lOgreMainStatic
LOCAL_LDLIBS += -lzzip -lz -lFreeImage -lfreetype -lOIS @GLES_OPTIMISER@ @OGRE_BINARY_DIR@... @OGRE_BINARY_DIR@... @NDKOUT@...
LOCAL_STATIC_LIBRARIES := android_native_app_glue cpufeatures
@@ -16,9 +15,7 @@
LOCAL_CFLAGS += -I@... -I@... -I@...
LOCAL_CFLAGS += -fexceptions -frtti -x c++ -D___ANDROID___ -DANDROID -DZZIP_OMIT_CONFIG_H -DUSE_RTSHADER_SYSTEM=1
- LOCAL_PATH := @CMAKE_SOURCE_DIR@...
- LOCAL_SRC_FILES := SampleBrowser.cpp
-
+ @JNI_SRC@
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/cpufeatures)
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d CMake/Templates/AndroidGLES1.mk.in
--- a/CMake/Templates/AndroidGLES1.mk.in
+++ b/CMake/Templates/AndroidGLES1.mk.in
@@ -1,11 +1,10 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
- LOCAL_MODULE := OgreSampleBrowser
+ LOCAL_MODULE := @ANDROID_MOD_NAME@
LOCAL_LDLIBS := -landroid -lc -lm -ldl -llog -lEGL -lGLESv1_CM
LOCAL_LDLIBS += -L@... -L@...@
- LOCAL_LDLIBS += -lSample_CameraTrack -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_DynTex
- LOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke
+ @SAMPLE_LDLIBS@
LOCAL_LDLIBS += -lPlugin_ParticleFXStatic -lPlugin_OctreeSceneManagerStatic -lRenderSystem_GLESStatic -lOgreOverlayStatic -lOgreMainStatic
LOCAL_LDLIBS += -lzzip -lz -lFreeImage -lfreetype -lOIS @OGRE_BINARY_DIR@... @OGRE_BINARY_DIR@... @NDKOUT@...
LOCAL_STATIC_LIBRARIES := android_native_app_glue cpufeatures
@@ -16,9 +15,7 @@
LOCAL_CFLAGS += -I@... -I@... -I@...
LOCAL_CFLAGS += -fexceptions -frtti -x c++ -D___ANDROID___ -DANDROID -DZZIP_OMIT_CONFIG_H
- LOCAL_PATH := @CMAKE_SOURCE_DIR@...
- LOCAL_SRC_FILES := SampleBrowser.cpp
-
+ @JNI_SRC@
include $(BUILD_SHARED_LIBRARY)
$(call import-module,android/cpufeatures)
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d CMake/Templates/AndroidManifest_JNI.xml.in
--- /dev/null
+++ b/CMake/Templates/AndroidManifest_JNI.xml.in
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="org.ogre3d.jni"
+ android:versionCode="1"
+ android:versionName="1.0"
+ android:installLocation="auto">
+
+ <uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
+
+ <application android:label="@ANDROID_MOD_NAME@" android:hasCode="true">
+ <activity android:name="org.ogre3d.android.MainActivity"
+ android:label="@ANDROID_MOD_NAME@"
+ android:configChanges="orientation@..."
+ android:debuggable="true"
+ android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
\ No newline at end of file
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d CMake/toolchain/AndroidJNI.cmake
--- /dev/null
+++ b/CMake/toolchain/AndroidJNI.cmake
@@ -0,0 +1,98 @@
+#-------------------------------------------------------------------
+# This file is part of the CMake build system for OGRE
+# (Object-oriented Graphics Rendering Engine)
+# For the latest info, see http://www.ogre3d.org/
+#
+# The contents of this file are placed in the public domain. Feel
+# free to make use of it in any way you like.
+#-------------------------------------------------------------------
+
+if(ANDROID)
+ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dummyJNI.cpp "int x = 23;")
+ ADD_LIBRARY(OgreJNIDummy MODULE ${CMAKE_CURRENT_BINARY_DIR}/dummyJNI.cpp)
+
+ if(OGRE_BUILD_RENDERSYSTEM_GLES2)
+ add_dependencies(OgreJNIDummy OgreMain RenderSystem_GLES2)
+ else()
+ add_dependencies(OgreJNIDummy OgreMain RenderSystem_GLES)
+ endif()
+
+ if(APPLE OR WIN32)
+ SET(ANDROID_EXECUTABLE "android")
+ SET(NDK_BUILD_EXECUTABLE "ndk-build")
+ else()
+ SET(ANDROID_EXECUTABLE "$ENV{ANDROID_SDK}/tools/android")
+ SET(NDK_BUILD_EXECUTABLE "$ENV{ANDROID_NDK}/ndk-build")
+ endif()
+
+ SET(ANDROID_MOD_NAME "OgreJNI")
+ SET(JNI_SRC "LOCAL_PATH := @CMAKE_SOURCE_DIR@...")
+ SET(JNI_SRC "${JNI_SRC}\tLOCAL_SRC_FILES := OgreActivityJNI.cpp\n")
+ SET(ANT_EXECUTABLE "ant")
+
+ if(${ANDROID_NATIVE_API_LEVEL} LESS 14)
+ MATH(EXPR ANDROID_SDK_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}+1")
+ else()
+ SET(ANDROID_SDK_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}")
+ SET(SCREEN_SIZE "|screenSize")
+ endif()
+
+ if(OGRE_CONFIG_ENABLE_GLES2_GLSL_OPTIMISER)
+ SET(GLES_OPTIMISER "-lglsl_optimizer -lmesa -lglcpp-library")
+ endif()
+
+ SET(ANDROID_TARGET "android-${ANDROID_SDK_API_LEVEL}")
+
+ SET(NDKOUT "${CMAKE_BINARY_DIR}/OgreJNI")
+ file(MAKE_DIRECTORY "${NDKOUT}")
+ file(MAKE_DIRECTORY "${NDKOUT}/jni")
+ file(MAKE_DIRECTORY "${NDKOUT}/assets")
+ file(MAKE_DIRECTORY "${NDKOUT}/res")
+ file(MAKE_DIRECTORY "${NDKOUT}/src")
+ file(MAKE_DIRECTORY "${NDKOUT}/src/org")
+ file(MAKE_DIRECTORY "${NDKOUT}/src/org/ogre3d")
+ file(MAKE_DIRECTORY "${NDKOUT}/src/org/ogre3d/android")
+ file(COPY "@CMAKE_SOURCE_DIR@..." DESTINATION "${NDKOUT}/src/org/ogre3d/android")
+ file(COPY "@CMAKE_SOURCE_DIR@..." DESTINATION "${NDKOUT}/src/org/ogre3d/android")
+
+ file(WRITE "${NDKOUT}/default.properties" "target=${ANDROID_TARGET}")
+ file(WRITE "${NDKOUT}/jni/Application.mk" "APP_ABI := ${ANDROID_ABI}\nAPP_STL := gnustl_static ")
+ configure_file("${OGRE_TEMPLATES_DIR}/AndroidManifest_JNI.xml.in" "${NDKOUT}/AndroidManifest.xml" @ONLY)
+
+ if(NOT ANDROID_GLES_ONLY)
+ configure_file("${OGRE_TEMPLATES_DIR}/Android.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
+ else()
+ configure_file("${OGRE_TEMPLATES_DIR}/AndroidGLES1.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
+ endif()
+
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${ANDROID_EXECUTABLE} update project --target ${ANDROID_TARGET} --path "${NDKOUT}"
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+
+ if(DEBUG)
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${NDK_BUILD_EXECUTABLE} all -j2 V=1 NDK_DEBUG=1
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+ else()
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${NDK_BUILD_EXECUTABLE} all -j2
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+ endif()
+
+ add_custom_command(
+ TARGET OgreJNIDummy
+ POST_BUILD
+ COMMAND ${ANT_EXECUTABLE} debug
+ WORKING_DIRECTORY ${NDKOUT}
+ )
+
+endif()
\ No newline at end of file
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -476,6 +476,11 @@
# Setup samples
add_subdirectory(Samples)
+#Add android JNI binding
+if(ANDROID)
+ include(toolchain/AndroidJNI)
+endif()
+
# Setup command-line tools
if (OGRE_BUILD_TOOLS)
add_subdirectory(Tools)
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d OgreMain/src/Android/JNI/MainActivity.java
--- /dev/null
+++ b/OgreMain/src/Android/JNI/MainActivity.java
@@ -0,0 +1,130 @@
+package org.ogre3d.android;
+
+import org.ogre3d.android.OgreActivityJNI;
+
+import android.app.Activity;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.os.Bundle;
+import android.os.Handler;
+import android.view.Surface;
+import android.view.SurfaceHolder;
+import android.view.SurfaceHolder.Callback;
+import android.view.SurfaceView;
+
+public class MainActivity extends Activity implements SensorEventListener {
+ protected Handler handler = null;
+ protected SurfaceView surfaceView = null;
+ protected Surface lastSurface = null;
+
+ private Runnable renderer = null;
+ private boolean paused = false;
+ private boolean initOGRE = false;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ handler = new Handler();
+ sysInit();
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ handler.removeCallbacks(renderer);
+ paused = true;
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ paused = false;
+ handler.post(renderer);
+ }
+
+
+
+ private void sysInit() {
+ final Runnable initRunnable = new Runnable() {
+ public void run() {
+ if (!initOGRE) {
+ initOGRE = true;
+ OgreActivityJNI.create();
+
+ renderer = new Runnable() {
+ public void run() {
+
+ if (paused)
+ return;
+
+ if (!wndCreate && lastSurface != null) {
+ wndCreate = true;
+ OgreActivityJNI.initWindow(lastSurface);
+ handler.post(this);
+ return;
+ }
+
+ if (initOGRE && wndCreate)
+ OgreActivityJNI.renderOneFrame();
+
+ handler.post(this);
+ }
+ };
+
+ handler.post(renderer);
+ }
+ }
+
+ };
+
+ SurfaceView view = new SurfaceView(this);
+ SurfaceHolder holder = view.getHolder();
+ // holder.setType(SurfaceHolder.SURFACE_TYPE_GPU);
+ surfaceView = view;
+
+ holder.addCallback(new Callback() {
+ public void surfaceCreated(SurfaceHolder holder) {
+ if (holder.getSurface() != null
+ && holder.getSurface().isValid()) {
+ lastSurface = holder.getSurface();
+ handler.post(initRunnable);
+ }
+ }
+
+ public void surfaceDestroyed(SurfaceHolder holder) {
+ if (initOGRE && wndCreate) {
+ wndCreate = false;
+ lastSurface = null;
+ handler.post(new Runnable() {
+ public void run() {
+ OgreActivityJNI.termWindow();
+ }
+ });
+ }
+ }
+
+ public void surfaceChanged(SurfaceHolder holder, int format,
+ int width, int height) {
+
+ }
+ });
+ setContentView(surfaceView);
+ }
+
+ boolean wndCreate = false;
+
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {
+
+ }
+
+ public void onSensorChanged(SensorEvent event) {
+ if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
+ }
+
+ }
+
+ static {
+ System.loadLibrary("OgreJNI");
+ }
+}
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d OgreMain/src/Android/JNI/OgreActivityJNI.cpp
--- /dev/null
+++ b/OgreMain/src/Android/JNI/OgreActivityJNI.cpp
@@ -0,0 +1,174 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+(Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2012 Torus Knot Software Ltd
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+-----------------------------------------------------------------------------
+*/
+
+#include <jni.h>
+#include <EGL/egl.h>
+#include <android/api-level.h>
+#include <android/native_window_jni.h>
+#include "OgrePlatform.h"
+#include "OgreRoot.h"
+#include "OgreRenderWindow.h"
+#include "Android/OgreAndroidEGLWindow.h"
+
+#include "OgreOctreePlugin.h"
+#include "OgreParticleFXPlugin.h"
+#include "OgreConfigFile.h"
+
+#ifdef OGRE_BUILD_RENDERSYSTEM_GLES2
+# include "OgreGLES2Plugin.h"
+# define GLESRS GLES2Plugin
+#else
+# include "OgreGLESPlugin.h"
+# define GLESRS GLESPlugin
+#endif
+
+using namespace Ogre;
+
+static bool gInit = false;
+static Ogre::Root* gRoot = NULL;
+static Ogre::RenderWindow* gRenderWnd = NULL;
+static Ogre::OctreePlugin* gOctreePlugin = NULL;
+static Ogre::ParticleFXPlugin* gParticleFXPlugin = NULL;
+static Ogre::GLESRS* gGLESPlugin = NULL;
+
+static Ogre::SceneManager* pSceneMgr = NULL;
+static Ogre::Camera* pCamera = NULL;
+static JavaVM* gVM = NULL;
+extern "C"
+{
+ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
+ {
+ JNIEnv *env;
+ jclass k;
+ jint r;
+
+ gVM = vm;
+ r = vm->GetEnv ((void **) &env, JNI_VERSION_1_4);
+ k = env->FindClass ("org/ogre3d/android/OgreActivityJNI");
+ return JNI_VERSION_1_4;
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_create(JNIEnv * env, jobject obj)
+ {
+ if(gInit)
+ return;
+
+ gRoot = new Ogre::Root();
+
+ gGLESPlugin = OGRE_NEW GLESRS();
+ gRoot->installPlugin(gGLESPlugin);
+
+ gOctreePlugin = OGRE_NEW OctreePlugin();
+ gRoot->installPlugin(gOctreePlugin);
+
+ gParticleFXPlugin = OGRE_NEW ParticleFXPlugin();
+ gRoot->installPlugin(gParticleFXPlugin);
+
+ gRoot->setRenderSystem(gRoot->getAvailableRenderers().at(0));
+ gRoot->initialise(false);
+ gInit = true;
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_destroy(JNIEnv * env, jobject obj)
+ {
+ if(!gInit)
+ return;
+
+ gInit = false;
+
+ OGRE_DELETE gRoot;
+ gRoot = NULL;
+ gRenderWnd = NULL;
+
+ OGRE_DELETE gParticleFXPlugin;
+ gParticleFXPlugin = NULL;
+
+ OGRE_DELETE gOctreePlugin;
+ gOctreePlugin = NULL;
+
+ OGRE_DELETE gGLESPlugin;
+ gGLESPlugin = NULL;
+ }
+
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_initWindow(JNIEnv * env, jobject obj, jobject surface)
+ {
+ if(surface)
+ {
+ ANativeWindow* nativeWnd = ANativeWindow_fromSurface(env, surface);
+ if (nativeWnd && gRoot)
+ {
+ if (!gRenderWnd)
+ {
+ Ogre::NameValuePairList opt;
+ opt["externalWindowHandle"] = Ogre::StringConverter::toString((int)nativeWnd);
+ gRenderWnd = Ogre::Root::getSingleton().createRenderWindow("OgreWindow", 0, 0, false, &opt);
+
+
+ if(pSceneMgr == NULL)
+ {
+ pSceneMgr = gRoot->createSceneManager(Ogre::ST_GENERIC);
+ pCamera = pSceneMgr->createCamera("MyCam");
+
+ Ogre::Viewport* vp = gRenderWnd->addViewport(pCamera);
+ vp->setBackgroundColour(Ogre::ColourValue(1,0,0));
+ }
+ }
+ else
+ {
+ static_cast<Ogre::AndroidEGLWindow*>(gRenderWnd)->_createInternalResources(nativeWnd, NULL);
+ }
+ }
+ }
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_termWindow(JNIEnv * env, jobject obj)
+ {
+ if(gRoot && gRenderWnd)
+ {
+ static_cast<Ogre::AndroidEGLWindow*>(gRenderWnd)->_destroyInternalResources();
+ }
+ }
+
+ JNIEXPORT void JNICALL Java_org_ogre3d_android_OgreActivityJNI_renderOneFrame(JNIEnv * env, jobject obj)
+ {
+ if(gRenderWnd != NULL && gRenderWnd->isActive())
+ {
+ try
+ {
+ if(gVM->AttachCurrentThread(&env, NULL) < 0)
+ return;
+
+ gRenderWnd->windowMovedOrResized();
+ gRoot->renderOneFrame();
+
+ //gVM->DetachCurrentThread();
+ }catch(Ogre::RenderingAPIException ex) {}
+ }
+ }
+};
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d OgreMain/src/Android/JNI/OgreActivityJNI.java
--- /dev/null
+++ b/OgreMain/src/Android/JNI/OgreActivityJNI.java
@@ -0,0 +1,11 @@
+package org.ogre3d.android;
+
+import android.view.Surface;
+
+public class OgreActivityJNI {
+ public native static void create();
+ public native static void destroy();
+ public native static void initWindow(Surface surface);
+ public native static void termWindow();
+ public native static void renderOneFrame();
+}
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d RenderSystems/GLES/src/OgreGLESRenderSystem.cpp
--- a/RenderSystems/GLES/src/OgreGLESRenderSystem.cpp
+++ b/RenderSystems/GLES/src/OgreGLESRenderSystem.cpp
@@ -2931,9 +2931,8 @@
{
LogManager::getSingleton().logMessage("********************************************");
LogManager::getSingleton().logMessage("*** OpenGL ES 1.x Reset Renderer Started ***");
- LogManager::getSingleton().logMessage("********************************************");
+ LogManager::getSingleton().logMessage("********************************************");
- mStateCacheManager->clearCache();
initialiseContext(win);
mGLSupport->initialiseExtensions();
@@ -2952,6 +2951,7 @@
GLESRenderSystem::mResourceManager->notifyOnContextReset();
+ mStateCacheManager->clearCache();
_setViewport(NULL);
_setRenderTarget(win);
}
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
--- a/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
+++ b/RenderSystems/GLES2/src/OgreGLES2RenderSystem.cpp
@@ -2218,6 +2218,7 @@
GLES2RenderSystem::mResourceManager->notifyOnContextReset();
+ mStateCacheManager->clearCache();
_setViewport(NULL);
_setRenderTarget(win);
}
diff -r 91beb871bd82fa9f9d87462fb57b0ae3f8487901 -r 8a828aa2e26f105cc73cb8220a05948fde25393d Samples/Browser/CMakeLists.txt
--- a/Samples/Browser/CMakeLists.txt
+++ b/Samples/Browser/CMakeLists.txt
@@ -90,13 +90,9 @@
if(APPLE OR WIN32)
SET(ANDROID_EXECUTABLE "android")
+ SET(NDK_BUILD_EXECUTABLE "ndk-build")
else()
SET(ANDROID_EXECUTABLE "$ENV{ANDROID_SDK}/tools/android")
- endif()
-
- if(APPLE OR WIN32)
- SET(NDK_BUILD_EXECUTABLE "ndk-build")
- else()
SET(NDK_BUILD_EXECUTABLE "$ENV{ANDROID_NDK}/ndk-build")
endif()
@@ -123,9 +119,17 @@
file(WRITE "${NDKOUT}/jni/Application.mk" "APP_ABI := ${ANDROID_ABI}\nAPP_STL := gnustl_static ")
configure_file("${OGRE_TEMPLATES_DIR}/AndroidManifest.xml.in" "${NDKOUT}/AndroidManifest.xml" @ONLY)
+ SET(ANDROID_MOD_NAME "OgreSampleBrowser")
+ SET(JNI_SRC "LOCAL_PATH := @CMAKE_SOURCE_DIR@...")
+ SET(JNI_SRC "${JNI_SRC}\tLOCAL_SRC_FILES := SampleBrowser.cpp\n")
+
if(NOT ANDROID_GLES_ONLY)
- configure_file("${OGRE_TEMPLATES_DIR}/Android.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
+ SET(SAMPLE_LDLIBS "LOCAL_LDLIBS += -lSample_CameraTrack -lSample_CelShading -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_CubeMapping -lSample_DynTex\n")
+ SET(SAMPLE_LDLIBS "${SAMPLE_LDLIBS}\tLOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Fresnel -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_MeshLod -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke\n")
+ configure_file("${OGRE_TEMPLATES_DIR}/Android.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
else()
+ SET(SAMPLE_LDLIBS "LOCAL_LDLIBS += -lSample_CameraTrack -lSample_Character -lSample_Compositor -lSample_Lighting -lSample_BezierPatch -lSample_DynTex\n")
+ SET(SAMPLE_LDLIBS "${SAMPLE_LDLIBS}\tLOCAL_LDLIBS += -lSample_FacialAnimation -lSample_Grass -lSample_ParticleFX -lSample_Lighting -lSample_SkyBox -lSample_SkyPlane -lSample_SkyDome -lSample_Smoke\n")
configure_file("${OGRE_TEMPLATES_DIR}/AndroidGLES1.mk.in" "${NDKOUT}/jni/Android.mk" @ONLY)
endif()
https://bitbucket.org/sinbad/ogre/commits/41210e4fa67c/
changeset: 41210e4fa67c
branch: v1-9
user: wolf...@...
date: 2013-02-24 09:26:48
summary: * Android: Renenable RTSS workaround
affected #: 1 file
diff -r 8a828aa2e26f105cc73cb8220a05948fde25393d -r 41210e4fa67c290df2ebaf151d070d05e9649333 Components/RTShaderSystem/src/OgreShaderGLSLESProgramWriter.cpp
--- a/Components/RTShaderSystem/src/OgreShaderGLSLESProgramWriter.cpp
+++ b/Components/RTShaderSystem/src/OgreShaderGLSLESProgramWriter.cpp
@@ -312,6 +312,15 @@
// The function name must always main.
os << "void main() {" << std::endl;
+ if (gpuType == GPT_FRAGMENT_PROGRAM)
+ {
+ os << "\tvec4 outputColor;" << std::endl;
+ }
+ else if (gpuType == GPT_VERTEX_PROGRAM)
+ {
+ os << "\tvec4 outputPosition;" << std::endl;
+ }
+
// Write local parameters.
const ShaderParameterList& localParams = curFunction->getLocalParameters();
ShaderParameterConstIterator itParam = localParams.begin();
@@ -514,7 +523,16 @@
localOs << std::endl;
os << localOs.str();
}
-
+
+ if (gpuType == GPT_FRAGMENT_PROGRAM)
+ {
+ os << "\tgl_FragColor = outputColor;" << std::endl;
+ }
+ else if (gpuType == GPT_VERTEX_PROGRAM)
+ {
+ os << "\tgl_Position = outputPosition;" << std::endl;
+ }
+
os << "}" << std::endl;
}
os << std::endl;
@@ -614,7 +632,7 @@
// GLSL vertex program has to write always gl_Position
if(pParam->getContent() == Parameter::SPC_POSITION_PROJECTIVE_SPACE)
{
- mInputToGLStatesMap[pParam->getName()] = "gl_Position";
+ mInputToGLStatesMap[pParam->getName()] = "outputPosition";
}
else
{
@@ -633,7 +651,7 @@
pParam->getSemantic() == Parameter::SPS_COLOR)
{
// GLSL ES fragment program has to always write gl_FragColor
- mInputToGLStatesMap[pParam->getName()] = "gl_FragColor";
+ mInputToGLStatesMap[pParam->getName()] = "outputColor";
}
}
}
https://bitbucket.org/sinbad/ogre/commits/90c1f7853808/
changeset: 90c1f7853808
branch: v1-9
user: wolf...@...
date: 2013-02-24 13:39:33
summary: Add PVR version detection to handle PVRTCV2 / PVRTCV2 textures
affected #: 2 files
Diff not available.
https://bitbucket.org/sinbad/ogre/commits/2513d16c886b/
changeset: 2513d16c886b
branch: v1-9
user: wolf...@...
date: 2013-02-24 13:41:23
summary: * Add missing license header
affected #: 2 files
Diff not available.
https://bitbucket.org/sinbad/ogre/commits/7da20093b77f/
changeset: 7da20093b77f
branch: v1-9
user: wolf...@...
date: 2013-02-24 13:42:16
summary: Merge
affected #: 14 files
Diff not available.
Repository URL: https://bitbucket.org/sinbad/ogre/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
|