diff --git a/Projects/Android/Android.iml b/Projects/Android/Android.iml
index 5fb34c6..39a4fd7 100644
--- a/Projects/Android/Android.iml
+++ b/Projects/Android/Android.iml
@@ -77,14 +77,6 @@
-
-
-
-
-
-
-
-
@@ -93,6 +85,14 @@
+
+
+
+
+
+
+
+
@@ -127,6 +127,7 @@
+
diff --git a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c
index 05a8fb4..77ce81d 100644
--- a/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c
+++ b/Projects/Android/jni/src/Lambda1VR/L1VR_SurfaceView.c
@@ -30,18 +30,14 @@ Copyright : Copyright 2015 Oculus VR, LLC. All Rights reserved.
#include
#include
-//GL4ES
-//#include <../src/gl/loader.h>
-//#include
#include
#include
#include
#include
#include
-//#include
-#include
#include
+#include
#if !defined( EGL_OPENGL_ES3_BIT_KHR )
#define EGL_OPENGL_ES3_BIT_KHR 0x0040
@@ -79,20 +75,16 @@ PFNEGLGETSYNCATTRIBKHRPROC eglGetSyncAttribKHR;
#include "VrApi_Helpers.h"
#include "VrApi_SystemUtils.h"
#include "VrApi_Input.h"
+#include "VrApi_Types.h"
+
#include "../gl4es/src/gl/loader.h"
+#include "VrCompositor.h"
+
#ifndef NDEBUG
#define DEBUG 1
#endif
-#define LOG_TAG "Lambda1VR"
-
-#define ALOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
-#if DEBUG
-#define ALOGV(...) __android_log_print( ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__ )
-#else
-#define ALOGV(...)
-#endif
int CPU_LEVEL = 2;
int GPU_LEVEL = 3;
@@ -156,6 +148,10 @@ static bool xash_initialised = false;
typedef void (*pfnChangeGame)( const char *progname );
extern int Host_Main( int argc, const char **argv, const char *progname, int bChangeGame, pfnChangeGame func );
+static bool useScreenLayer()
+{
+ return (cls.demoplayback || cls.state == ca_cinematic || cls.key_dest != key_game);
+}
//Timing stuff for joypad control
static long oldtime=0;
@@ -194,23 +190,6 @@ float weaponOffset[3];
float horizFOV;
float vertFOV;
-int bigScreen = 0;
-ovrMatrix4f modelScreen;
-ovrMatrix4f rotation;
-
-void BigScreenMode(int mode)
-{
- if (mode == 1)// && key_consoleactive == 0) // bit of a hack, but only way rotation set when menu first invoked
- {
- rotation = ovrMatrix4f_CreateRotation( 0.0f, radians(hmdorientation[YAW]), 0.0f );
- }
-
- if (bigScreen != 2)
- {
- bigScreen = mode;
- }
-}
-
extern int stereoMode;
qboolean demoplayback = false;
@@ -356,43 +335,6 @@ static const char * GlFrameBufferStatusString( GLenum status )
}
}
-#define CHECK_GL_ERRORS
-#ifdef CHECK_GL_ERRORS
-
-static const char * GlErrorString( GLenum error )
-{
- switch ( error )
- {
- case GL_NO_ERROR: return "GL_NO_ERROR";
- case GL_INVALID_ENUM: return "GL_INVALID_ENUM";
- case GL_INVALID_VALUE: return "GL_INVALID_VALUE";
- case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION";
- case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION";
- case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY";
- default: return "unknown";
- }
-}
-
-static void GLCheckErrors( int line )
-{
- for ( int i = 0; i < 10; i++ )
- {
- const GLenum error = glGetError();
- if ( error == GL_NO_ERROR )
- {
- break;
- }
- ALOGE( "GL error on line %d: %s", line, GlErrorString( error ) );
- }
-}
-
-#define GL( func ) func; GLCheckErrors( __LINE__ );
-
-#else // CHECK_GL_ERRORS
-
-#define GL( func ) func;
-
-#endif // CHECK_GL_ERRORS
/*
================================================================================
@@ -580,17 +522,6 @@ ovrFramebuffer
================================================================================
*/
-typedef struct
-{
- int Width;
- int Height;
- int Multisamples;
- int TextureSwapChainLength;
- int TextureSwapChainIndex;
- ovrTextureSwapChain * ColorTextureSwapChain;
- GLuint * DepthBuffers;
- GLuint * FrameBuffers;
-} ovrFramebuffer;
static void ovrFramebuffer_Clear( ovrFramebuffer * frameBuffer )
{
@@ -668,7 +599,7 @@ static bool ovrFramebuffer_Create( ovrFramebuffer * frameBuffer, const GLenum co
return true;
}
-static void ovrFramebuffer_Destroy( ovrFramebuffer * frameBuffer )
+void ovrFramebuffer_Destroy( ovrFramebuffer * frameBuffer )
{
LOAD_GLES2(glDeleteFramebuffers);
LOAD_GLES2(glDeleteRenderbuffers);
@@ -684,22 +615,20 @@ static void ovrFramebuffer_Destroy( ovrFramebuffer * frameBuffer )
ovrFramebuffer_Clear( frameBuffer );
}
-static void ovrFramebuffer_SetCurrent( ovrFramebuffer * frameBuffer )
+void ovrFramebuffer_SetCurrent( ovrFramebuffer * frameBuffer )
{
LOAD_GLES2(glBindFramebuffer);
GL( gles_glBindFramebuffer( GL_DRAW_FRAMEBUFFER, frameBuffer->FrameBuffers[frameBuffer->TextureSwapChainIndex] ) );
}
-static void ovrFramebuffer_SetNone()
+void ovrFramebuffer_SetNone()
{
LOAD_GLES2(glBindFramebuffer);
GL( gles_glBindFramebuffer( GL_DRAW_FRAMEBUFFER, 0 ) );
}
-static void ovrFramebuffer_Resolve( ovrFramebuffer * frameBuffer )
+void ovrFramebuffer_Resolve( ovrFramebuffer * frameBuffer )
{
- LOAD_GLES2(glFlush);
-
// Discard the depth buffer, so the tiler won't need to write it back out to memory.
const GLenum depthAttachment[1] = { GL_DEPTH_ATTACHMENT };
glInvalidateFramebuffer( GL_DRAW_FRAMEBUFFER, 1, depthAttachment );
@@ -708,14 +637,14 @@ static void ovrFramebuffer_Resolve( ovrFramebuffer * frameBuffer )
glFlush();
}
-static void ovrFramebuffer_Advance( ovrFramebuffer * frameBuffer )
+void ovrFramebuffer_Advance( ovrFramebuffer * frameBuffer )
{
// Advance to the next texture from the set.
frameBuffer->TextureSwapChainIndex = ( frameBuffer->TextureSwapChainIndex + 1 ) % frameBuffer->TextureSwapChainLength;
}
-static void ovrFramebuffer_ClearEdgeTexels( ovrFramebuffer * frameBuffer )
+void ovrFramebuffer_ClearEdgeTexels( ovrFramebuffer * frameBuffer )
{
LOAD_GLES2(glEnable);
LOAD_GLES2(glDisable);
@@ -758,149 +687,21 @@ ovrRenderer
*/
-typedef struct
-{
- ovrFramebuffer FrameBuffer[VRAPI_FRAME_LAYER_EYE_MAX];
- ovrFramebuffer L1VRFrameBuffer;
- ovrMatrix4f ProjectionMatrix;
- int NumBuffers;
-} ovrRenderer;
-
-static void ovrRenderer_Clear( ovrRenderer * renderer )
+void ovrRenderer_Clear( ovrRenderer * renderer )
{
for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
{
ovrFramebuffer_Clear( &renderer->FrameBuffer[eye] );
}
- ovrFramebuffer_Clear( &renderer->L1VRFrameBuffer );
renderer->ProjectionMatrix = ovrMatrix4f_CreateIdentity();
renderer->NumBuffers = VRAPI_FRAME_LAYER_EYE_MAX;
}
-static const char VERTEX_SHADER[] =
- "uniform mat4 u_MVPMatrix;"
- "attribute vec4 a_Position;"
- "attribute vec2 a_texCoord;"
- "varying vec2 v_texCoord;"
- "void main() {"
- " gl_Position = u_MVPMatrix * a_Position;"
- " v_texCoord = a_texCoord;"
- "}";
-
-
-static const char FRAGMENT_SHADER[] =
- "precision mediump float;"
- "varying vec2 v_texCoord;"
- "uniform sampler2D s_texture;"
- "uniform sampler2D s_texture1;"
- "void main() {"
- " gl_FragColor = texture2D( s_texture, v_texCoord ) * texture2D( s_texture1, v_texCoord );"
- "}";
-
-int loadShader(int type, const char * shaderCode){
- LOAD_GLES2(glCreateShader);
- LOAD_GLES2(glShaderSource);
- LOAD_GLES2(glCompileShader);
-
- int shader = gles_glCreateShader(type);
- GL( gles_glShaderSource(shader, 1, &shaderCode, 0));
- GL( gles_glCompileShader(shader));
- return shader;
-}
-
-int BuildScreenVignetteTexture( )
+void ovrRenderer_Create( ovrRenderer * renderer, const ovrJava * java )
{
- LOAD_GLES2(glGenTextures);
- LOAD_GLES2(glBindTexture);
- LOAD_GLES2(glTexImage2D);
- LOAD_GLES2(glTexParameteri);
-
- static const int scale = 8;
- static const int width = 10 * scale;
- static const int height = 8 * scale;
- unsigned char buffer[width * height];
- memset( buffer, 255, sizeof( buffer ) );
- for ( int i = 0; i < width; i++ )
- {
- buffer[i] = 0;
- buffer[width*height - 1 - i] = 0;
- }
- for ( int i = 0; i < height; i++ )
- {
- buffer[i * width] = 0;
- buffer[i * width + width - 1] = 0;
- }
- GLuint texId = 0;
- gles_glGenTextures( 1, &texId );
- gles_glBindTexture( GL_TEXTURE_2D, texId );
- gles_glTexImage2D( GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, buffer );
- gles_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
- gles_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- gles_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
- gles_glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
- gles_glBindTexture( GL_TEXTURE_2D, 0 );
-
- return texId;
-}
-
-static short indices[6] = {0, 1, 2, 0, 2, 3};
-
-static float uvs[8] = {
- 0.0f, 1.0f,
- 0.0f, 0.0f,
- 1.0f, 0.0f,
- 1.0f, 1.0f
-};
-
-static float SCREEN_COORDS[12] = {
- -2.0f, 1.75f, 0.0f,
- -2.0f, -1.75f, 0.0f,
- 2.0f, -1.75f, 0.0f,
- 2.0f, 1.75f, 0.0f
-};
-
-int vignetteTexture = 0;
-
-int sp_Image = 0;
-int positionParam = 0;
-int texCoordParam = 0;
-int samplerParam = 0;
-int vignetteParam = 0;
-int modelViewProjectionParam = 0;
-
-static void ovrRenderer_Create( ovrRenderer * renderer, const ovrJava * java )
-{
- LOAD_GLES2(glCreateProgram);
- LOAD_GLES2(glAttachShader);
- LOAD_GLES2(glLinkProgram);
- LOAD_GLES2(glGetAttribLocation);
- LOAD_GLES2(glGetUniformLocation);
-
renderer->NumBuffers = VRAPI_FRAME_LAYER_EYE_MAX;
- // Create the shaders, images
- int vertexShader = loadShader(GL_VERTEX_SHADER, VERTEX_SHADER);
- int fragmentShader = loadShader(GL_FRAGMENT_SHADER, FRAGMENT_SHADER);
-
-
- sp_Image = gles_glCreateProgram(); // create empty OpenGL ES Program
- GL( gles_glAttachShader(sp_Image, vertexShader)); // add the vertex shader to program
- GL( gles_glAttachShader(sp_Image, fragmentShader)); // add the fragment shader to program
- GL( gles_glLinkProgram(sp_Image)); // creates OpenGL ES program executable
- positionParam = GL( gles_glGetAttribLocation(sp_Image, "a_Position"));
- texCoordParam = GL( gles_glGetAttribLocation(sp_Image, "a_texCoord"));
- modelViewProjectionParam = GL( gles_glGetUniformLocation(sp_Image, "u_MVPMatrix"));
- samplerParam = GL( gles_glGetUniformLocation(sp_Image, "s_texture"));
- vignetteParam = GL( gles_glGetUniformLocation(sp_Image, "s_texture1"));
-
- vignetteTexture = BuildScreenVignetteTexture();
-
- modelScreen = ovrMatrix4f_CreateIdentity();
- rotation = ovrMatrix4f_CreateIdentity();
- ovrMatrix4f translation = ovrMatrix4f_CreateTranslation( 0, 0, -3.0f );
- modelScreen = ovrMatrix4f_Multiply( &modelScreen, &translation );
-
horizFOV = vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X);
vertFOV = vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y);
@@ -914,12 +715,6 @@ static void ovrRenderer_Create( ovrRenderer * renderer, const ovrJava * java )
NUM_MULTI_SAMPLES );
}
- ovrFramebuffer_Create( &renderer->L1VRFrameBuffer,
- GL_RGBA8,
- vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH ),
- vrapi_GetSystemPropertyInt( java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT ),
- NUM_MULTI_SAMPLES );
-
// Setup the projection matrix.
renderer->ProjectionMatrix = ovrMatrix4f_CreateProjectionFov(
vrapi_GetSystemPropertyFloat( java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X ),
@@ -928,13 +723,12 @@ static void ovrRenderer_Create( ovrRenderer * renderer, const ovrJava * java )
}
-static void ovrRenderer_Destroy( ovrRenderer * renderer )
+void ovrRenderer_Destroy( ovrRenderer * renderer )
{
for ( int eye = 0; eye < renderer->NumBuffers; eye++ )
{
ovrFramebuffer_Destroy( &renderer->FrameBuffer[eye] );
}
- ovrFramebuffer_Destroy( &renderer->L1VRFrameBuffer );
renderer->ProjectionMatrix = ovrMatrix4f_CreateIdentity();
}
@@ -989,7 +783,7 @@ void setHMDPosition( float x, float y, float z )
{
hmdPosition[0] = x;
hmdPosition[1] = y;
- if (bigScreen)
+ if (useScreenLayer())
{
playerHeight = y;
}
@@ -1000,99 +794,23 @@ void Host_BeginFrame();
void Host_Frame(int eye);
void Host_EndFrame();
-static ovrLayerProjection2 ovrRenderer_RenderFrame( ovrRenderer * renderer, const ovrJava * java,
+void VR_GetMove( float *forward, float *side, float *yaw, float *pitch, float *roll )
+{
+ *yaw = hmdorientation[YAW];
+ *pitch = hmdorientation[PITCH];
+ *roll = hmdorientation[ROLL];
+}
+
+void RenderFrame( ovrRenderer * renderer, const ovrJava * java,
const ovrTracking2 * tracking, ovrMobile * ovr )
{
- LOAD_GLES2(glEnable);
- LOAD_GLES2(glDepthMask);
- LOAD_GLES2(glDepthFunc);
- LOAD_GLES2(glViewport);
- LOAD_GLES2(glScissor);
- LOAD_GLES2(glClearColor);
- LOAD_GLES2(glClear);
- LOAD_GLES2(glDisable);
- LOAD_GLES2(glUseProgram);
- LOAD_GLES2(glVertexAttribPointer);
- LOAD_GLES2(glUniformMatrix4fv);
- LOAD_GLES2(glActiveTexture);
- LOAD_GLES2(glGetIntegerv);
- LOAD_GLES2(glBindTexture);
- LOAD_GLES2(glUniform1i);
- LOAD_GLES2(glDrawElements);
-
- ovrTracking2 updatedTracking = *tracking;
-
- //Get orientation
- // We extract Yaw, Pitch, Roll instead of directly using the orientation
- // to allow "additional" yaw manipulation with mouse/controller.
- const ovrQuatf quatHmd = tracking->HeadPose.Pose.Orientation;
- const ovrVector3f positionHmd = tracking->HeadPose.Pose.Position;
- QuatToYawPitchRoll(quatHmd, hmdorientation);
- setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z);
-
- //TODO: fix
- if (true) { //cl_trackingmode.flags == 0) {
- //Use hmd position for world position
- setWorldPosition(positionHmd.x, positionHmd.y, positionHmd.z);
- }
-
- ALOGV(" HMD-Yaw: %f", hmdorientation[YAW]);
- ALOGV(" HMD-Position: %f, %f, %f", positionHmd.x, positionHmd.y, positionHmd.z);
-
- //Set move information - if showing menu, don't pass head orientation through
-// QC_MoveEvent(hmdorientation[YAW], hmdorientation[PITCH], hmdorientation[ROLL]);
-
- //Set everything up
- Host_BeginFrame();
-
- ovrMatrix4f eyeViewMatrixTransposed[2];
- eyeViewMatrixTransposed[0] = ovrMatrix4f_Transpose( &updatedTracking.Eye[0].ViewMatrix );
- eyeViewMatrixTransposed[1] = ovrMatrix4f_Transpose( &updatedTracking.Eye[1].ViewMatrix );
-
- ovrMatrix4f projectionMatrixTransposed[2];
- projectionMatrixTransposed[0] = ovrMatrix4f_Transpose( &updatedTracking.Eye[0].ProjectionMatrix );
- projectionMatrixTransposed[1] = ovrMatrix4f_Transpose( &updatedTracking.Eye[1].ProjectionMatrix );
-
-
- ovrLayerProjection2 layer = vrapi_DefaultLayerProjection2();
- layer.HeadPose = updatedTracking.HeadPose;
- for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
- {
- ovrFramebuffer * frameBuffer = &renderer->FrameBuffer[renderer->NumBuffers == 1 ? 0 : eye];
- layer.Textures[eye].ColorSwapChain = frameBuffer->ColorTextureSwapChain;
- layer.Textures[eye].SwapChainIndex = frameBuffer->TextureSwapChainIndex;
-
- ovrMatrix4f projectionMatrix;
- if (bigScreen) {
- projectionMatrix = ovrMatrix4f_CreateProjectionFov(horizFOV, vertFOV,
- 0.0f, 0.0f, 0.1f,
- 0.0f);
- } else{
- projectionMatrix = ovrMatrix4f_CreateProjectionFov(horizFOV, vertFOV+4.0f,
- 0.0f, 0.0f, 0.1f,
- 0.0f);
- }
-// layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection(
-// &projectionMatrix);
-
- //Gear VR
- layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection( &updatedTracking.Eye[eye].ProjectionMatrix );
-
- layer.Textures[eye].TextureRect.x = 0;
- layer.Textures[eye].TextureRect.y = 0;
- layer.Textures[eye].TextureRect.width = 1.0f;
- layer.Textures[eye].TextureRect.height = 1.0f;
- }
- layer.Header.Flags |= VRAPI_FRAME_LAYER_FLAG_CHROMATIC_ABERRATION_CORRECTION;
+ //Set everything up
+ Host_BeginFrame();
// Render the eye images.
for ( int eye = 0; eye < renderer->NumBuffers; eye++ )
{
- bool screen = false;
- ovrFramebuffer * frameBuffer = &renderer->FrameBuffer[eye];
- if (screen)//bigScreen != 0 || demoplayback)
- frameBuffer = &renderer->L1VRFrameBuffer;
-
+ ovrFramebuffer * frameBuffer = &(renderer->FrameBuffer[eye]);
ovrFramebuffer_SetCurrent( frameBuffer );
{
@@ -1115,73 +833,6 @@ static ovrLayerProjection2 ovrRenderer_RenderFrame( ovrRenderer * renderer, cons
//Clear edge to prevent smearing
ovrFramebuffer_ClearEdgeTexels( frameBuffer );
-
- if (screen)//bigScreen != 0 || demoplayback)// || key_consoleactive)
- {
- frameBuffer = &renderer->FrameBuffer[eye];
- ovrFramebuffer_SetCurrent( frameBuffer );
-
- // Apply the projection and view transformation
- ovrMatrix4f modelView = ovrMatrix4f_Multiply( &updatedTracking.Eye[0].ViewMatrix, &rotation );
- modelView = ovrMatrix4f_Multiply( &modelView, &modelScreen );
- ovrMatrix4f modelViewProjection = ovrMatrix4f_Multiply( &renderer->ProjectionMatrix, &modelView );
-
- GLint originalTex0 = 0;
- GLint originalTex1 = 0;
- GL( gles_glEnable( GL_SCISSOR_TEST ) );
- GL( gles_glDepthMask( GL_TRUE ) );
- GL( gles_glEnable( GL_DEPTH_TEST ) );
- GL( gles_glDepthFunc( GL_LEQUAL ) );
- GL( gles_glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height ) );
- GL( gles_glScissor( 0, 0, frameBuffer->Width, frameBuffer->Height ) );
- GL( gles_glClearColor( 0.01f, 0.0f, 0.0f, 1.0f ) );
- GL( gles_glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) );
- GL( gles_glDisable(GL_SCISSOR_TEST));
-
- GL( gles_glUseProgram(sp_Image));
-
- // Set the position of the screen
- GL( gles_glVertexAttribPointer(positionParam, 3, GL_FLOAT, GL_FALSE, 0, SCREEN_COORDS));
-
- // Prepare the texture coordinates
- GL( gles_glVertexAttribPointer(texCoordParam, 2, GL_FLOAT, GL_FALSE, 0, uvs) );
-
- // Apply the projection and view transformation
- modelView = ovrMatrix4f_Multiply( &modelView, &modelScreen );
-
- GL( gles_glUniformMatrix4fv(modelViewProjectionParam, 1, GL_TRUE, (const GLfloat *)modelViewProjection.M[0]) );
-
- GL( gles_glActiveTexture(GL_TEXTURE0) );
-
- GLuint colorTexture = vrapi_GetTextureSwapChainHandle(
- renderer->L1VRFrameBuffer.ColorTextureSwapChain,
- renderer->L1VRFrameBuffer.TextureSwapChainIndex);
- gles_glGetIntegerv(GL_TEXTURE_BINDING_2D, &originalTex0);
- GL( gles_glBindTexture( GL_TEXTURE_2D, colorTexture ) );
-
- // Set the sampler texture unit to our fbo's color texture
- GL( gles_glUniform1i(samplerParam, 0) );
-
- //Bind vignette texture to texture 1
- GL( gles_glActiveTexture( GL_TEXTURE1 ) );
- gles_glGetIntegerv(GL_TEXTURE_BINDING_2D, &originalTex1);
- GL( gles_glBindTexture( GL_TEXTURE_2D, vignetteTexture) );
- GL( gles_glUniform1i(vignetteParam, 1) );
-
- // Draw the triangles
- GL( gles_glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, indices) );
-
-
- //Restore previously active textures
- GL( gles_glBindTexture(GL_TEXTURE_2D, originalTex1) );
- GL( gles_glActiveTexture(GL_TEXTURE0) );
- GL( gles_glBindTexture(GL_TEXTURE_2D, originalTex0) );
-
-
- //Clear edge to prevent smearing
- ovrFramebuffer_ClearEdgeTexels( frameBuffer );
- }
-
ovrFramebuffer_Resolve( frameBuffer );
ovrFramebuffer_Advance( frameBuffer );
}
@@ -1189,10 +840,9 @@ static ovrLayerProjection2 ovrRenderer_RenderFrame( ovrRenderer * renderer, cons
Host_EndFrame();
ovrFramebuffer_SetNone();
-
- return layer;
}
+
/*
================================================================================
@@ -1217,6 +867,7 @@ typedef struct
ANativeWindow * NativeWindow;
bool Resumed;
ovrMobile * Ovr;
+ ovrScene Scene;
long long FrameIndex;
double DisplayTime;
int SwapInterval;
@@ -1224,6 +875,8 @@ typedef struct
int GpuLevel;
int MainThreadTid;
int RenderThreadTid;
+ ovrLayer_Union2 Layers[ovrMaxLayerCount];
+ int LayerCount;
ovrRenderer Renderer;
} ovrApp;
@@ -1245,6 +898,7 @@ static void ovrApp_Clear( ovrApp * app )
ovrEgl_Clear( &app->Egl );
+ ovrScene_Clear( &app->Scene );
ovrRenderer_Clear( &app->Renderer );
}
@@ -1375,104 +1029,6 @@ ovrInputStateTrackedRemote rightTrackedRemoteState_old;
ovrInputStateTrackedRemote rightTrackedRemoteState_new;
ovrTracking rightRemoteTracking;
-//Text Input stuff
-bool textInput = false;
-int shift = 0;
-int left_grid = 0;
-char left_lower[3][10] = {"bcfihgdae", "klorqpmjn", "tuwzyxvs "};
-char left_shift[3][10] = {"BCFIHGDAE", "KLORQPMJN", "TUWZYXVS "};
-int right_grid = 0;
-char right_lower[2][10] = {"236987415", "+-)]&[(?0"};
-char right_shift[2][10] = {"\"*:|._~/#", "%^}>,<{\\@"};
-
-char left_grid_map[2][3][3][8] = {
- {
- {
- "a b c", "j k l", "s t u"
- },
- {
- "d e f", "m n o", "v w"
- },
- {
- "g h i", "p q r", "x y z"
- },
- },
- {
- {
- "A B C", "J K L", "S T U"
- },
- {
- "D E F", "M N O", "V W"
- },
- {
- "G H I", "P Q R", "X Y Z"
- },
-
- }
-};
-
-
-char right_grid_map[2][3][2][8] = {
- {
- {
- "1 2 3", "? + -"
- },
- {
- "4 5 6", "( 0 )"
- },
- {
- "7 8 9", "[ & ]"
- },
- },
- {
- {
- "/ \" *", "\\ % ^"
- },
- {
- "~ # :", "{ @ }"
- },
- {
- "_ . |", "< , >"
- },
- }
-};
-
-
-static int getCharacter(float x, float y)
-{
- int c = 8;
- if (x < -0.3f || x > 0.3f || y < -0.3f || y > 0.3f)
- {
- if (x == 0.0f)
- {
- if (y > 0.0f)
- {
- c = 0;
- }
- else
- {
- c = 4;
- }
- }
- else
- {
- float angle = atanf(y / x) / ((float)M_PI / 180.0f);
- if (x > 0.0f)
- {
- c = (int)(((90.0f - angle) + 22.5f) / 45.0f);
- }
- else
- {
- c = (int)(((90.0f - angle) + 22.5f) / 45.0f) + 4;
- if (c == 8)
- c = 0;
- }
- }
- }
-
- return c;
-}
-
extern int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy );
float initialTouchX, initialTouchY;
@@ -1644,9 +1200,7 @@ static void ovrApp_HandleInput( ovrApp * app )
const ovrQuatf quatRemote = rightRemoteTracking.HeadPose.Pose.Orientation;
float remoteAngles[3];
QuatToYawPitchRoll(quatRemote, remoteAngles);
- bool touchingTrackpad = (rightTrackedRemoteState_new.TrackpadStatus != 0);
- if (touchingTrackpad &&
- remoteAngles[YAW] > -30.0f && remoteAngles[YAW] < 30.0f &&
+ if (remoteAngles[YAW] > -30.0f && remoteAngles[YAW] < 30.0f &&
remoteAngles[PITCH] > -30.0f && remoteAngles[PITCH] < 30.0f) {
int newRemoteTrigState = (rightTrackedRemoteState_new.Buttons & ovrButton_A) != 0;
@@ -1654,7 +1208,7 @@ static void ovrApp_HandleInput( ovrApp * app )
touchEventType t = event_motion;
- float touchX = (remoteAngles[YAW] + 30.0f) / 60.0f;
+ float touchX = (-remoteAngles[YAW] + 30.0f) / 60.0f;
float touchY = (remoteAngles[PITCH] + 30.0f) / 60.0f;
if (newRemoteTrigState != prevRemoteTrigState)
{
@@ -1723,20 +1277,6 @@ static void ovrApp_HandleInput( ovrApp * app )
controllerYawHeading = controllerAngles[YAW] - gunangles[YAW] + yawOffset;
hmdYawHeading = hmdorientation[YAW] - gunangles[YAW] + yawOffset;
-
-#ifndef NDEBUG
- //Change heading mode on click of off=hand joystick
- if ((offHandTrackedRemoteState->Buttons & ovrButton_Joystick) && bigScreen == 0 &&
- (offHandTrackedRemoteState->Buttons & ovrButton_Joystick) !=
- (offHandTrackedRemoteStateOld->Buttons & ovrButton_Joystick)) {
-// Cvar_SetValueQuick(&cl_walkdirection, 1 - cl_walkdirection.flags);
-// if (cl_walkdirection.flags == 1) {
-// SCR_CenterPrint("Heading Mode: Direction of HMD");
-// } else {
-// SCR_CenterPrint("Heading Mode: Direction of off-hand controller");
-// }
- }
-#endif
}
//Right-hand specific stuff
@@ -1767,41 +1307,10 @@ static void ovrApp_HandleInput( ovrApp * app )
// QC_MotionEvent(delta, rightTrackedRemoteState_new.Joystick.x,
// rightTrackedRemoteState_new.Joystick.y);
- if (bigScreen != 0) {
- int rightJoyState = (rightTrackedRemoteState_new.Joystick.x > 0.7f ? 1 : 0);
- if (rightJoyState != (rightTrackedRemoteState_old.Joystick.x > 0.7f ? 1 : 0)) {
- Key_Event('d', rightJoyState);
- //QC_KeyEvent(rightJoyState, 'd', 0);
- }
- rightJoyState = (rightTrackedRemoteState_new.Joystick.x < -0.7f ? 1 : 0);
- if (rightJoyState != (rightTrackedRemoteState_old.Joystick.x < -0.7f ? 1 : 0)) {
- Key_Event('a', rightJoyState);
- //QC_KeyEvent(rightJoyState, 'a', 0);
- }
- rightJoyState = (rightTrackedRemoteState_new.Joystick.y < -0.7f ? 1 : 0);
- if (rightJoyState != (rightTrackedRemoteState_old.Joystick.y < -0.7f ? 1 : 0)) {
- Key_Event(K_DOWNARROW, rightJoyState);
- //QC_KeyEvent(rightJoyState, K_DOWNARROW, 0);
- }
- rightJoyState = (rightTrackedRemoteState_new.Joystick.y > 0.7f ? 1 : 0);
- if (rightJoyState != (rightTrackedRemoteState_old.Joystick.y > 0.7f ? 1 : 0)) {
- Key_Event(K_UPARROW, rightJoyState);
- //QC_KeyEvent(rightJoyState, K_UPARROW, 0);
- }
-
- //Click an option
- handleTrackedControllerButton(&rightTrackedRemoteState_new,
- &rightTrackedRemoteState_old, ovrButton_A, K_ENTER);
-
- //Back button
- handleTrackedControllerButton(&rightTrackedRemoteState_new,
- &rightTrackedRemoteState_old, ovrButton_B, K_ESCAPE);
- } else {
- //Jump
- handleTrackedControllerButton(&rightTrackedRemoteState_new,
- &rightTrackedRemoteState_old, ovrButton_A, K_SPACE);
- }
+ //Jump
+ handleTrackedControllerButton(&rightTrackedRemoteState_new,
+ &rightTrackedRemoteState_old, ovrButton_A, K_SPACE);
if (cl_righthanded.flags) {
//Fire
@@ -1847,29 +1356,6 @@ static void ovrApp_HandleInput( ovrApp * app )
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
ovrButton_Enter, K_ESCAPE);
- if (bigScreen != 0) {
- int leftJoyState = (leftTrackedRemoteState_new.Joystick.x > 0.7f ? 1 : 0);
- if (leftJoyState != (leftTrackedRemoteState_old.Joystick.x > 0.7f ? 1 : 0)) {
- Key_Event('d', leftJoyState);
- //QC_KeyEvent(leftJoyState, 'd', 0);
- }
- leftJoyState = (leftTrackedRemoteState_new.Joystick.x < -0.7f ? 1 : 0);
- if (leftJoyState != (leftTrackedRemoteState_old.Joystick.x < -0.7f ? 1 : 0)) {
- Key_Event('a', leftJoyState);
- //QC_KeyEvent(leftJoyState, 'a', 0);
- }
- leftJoyState = (leftTrackedRemoteState_new.Joystick.y < -0.7f ? 1 : 0);
- if (leftJoyState != (leftTrackedRemoteState_old.Joystick.y < -0.7f ? 1 : 0)) {
- Key_Event(K_DOWNARROW, leftJoyState);
- // QC_KeyEvent(leftJoyState, K_DOWNARROW, 0);
- }
- leftJoyState = (leftTrackedRemoteState_new.Joystick.y > 0.7f ? 1 : 0);
- if (leftJoyState != (leftTrackedRemoteState_old.Joystick.y > 0.7f ? 1 : 0)) {
- Key_Event(K_UPARROW, leftJoyState);
-// QC_KeyEvent(leftJoyState, K_UPARROW, 0);
- }
- }
-
//Adjust to be off-hand controller oriented
vec2_t v;
@@ -1897,23 +1383,6 @@ static void ovrApp_HandleInput( ovrApp * app )
handleTrackedControllerButton(&leftTrackedRemoteState_new, &leftTrackedRemoteState_old,
ovrButton_GripTrigger, '#');
-#ifndef NDEBUG
- //Give all weapons and all ammo and god mode
- if ((leftTrackedRemoteState_new.Buttons & ovrButton_X) &&
- (leftTrackedRemoteState_new.Buttons & ovrButton_X) !=
- (leftTrackedRemoteState_old.Buttons & ovrButton_X)) {
-// Cbuf_InsertText("God\n");
-// Cbuf_InsertText("Impulse 9\n");
- }
-#endif
-
- //Toggle text input
- if ((leftTrackedRemoteState_new.Buttons & ovrButton_Y) &&
- (leftTrackedRemoteState_new.Buttons & ovrButton_Y) !=
- (leftTrackedRemoteState_old.Buttons & ovrButton_Y)) {
- textInput = !textInput;
- }
-
leftTrackedRemoteState_old = leftTrackedRemoteState_new;
}
@@ -2154,6 +1623,8 @@ void Android_MessageBox(const char *title, const char *text)
ALOGE("%s %s", title, text);
}
+void initialize_gl4es();
+
void * AppThreadFunction( void * parm )
{
ovrAppThread * appThread = (ovrAppThread *)parm;
@@ -2198,9 +1669,6 @@ void * AppThreadFunction( void * parm )
//Always use this folder
chdir("/sdcard/xash");
- //Initialise gl4es
- Com_LoadLibrary("gl4es", 0);
-
const double startTime = GetTimeInSeconds();
for ( bool destroyed = false; destroyed == false; )
@@ -2230,28 +1698,16 @@ void * AppThreadFunction( void * parm )
if (arg)
{
-// QC_SetResolution(vrapi_GetSystemPropertyInt( &java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH ) * SS_MULTIPLIER,
-// vrapi_GetSystemPropertyInt( &java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT ) * SS_MULTIPLIER);
-
Host_Main(argc, argv, "valve", false, NULL);
- //main(argc, argv);
}
else
{
int argc = 1; char *argv[] = { "xash3d" };
Host_Main(argc, argv, "valve", false, NULL);
-
- //QC_SetResolution(vrapi_GetSystemPropertyInt( &java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH ) * SS_MULTIPLIER,
- // vrapi_GetSystemPropertyInt( &java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT ) * SS_MULTIPLIER);
-
- //main(argc, argv);
}
xash_initialised = true;
-
- //Ensure game starts with credits active
- //MR_ToggleMenu(2);
}
break;
}
@@ -2290,6 +1746,13 @@ void * AppThreadFunction( void * parm )
continue;
}
+ // Create the scene if not yet created.
+ // The scene is created here to be able to show a loading icon.
+ if ( !ovrScene_IsCreated( &appState.Scene ) )
+ {
+ ovrScene_Create( m_width, m_height, &appState.Scene, &java );
+ }
+
// This is the only place the frame index is incremented, right before
// calling vrapi_GetPredictedDisplayTime().
appState.FrameIndex++;
@@ -2333,40 +1796,133 @@ void * AppThreadFunction( void * parm )
runStatus = 0;
}
#endif
- // Get the HMD pose, predicted for the middle of the time period during which
- // the new eye images will be displayed. The number of frames predicted ahead
- // depends on the pipeline depth of the engine and the synthesis rate.
- // The better the prediction, the less black will be pulled in at the edges.
- const double predictedDisplayTime = vrapi_GetPredictedDisplayTime(appState.Ovr,
- appState.FrameIndex);
- const ovrTracking2 tracking = vrapi_GetPredictedTracking2(appState.Ovr,
- predictedDisplayTime);
- appState.DisplayTime = predictedDisplayTime;
+ // Get the HMD pose, predicted for the middle of the time period during which
+ // the new eye images will be displayed. The number of frames predicted ahead
+ // depends on the pipeline depth of the engine and the synthesis rate.
+ // The better the prediction, the less black will be pulled in at the edges.
+ const double predictedDisplayTime = vrapi_GetPredictedDisplayTime(appState.Ovr,
+ appState.FrameIndex);
+ const ovrTracking2 tracking = vrapi_GetPredictedTracking2(appState.Ovr,
+ predictedDisplayTime);
- ovrApp_HandleInput(&appState);
+ appState.DisplayTime = predictedDisplayTime;
+
+ ovrApp_HandleInput(&appState);
+
+ //Get orientation
+ // We extract Yaw, Pitch, Roll instead of directly using the orientation
+ // to allow "additional" yaw manipulation with mouse/controller.
+ const ovrQuatf quatHmd = tracking.HeadPose.Pose.Orientation;
+ const ovrVector3f positionHmd = tracking.HeadPose.Pose.Position;
+ QuatToYawPitchRoll(quatHmd, hmdorientation);
+ setHMDPosition(positionHmd.x, positionHmd.y, positionHmd.z);
+
+ //TODO: fix - set to use HMD position for world position
+ if (true) {
+ setWorldPosition(positionHmd.x, positionHmd.y, positionHmd.z);
+ }
+
+ ALOGV(" HMD-Position: %f, %f, %f", positionHmd.x, positionHmd.y, positionHmd.z);
+
+ ovrSubmitFrameDescription2 frameDesc = { 0 };
+ if (!useScreenLayer()) {
+
+ ovrLayerProjection2 layer = vrapi_DefaultLayerProjection2();
+ layer.HeadPose = tracking.HeadPose;
+ for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
+ {
+ ovrFramebuffer * frameBuffer = &appState.Renderer.FrameBuffer[appState.Renderer.NumBuffers == 1 ? 0 : eye];
+ layer.Textures[eye].ColorSwapChain = frameBuffer->ColorTextureSwapChain;
+ layer.Textures[eye].SwapChainIndex = frameBuffer->TextureSwapChainIndex;
+
+#define OCULUS_QUEST
+#ifdef OCULUS_QUEST
+ ovrMatrix4f projectionMatrix;
+ projectionMatrix = ovrMatrix4f_CreateProjectionFov(horizFOV, vertFOV,
+ 0.0f, 0.0f, 0.1f,
+ 0.0f);
+
+ layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection(
+ &projectionMatrix);
+#else
+
+ //Gear VR
+ layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection( &tracking.Eye[eye].ProjectionMatrix );
+#endif
+
+ layer.Textures[eye].TextureRect.x = 0;
+ layer.Textures[eye].TextureRect.y = 0;
+ layer.Textures[eye].TextureRect.width = 1.0f;
+ layer.Textures[eye].TextureRect.height = 1.0f;
+ }
+ layer.Header.Flags |= VRAPI_FRAME_LAYER_FLAG_CHROMATIC_ABERRATION_CORRECTION;
+
+ //Call the game drawing code to populate the cylinder layer texture
+ RenderFrame(&appState.Renderer,
+ &appState.Java,
+ &tracking,
+ appState.Ovr);
+
+ // Set up the description for this frame.
+ const ovrLayerHeader2 *layers[] =
+ {
+ &layer.Header
+ };
+
+ ovrSubmitFrameDescription2 frameDesc = {};
+ frameDesc.Flags = 0;
+ frameDesc.SwapInterval = appState.SwapInterval;
+ frameDesc.FrameIndex = appState.FrameIndex;
+ frameDesc.DisplayTime = appState.DisplayTime;
+ frameDesc.LayerCount = 1;
+ frameDesc.Layers = layers;
+
+ // Hand over the eye images to the time warp.
+ vrapi_SubmitFrame2(appState.Ovr, &frameDesc);
+
+ } else {
+ // Set-up the compositor layers for this frame.
+ // NOTE: Multiple independent layers are allowed, but they need to be added
+ // in a depth consistent order.
+ memset( appState.Layers, 0, sizeof( ovrLayer_Union2 ) * ovrMaxLayerCount );
+ appState.LayerCount = 0;
+
+ // Render the world-view layer (simple ground plane)
+// appState.Layers[appState.LayerCount++].Projection =
+// ovrRenderer_RenderGroundPlaneToEyeBuffer( &appState.Renderer, &appState.Java,
+// &appState.Scene, &tracking );
+
+ // Add a simple cylindrical layer
+ appState.Layers[appState.LayerCount++].Cylinder =
+ BuildCylinderLayer( &appState.Scene.CylinderRenderer,
+ appState.Scene.CylinderWidth, appState.Scene.CylinderHeight, &tracking );
+
+ //Call the game drawing code to populate the cylinder layer texture
+ RenderFrame(&appState.Scene.CylinderRenderer,
+ &appState.Java,
+ &tracking,
+ appState.Ovr);
- // Render eye images and setup the primary layer using ovrTracking2.
- const ovrLayerProjection2 worldLayer = ovrRenderer_RenderFrame(&appState.Renderer,
- &appState.Java,
- &tracking, appState.Ovr);
+ // Compose the layers for this frame.
+ const ovrLayerHeader2 * layerHeaders[ovrMaxLayerCount] = { 0 };
+ for ( int i = 0; i < appState.LayerCount; i++ )
+ {
+ layerHeaders[i] = &appState.Layers[i].Header;
+ }
- const ovrLayerHeader2 *layers[] =
- {
- &worldLayer.Header
- };
+ // Set up the description for this frame.
+ frameDesc.Flags = 0;
+ frameDesc.SwapInterval = appState.SwapInterval;
+ frameDesc.FrameIndex = appState.FrameIndex;
+ frameDesc.DisplayTime = appState.DisplayTime;
+ frameDesc.LayerCount = appState.LayerCount;
+ frameDesc.Layers = layerHeaders;
- ovrSubmitFrameDescription2 frameDesc = {};
- frameDesc.Flags = 0;
- frameDesc.SwapInterval = appState.SwapInterval;
- frameDesc.FrameIndex = appState.FrameIndex;
- frameDesc.DisplayTime = appState.DisplayTime;
- frameDesc.LayerCount = 1;
- frameDesc.Layers = layers;
-
- // Hand over the eye images to the time warp.
- vrapi_SubmitFrame2(appState.Ovr, &frameDesc);
+ // Hand over the eye images to the time warp.
+ vrapi_SubmitFrame2(appState.Ovr, &frameDesc);
+ }
}
else
{
@@ -2496,6 +2052,7 @@ JNIEXPORT jlong JNICALL Java_com_drbeef_lambda1vr_GLES3JNILib_onCreate( JNIEnv *
}
}
+ initialize_gl4es();
ovrAppThread * appThread = (ovrAppThread *) malloc( sizeof( ovrAppThread ) );
ovrAppThread_Create( appThread, env, activity );
diff --git a/Projects/Android/jni/src/Lambda1VR/VrCompositor.c b/Projects/Android/jni/src/Lambda1VR/VrCompositor.c
new file mode 100644
index 0000000..ee731a8
--- /dev/null
+++ b/Projects/Android/jni/src/Lambda1VR/VrCompositor.c
@@ -0,0 +1,644 @@
+/************************************************************************************
+
+Filename : VrCompositor.c
+
+*************************************************************************************/
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include // for prctl( PR_SET_NAME )
+#include
+#include // for AWINDOW_FLAG_KEEP_SCREEN_ON
+
+#include
+#include
+#include
+#include
+
+
+
+#include
+#include
+
+#include "../gl4es/src/gl/loader.h"
+#include "VrCompositor.h"
+
+
+
+/*
+================================================================================
+
+renderState
+
+================================================================================
+*/
+
+
+void getCurrentRenderState( renderState * state)
+{
+ LOAD_GLES2(glGetIntegerv);
+
+ state->VertexBuffer = 0;
+ state->IndexBuffer = 0;
+ state->VertexArrayObject = 0;
+ state->Program = 0;
+
+ gles_glGetIntegerv(GL_ARRAY_BUFFER, &state->VertexBuffer );
+ gles_glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER, &state->IndexBuffer );
+ gles_glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &state->VertexArrayObject );
+ gles_glGetIntegerv(GL_CURRENT_PROGRAM, &state->Program );
+}
+
+void restoreRenderState( renderState * state )
+{
+ LOAD_GLES2(glBindBuffer);
+ LOAD_GLES2(glUseProgram);
+
+ GL( gles_glUseProgram( state->Program ) );
+ GL( glBindVertexArray( state->VertexArrayObject ) );
+ GL( gles_glBindBuffer( GL_ARRAY_BUFFER, state->VertexBuffer ) );
+ GL( gles_glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, state->IndexBuffer ) );
+}
+
+
+/*
+================================================================================
+
+ovrGeometry
+
+================================================================================
+*/
+
+enum VertexAttributeLocation
+{
+ VERTEX_ATTRIBUTE_LOCATION_POSITION,
+ VERTEX_ATTRIBUTE_LOCATION_COLOR,
+ VERTEX_ATTRIBUTE_LOCATION_UV,
+};
+
+typedef struct
+{
+ enum VertexAttributeLocation location;
+ const char * name;
+} ovrVertexAttribute;
+
+static ovrVertexAttribute ProgramVertexAttributes[] =
+{
+ { VERTEX_ATTRIBUTE_LOCATION_POSITION, "vertexPosition" },
+ { VERTEX_ATTRIBUTE_LOCATION_COLOR, "vertexColor" },
+ { VERTEX_ATTRIBUTE_LOCATION_UV, "vertexUv" },
+};
+
+static void ovrGeometry_Clear( ovrGeometry * geometry )
+{
+ geometry->VertexBuffer = 0;
+ geometry->IndexBuffer = 0;
+ geometry->VertexArrayObject = 0;
+ geometry->VertexCount = 0;
+ geometry->IndexCount = 0;
+ for ( int i = 0; i < MAX_VERTEX_ATTRIB_POINTERS; i++ )
+ {
+ memset( &geometry->VertexAttribs[i], 0, sizeof( geometry->VertexAttribs[i] ) );
+ geometry->VertexAttribs[i].Index = -1;
+ }
+}
+
+static void ovrGeometry_CreateGroundPlane( ovrGeometry * geometry )
+{
+ LOAD_GLES2(glGenBuffers);
+ LOAD_GLES2(glBindBuffer);
+ LOAD_GLES2(glBufferData);
+
+ typedef struct
+ {
+ float positions[4][4];
+ unsigned char colors[4][4];
+ } ovrCubeVertices;
+
+ static const ovrCubeVertices cubeVertices =
+ {
+ // positions
+ {
+ { 4.5f, -1.2f, 4.5f, 1.0f },
+ { 4.5f, -1.2f, -4.5f, 1.0f },
+ { -4.5f, -1.2f, -4.5f, 1.0f },
+ { -4.5f, -1.2f, 4.5f, 1.0f }
+ },
+ // colors
+ {
+ { 255, 0, 0, 255 },
+ { 0, 255, 0, 255 },
+ { 0, 0, 255, 255 },
+ { 255, 255, 0, 255 },
+ },
+ };
+
+ static const unsigned short cubeIndices[6] =
+ {
+ 0, 1, 2,
+ 0, 2, 3,
+ };
+
+ geometry->VertexCount = 4;
+ geometry->IndexCount = 6;
+
+ geometry->VertexAttribs[0].Index = VERTEX_ATTRIBUTE_LOCATION_POSITION;
+ geometry->VertexAttribs[0].Size = 4;
+ geometry->VertexAttribs[0].Type = GL_FLOAT;
+ geometry->VertexAttribs[0].Normalized = false;
+ geometry->VertexAttribs[0].Stride = sizeof( cubeVertices.positions[0] );
+ geometry->VertexAttribs[0].Pointer = (const GLvoid *)offsetof( ovrCubeVertices, positions );
+
+ geometry->VertexAttribs[1].Index = VERTEX_ATTRIBUTE_LOCATION_COLOR;
+ geometry->VertexAttribs[1].Size = 4;
+ geometry->VertexAttribs[1].Type = GL_UNSIGNED_BYTE;
+ geometry->VertexAttribs[1].Normalized = true;
+ geometry->VertexAttribs[1].Stride = sizeof( cubeVertices.colors[0] );
+ geometry->VertexAttribs[1].Pointer = (const GLvoid *)offsetof( ovrCubeVertices, colors );
+
+ renderState state;
+ getCurrentRenderState(&state);
+
+ GL( gles_glGenBuffers( 1, &geometry->VertexBuffer ) );
+ GL( gles_glBindBuffer( GL_ARRAY_BUFFER, geometry->VertexBuffer ) );
+ GL( gles_glBufferData( GL_ARRAY_BUFFER, sizeof( cubeVertices ), &cubeVertices, GL_STATIC_DRAW ) );
+
+ GL( gles_glGenBuffers( 1, &geometry->IndexBuffer ) );
+ GL( gles_glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, geometry->IndexBuffer ) );
+ GL( gles_glBufferData( GL_ELEMENT_ARRAY_BUFFER, sizeof( cubeIndices ), cubeIndices, GL_STATIC_DRAW ) );
+
+ restoreRenderState(&state);
+}
+
+static void ovrGeometry_Destroy( ovrGeometry * geometry )
+{
+ LOAD_GLES2(glDeleteBuffers);
+
+ GL( gles_glDeleteBuffers( 1, &geometry->IndexBuffer ) );
+ GL( gles_glDeleteBuffers( 1, &geometry->VertexBuffer ) );
+
+ ovrGeometry_Clear( geometry );
+}
+
+static void ovrGeometry_CreateVAO( ovrGeometry * geometry )
+{
+ LOAD_GLES2(glBindBuffer);
+
+ renderState state;
+ getCurrentRenderState(&state);
+
+ GL( glGenVertexArrays( 1, &geometry->VertexArrayObject ) );
+ GL( glBindVertexArray( geometry->VertexArrayObject ) );
+
+ GL( gles_glBindBuffer( GL_ARRAY_BUFFER, geometry->VertexBuffer ) );
+
+ for ( int i = 0; i < MAX_VERTEX_ATTRIB_POINTERS; i++ )
+ {
+ if ( geometry->VertexAttribs[i].Index != -1 )
+ {
+ GL( glEnableVertexAttribArray( geometry->VertexAttribs[i].Index ) );
+ GL( glVertexAttribPointer( geometry->VertexAttribs[i].Index, geometry->VertexAttribs[i].Size,
+ geometry->VertexAttribs[i].Type, geometry->VertexAttribs[i].Normalized,
+ geometry->VertexAttribs[i].Stride, geometry->VertexAttribs[i].Pointer ) );
+ }
+ }
+
+ GL( gles_glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, geometry->IndexBuffer ) );
+
+ restoreRenderState(&state);
+}
+
+static void ovrGeometry_DestroyVAO( ovrGeometry * geometry )
+{
+ GL( glDeleteVertexArrays( 1, &geometry->VertexArrayObject ) );
+}
+
+/*
+================================================================================
+
+ovrProgram
+
+================================================================================
+*/
+
+
+typedef struct
+{
+ enum
+ {
+ UNIFORM_VIEW_PROJ_MATRIX,
+ } index;
+ enum
+ {
+ UNIFORM_TYPE_VECTOR4,
+ UNIFORM_TYPE_MATRIX4X4,
+ UNIFORM_TYPE_INT,
+ UNIFORM_TYPE_BUFFER,
+ } type;
+ const char * name;
+} ovrUniform;
+
+static ovrUniform ProgramUniforms[] =
+{
+ { UNIFORM_VIEW_PROJ_MATRIX, UNIFORM_TYPE_MATRIX4X4, "viewProjectionMatrix" },
+};
+
+static void ovrProgram_Clear( ovrProgram * program )
+{
+ program->Program = 0;
+ program->VertexShader = 0;
+ program->FragmentShader = 0;
+ memset( program->UniformLocation, 0, sizeof( program->UniformLocation ) );
+ memset( program->UniformBinding, 0, sizeof( program->UniformBinding ) );
+ memset( program->Textures, 0, sizeof( program->Textures ) );
+}
+
+static bool ovrProgram_Create( ovrProgram * program, const char * vertexSource, const char * fragmentSource )
+{
+ LOAD_GLES2(glGetIntegerv);
+ LOAD_GLES2(glCreateShader);
+ LOAD_GLES2(glShaderSource);
+ LOAD_GLES2(glCompileShader);
+ LOAD_GLES2(glGetShaderiv);
+ LOAD_GLES2(glGetShaderInfoLog);
+ LOAD_GLES2(glAttachShader);
+ LOAD_GLES2(glBindAttribLocation);
+ LOAD_GLES2(glLinkProgram);
+ LOAD_GLES2(glGetProgramiv);
+ LOAD_GLES2(glGetUniformLocation);
+ LOAD_GLES2(glCreateProgram);
+ LOAD_GLES2(glUseProgram);
+ LOAD_GLES2(glUniform1i);
+ LOAD_GLES2(glGetProgramInfoLog);
+
+ GLint r;
+
+ GL( program->VertexShader = gles_glCreateShader( GL_VERTEX_SHADER ) );
+
+ GL( gles_glShaderSource( program->VertexShader, 1, &vertexSource, 0 ) );
+ GL( gles_glCompileShader( program->VertexShader ) );
+ GL( gles_glGetShaderiv( program->VertexShader, GL_COMPILE_STATUS, &r ) );
+ if ( r == GL_FALSE )
+ {
+ GLchar msg[4096];
+ GL( gles_glGetShaderInfoLog( program->VertexShader, sizeof( msg ), 0, msg ) );
+ ALOGE( "%s\n%s\n", vertexSource, msg );
+ return false;
+ }
+
+ GL( program->FragmentShader = gles_glCreateShader( GL_FRAGMENT_SHADER ) );
+ GL( gles_glShaderSource( program->FragmentShader, 1, &fragmentSource, 0 ) );
+ GL( gles_glCompileShader( program->FragmentShader ) );
+ GL( gles_glGetShaderiv( program->FragmentShader, GL_COMPILE_STATUS, &r ) );
+ if ( r == GL_FALSE )
+ {
+ GLchar msg[4096];
+ GL( gles_glGetShaderInfoLog( program->FragmentShader, sizeof( msg ), 0, msg ) );
+ ALOGE( "%s\n%s\n", fragmentSource, msg );
+ return false;
+ }
+
+ GL( program->Program = gles_glCreateProgram() );
+ GL( gles_glAttachShader( program->Program, program->VertexShader ) );
+ GL( gles_glAttachShader( program->Program, program->FragmentShader ) );
+
+ // Bind the vertex attribute locations.
+ for ( int i = 0; i < sizeof( ProgramVertexAttributes ) / sizeof( ProgramVertexAttributes[0] ); i++ )
+ {
+ GL( gles_glBindAttribLocation( program->Program, ProgramVertexAttributes[i].location, ProgramVertexAttributes[i].name ) );
+ }
+
+ GL( gles_glLinkProgram( program->Program ) );
+ GL( gles_glGetProgramiv( program->Program, GL_LINK_STATUS, &r ) );
+ if ( r == GL_FALSE )
+ {
+ GLchar msg[4096];
+ GL( gles_glGetProgramInfoLog( program->Program, sizeof( msg ), 0, msg ) );
+ ALOGE( "Linking program failed: %s\n", msg );
+ return false;
+ }
+
+ int numBufferBindings = 0;
+
+ // Get the uniform locations.
+ memset( program->UniformLocation, -1, sizeof( program->UniformLocation ) );
+ for ( int i = 0; i < sizeof( ProgramUniforms ) / sizeof( ProgramUniforms[0] ); i++ )
+ {
+ const int uniformIndex = ProgramUniforms[i].index;
+ if ( ProgramUniforms[i].type == UNIFORM_TYPE_BUFFER )
+ {
+ GL( program->UniformLocation[uniformIndex] = glGetUniformBlockIndex( program->Program, ProgramUniforms[i].name ) );
+ program->UniformBinding[uniformIndex] = numBufferBindings++;
+ GL( glUniformBlockBinding( program->Program, program->UniformLocation[uniformIndex], program->UniformBinding[uniformIndex] ) );
+ }
+ else
+ {
+ GL( program->UniformLocation[uniformIndex] = gles_glGetUniformLocation( program->Program, ProgramUniforms[i].name ) );
+ program->UniformBinding[uniformIndex] = program->UniformLocation[uniformIndex];
+ }
+ }
+
+ renderState state;
+ getCurrentRenderState(&state);
+
+ GL( gles_glUseProgram( program->Program ) );
+
+ // Get the texture locations.
+ for ( int i = 0; i < MAX_PROGRAM_TEXTURES; i++ )
+ {
+ char name[32];
+ sprintf( name, "Texture%i", i );
+ program->Textures[i] = gles_glGetUniformLocation( program->Program, name );
+ if ( program->Textures[i] != -1 )
+ {
+ GL( gles_glUniform1i( program->Textures[i], i ) );
+ }
+ }
+
+ restoreRenderState(&state);
+
+ return true;
+}
+
+static void ovrProgram_Destroy( ovrProgram * program )
+{
+ LOAD_GLES2(glDeleteProgram);
+ LOAD_GLES2(glDeleteShader);
+
+ if ( program->Program != 0 )
+ {
+ GL( gles_glDeleteProgram( program->Program ) );
+ program->Program = 0;
+ }
+ if ( program->VertexShader != 0 )
+ {
+ GL( gles_glDeleteShader( program->VertexShader ) );
+ program->VertexShader = 0;
+ }
+ if ( program->FragmentShader != 0 )
+ {
+ GL( gles_glDeleteShader( program->FragmentShader ) );
+ program->FragmentShader = 0;
+ }
+}
+
+static const char VERTEX_SHADER[] =
+ "#version 300 es\n"
+ "in vec3 vertexPosition;\n"
+ "in vec4 vertexColor;\n"
+ "uniform mat4 viewProjectionMatrix;\n"
+ "out vec4 fragmentColor;\n"
+ "void main()\n"
+ "{\n"
+ " gl_Position = viewProjectionMatrix * vec4( vertexPosition, 1.0 );\n"
+ " fragmentColor = vertexColor;\n"
+ "}\n";
+
+static const char FRAGMENT_SHADER[] =
+ "#version 300 es\n"
+ "in lowp vec4 fragmentColor;\n"
+ "out lowp vec4 outColor;\n"
+ "void main()\n"
+ "{\n"
+ " outColor = fragmentColor;\n"
+ "}\n";
+
+/*
+================================================================================
+
+ovrScene
+
+================================================================================
+*/
+
+void ovrScene_Clear( ovrScene * scene )
+{
+ scene->CreatedScene = false;
+ scene->CreatedVAOs = false;
+ ovrProgram_Clear( &scene->Program );
+ ovrGeometry_Clear( &scene->GroundPlane );
+ ovrRenderer_Clear( &scene->CylinderRenderer );
+
+ scene->CylinderWidth = 0;
+ scene->CylinderHeight = 0;
+}
+
+bool ovrScene_IsCreated( ovrScene * scene )
+{
+ return scene->CreatedScene;
+}
+
+void ovrScene_CreateVAOs( ovrScene * scene )
+{
+ if ( !scene->CreatedVAOs )
+ {
+ ovrGeometry_CreateVAO( &scene->GroundPlane );
+ scene->CreatedVAOs = true;
+ }
+}
+
+void ovrScene_DestroyVAOs( ovrScene * scene )
+{
+ if ( scene->CreatedVAOs )
+ {
+ ovrGeometry_DestroyVAO( &scene->GroundPlane );
+ scene->CreatedVAOs = false;
+ }
+}
+
+void ovrScene_Create( int width, int height, ovrScene * scene, const ovrJava * java )
+{
+ // Simple ground plane geometry.
+ {
+ ovrProgram_Create( &scene->Program, VERTEX_SHADER, FRAGMENT_SHADER );
+ ovrGeometry_CreateGroundPlane( &scene->GroundPlane );
+ ovrScene_CreateVAOs( scene );
+ }
+
+ // Create Cylinder renderer
+ {
+ scene->CylinderWidth = width;
+ scene->CylinderHeight = height;
+
+ //Create cylinder renderer
+ ovrRenderer_Create( &scene->CylinderRenderer, java );
+ }
+
+ scene->CreatedScene = true;
+}
+
+void ovrScene_Destroy( ovrScene * scene )
+{
+ ovrScene_DestroyVAOs( scene );
+ ovrProgram_Destroy( &scene->Program );
+ ovrGeometry_Destroy( &scene->GroundPlane );
+ ovrRenderer_Destroy( &scene->CylinderRenderer );
+
+ scene->CreatedScene = false;
+}
+
+/*
+================================================================================
+
+ovrRenderer
+
+================================================================================
+*/
+
+ovrLayerProjection2 ovrRenderer_RenderGroundPlaneToEyeBuffer( ovrRenderer * renderer, const ovrJava * java,
+ const ovrScene * scene, const ovrTracking2 * tracking )
+{
+ LOAD_GLES2(glEnable);
+ LOAD_GLES2(glDepthMask);
+ LOAD_GLES2(glDepthFunc);
+ LOAD_GLES2(glViewport);
+ LOAD_GLES2(glScissor);
+ LOAD_GLES2(glClearColor);
+ LOAD_GLES2(glClear);
+ LOAD_GLES2(glDisable);
+ LOAD_GLES2(glGetIntegerv);
+ LOAD_GLES2(glBindBuffer);
+ LOAD_GLES2(glCullFace);
+ LOAD_GLES2(glDrawElements);
+ LOAD_GLES2(glUseProgram);
+ LOAD_GLES(glUniformMatrix4fv);
+
+ ovrLayerProjection2 layer = vrapi_DefaultLayerProjection2();
+ layer.HeadPose = tracking->HeadPose;
+ for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
+ {
+ ovrFramebuffer * frameBuffer = &renderer->FrameBuffer[eye];
+ layer.Textures[eye].ColorSwapChain = frameBuffer->ColorTextureSwapChain;
+ layer.Textures[eye].SwapChainIndex = frameBuffer->TextureSwapChainIndex;
+ layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection( &tracking->Eye[eye].ProjectionMatrix );
+ }
+ layer.Header.Flags |= VRAPI_FRAME_LAYER_FLAG_CHROMATIC_ABERRATION_CORRECTION;
+
+ for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
+ {
+ ovrFramebuffer * frameBuffer = &renderer->FrameBuffer[eye];
+ ovrFramebuffer_SetCurrent( frameBuffer );
+
+ renderState state;
+ getCurrentRenderState(&state);
+
+ GL( gles_glUseProgram( scene->Program.Program ) );
+
+ ovrMatrix4f viewProjMatrix = ovrMatrix4f_Multiply( &tracking->Eye[eye].ProjectionMatrix, &tracking->Eye[eye].ViewMatrix );
+ glUniformMatrix4fv( scene->Program.UniformLocation[UNIFORM_VIEW_PROJ_MATRIX], 1, GL_TRUE, &viewProjMatrix.M[0][0] );
+
+ GL( gles_glEnable( GL_SCISSOR_TEST ) );
+ GL( gles_glDepthMask( GL_TRUE ) );
+ GL( gles_glEnable( GL_DEPTH_TEST ) );
+ GL( gles_glDepthFunc( GL_LEQUAL ) );
+ GL( gles_glEnable( GL_CULL_FACE ) );
+ GL( gles_glCullFace( GL_BACK ) );
+ GL( gles_glViewport( 0, 0, frameBuffer->Width, frameBuffer->Height ) );
+ GL( gles_glScissor( 0, 0, frameBuffer->Width, frameBuffer->Height ) );
+ GL( gles_glClearColor( 0.0f, 0.0f, 0.0f, 1.0f ) );
+ GL( gles_glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) );
+
+ //bind buffers
+ GL( gles_glBindBuffer( GL_ARRAY_BUFFER, scene->GroundPlane.VertexBuffer ) );
+ GL( gles_glBindBuffer( GL_ELEMENT_ARRAY_BUFFER, scene->GroundPlane.IndexBuffer ) );
+ GL( glBindVertexArray( scene->GroundPlane.VertexArrayObject ) );
+
+ GL( gles_glDrawElements( GL_TRIANGLES, scene->GroundPlane.IndexCount, GL_UNSIGNED_SHORT, NULL ) );
+
+ restoreRenderState(&state);
+
+ // Explicitly clear the border texels to black when GL_CLAMP_TO_BORDER is not available.
+ ovrFramebuffer_ClearEdgeTexels( frameBuffer );
+
+ ovrFramebuffer_Resolve( frameBuffer );
+ ovrFramebuffer_Advance( frameBuffer );
+ }
+
+ ovrFramebuffer_SetNone();
+
+ return layer;
+}
+
+// Assumes landscape cylinder shape.
+ovrMatrix4f CylinderModelMatrix( const int texWidth, const int texHeight,
+ const ovrVector3f translation,
+ const float rotateYaw,
+ const float rotatePitch,
+ const float radius,
+ const float density )
+{
+ const ovrMatrix4f scaleMatrix = ovrMatrix4f_CreateScale( radius, radius * (float)texHeight * VRAPI_PI / density, radius );
+ const ovrMatrix4f transMatrix = ovrMatrix4f_CreateTranslation( translation.x, translation.y, translation.z );
+ const ovrMatrix4f rotXMatrix = ovrMatrix4f_CreateRotation( rotateYaw, 0.0f, 0.0f );
+ const ovrMatrix4f rotYMatrix = ovrMatrix4f_CreateRotation( 0.0f, rotatePitch, 0.0f );
+
+ const ovrMatrix4f m0 = ovrMatrix4f_Multiply( &transMatrix, &scaleMatrix );
+ const ovrMatrix4f m1 = ovrMatrix4f_Multiply( &rotXMatrix, &m0 );
+ const ovrMatrix4f m2 = ovrMatrix4f_Multiply( &rotYMatrix, &m1 );
+
+ return m2;
+}
+
+ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer,
+ const int textureWidth, const int textureHeight,
+ const ovrTracking2 * tracking )
+{
+ ovrLayerCylinder2 layer = vrapi_DefaultLayerCylinder2();
+
+ const float fadeLevel = 1.0f;
+ layer.Header.ColorScale.x =
+ layer.Header.ColorScale.y =
+ layer.Header.ColorScale.z =
+ layer.Header.ColorScale.w = fadeLevel;
+ layer.Header.SrcBlend = VRAPI_FRAME_LAYER_BLEND_SRC_ALPHA;
+ layer.Header.DstBlend = VRAPI_FRAME_LAYER_BLEND_ONE_MINUS_SRC_ALPHA;
+
+ //layer.Header.Flags = VRAPI_FRAME_LAYER_FLAG_CLIP_TO_TEXTURE_RECT;
+
+ layer.HeadPose = tracking->HeadPose;
+
+ const float density = 4500.0f;
+ const float rotateYaw = 0.0f;
+ const float rotatePitch = 0.0f;
+ const float radius = 3.0f;
+ const ovrVector3f translation = { 0.0f, 0.0f, 0.0f };
+
+ ovrMatrix4f cylinderTransform =
+ CylinderModelMatrix( textureWidth, textureHeight, translation,
+ rotateYaw, rotatePitch, radius, density );
+
+ const float circScale = density * 0.5f / textureWidth;
+ const float circBias = -circScale * ( 0.5f * ( 1.0f - 1.0f / circScale ) );
+
+ for ( int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; eye++ )
+ {
+ ovrFramebuffer * cylinderFrameBuffer = &cylinderRenderer->FrameBuffer[eye];
+
+ ovrMatrix4f modelViewMatrix = ovrMatrix4f_Multiply( &tracking->Eye[eye].ViewMatrix, &cylinderTransform );
+ layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_Inverse( &modelViewMatrix );
+ layer.Textures[eye].ColorSwapChain = cylinderFrameBuffer->ColorTextureSwapChain;
+ layer.Textures[eye].SwapChainIndex = cylinderFrameBuffer->TextureSwapChainIndex;
+
+ // Texcoord scale and bias is just a representation of the aspect ratio. The positioning
+ // of the cylinder is handled entirely by the TexCoordsFromTanAngles matrix.
+
+ const float texScaleX = circScale;
+ const float texBiasX = circBias;
+ const float texScaleY = 0.5f;
+ const float texBiasY = -texScaleY * ( 0.5f * ( 1.0f - ( 1.0f / texScaleY ) ) );
+
+ layer.Textures[eye].TextureMatrix.M[0][0] = texScaleX;
+ layer.Textures[eye].TextureMatrix.M[0][2] = texBiasX;
+ layer.Textures[eye].TextureMatrix.M[1][1] = texScaleY;
+ layer.Textures[eye].TextureMatrix.M[1][2] = texBiasY;
+
+ layer.Textures[eye].TextureRect.width = 1.0f;
+ layer.Textures[eye].TextureRect.height = 1.0f;
+ }
+
+ return layer;
+}
diff --git a/Projects/Android/jni/src/Lambda1VR/VrCompositor.h b/Projects/Android/jni/src/Lambda1VR/VrCompositor.h
new file mode 100644
index 0000000..414ccad
--- /dev/null
+++ b/Projects/Android/jni/src/Lambda1VR/VrCompositor.h
@@ -0,0 +1,223 @@
+/************************************************************************************
+
+Filename : VrCompositor.h
+
+*************************************************************************************/
+#define LOG_TAG "Lambda1VR"
+
+#define ALOGE(...) __android_log_print( ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__ )
+#if DEBUG
+#define ALOGV(...) __android_log_print( ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__ )
+#else
+#define ALOGV(...)
+#endif
+
+#define CHECK_GL_ERRORS
+#ifdef CHECK_GL_ERRORS
+
+static const char * GlErrorString( GLenum error )
+{
+ switch ( error )
+ {
+ case GL_NO_ERROR: return "GL_NO_ERROR";
+ case GL_INVALID_ENUM: return "GL_INVALID_ENUM";
+ case GL_INVALID_VALUE: return "GL_INVALID_VALUE";
+ case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION";
+ case GL_INVALID_FRAMEBUFFER_OPERATION: return "GL_INVALID_FRAMEBUFFER_OPERATION";
+ case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY";
+ default: return "unknown";
+ }
+}
+
+static void GLCheckErrors( int line )
+{
+ for ( int i = 0; i < 10; i++ )
+ {
+ const GLenum error = glGetError();
+ if ( error == GL_NO_ERROR )
+ {
+ break;
+ }
+ ALOGE( "GL error on line %d: %s", line, GlErrorString( error ) );
+ }
+}
+
+#define GL( func ) func; GLCheckErrors( __LINE__ );
+
+#else // CHECK_GL_ERRORS
+
+#define GL( func ) func;
+
+#endif // CHECK_GL_ERRORS
+
+
+/*
+================================================================================
+
+ovrFramebuffer
+
+================================================================================
+*/
+
+typedef struct
+{
+ int Width;
+ int Height;
+ int Multisamples;
+ int TextureSwapChainLength;
+ int TextureSwapChainIndex;
+ ovrTextureSwapChain * ColorTextureSwapChain;
+ GLuint * DepthBuffers;
+ GLuint * FrameBuffers;
+} ovrFramebuffer;
+
+void ovrFramebuffer_SetCurrent( ovrFramebuffer * frameBuffer );
+void ovrFramebuffer_Destroy( ovrFramebuffer * frameBuffer );
+void ovrFramebuffer_SetNone();
+void ovrFramebuffer_Resolve( ovrFramebuffer * frameBuffer );
+void ovrFramebuffer_Advance( ovrFramebuffer * frameBuffer );
+void ovrFramebuffer_ClearEdgeTexels( ovrFramebuffer * frameBuffer );
+
+/*
+================================================================================
+
+ovrRenderer
+
+================================================================================
+*/
+
+typedef struct
+{
+ ovrFramebuffer FrameBuffer[VRAPI_FRAME_LAYER_EYE_MAX];
+ ovrMatrix4f ProjectionMatrix;
+ int NumBuffers;
+} ovrRenderer;
+
+
+void ovrRenderer_Clear( ovrRenderer * renderer );
+void ovrRenderer_Create( ovrRenderer * renderer, const ovrJava * java );
+void ovrRenderer_Destroy( ovrRenderer * renderer );
+
+
+/*
+================================================================================
+
+renderState
+
+================================================================================
+*/
+
+typedef struct
+{
+ GLuint VertexBuffer;
+ GLuint IndexBuffer;
+ GLuint VertexArrayObject;
+ GLuint Program;
+ GLuint VertexShader;
+ GLuint FragmentShader;
+} renderState;
+
+void getCurrentRenderState( renderState * state);
+void restoreRenderState( renderState * state );
+
+/*
+================================================================================
+
+ovrGeometry
+
+================================================================================
+*/
+
+typedef struct
+{
+ GLuint Index;
+ GLint Size;
+ GLenum Type;
+ GLboolean Normalized;
+ GLsizei Stride;
+ const GLvoid * Pointer;
+} ovrVertexAttribPointer;
+
+#define MAX_VERTEX_ATTRIB_POINTERS 3
+
+typedef struct
+{
+ GLuint VertexBuffer;
+ GLuint IndexBuffer;
+ GLuint VertexArrayObject;
+ int VertexCount;
+ int IndexCount;
+ ovrVertexAttribPointer VertexAttribs[MAX_VERTEX_ATTRIB_POINTERS];
+} ovrGeometry;
+
+/*
+================================================================================
+
+ovrProgram
+
+================================================================================
+*/
+
+#define MAX_PROGRAM_UNIFORMS 8
+#define MAX_PROGRAM_TEXTURES 8
+
+typedef struct
+{
+ GLuint Program;
+ GLuint VertexShader;
+ GLuint FragmentShader;
+ // These will be -1 if not used by the program.
+ GLint UniformLocation[MAX_PROGRAM_UNIFORMS]; // ProgramUniforms[].name
+ GLint UniformBinding[MAX_PROGRAM_UNIFORMS]; // ProgramUniforms[].name
+ GLint Textures[MAX_PROGRAM_TEXTURES]; // Texture%i
+} ovrProgram;
+
+/*
+================================================================================
+
+ovrScene
+
+================================================================================
+*/
+
+typedef struct
+{
+ bool CreatedScene;
+ bool CreatedVAOs;
+ ovrProgram Program;
+ ovrGeometry GroundPlane;
+
+ //Proper renderer for stereo rendering to the cylinder layer
+ ovrRenderer CylinderRenderer;
+
+ int CylinderWidth;
+ int CylinderHeight;
+} ovrScene;
+
+bool ovrScene_IsCreated( ovrScene * scene );
+void ovrScene_Clear( ovrScene * scene );
+void ovrScene_Create( int width, int height, ovrScene * scene, const ovrJava * java );
+void ovrScene_CreateVAOs( ovrScene * scene );
+void ovrScene_DestroyVAOs( ovrScene * scene );
+void ovrScene_Destroy( ovrScene * scene );
+
+/*
+================================================================================
+
+ovrRenderer
+
+================================================================================
+*/
+
+ovrLayerProjection2 ovrRenderer_RenderGroundPlaneToEyeBuffer( ovrRenderer * renderer, const ovrJava * java,
+ const ovrScene * scene, const ovrTracking2 * tracking );
+
+ovrLayerProjection2 ovrRenderer_RenderToEyeBuffer( ovrRenderer * renderer, const ovrJava * java,
+ const ovrTracking2 * tracking );
+
+ovrLayerCylinder2 BuildCylinderLayer( ovrRenderer * cylinderRenderer,
+ const int textureWidth, const int textureHeight,
+ const ovrTracking2 * tracking );
+;
+
+
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/Android.mk b/Projects/Android/jni/src/Xash3D/xash3d/engine/Android.mk
index 71f2379..e917069 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/Android.mk
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/Android.mk
@@ -13,6 +13,9 @@ include $(XASH3D_CONFIG)
LOCAL_CFLAGS += -D__MULTITEXTURE_SUPPORT__ -DXASH_GLES -DXASH_GL4ES -DUSE_EVDEV -DXASH_DYNAMIC_DLADDR -DCRASHHANDLER -DXASH_OPENSL -DXASH_SKIPCRTLIB -DXASH_FORCEINLINE -DXASH_FASTSTR
+#enable VR compatibility
+LOCAL_CFLAGS += -DVR
+
XASH_COMMIT := $(firstword $(shell cd $(LOCAL_PATH)&&git rev-parse --short=6 HEAD) unknown)
LOCAL_CFLAGS += -DXASH_BUILD_COMMIT=\"$(XASH_COMMIT)\"
@@ -41,6 +44,7 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
LOCAL_SRC_FILES := \
$(LOCAL_PATH)/../../../Lambda1VR/L1VR_SurfaceView.c \
+ $(LOCAL_PATH)/../../../Lambda1VR/VrCompositor.c \
$(LOCAL_PATH)/../../../Lambda1VR/argtable3.c \
client/cl_cmds.c \
client/cl_demo.c \
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/cdll_exp.h b/Projects/Android/jni/src/Xash3D/xash3d/engine/cdll_exp.h
index 796ca33..2036c2c 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/cdll_exp.h
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/cdll_exp.h
@@ -71,7 +71,12 @@ typedef struct cldll_func_s
// More extenstions for the extensions god! (SDL Xash port)
int (*pfnTouchEvent)( int type, int fingerID, float x, float y, float dx, float dy );
void (*pfnMoveEvent)( float forwardmove, float sidemove );
+
+#ifdef VR
+ void (*pfnLookEvent)( float relyaw, float relpitch, float relroll );
+#else
void (*pfnLookEvent)( float relyaw, float relpitch );
+#endif
} cldll_func_t;
#endif//CDLL_EXP_H
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c
index 89928c5..d793e2d 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_main.c
@@ -1097,7 +1097,12 @@ void CL_ClearState( void )
Cvar_FullSet( "cl_background", "0", CVAR_READ_ONLY );
cl.refdef.movevars = &clgame.movevars;
cl.maxclients = 1; // allow to drawing player in menu
+
+#ifdef VR
+ cl.scr_fov = 110.0f;
+#else
cl.scr_fov = 90.0f;
+#endif
Cvar_SetFloat( "scr_download", 0.0f );
Cvar_SetFloat( "scr_loading", 0.0f );
@@ -2263,13 +2268,19 @@ Host_ClientFrame
==================
*/
+#ifdef VR
int r_stereo_side; // Move this.. this is bad placement
void Host_ClientFrame( int eye )
+#else
+void Host_ClientFrame( )
+#endif
{
// if client is not active, skip render functions
// decide the simulation time
- if (eye == 0) {
+#ifdef VR
+ if (eye == VR_EYE_MONO || eye == VR_EYE_LEFT ) {
+#endif
cl.oldtime = cl.time;
cl.time += host.frametime;
@@ -2305,13 +2316,18 @@ void Host_ClientFrame( int eye )
CL_PredictMovement();
}
}
+#ifdef VR
}
- // update the screen
r_stereo_side = eye;
+#endif
+
+ // update the screen
SCR_UpdateScreen ();
- if (eye == 1)
+#ifdef VR
+ if (eye == VR_EYE_MONO || eye == VR_EYE_RIGHT)
+#endif
{
if( cls.initialized )
{
@@ -2327,7 +2343,9 @@ void Host_ClientFrame( int eye )
Con_RunConsole();
cls.framecount++;
+#ifdef VR
}
+#endif
}
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_view.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_view.c
index 50b90e6..325c2ce 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_view.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/cl_view.c
@@ -415,7 +415,10 @@ void V_PostRender( void )
if( draw_2d )
{
- //Touch_Draw();
+#ifndef VR
+ //No touch controls in VR!
+ Touch_Draw();
+#endif
SCR_RSpeeds();
SCR_NetSpeeds();
SCR_DrawFPS();
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_rmain.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_rmain.c
index be3102e..548d33a 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_rmain.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/gl_rmain.c
@@ -651,53 +651,39 @@ static void R_SetupProjectionMatrix( const ref_params_t *fd, matrix4x4 m )
Matrix4x4_CreateProjection( m, xMax, xMin, yMax, yMin, zNear, zFar );
}
-
-/*
-=============
-R_SetupModelviewMatrix
-=============
-*/
-static float R_GetWorldScale()
-{
- return 100.0f; //Change to use a cvar
-}
-
+#ifdef VR
/*
=============
R_SetupModelviewMatrix
=============
*/
+extern convar_t *r_worldscale;
extern int r_stereo_side;
static void R_SetupModelviewMatrix( const ref_params_t *fd, matrix4x4 m )
{
-#ifndef ORIGINAL
Matrix4x4_CreateModelview( m );
- Matrix4x4_ConcatTranslate( m, 0, R_GetWorldScale() * (0.065f / 2.0f) * ((r_stereo_side - 0.5f) * 2.0f), 0 );
+ Matrix4x4_ConcatTranslate( m, 0, r_worldscale->value * (0.065f / 2.0f) * ((r_stereo_side - 0.5f) * 2.0f), 0 );
Matrix4x4_ConcatRotate( m, -fd->viewangles[ROLL], 1, 0, 0 );
Matrix4x4_ConcatRotate( m, -fd->viewangles[PITCH], 0, 1, 0 );
Matrix4x4_ConcatRotate( m, -fd->viewangles[YAW], 0, 0, 1 );
Matrix4x4_ConcatTranslate( m, -fd->vieworg[0], -fd->vieworg[1], -fd->vieworg[2] );
-#else
- matrix4x4 original;
- Matrix4x4_CreateModelview( original );
- vec3_t vieworg;
- VectorNegate(fd->vieworg, vieworg);
- vec3_t viewangles;
- VectorNegate(fd->viewangles, viewangles);
-
- matrix4x4 translate;
- Matrix4x4_CreateFromEntity(translate, viewangles, vieworg, 1.0f);
-
- /* adjust for stereo display */
- matrix4x4 offsetmatrix;
- Matrix4x4_LoadIdentity(offsetmatrix);
- //Matrix4x4_CreateTranslate(offsetmatrix, 0, (0.065f / 2.0f) * ((r_stereo_side - 0.5f) * 2.0f), 0);
-
- matrix4x4 temp;
- Matrix4x4_Concat(temp, original, translate);
- Matrix4x4_Concat(m, m, offsetmatrix);
-#endif
}
+#else
+static void R_SetupModelviewMatrix( const ref_params_t *fd, matrix4x4 m )
+{
+#if 0
+ Matrix4x4_LoadIdentity( m );
+ Matrix4x4_ConcatRotate( m, -90, 1, 0, 0 );
+ Matrix4x4_ConcatRotate( m, 90, 0, 0, 1 );
+#else
+ Matrix4x4_CreateModelview( m );
+#endif
+ Matrix4x4_ConcatRotate( m, -fd->viewangles[2], 1, 0, 0 );
+ Matrix4x4_ConcatRotate( m, -fd->viewangles[0], 0, 1, 0 );
+ Matrix4x4_ConcatRotate( m, -fd->viewangles[1], 0, 0, 1 );
+ Matrix4x4_ConcatTranslate( m, -fd->vieworg[0], -fd->vieworg[1], -fd->vieworg[2] );
+}
+#endif
/*
=============
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/input.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/input.c
index b883720..181befb 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/input.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/input.c
@@ -839,6 +839,9 @@ void IN_JoyAppendMove( usercmd_t *cmd, float forwardmove, float sidemove )
}
}
+void VR_GetMove( float *forward, float *side, float *yaw, float *pitch, float *roll );
+
+
/*
================
IN_EngineAppendMove
@@ -848,7 +851,11 @@ Called from cl_main.c after generating command in client
*/
void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
{
+#ifdef VR
+ float forward, side, dpitch, dyaw, droll;
+#else
float forward, side, dpitch, dyaw;
+#endif
if( clgame.dllFuncs.pfnLookEvent )
return;
@@ -856,7 +863,11 @@ void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
if( cls.key_dest != key_game || cl.refdef.paused || cl.refdef.intermission )
return;
+#ifdef VR
+ forward = side = dpitch = dyaw = droll = 0;
+#else
forward = side = dpitch = dyaw = 0;
+#endif
if(active)
{
@@ -880,7 +891,13 @@ void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
}
#endif
Joy_FinalizeMove( &forward, &side, &dyaw, &dpitch );
+
+#ifdef VR
+ VR_GetMove( &forward, &side, &dyaw, &dpitch, &droll );
+#else
Touch_GetMove( &forward, &side, &dyaw, &dpitch );
+#endif
+
IN_JoyAppendMove( cmd, forward, side );
#ifdef USE_EVDEV
IN_EvdevMove( &dyaw, &dpitch );
@@ -896,6 +913,9 @@ void IN_EngineAppendMove( float frametime, usercmd_t *cmd, qboolean active )
cl.refdef.cl_viewangles[YAW] += dyaw * sensitivity;
cl.refdef.cl_viewangles[PITCH] += dpitch * sensitivity;
cl.refdef.cl_viewangles[PITCH] = bound( -90, cl.refdef.cl_viewangles[PITCH], 90 );
+#ifdef VR
+ cl.refdef.cl_viewangles[ROLL] += droll;
+#endif
}
}
/*
@@ -908,7 +928,12 @@ Called every frame, even if not generating commands
void Host_InputFrame( void )
{
qboolean shutdownMouse = false;
+
+#ifdef VR
+ float forward = 0, side = 0, pitch = 0, yaw = 0, roll = 0;
+#else
float forward = 0, side = 0, pitch = 0, yaw = 0;
+#endif
#ifdef USE_EVDEV
IN_EvdevFrame();
@@ -935,7 +960,13 @@ void Host_InputFrame( void )
#endif
Joy_FinalizeMove( &forward, &side, &yaw, &pitch );
+
+#ifdef VR
+ VR_GetMove( &forward, &side, &yaw, &pitch, &roll );
+#else
Touch_GetMove( &forward, &side, &yaw, &pitch );
+#endif
+
#ifdef USE_EVDEV
IN_EvdevMove( &yaw, &pitch );
#endif
@@ -949,7 +980,11 @@ void Host_InputFrame( void )
if( cls.key_dest == key_game )
{
+#ifdef VR
+ clgame.dllFuncs.pfnLookEvent( yaw, pitch, roll );
+#else
clgame.dllFuncs.pfnLookEvent( yaw, pitch );
+#endif
clgame.dllFuncs.pfnMoveEvent( forward, side );
}
}
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c
index ec1c1fb..ebc21b1 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/touch.c
@@ -111,6 +111,8 @@ struct touch_s
float side;
float yaw;
float pitch;
+ float x;
+ float y;
// editing
touch_button_t *edit;
@@ -1746,6 +1748,9 @@ static int Touch_ControlsEvent( touchEventType type, int fingerID, float x, floa
int IN_TouchEvent( touchEventType type, int fingerID, float x, float y, float dx, float dy )
{
+ //Store for rendering a simple pointer
+ touch.x = x;
+ touch.y = y;
// simulate menu mouse click
if( cls.key_dest != key_game && !touch_in_menu->integer )
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/vid_common.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/vid_common.c
index 2f63ac6..c35b830 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/client/vid_common.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/client/vid_common.c
@@ -54,6 +54,10 @@ convar_t *gl_msaa;
convar_t *gl_overbright;
convar_t *gl_overbright_studio;
+#ifdef VR
+convar_t *r_worldscale;
+#endif
+
convar_t *r_xpos;
convar_t *r_ypos;
convar_t *r_speeds;
@@ -873,6 +877,10 @@ void GL_InitCommands( void )
r_underwater_distortion = Cvar_Get( "r_underwater_distortion", "0.4", CVAR_ARCHIVE, "underwater distortion speed" );
mp_decals = Cvar_Get( "mp_decals", "300", CVAR_ARCHIVE, "sets the maximum number of decals in multiplayer" );
+#ifdef VR
+ r_worldscale = Cvar_Get( "r_worldscale", "30", CVAR_ARCHIVE, "Sets the world scale for stereo separation" );
+#endif
+
gl_picmip = Cvar_Get( "gl_picmip", "0", CVAR_GLCONFIG, "reduces resolution of textures by powers of 2" );
gl_skymip = Cvar_Get( "gl_skymip", "0", CVAR_GLCONFIG, "reduces resolution of skybox textures by powers of 2" );
gl_allow_software = Cvar_Get( "gl_allow_software", "0", CVAR_ARCHIVE, "allow OpenGL software emulation" );
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/common.h b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/common.h
index a0e8e2e..636ddf4 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/common.h
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/common.h
@@ -179,6 +179,12 @@ typedef enum
#define MIN_FPS 15.0 // host minimum fps value for maxfps.
#define MAX_FPS 500.0 // upper limit for maxfps.
+#ifdef VR
+#define VR_EYE_MONO -1
+#define VR_EYE_LEFT 0
+#define VR_EYE_RIGHT 1
+#endif
+
#define MAX_FRAMETIME 0.1
#define MIN_FRAMETIME 0.000001
@@ -797,7 +803,11 @@ CLIENT / SERVER SYSTEMS
*/
void CL_Init( void );
void CL_Shutdown( void );
+#ifdef VR
void Host_ClientFrame( int eye );
+#else
+void Host_ClientFrame( );
+#endif
void Host_RenderFrame( void );
void Host_ClientBegin( void );
qboolean CL_Active( void );
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/host.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/host.c
index 311f744..816dc70 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/host.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/host.c
@@ -258,6 +258,54 @@ Host_AbortCurrentFrame
aborts the current host frame and goes on with the next one
================
*/
+
+#ifndef VR
+
+void Host_Frame( float time );
+void Host_RunFrame()
+{
+ static double oldtime, newtime;
+
+ if( !oldtime )
+ oldtime = Sys_DoubleTime();
+
+#if XASH_INPUT == INPUT_SDL
+ SDLash_RunEvents();
+#elif XASH_INPUT == INPUT_ANDROID
+ Android_RunEvents();
+#endif
+
+ newtime = Sys_DoubleTime ();
+
+ Host_Frame( newtime - oldtime );
+
+ oldtime = newtime;
+#ifdef __EMSCRIPTEN__
+ #ifdef EMSCRIPTEN_ASYNC
+ emscripten_sleep(1);
+#else
+ if( host.crashed || host.shutdown_issued )
+ emscripten_cancel_main_loop();
+#endif
+#endif
+}
+
+void Host_FrameLoop()
+{
+#if defined __EMSCRIPTEN__ && !defined EMSCRIPTEN_ASYNC
+ emscripten_cancel_main_loop();
+ emscripten_set_main_loop( Host_RunFrame, 0, 0 );
+#else
+ // main window message loop
+ while( !host.crashed && !host.shutdown_issued )
+ {
+ Host_RunFrame();
+ }
+#endif
+}
+
+#endif // !VR
+
void EXPORT Host_AbortCurrentFrame( void )
{
#ifndef NO_SJLJ
@@ -646,10 +694,12 @@ qboolean Host_FilterTime( float time )
host.realtime += time;
+ //Don't limit FPS in VR
+#ifndef VR
// dedicated's tic_rate regulates server frame rate. Don't apply fps filter here.
fps = host_maxfps->value;
- if( false )// fps != 0 )
+ if( fps != 0 )
{
float minframetime;
@@ -665,6 +715,7 @@ qboolean Host_FilterTime( float time )
return false;
}
}
+#endif
host.frametime = host.realtime - oldtime;
host.realframetime = bound( MIN_FRAMETIME, host.frametime, MAX_FRAMETIME );
@@ -724,6 +775,7 @@ void Host_Autosleep( void )
Host_Frame
=================
*/
+#ifdef VR
void Host_Frame( int eye )
{
@@ -732,6 +784,44 @@ void Host_Frame( int eye )
HTTP_Run();
}
+#else
+
+void Host_Frame( float time )
+{
+#ifndef NO_SJLJ
+ if( setjmp( host.abortframe ))
+ return;
+#endif
+
+ Host_Autosleep();
+
+ // decide the simulation time
+ if( !Host_FilterTime( time ))
+ return;
+
+ rand (); // keep the random time dependent
+
+ Sys_SendKeyEvents (); // call WndProc on WIN32
+
+ Host_InputFrame (); // input frame
+
+#ifndef XASH_DEDICATED
+ Host_ClientBegin(); // prepare client command
+#endif
+
+ Host_GetConsoleCommands ();
+
+ Host_ServerFrame (); // server frame
+
+ if ( !Host_IsDedicated() )
+ Host_ClientFrame (); // client frame
+
+ HTTP_Run();
+
+ host.framecount++;
+}
+
+#endif //VR
/*
================
@@ -1162,6 +1252,7 @@ void Host_FreeCommon( void )
Mem_FreePool( &host.mempool );
}
+#ifdef VR
static double oldtime, newtime;
void Host_BeginFrame() {
@@ -1215,6 +1306,8 @@ void Host_EndFrame()
#endif
}
+#endif //VR
+
/*
=================
Host_Main
@@ -1238,7 +1331,7 @@ int EXPORT Host_Main( int argc, const char **argv, const char *progname, int bCh
}
host_cheats = Cvar_Get( "sv_cheats", "0", CVAR_LATCH, "allow usage of cheat commands and variables" );
- host_maxfps = Cvar_Get( "fps_max", "150", CVAR_ARCHIVE, "host fps upper limit" );
+ host_maxfps = Cvar_Get( "fps_max", "72", CVAR_ARCHIVE, "host fps upper limit" );
host_sleeptime = Cvar_Get( "sleeptime", "1", CVAR_ARCHIVE, "higher value means lower accuracy" );
host_framerate = Cvar_Get( "host_framerate", "0", 0, "locks frame timing to this value in seconds" );
host_serverstate = Cvar_Get( "host_serverstate", "0", CVAR_INIT, "displays current server state" );
@@ -1374,6 +1467,11 @@ int EXPORT Host_Main( int argc, const char **argv, const char *progname, int bCh
if( host.state == HOST_INIT )
host.state = HOST_FRAME; // initialization is finished
+#ifndef VR
+ Host_FrameLoop();
+
+ // never reached
+#endif
return 0;
}
diff --git a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/library.c b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/library.c
index b72e068..d686292 100644
--- a/Projects/Android/jni/src/Xash3D/xash3d/engine/common/library.c
+++ b/Projects/Android/jni/src/Xash3D/xash3d/engine/common/library.c
@@ -338,6 +338,8 @@ void *Com_FunctionFromName( void *hInstance, const char *pName )
{
#ifdef __ANDROID__
// Shitty Android's dlsym don't resolve weak symbols
+
+ //Had to remove as support for the methods in dlsym_weak has been removed in the required SDK version
//if( !( function = dlsym_weak( hInstance, pName ) ) )
#endif
{
diff --git a/Projects/Android/jni/src/gl4es/Android.mk b/Projects/Android/jni/src/gl4es/Android.mk
index a0665be..5433bae 100644
--- a/Projects/Android/jni/src/gl4es/Android.mk
+++ b/Projects/Android/jni/src/gl4es/Android.mk
@@ -78,7 +78,9 @@ LOCAL_CFLAGS += -g -std=c99 -funwind-tables -O3 -DBCMHOST -fvisibility=hidden -i
LOCAL_CFLAGS += -DNOX11
LOCAL_CFLAGS += -DNO_GBM
LOCAL_CFLAGS += -DDEFAULT_ES=2
+LOCAL_CFLAGS += -DNO_INIT_CONSTRUCTOR
-LOCAL_LDLIBS := -ldl -llog
+
+LOCAL_LDLIBS := -ldl -llog -lEGL -lGLESv3
include $(BUILD_SHARED_LIBRARY)
diff --git a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.cpp b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.cpp
index 3233d79..3e1633a 100644
--- a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.cpp
+++ b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.cpp
@@ -21,11 +21,22 @@ extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove
currentInput->IN_ClientMoveEvent(forwardmove, sidemove);
}
+#ifdef VR
+
+extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch, float relroll )
+{
+ currentInput->IN_ClientLookEvent(relyaw, relpitch, relroll);
+}
+
+#else
+
extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch )
{
- currentInput->IN_ClientLookEvent(relyaw, relpitch);
+ currentInput->IN_ClientLookEvent(relyaw, relpitch );
}
+#endif
+
void IN_Move( float frametime, usercmd_t *cmd )
{
currentInput->IN_Move(frametime, cmd);
diff --git a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.h b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.h
index c13b7fa..696f069 100644
--- a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.h
+++ b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_mouse.h
@@ -9,7 +9,11 @@ class AbstractInput
{
public:
virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) = 0;
+#ifdef VR
+ virtual void IN_ClientLookEvent( float relyaw, float relpitch, float relroll ) = 0;
+#else
virtual void IN_ClientLookEvent( float relyaw, float relpitch ) = 0;
+#endif
virtual void IN_Move( float frametime, usercmd_t *cmd ) = 0;
virtual void IN_MouseEvent( int mstate ) = 0;
virtual void IN_ClearStates( void ) = 0;
@@ -25,7 +29,12 @@ class FWGSInput : public AbstractInput
{
public:
virtual void IN_ClientMoveEvent( float forwardmove, float sidemove );
+
+#ifdef VR
+ virtual void IN_ClientLookEvent( float relyaw, float relpitch, float relroll );
+#else
virtual void IN_ClientLookEvent( float relyaw, float relpitch );
+#endif
virtual void IN_Move( float frametime, usercmd_t *cmd );
virtual void IN_MouseEvent( int mstate );
virtual void IN_ClearStates( void );
@@ -40,8 +49,10 @@ protected:
float ac_forwardmove;
float ac_sidemove;
int ac_movecount;
+ float old_yaw;
float rel_yaw;
float rel_pitch;
+ float rel_roll;
};
// No need for goldsource input support on the platforms that are not supported by GoldSource.
@@ -51,7 +62,11 @@ class GoldSourceInput : public AbstractInput
{
public:
virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) {}
+#ifdef VR
+ virtual void IN_ClientLookEvent( float relyaw, float relpitch, float relroll ) {}
+#else
virtual void IN_ClientLookEvent( float relyaw, float relpitch ) {}
+#endif
virtual void IN_Move( float frametime, usercmd_t *cmd );
virtual void IN_MouseEvent( int mstate );
virtual void IN_ClearStates( void );
diff --git a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_xash3d.cpp b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_xash3d.cpp
index 2ff572e..9d9a924 100644
--- a/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_xash3d.cpp
+++ b/Projects/Android/jni/src/hlsdk-xash3d/cl_dll/input_xash3d.cpp
@@ -133,10 +133,20 @@ void FWGSInput::IN_ClientMoveEvent( float forwardmove, float sidemove )
ac_movecount++;
}
+#ifdef VR
+void FWGSInput::IN_ClientLookEvent( float relyaw, float relpitch, float relroll )
+#else
void FWGSInput::IN_ClientLookEvent( float relyaw, float relpitch )
+#endif
{
+#ifdef VR
+ rel_yaw = relyaw;
+ rel_pitch = relpitch;
+ rel_roll = relroll;
+#else
rel_yaw += relyaw;
rel_pitch += relpitch;
+#endif
}
// Rotate camera and add move values to usercmd
@@ -170,6 +180,8 @@ void FWGSInput::IN_Move( float frametime, usercmd_t *cmd )
{
gEngfuncs.GetViewAngles( viewangles );
}
+
+#ifndef VR
if( gHUD.GetSensitivity() != 0 )
{
rel_yaw *= gHUD.GetSensitivity();
@@ -180,17 +192,30 @@ void FWGSInput::IN_Move( float frametime, usercmd_t *cmd )
rel_yaw *= sensitivity->value;
rel_pitch *= sensitivity->value;
}
+#endif
+
+ viewangles[YAW] -= old_yaw;
viewangles[YAW] += rel_yaw;
+
+#ifndef VR
if( fLadder )
{
if( cl_laddermode->value == 1 )
viewangles[YAW] -= ac_sidemove * 5;
ac_sidemove = 0;
}
+#endif
+
if( gHUD.m_MOTD.m_bShow )
gHUD.m_MOTD.scroll += rel_pitch;
else
+#ifndef VR
viewangles[PITCH] += rel_pitch;
+#else
+ viewangles[PITCH] = rel_pitch;
+
+ viewangles[ROLL] = rel_roll;
+#endif //!VR
if( viewangles[PITCH] > cl_pitchdown->value )
viewangles[PITCH] = cl_pitchdown->value;
@@ -199,7 +224,10 @@ void FWGSInput::IN_Move( float frametime, usercmd_t *cmd )
// HACKHACK: change viewangles directly in viewcode,
// so viewangles when player is dead will not be changed on server
+
+#ifndef VR
if( !CL_IsDead() )
+#endif
{
gEngfuncs.SetViewAngles( viewangles );
}
@@ -220,7 +248,13 @@ void FWGSInput::IN_Move( float frametime, usercmd_t *cmd )
}
}
+#ifndef VR
ac_sidemove = ac_forwardmove = rel_pitch = rel_yaw = 0;
+#else
+ old_yaw = rel_yaw;
+ ac_sidemove = ac_forwardmove = rel_pitch = rel_roll = 0;
+#endif
+
ac_movecount = 0;
}
@@ -281,5 +315,5 @@ void FWGSInput::IN_Init( void )
sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE );
in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE );
cl_laddermode = gEngfuncs.pfnRegisterVariable( "cl_laddermode", "2", FCVAR_ARCHIVE );
- ac_forwardmove = ac_sidemove = rel_yaw = rel_pitch = 0;
+ ac_forwardmove = ac_sidemove = rel_yaw = rel_pitch = old_yaw = 0;
}
diff --git a/xash-extras/credits.txt b/assets/credits.txt
similarity index 100%
rename from xash-extras/credits.txt
rename to assets/credits.txt
diff --git a/xash-extras/creditsfont_cp1251.fnt b/assets/creditsfont_cp1251.fnt
similarity index 100%
rename from xash-extras/creditsfont_cp1251.fnt
rename to assets/creditsfont_cp1251.fnt
diff --git a/xash-extras/fastdl.txt b/assets/fastdl.txt
similarity index 100%
rename from xash-extras/fastdl.txt
rename to assets/fastdl.txt
diff --git a/xash-extras/font0_cp1251.fnt b/assets/font0_cp1251.fnt
similarity index 100%
rename from xash-extras/font0_cp1251.fnt
rename to assets/font0_cp1251.fnt
diff --git a/xash-extras/font0_cp1252.fnt b/assets/font0_cp1252.fnt
similarity index 100%
rename from xash-extras/font0_cp1252.fnt
rename to assets/font0_cp1252.fnt
diff --git a/xash-extras/font1_cp1251.fnt b/assets/font1_cp1251.fnt
similarity index 100%
rename from xash-extras/font1_cp1251.fnt
rename to assets/font1_cp1251.fnt
diff --git a/xash-extras/font1_cp1252.fnt b/assets/font1_cp1252.fnt
similarity index 100%
rename from xash-extras/font1_cp1252.fnt
rename to assets/font1_cp1252.fnt
diff --git a/xash-extras/font2_cp1251.fnt b/assets/font2_cp1251.fnt
similarity index 100%
rename from xash-extras/font2_cp1251.fnt
rename to assets/font2_cp1251.fnt
diff --git a/xash-extras/font2_cp1252.fnt b/assets/font2_cp1252.fnt
similarity index 100%
rename from xash-extras/font2_cp1252.fnt
rename to assets/font2_cp1252.fnt
diff --git a/xash-extras/gfx/shell/btn_gamepad.tga b/assets/gfx/shell/btn_gamepad.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_gamepad.tga
rename to assets/gfx/shell/btn_gamepad.tga
diff --git a/xash-extras/gfx/shell/btn_touch.tga b/assets/gfx/shell/btn_touch.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_touch.tga
rename to assets/gfx/shell/btn_touch.tga
diff --git a/xash-extras/gfx/shell/btn_touch_buttons.tga b/assets/gfx/shell/btn_touch_buttons.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_touch_buttons.tga
rename to assets/gfx/shell/btn_touch_buttons.tga
diff --git a/xash-extras/gfx/shell/btn_touch_editor.tga b/assets/gfx/shell/btn_touch_editor.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_touch_editor.tga
rename to assets/gfx/shell/btn_touch_editor.tga
diff --git a/xash-extras/gfx/shell/btn_touch_options.tga b/assets/gfx/shell/btn_touch_options.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_touch_options.tga
rename to assets/gfx/shell/btn_touch_options.tga
diff --git a/xash-extras/gfx/shell/btn_touch_reset.tga b/assets/gfx/shell/btn_touch_reset.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_touch_reset.tga
rename to assets/gfx/shell/btn_touch_reset.tga
diff --git a/xash-extras/gfx/shell/btn_touch_save.tga b/assets/gfx/shell/btn_touch_save.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_touch_save.tga
rename to assets/gfx/shell/btn_touch_save.tga
diff --git a/xash-extras/gfx/shell/btn_touch_select.tga b/assets/gfx/shell/btn_touch_select.tga
similarity index 100%
rename from xash-extras/gfx/shell/btn_touch_select.tga
rename to assets/gfx/shell/btn_touch_select.tga
diff --git a/xash-extras/gfx/shell/btns_main.bmp b/assets/gfx/shell/btns_main.bmp
similarity index 100%
rename from xash-extras/gfx/shell/btns_main.bmp
rename to assets/gfx/shell/btns_main.bmp
diff --git a/xash-extras/gfx/shell/cb_checked.tga b/assets/gfx/shell/cb_checked.tga
similarity index 100%
rename from xash-extras/gfx/shell/cb_checked.tga
rename to assets/gfx/shell/cb_checked.tga
diff --git a/xash-extras/gfx/shell/cb_disabled.tga b/assets/gfx/shell/cb_disabled.tga
similarity index 100%
rename from xash-extras/gfx/shell/cb_disabled.tga
rename to assets/gfx/shell/cb_disabled.tga
diff --git a/xash-extras/gfx/shell/cb_down.tga b/assets/gfx/shell/cb_down.tga
similarity index 100%
rename from xash-extras/gfx/shell/cb_down.tga
rename to assets/gfx/shell/cb_down.tga
diff --git a/xash-extras/gfx/shell/cb_empty.tga b/assets/gfx/shell/cb_empty.tga
similarity index 100%
rename from xash-extras/gfx/shell/cb_empty.tga
rename to assets/gfx/shell/cb_empty.tga
diff --git a/xash-extras/gfx/shell/cb_over.tga b/assets/gfx/shell/cb_over.tga
similarity index 100%
rename from xash-extras/gfx/shell/cb_over.tga
rename to assets/gfx/shell/cb_over.tga
diff --git a/xash-extras/gfx/shell/cls_d.tga b/assets/gfx/shell/cls_d.tga
similarity index 100%
rename from xash-extras/gfx/shell/cls_d.tga
rename to assets/gfx/shell/cls_d.tga
diff --git a/xash-extras/gfx/shell/cls_f.tga b/assets/gfx/shell/cls_f.tga
similarity index 100%
rename from xash-extras/gfx/shell/cls_f.tga
rename to assets/gfx/shell/cls_f.tga
diff --git a/xash-extras/gfx/shell/cls_n.tga b/assets/gfx/shell/cls_n.tga
similarity index 100%
rename from xash-extras/gfx/shell/cls_n.tga
rename to assets/gfx/shell/cls_n.tga
diff --git a/xash-extras/gfx/shell/colors.lst b/assets/gfx/shell/colors.lst
similarity index 100%
rename from xash-extras/gfx/shell/colors.lst
rename to assets/gfx/shell/colors.lst
diff --git a/xash-extras/gfx/shell/divider.tga b/assets/gfx/shell/divider.tga
similarity index 100%
rename from xash-extras/gfx/shell/divider.tga
rename to assets/gfx/shell/divider.tga
diff --git a/xash-extras/gfx/shell/dnarrowd.tga b/assets/gfx/shell/dnarrowd.tga
similarity index 100%
rename from xash-extras/gfx/shell/dnarrowd.tga
rename to assets/gfx/shell/dnarrowd.tga
diff --git a/xash-extras/gfx/shell/dnarrowf.tga b/assets/gfx/shell/dnarrowf.tga
similarity index 100%
rename from xash-extras/gfx/shell/dnarrowf.tga
rename to assets/gfx/shell/dnarrowf.tga
diff --git a/xash-extras/gfx/shell/dnarrowp.tga b/assets/gfx/shell/dnarrowp.tga
similarity index 100%
rename from xash-extras/gfx/shell/dnarrowp.tga
rename to assets/gfx/shell/dnarrowp.tga
diff --git a/xash-extras/gfx/shell/down.tga b/assets/gfx/shell/down.tga
similarity index 100%
rename from xash-extras/gfx/shell/down.tga
rename to assets/gfx/shell/down.tga
diff --git a/xash-extras/gfx/shell/favorite.tga b/assets/gfx/shell/favorite.tga
similarity index 100%
rename from xash-extras/gfx/shell/favorite.tga
rename to assets/gfx/shell/favorite.tga
diff --git a/xash-extras/gfx/shell/font.tga b/assets/gfx/shell/font.tga
similarity index 100%
rename from xash-extras/gfx/shell/font.tga
rename to assets/gfx/shell/font.tga
diff --git a/xash-extras/gfx/shell/gamma.tga b/assets/gfx/shell/gamma.tga
similarity index 100%
rename from xash-extras/gfx/shell/gamma.tga
rename to assets/gfx/shell/gamma.tga
diff --git a/xash-extras/gfx/shell/head_advanced.tga b/assets/gfx/shell/head_advanced.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_advanced.tga
rename to assets/gfx/shell/head_advanced.tga
diff --git a/xash-extras/gfx/shell/head_advoptions.tga b/assets/gfx/shell/head_advoptions.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_advoptions.tga
rename to assets/gfx/shell/head_advoptions.tga
diff --git a/xash-extras/gfx/shell/head_audio.tga b/assets/gfx/shell/head_audio.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_audio.tga
rename to assets/gfx/shell/head_audio.tga
diff --git a/xash-extras/gfx/shell/head_config.tga b/assets/gfx/shell/head_config.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_config.tga
rename to assets/gfx/shell/head_config.tga
diff --git a/xash-extras/gfx/shell/head_controls.tga b/assets/gfx/shell/head_controls.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_controls.tga
rename to assets/gfx/shell/head_controls.tga
diff --git a/xash-extras/gfx/shell/head_creategame.tga b/assets/gfx/shell/head_creategame.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_creategame.tga
rename to assets/gfx/shell/head_creategame.tga
diff --git a/xash-extras/gfx/shell/head_createroom.tga b/assets/gfx/shell/head_createroom.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_createroom.tga
rename to assets/gfx/shell/head_createroom.tga
diff --git a/xash-extras/gfx/shell/head_custom.tga b/assets/gfx/shell/head_custom.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_custom.tga
rename to assets/gfx/shell/head_custom.tga
diff --git a/xash-extras/gfx/shell/head_customize.tga b/assets/gfx/shell/head_customize.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_customize.tga
rename to assets/gfx/shell/head_customize.tga
diff --git a/xash-extras/gfx/shell/head_filter.tga b/assets/gfx/shell/head_filter.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_filter.tga
rename to assets/gfx/shell/head_filter.tga
diff --git a/xash-extras/gfx/shell/head_gameopts.tga b/assets/gfx/shell/head_gameopts.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_gameopts.tga
rename to assets/gfx/shell/head_gameopts.tga
diff --git a/xash-extras/gfx/shell/head_gamepad.tga b/assets/gfx/shell/head_gamepad.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_gamepad.tga
rename to assets/gfx/shell/head_gamepad.tga
diff --git a/xash-extras/gfx/shell/head_gore.tga b/assets/gfx/shell/head_gore.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_gore.tga
rename to assets/gfx/shell/head_gore.tga
diff --git a/xash-extras/gfx/shell/head_inetgames.tga b/assets/gfx/shell/head_inetgames.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_inetgames.tga
rename to assets/gfx/shell/head_inetgames.tga
diff --git a/xash-extras/gfx/shell/head_keyboard.tga b/assets/gfx/shell/head_keyboard.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_keyboard.tga
rename to assets/gfx/shell/head_keyboard.tga
diff --git a/xash-extras/gfx/shell/head_lan.tga b/assets/gfx/shell/head_lan.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_lan.tga
rename to assets/gfx/shell/head_lan.tga
diff --git a/xash-extras/gfx/shell/head_load.tga b/assets/gfx/shell/head_load.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_load.tga
rename to assets/gfx/shell/head_load.tga
diff --git a/xash-extras/gfx/shell/head_multi.tga b/assets/gfx/shell/head_multi.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_multi.tga
rename to assets/gfx/shell/head_multi.tga
diff --git a/xash-extras/gfx/shell/head_newgame.tga b/assets/gfx/shell/head_newgame.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_newgame.tga
rename to assets/gfx/shell/head_newgame.tga
diff --git a/xash-extras/gfx/shell/head_play.tga b/assets/gfx/shell/head_play.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_play.tga
rename to assets/gfx/shell/head_play.tga
diff --git a/xash-extras/gfx/shell/head_playrec.tga b/assets/gfx/shell/head_playrec.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_playrec.tga
rename to assets/gfx/shell/head_playrec.tga
diff --git a/xash-extras/gfx/shell/head_readme.tga b/assets/gfx/shell/head_readme.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_readme.tga
rename to assets/gfx/shell/head_readme.tga
diff --git a/xash-extras/gfx/shell/head_record.tga b/assets/gfx/shell/head_record.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_record.tga
rename to assets/gfx/shell/head_record.tga
diff --git a/xash-extras/gfx/shell/head_room.tga b/assets/gfx/shell/head_room.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_room.tga
rename to assets/gfx/shell/head_room.tga
diff --git a/xash-extras/gfx/shell/head_rooms.tga b/assets/gfx/shell/head_rooms.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_rooms.tga
rename to assets/gfx/shell/head_rooms.tga
diff --git a/xash-extras/gfx/shell/head_save.tga b/assets/gfx/shell/head_save.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_save.tga
rename to assets/gfx/shell/head_save.tga
diff --git a/xash-extras/gfx/shell/head_saveload.tga b/assets/gfx/shell/head_saveload.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_saveload.tga
rename to assets/gfx/shell/head_saveload.tga
diff --git a/xash-extras/gfx/shell/head_single.tga b/assets/gfx/shell/head_single.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_single.tga
rename to assets/gfx/shell/head_single.tga
diff --git a/xash-extras/gfx/shell/head_specgames.tga b/assets/gfx/shell/head_specgames.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_specgames.tga
rename to assets/gfx/shell/head_specgames.tga
diff --git a/xash-extras/gfx/shell/head_touch.tga b/assets/gfx/shell/head_touch.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_touch.tga
rename to assets/gfx/shell/head_touch.tga
diff --git a/xash-extras/gfx/shell/head_touch_buttons.tga b/assets/gfx/shell/head_touch_buttons.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_touch_buttons.tga
rename to assets/gfx/shell/head_touch_buttons.tga
diff --git a/xash-extras/gfx/shell/head_touch_options.tga b/assets/gfx/shell/head_touch_options.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_touch_options.tga
rename to assets/gfx/shell/head_touch_options.tga
diff --git a/xash-extras/gfx/shell/head_video.tga b/assets/gfx/shell/head_video.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_video.tga
rename to assets/gfx/shell/head_video.tga
diff --git a/xash-extras/gfx/shell/head_vidmodes.tga b/assets/gfx/shell/head_vidmodes.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_vidmodes.tga
rename to assets/gfx/shell/head_vidmodes.tga
diff --git a/xash-extras/gfx/shell/head_vidoptions.tga b/assets/gfx/shell/head_vidoptions.tga
similarity index 100%
rename from xash-extras/gfx/shell/head_vidoptions.tga
rename to assets/gfx/shell/head_vidoptions.tga
diff --git a/xash-extras/gfx/shell/kb_act.lst b/assets/gfx/shell/kb_act.lst
similarity index 100%
rename from xash-extras/gfx/shell/kb_act.lst
rename to assets/gfx/shell/kb_act.lst
diff --git a/xash-extras/gfx/shell/kb_def.lst b/assets/gfx/shell/kb_def.lst
similarity index 100%
rename from xash-extras/gfx/shell/kb_def.lst
rename to assets/gfx/shell/kb_def.lst
diff --git a/xash-extras/gfx/shell/kb_keys.lst b/assets/gfx/shell/kb_keys.lst
similarity index 100%
rename from xash-extras/gfx/shell/kb_keys.lst
rename to assets/gfx/shell/kb_keys.lst
diff --git a/xash-extras/gfx/shell/larrowdefault.tga b/assets/gfx/shell/larrowdefault.tga
similarity index 100%
rename from xash-extras/gfx/shell/larrowdefault.tga
rename to assets/gfx/shell/larrowdefault.tga
diff --git a/xash-extras/gfx/shell/larrowflyover.tga b/assets/gfx/shell/larrowflyover.tga
similarity index 100%
rename from xash-extras/gfx/shell/larrowflyover.tga
rename to assets/gfx/shell/larrowflyover.tga
diff --git a/xash-extras/gfx/shell/larrowpressed.tga b/assets/gfx/shell/larrowpressed.tga
similarity index 100%
rename from xash-extras/gfx/shell/larrowpressed.tga
rename to assets/gfx/shell/larrowpressed.tga
diff --git a/xash-extras/gfx/shell/listen.tga b/assets/gfx/shell/listen.tga
similarity index 100%
rename from xash-extras/gfx/shell/listen.tga
rename to assets/gfx/shell/listen.tga
diff --git a/xash-extras/gfx/shell/lock.tga b/assets/gfx/shell/lock.tga
similarity index 100%
rename from xash-extras/gfx/shell/lock.tga
rename to assets/gfx/shell/lock.tga
diff --git a/xash-extras/gfx/shell/min_d.tga b/assets/gfx/shell/min_d.tga
similarity index 100%
rename from xash-extras/gfx/shell/min_d.tga
rename to assets/gfx/shell/min_d.tga
diff --git a/xash-extras/gfx/shell/min_f.tga b/assets/gfx/shell/min_f.tga
similarity index 100%
rename from xash-extras/gfx/shell/min_f.tga
rename to assets/gfx/shell/min_f.tga
diff --git a/xash-extras/gfx/shell/min_n.tga b/assets/gfx/shell/min_n.tga
similarity index 100%
rename from xash-extras/gfx/shell/min_n.tga
rename to assets/gfx/shell/min_n.tga
diff --git a/xash-extras/gfx/shell/nonfav.tga b/assets/gfx/shell/nonfav.tga
similarity index 100%
rename from xash-extras/gfx/shell/nonfav.tga
rename to assets/gfx/shell/nonfav.tga
diff --git a/xash-extras/gfx/shell/notsecure.tga b/assets/gfx/shell/notsecure.tga
similarity index 100%
rename from xash-extras/gfx/shell/notsecure.tga
rename to assets/gfx/shell/notsecure.tga
diff --git a/xash-extras/gfx/shell/rarrowdefault.tga b/assets/gfx/shell/rarrowdefault.tga
similarity index 100%
rename from xash-extras/gfx/shell/rarrowdefault.tga
rename to assets/gfx/shell/rarrowdefault.tga
diff --git a/xash-extras/gfx/shell/rarrowflyover.tga b/assets/gfx/shell/rarrowflyover.tga
similarity index 100%
rename from xash-extras/gfx/shell/rarrowflyover.tga
rename to assets/gfx/shell/rarrowflyover.tga
diff --git a/xash-extras/gfx/shell/rarrowpressed.tga b/assets/gfx/shell/rarrowpressed.tga
similarity index 100%
rename from xash-extras/gfx/shell/rarrowpressed.tga
rename to assets/gfx/shell/rarrowpressed.tga
diff --git a/xash-extras/gfx/shell/scrn.tga b/assets/gfx/shell/scrn.tga
similarity index 100%
rename from xash-extras/gfx/shell/scrn.tga
rename to assets/gfx/shell/scrn.tga
diff --git a/xash-extras/gfx/shell/secure.tga b/assets/gfx/shell/secure.tga
similarity index 100%
rename from xash-extras/gfx/shell/secure.tga
rename to assets/gfx/shell/secure.tga
diff --git a/xash-extras/gfx/shell/slider.tga b/assets/gfx/shell/slider.tga
similarity index 100%
rename from xash-extras/gfx/shell/slider.tga
rename to assets/gfx/shell/slider.tga
diff --git a/xash-extras/gfx/shell/sm_dnarf.tga b/assets/gfx/shell/sm_dnarf.tga
similarity index 100%
rename from xash-extras/gfx/shell/sm_dnarf.tga
rename to assets/gfx/shell/sm_dnarf.tga
diff --git a/xash-extras/gfx/shell/sm_dnarw.tga b/assets/gfx/shell/sm_dnarw.tga
similarity index 100%
rename from xash-extras/gfx/shell/sm_dnarw.tga
rename to assets/gfx/shell/sm_dnarw.tga
diff --git a/xash-extras/gfx/shell/splash.bmp b/assets/gfx/shell/splash.bmp
similarity index 100%
rename from xash-extras/gfx/shell/splash.bmp
rename to assets/gfx/shell/splash.bmp
diff --git a/xash-extras/gfx/shell/unlock.tga b/assets/gfx/shell/unlock.tga
similarity index 100%
rename from xash-extras/gfx/shell/unlock.tga
rename to assets/gfx/shell/unlock.tga
diff --git a/xash-extras/gfx/shell/up.tga b/assets/gfx/shell/up.tga
similarity index 100%
rename from xash-extras/gfx/shell/up.tga
rename to assets/gfx/shell/up.tga
diff --git a/xash-extras/gfx/shell/uparrowd.tga b/assets/gfx/shell/uparrowd.tga
similarity index 100%
rename from xash-extras/gfx/shell/uparrowd.tga
rename to assets/gfx/shell/uparrowd.tga
diff --git a/xash-extras/gfx/shell/uparrowf.tga b/assets/gfx/shell/uparrowf.tga
similarity index 100%
rename from xash-extras/gfx/shell/uparrowf.tga
rename to assets/gfx/shell/uparrowf.tga
diff --git a/xash-extras/gfx/shell/uparrowp.tga b/assets/gfx/shell/uparrowp.tga
similarity index 100%
rename from xash-extras/gfx/shell/uparrowp.tga
rename to assets/gfx/shell/uparrowp.tga
diff --git a/xash-extras/media/launch_deny1.wav b/assets/media/launch_deny1.wav
similarity index 100%
rename from xash-extras/media/launch_deny1.wav
rename to assets/media/launch_deny1.wav
diff --git a/xash-extras/media/launch_deny2.wav b/assets/media/launch_deny2.wav
similarity index 100%
rename from xash-extras/media/launch_deny2.wav
rename to assets/media/launch_deny2.wav
diff --git a/xash-extras/media/launch_dnmenu1.wav b/assets/media/launch_dnmenu1.wav
similarity index 100%
rename from xash-extras/media/launch_dnmenu1.wav
rename to assets/media/launch_dnmenu1.wav
diff --git a/xash-extras/media/launch_glow1.wav b/assets/media/launch_glow1.wav
similarity index 100%
rename from xash-extras/media/launch_glow1.wav
rename to assets/media/launch_glow1.wav
diff --git a/xash-extras/media/launch_select1.wav b/assets/media/launch_select1.wav
similarity index 100%
rename from xash-extras/media/launch_select1.wav
rename to assets/media/launch_select1.wav
diff --git a/xash-extras/media/launch_select2.wav b/assets/media/launch_select2.wav
similarity index 100%
rename from xash-extras/media/launch_select2.wav
rename to assets/media/launch_select2.wav
diff --git a/xash-extras/media/launch_upmenu1.wav b/assets/media/launch_upmenu1.wav
similarity index 100%
rename from xash-extras/media/launch_upmenu1.wav
rename to assets/media/launch_upmenu1.wav
diff --git a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java
index 9f04104..d984c19 100644
--- a/java/com/drbeef/lambda1vr/GLES3JNIActivity.java
+++ b/java/com/drbeef/lambda1vr/GLES3JNIActivity.java
@@ -40,8 +40,6 @@ import static android.system.Os.setenv;
private SurfaceView mView;
private SurfaceHolder mSurfaceHolder;
private long mNativeHandle;
-
- private final boolean m_asynchronousTracking = false;
@Override protected void onCreate( Bundle icicle )
{