1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-10 23:24:06 +02:00

#15 fix android build

This commit is contained in:
XProger
2017-04-24 01:50:27 +03:00
parent aad89fcdba
commit 3f88038990
6 changed files with 38 additions and 35 deletions

View File

@@ -20,13 +20,15 @@ struct Camera : Controller {
float timer;
int actTargetEntity, actCamera;
bool cutscene;
bool firstPerson;
Basis prevBasis;
Basis prevBasis;
vec4 *reflectPlane;
Camera(IGame *game, Lara *owner) : Controller(game, owner ? owner->entity : 0), owner(owner), frustum(new Frustum()), timer(0.0f), actTargetEntity(-1), actCamera(-1), reflectPlane(NULL) {
bool cutscene;
bool firstPerson;
bool isVR;
Camera(IGame *game, Lara *owner) : Controller(game, owner ? owner->entity : 0), owner(owner), frustum(new Frustum()), timer(0.0f), actTargetEntity(-1), actCamera(-1), reflectPlane(NULL), isVR(false) {
changeView(false);
cutscene = owner->getEntity().type != TR::Entity::LARA && level->cameraFrames;
}
@@ -250,8 +252,11 @@ struct Camera : Controller {
checkRoom();
}
mat4 head = Input::head.getMatrix();
mViewInv = mat4(pos, target, vec3(0, -1, 0)) * head;
mViewInv = mat4(pos, target, vec3(0, -1, 0));
if (isVR) {
mat4 head = Input::head.getMatrix();
mViewInv = mViewInv * head;
}
updateListener();
}
@@ -268,7 +273,9 @@ struct Camera : Controller {
Core::mViewInv = mViewInv;
Core::mView = Core::mViewInv.inverse();
Core::mView.translate(Core::mViewInv.right.xyz * (-Core::eye * 32.0f));
if (isVR)
Core::mView.translate(Core::mViewInv.right.xyz * (-Core::eye * 32.0f));
Core::mProj = getProjMatrix();

View File

@@ -8,13 +8,16 @@
#include <gl/glext.h>
#elif ANDROID
#define MOBILE
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <dlfcn.h>
#define GL_TEXTURE_COMPARE_MODE 0x884C
#define GL_TEXTURE_COMPARE_FUNC 0x884D
#define GL_COMPARE_REF_TO_TEXTURE 0x884E
#define GL_CLAMP_TO_BORDER 0x812D
#define GL_TEXTURE_BORDER_COLOR 0x1004
#define GL_TEXTURE_COMPARE_MODE 0x884C
#define GL_TEXTURE_COMPARE_FUNC 0x884D
#define GL_COMPARE_REF_TO_TEXTURE 0x884E
#undef GL_RGBA32F
#undef GL_RGBA16F
@@ -63,6 +66,9 @@
#define glDeleteVertexArrays glDeleteVertexArraysOES
#define glBindVertexArray glBindVertexArrayOES
#define GL_CLAMP_TO_BORDER GL_CLAMP_TO_BORDER_EXT
#define GL_TEXTURE_BORDER_COLOR GL_TEXTURE_BORDER_COLOR_EXT
#define GL_TEXTURE_COMPARE_MODE GL_TEXTURE_COMPARE_MODE_EXT
#define GL_TEXTURE_COMPARE_FUNC GL_TEXTURE_COMPARE_FUNC_EXT
#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_REF_TO_TEXTURE_EXT

View File

@@ -1,5 +1,5 @@
#ifndef H_GAME_TR
#define H_GAME_TR
#ifndef H_GAME
#define H_GAME
#include "core.h"
#include "format.h"

View File

@@ -8,7 +8,7 @@ android {
minSdkVersion 18
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionName "0.1"
ndk {
abiFilters 'armeabi-v7a'
}

View File

@@ -1,8 +1,6 @@
#include <jni.h>
#include <android/log.h>
//#include "vr/gvr/capi/include/gvr.h"
#include <sys/time.h>
#include <stdint.h>
#include <stdio.h>
#include <math.h>
@@ -20,7 +18,7 @@ int getTime() {
extern "C" {
int lastTime, fpsTime, fps;
int lastTime;
char Stream::cacheDir[255];
char Stream::contentDir[255];
@@ -44,8 +42,6 @@ JNI_METHOD(void, nativeInit)(JNIEnv* env, jobject obj, jstring packName, jstring
Game::init(level, music);
lastTime = getTime();
fpsTime = lastTime + 1000;
fps = 0;
}
JNI_METHOD(void, nativeFree)(JNIEnv* env) {
@@ -68,12 +64,6 @@ JNI_METHOD(void, nativeRender)(JNIEnv* env) {
Core::stats.dips = 0;
Core::stats.tris = 0;
Game::render();
if (fpsTime < getTime()) {
LOG("FPS: %d DIP: %d TRI: %d\n", fps, Core::stats.dips, Core::stats.tris);
fps = 0;
fpsTime = getTime() + 1000;
} else
fps++;
}
JNI_METHOD(void, nativeResize)(JNIEnv* env, jobject obj, jint w, jint h) {
@@ -137,11 +127,11 @@ JNI_METHOD(void, nativeTouch)(JNIEnv* env, jobject obj, jint id, jint state, jfl
}
if (id == -100) {
switch (state) {
case 0 : Input::head.basis.rot.x = x; Input::head.basis.rot.y = y; break;
case 1 : Input::head.basis.rot.z = x; Input::head.basis.rot.w = y; Input::head.set(); break;
}
return;
switch (state) {
case 0 : Input::head.basis.rot.x = x; Input::head.basis.rot.y = y; break;
case 1 : Input::head.basis.rot.z = x; Input::head.basis.rot.w = y; Input::head.set(); break;
}
return;
}
// touch

View File

@@ -58,12 +58,13 @@ public class MainActivity extends Activity implements OnTouchListener, OnKeyList
//setAsyncReprojectionEnabled(true);
//setSustainedPerformanceMode(this, true);
setContentView(view);
/*
SensorManager sm = (SensorManager)getSystemService(SENSOR_SERVICE);
sm.registerListener(this, sm.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_FASTEST);
*/
try {
String packName = getPackageManager().getPackageInfo(getPackageName(), PackageManager.GET_ACTIVITIES).applicationInfo.sourceDir;
// hardcoded demo level and music
AssetFileDescriptor fLevel = this.getResources().openRawResourceFd(R.raw.level2);
AssetFileDescriptor fMusic = this.getResources().openRawResourceFd(R.raw.music);
@@ -122,8 +123,6 @@ public class MainActivity extends Activity implements OnTouchListener, OnKeyList
@Override
public void onSensorChanged(SensorEvent event) {
// wrapper.onTouch(-100, 0, event.values[0], event.values[1]);
// wrapper.onTouch(-100, 1, event.values[2], event.values[3]);
wrapper.onTouch(-100, 0, -event.values[1], event.values[0]);
wrapper.onTouch(-100, 1, event.values[2], event.values[3]);
}
@@ -186,6 +185,7 @@ public class MainActivity extends Activity implements OnTouchListener, OnKeyList
}
}
// @TODO: use native OpenSL ES
class Sound {
private short buffer[];
private static AudioTrack audioTrack;