add preliminary Android build files for Bullet
add SimpleOpenGL3 example and show how to override keyboard, mouse, wheel, resize callbacks
This commit is contained in:
49
build3/Android/jni/Android.mk
Normal file
49
build3/Android/jni/Android.mk
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
LOCAL_PATH := ../../..
|
||||||
|
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
|
||||||
|
LOCAL_CFLAGS := $(LOCAL_C_INCLUDES:%=-I%) -DUSE_PTHREADS -mfpu=neon -mfloat-abi=softfp -pthread -DSCE_PFX_USE_SIMD_VECTORMATH
|
||||||
|
|
||||||
|
# apply these flags if needed
|
||||||
|
# -ffast-math -funsafe-math-optimizations
|
||||||
|
|
||||||
|
# apply this to disable optimization
|
||||||
|
# TARGET_CFLAGS := $(TARGET_CFLAGS) -O0
|
||||||
|
|
||||||
|
# apply these 2 to turn on assembly output (*.c/*.cpp to *.s file)
|
||||||
|
#compile-cpp-source = $(eval $(call ev-compile-cpp-source,$1,$(1:%$(LOCAL_CPP_EXTENSION)=%.s)))
|
||||||
|
#TARGET_CFLAGS := $(TARGET_CFLAGS) -S
|
||||||
|
|
||||||
|
# Enable or disable NEON. Don't forget to apply, or not apply, -mfpu=neon and -mfloat-abi=softfp
|
||||||
|
# flags in addition, e.g., if this is true both of those need to be included in LOCAL_CFLAGS
|
||||||
|
# to avoid the possibility that ndk-build will "forget" to add them on some files
|
||||||
|
LOCAL_ARM_NEON := true
|
||||||
|
|
||||||
|
TARGET_CFLAGS := $(filter-out -ffpu=vfp,$(TARGET_CFLAGS))
|
||||||
|
|
||||||
|
# setup to build static library
|
||||||
|
LOCAL_MODULE := libBullet
|
||||||
|
|
||||||
|
LOCAL_C_INCLUDES := $(LOCAL_PATH)/src
|
||||||
|
|
||||||
|
#find all the file recursively under jni/
|
||||||
|
FILE_LIST := $(wildcard \
|
||||||
|
$(LOCAL_PATH)/src/LinearMath/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/Bullet3Common/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletCollision/BroadphaseCollision/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletCollision/CollisionDispatch/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletCollision/CollisionShapes/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletCollision/NarrowPhaseCollision/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletDynamics/ConstraintSolver/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletDynamics/Dynamics/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletDynamics/Featherstone/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletDynamics/MLCPSolvers/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletDynamics/Vehicle/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletDynamics/Character/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletSoftBody/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletInverseDynamics/*.cpp \
|
||||||
|
$(LOCAL_PATH)/src/BulletInverseDynamics/details/*.cpp \
|
||||||
|
)
|
||||||
|
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
|
||||||
|
|
||||||
|
include $(BUILD_STATIC_LIBRARY)
|
||||||
7
build3/Android/jni/Application.mk
Normal file
7
build3/Android/jni/Application.mk
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
APP_MODULES := libBullet
|
||||||
|
APP_ABI := armeabi-v7a
|
||||||
|
APP_OPTIM := release
|
||||||
|
|
||||||
|
#We only need STL for placement new (#include <new>)
|
||||||
|
#We don't use STL in Bullet
|
||||||
|
APP_STL := stlport_static
|
||||||
@@ -199,6 +199,7 @@
|
|||||||
include "../examples/ExampleBrowser"
|
include "../examples/ExampleBrowser"
|
||||||
include "../examples/OpenGLWindow"
|
include "../examples/OpenGLWindow"
|
||||||
include "../examples/ThirdPartyLibs/Gwen"
|
include "../examples/ThirdPartyLibs/Gwen"
|
||||||
|
include "../examples/SimpleOpenGL3"
|
||||||
|
|
||||||
include "../examples/HelloWorld"
|
include "../examples/HelloWorld"
|
||||||
include "../examples/BasicDemo"
|
include "../examples/BasicDemo"
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ InternalOpenGL2RenderCallbacks::~InternalOpenGL2RenderCallbacks()
|
|||||||
|
|
||||||
void InternalOpenGL2RenderCallbacks::display2()
|
void InternalOpenGL2RenderCallbacks::display2()
|
||||||
{
|
{
|
||||||
|
|
||||||
assert(glGetError()==GL_NO_ERROR);
|
assert(glGetError()==GL_NO_ERROR);
|
||||||
// glViewport(0,0,10,10);
|
// glViewport(0,0,10,10);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "OpenGLWindow/SimpleOpenGL3App.h"
|
#include "OpenGLWindow/SimpleOpenGL3App.h"
|
||||||
|
|
||||||
#include "Bullet3Common/b3Vector3.h"
|
#include "Bullet3Common/b3Vector3.h"
|
||||||
#include "Bullet3Common/b3CommandLineArgs.h"
|
#include "Bullet3Common/b3CommandLineArgs.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
@@ -8,6 +9,50 @@
|
|||||||
char* gVideoFileName = 0;
|
char* gVideoFileName = 0;
|
||||||
char* gPngFileName = 0;
|
char* gPngFileName = 0;
|
||||||
|
|
||||||
|
static b3WheelCallback sOldWheelCB = 0;
|
||||||
|
static b3ResizeCallback sOldResizeCB = 0;
|
||||||
|
static b3MouseMoveCallback sOldMouseMoveCB = 0;
|
||||||
|
static b3MouseButtonCallback sOldMouseButtonCB = 0;
|
||||||
|
static b3KeyboardCallback sOldKeyboardCB = 0;
|
||||||
|
static b3RenderCallback sOldRenderCB = 0;
|
||||||
|
|
||||||
|
|
||||||
|
void MyWheelCallback(float deltax, float deltay)
|
||||||
|
{
|
||||||
|
if (sOldWheelCB)
|
||||||
|
sOldWheelCB(deltax,deltay);
|
||||||
|
}
|
||||||
|
void MyResizeCallback( float width, float height)
|
||||||
|
{
|
||||||
|
if (sOldResizeCB)
|
||||||
|
sOldResizeCB(width,height);
|
||||||
|
}
|
||||||
|
void MyMouseMoveCallback( float x, float y)
|
||||||
|
{
|
||||||
|
printf("Mouse Move: %f, %f\n", x,y);
|
||||||
|
|
||||||
|
if (sOldMouseMoveCB)
|
||||||
|
sOldMouseMoveCB(x,y);
|
||||||
|
}
|
||||||
|
void MyMouseButtonCallback(int button, int state, float x, float y)
|
||||||
|
{
|
||||||
|
if (sOldMouseButtonCB)
|
||||||
|
sOldMouseButtonCB(button,state,x,y);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MyKeyboardCallback(int keycode, int state)
|
||||||
|
{
|
||||||
|
//keycodes are in examples/CommonInterfaces/CommonWindowInterface.h
|
||||||
|
//for example B3G_ESCAPE for escape key
|
||||||
|
//state == 1 for pressed, state == 0 for released.
|
||||||
|
// use app->m_window->isModifiedPressed(...) to check for shift, escape and alt keys
|
||||||
|
printf("MyKeyboardCallback received key:%c in state %d\n",keycode,state);
|
||||||
|
if (sOldKeyboardCB)
|
||||||
|
sOldKeyboardCB(keycode,state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
b3CommandLineArgs myArgs(argc,argv);
|
b3CommandLineArgs myArgs(argc,argv);
|
||||||
@@ -17,8 +62,20 @@ int main(int argc, char* argv[])
|
|||||||
app->m_instancingRenderer->getActiveCamera()->setCameraDistance(13);
|
app->m_instancingRenderer->getActiveCamera()->setCameraDistance(13);
|
||||||
app->m_instancingRenderer->getActiveCamera()->setCameraPitch(0);
|
app->m_instancingRenderer->getActiveCamera()->setCameraPitch(0);
|
||||||
app->m_instancingRenderer->getActiveCamera()->setCameraTargetPosition(0,0,0);
|
app->m_instancingRenderer->getActiveCamera()->setCameraTargetPosition(0,0,0);
|
||||||
|
sOldKeyboardCB = app->m_window->getKeyboardCallback();
|
||||||
|
app->m_window->setKeyboardCallback(MyKeyboardCallback);
|
||||||
|
sOldMouseMoveCB = app->m_window->getMouseMoveCallback();
|
||||||
|
app->m_window->setMouseMoveCallback(MyMouseMoveCallback);
|
||||||
|
sOldMouseButtonCB = app->m_window->getMouseButtonCallback();
|
||||||
|
app->m_window->setMouseButtonCallback(MyMouseButtonCallback);
|
||||||
|
sOldWheelCB = app->m_window->getWheelCallback();
|
||||||
|
app->m_window->setWheelCallback(MyWheelCallback);
|
||||||
|
sOldResizeCB = app->m_window->getResizeCallback();
|
||||||
|
app->m_window->setResizeCallback(MyResizeCallback);
|
||||||
|
|
||||||
|
|
||||||
assert(glGetError()==GL_NO_ERROR);
|
|
||||||
|
assert(glGetError()==GL_NO_ERROR);
|
||||||
|
|
||||||
myArgs.GetCmdLineArgument("mp4_file",gVideoFileName);
|
myArgs.GetCmdLineArgument("mp4_file",gVideoFileName);
|
||||||
if (gVideoFileName)
|
if (gVideoFileName)
|
||||||
|
|||||||
Reference in New Issue
Block a user