VR API removed

This commit is contained in:
Lubos 2022-03-29 12:56:37 +02:00
parent 56d1334007
commit 96bf69cb15
14 changed files with 83 additions and 58 deletions

2
.gitignore vendored
View file

@ -1,4 +1,6 @@
build
android/app/src/main/cpp/code/OpenXR-SDK
android/app/src/main/cpp/code/OpenXR
android/app/src/main/cpp/code/VrApi
*.swp
*tags

View file

@ -282,7 +282,8 @@ LOKISETUPDIR=misc/setup
NSISDIR=misc/nsis
SDLHDIR=$(MOUNT_DIR)/SDL2
LIBSDIR=$(MOUNT_DIR)/libs
VRAPIDIR=$(MOUNT_DIR)/VrApi
OPENXRDIR=$(MOUNT_DIR)/OpenXR
OPENXRSDKDIR=$(MOUNT_DIR)/OpenXR-SDK
bin_path=$(shell which $(1) 2> /dev/null)
@ -466,11 +467,11 @@ ifeq ($(PLATFORM),android)
RENDERER_LIBS += $(LIBSDIR)/android/arm64-v8a/libSDL2.so
CLIENT_EXTRA_FILES += $(LIBSDIR)/android/arm64-v8a/libSDL2.so
# VrApi
BASE_CFLAGS += -I$(VRAPIDIR)/Include
CLIENT_LIBS += $(VRAPIDIR)/Libs/Android/arm64-v8a/Release/libvrapi.so
RENDERER_LIBS += $(VRAPIDIR)/Libs/Android/arm64-v8a/Release/libvrapi.so
CLIENT_EXTRA_FILES += $(VRAPIDIR)/Libs/Android/arm64-v8a/Release/libvrapi.so
# OpenXR
BASE_CFLAGS += -I$(OPENXRDIR)/Include -I$(OPENXRSDKDIR)/Include
CLIENT_LIBS += $(OPENXRDIR)/Libs/Android/arm64-v8a/Release/libopenxr_loader.so
RENDERER_LIBS += $(OPENXRDIR)/Libs/Android/arm64-v8a/Release/libopenxr_loader.so
CLIENT_EXTRA_FILES += $(OPENXRDIR)/Libs/Android/arm64-v8a/Release/libopenxr_loader.so
else # ifeq Android
#############################################################################

View file

@ -5,7 +5,9 @@
### Prerequisites
1. Install your copy of Quake III Arena from Steam.
2. Android Studio with NDK version 21.1.6352462.
3. Copy the Oculus VR SDK from https://developer.oculus.com/downloads/package/oculus-mobile-sdk/ and extract the VrApi folder to ./android/app/src/main/cpp/code/VrApi/
3. Download the Oculus VR SDK from https://developer.oculus.com/downloads/package/oculus-mobile-sdk/
4. Extract the OpenXR folder to ./android/app/src/main/cpp/code/OpenXR/
5. Extract the 3rdParty/khronos/openxr/OpenXR-SDK folder to ./android/app/src/main/cpp/code/OpenXR-SDK/
### Building and running the build
The scripts assume that you installed everything in the default locations. In case you want to deviate from that, the paths are in ./android/run.(sh|bat) and in Makefile.local.

View file

@ -15,7 +15,7 @@ endif()
add_custom_target(copy_libs
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../../../../build/${BUILD_FOLDER}/libioquake3_opengl2.so ${CMAKE_SOURCE_DIR}/../jniLibs/arm64-v8a/libioquake3_opengl2.so
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../../../../build/${BUILD_FOLDER}/libSDL2.so ${CMAKE_SOURCE_DIR}/../jniLibs/arm64-v8a/libSDL2.so
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../../../../build/${BUILD_FOLDER}/libvrapi.so ${CMAKE_SOURCE_DIR}/../jniLibs/arm64-v8a/libvrapi.so
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../../../../build/${BUILD_FOLDER}/libopenxr_loader.so ${CMAKE_SOURCE_DIR}/../jniLibs/arm64-v8a/libopenxr_loader.so
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../../../../build/${BUILD_FOLDER}/baseq3/cgameaarch64.so ${CMAKE_SOURCE_DIR}/../jniLibs/arm64-v8a/libcgameaarch64_baseq3.so
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../../../../build/${BUILD_FOLDER}/baseq3/qagameaarch64.so ${CMAKE_SOURCE_DIR}/../jniLibs/arm64-v8a/libqagameaarch64_baseq3.so
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../../../../../build/${BUILD_FOLDER}/baseq3/uiaarch64.so ${CMAKE_SOURCE_DIR}/../jniLibs/arm64-v8a/libuiaarch64_baseq3.so
@ -27,7 +27,7 @@ add_custom_target(copy_libs
add_dependencies(main copy_libs)
target_include_directories(main PRIVATE
${CMAKE_SOURCE_DIR}/code/VrApi/Include
${CMAKE_SOURCE_DIR}/code/OpenXR/Include
${CMAKE_SOURCE_DIR}/code/SDL2/include
${CMAKE_SOURCE_DIR}/code)
@ -40,5 +40,5 @@ target_link_libraries(main
android
ioquake3_opengl2
SDL2
vrapi
openxr_loader
${log-lib})

View file

@ -24,13 +24,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "tr_types.h"
#if __ANDROID__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
#include <VrApi.h>
#pragma clang diagnostic pop
#endif
#define REF_API_VERSION 8
//
@ -90,7 +83,7 @@ typedef struct {
void (*EndFrame)( int *frontEndMsec, int *backEndMsec );
#if __ANDROID__
void (*SetVRHeadsetParms)( const ovrMatrix4f *projectionMatrix,
void (*SetVRHeadsetParms)( const float projectionMatrix[4][4],
int renderBufferL, int renderBufferR );
#endif

View file

@ -673,7 +673,7 @@ void RB_SetGL2D (void) {
Mat4Ortho(0, width, height, 0, 0, 1, matrix);
GL_SetProjectionMatrix(matrix);
Mat4Identity(matrix);
GL_SetModelviewMatrix(matrix, false);
GL_SetModelviewMatrix(matrix, qfalse);
GL_State( GLS_DEPTHTEST_DISABLE |
GLS_SRCBLEND_SRC_ALPHA |

View file

@ -590,9 +590,9 @@ void R_Mat4Transpose( const float in[4][4], float* out ) {
}
void RE_SetVRHeadsetParms( const ovrMatrix4f *projectionMatrix,
void RE_SetVRHeadsetParms( const float projectionMatrix[4][4],
int renderBufferL, int renderBufferR ) {
R_Mat4Transpose(projectionMatrix->M, tr.vrParms.projection);
R_Mat4Transpose(projectionMatrix, tr.vrParms.projection);
tr.vrParms.renderBufferL = renderBufferL;
tr.vrParms.renderBufferR = renderBufferR;
tr.vrParms.valid = qtrue;

View file

@ -2507,7 +2507,7 @@ void RE_StretchPic ( float x, float y, float w, float h,
void RE_BeginFrame( stereoFrame_t stereoFrame );
void RE_EndFrame( int *frontEndMsec, int *backEndMsec );
#if __ANDROID__
void RE_SetVRHeadsetParms( const ovrMatrix4f *projectionMatrix,
void RE_SetVRHeadsetParms( const float matrix[4][4],
int renderBufferL, int renderBufferR );
#endif
void RE_SaveJPG(char * filename, int quality, int image_width, int image_height,

View file

@ -1,7 +1,4 @@
#include "vr_base.h"
#include "../VrApi/Include/VrApi.h"
#include "../VrApi/Include/VrApi_Helpers.h"
#include "../VrApi/Include/VrApi_Types.h"
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#include "../client/client.h"
@ -42,6 +39,8 @@ cvar_t *vr_weaponSelectorWithHud = NULL;
engine_t* VR_Init( ovrJava java )
{
//TODO:
/*
ovrInitParms initParams;
ovrResult initResult;
@ -50,7 +49,7 @@ engine_t* VR_Init( ovrJava java )
initParams = vrapi_DefaultInitParms(&java);
initResult = vrapi_Initialize(&initParams);
assert(initResult == VRAPI_INITIALIZE_SUCCESS);
*/
vr_engine.java = java;
return &vr_engine;
@ -176,11 +175,13 @@ void VR_InitCvars( void )
void VR_Destroy( engine_t* engine )
{
if (engine == &vr_engine) {
vrapi_Shutdown();
//TODO:vrapi_Shutdown();
}
}
void VR_EnterVR( engine_t* engine, ovrJava java ) {
//TODO:
/*
if (!engine->ovr) {
ovrModeParms modeParams = vrapi_DefaultModeParms(&java);
modeParams.Display = (size_t)eglGetCurrentDisplay();
@ -194,29 +195,33 @@ void VR_EnterVR( engine_t* engine, ovrJava java ) {
vrapi_SetClockLevels(engine->ovr, 4, 4);
}
*/
}
void VR_LeaveVR( engine_t* engine ) {
//TODO:
/*
if (engine->ovr) {
vrapi_LeaveVrMode(engine->ovr);
engine->ovr = NULL;
}
*/
}
engine_t* VR_GetEngine( void ) {
return &vr_engine;
}
bool VR_useScreenLayer( void )
int VR_useScreenLayer( void )
{
//intermission is never full screen
if ( cl.snap.ps.pm_type == PM_INTERMISSION )
{
return qfalse;
return 0;
}
int keyCatcher = Key_GetCatcher( );
return (bool)( clc.state == CA_CINEMATIC ||
return ( clc.state == CA_CINEMATIC ||
( keyCatcher & (KEYCATCH_UI | KEYCATCH_CONSOLE) ));
}
//#endif

View file

@ -12,7 +12,7 @@ void VR_EnterVR( engine_t* engine, ovrJava java );
void VR_LeaveVR( engine_t* engine );
engine_t* VR_GetEngine( void );
bool VR_useScreenLayer( void );
int VR_useScreenLayer( void );
float radians(float deg);

View file

@ -7,8 +7,6 @@
#include "../client/keycodes.h"
#include "../client/client.h"
#include "vr_base.h"
#include "../VrApi/Include/VrApi_Input.h"
#include "../VrApi/Include/VrApi_Helpers.h"
#include "vr_clientinfo.h"
#include <unistd.h>
@ -89,6 +87,8 @@ void rotateAboutOrigin(float x, float y, float rotation, vec2_t out)
out[1] = cosf(DEG2RAD(-rotation)) * y - sinf(DEG2RAD(-rotation)) * x;
}
//TODO:
/*
static ovrVector3f normalizeVec(ovrVector3f vec) {
//NOTE: leave w-component untouched
//@@const float EPSILON = 0.000001f;
@ -104,6 +104,7 @@ static ovrVector3f normalizeVec(ovrVector3f vec) {
result.z = vec.z * invLength;
return result;
}
*/
void NormalizeAngles(vec3_t angles)
{
@ -115,6 +116,8 @@ void NormalizeAngles(vec3_t angles)
while (angles[2] < -180) angles[2] += 360;
}
//TODO:
/*
void GetAnglesFromVectors(const ovrVector3f forward, const ovrVector3f right, const ovrVector3f up, vec3_t angles)
{
float sr, sp, sy, cr, cp, cy;
@ -192,11 +195,12 @@ void QuatToYawPitchRoll(ovrQuatf q, vec3_t rotation, vec3_t out) {
GetAnglesFromVectors(forwardNormal, rightNormal, upNormal, out);
}
*/
//0 = left, 1 = right
float vibration_channel_duration[2] = {0.0f, 0.0f};
float vibration_channel_intensity[2] = {0.0f, 0.0f};
ovrDeviceID controllerIDs[2];
//TODO:ovrDeviceID controllerIDs[2];
void VR_Vibrate( int duration, int chan, float intensity )
{
@ -224,7 +228,8 @@ static void VR_processHaptics() {
float frametime = timestamp - lastFrameTime;
lastFrameTime = timestamp;
for (int i = 0; i < 2; ++i) {
//TODO:
/*for (int i = 0; i < 2; ++i) {
if (vibration_channel_duration[i] > 0.0f ||
vibration_channel_duration[i] == -1.0f) {
vrapi_SetHapticVibrationSimple(VR_GetEngine()->ovr, controllerIDs[i],
@ -241,7 +246,7 @@ static void VR_processHaptics() {
} else {
vrapi_SetHapticVibrationSimple(VR_GetEngine()->ovr, controllerIDs[i], 0.0f);
}
}
}*/
}
// Returns true in case button press should be auto-repeated when holding (now only applicable for smooth-turn)
@ -428,6 +433,8 @@ void IN_VRInit( void )
android_haptic_event = (*engine->java.Env)->GetMethodID(engine->java.Env, callbackClass, "haptic_event","(Ljava/lang/String;IIIFF)V");
}
//TODO:
/*
static void IN_VRController( qboolean isRightController, ovrTracking remoteTracking )
{
if (isRightController == (vr_righthanded->integer != 0))
@ -515,6 +522,7 @@ static void IN_VRController( qboolean isRightController, ovrTracking remoteTrack
}
}
}
*/
static void IN_VRJoystick( qboolean isRightController, float joystickX, float joystickY )
{
@ -545,7 +553,8 @@ static void IN_VRJoystick( qboolean isRightController, float joystickX, float jo
else
{
//Positional movement speed correction for when we are not hitting target framerate
int refresh = vrapi_GetSystemPropertyInt(&(VR_GetEngine()->java), VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE);
//TODO:int refresh = vrapi_GetSystemPropertyInt(&(VR_GetEngine()->java), VRAPI_SYS_PROP_DISPLAY_REFRESH_RATE);
int refresh = 72;
float multiplier = (float)((1000.0 / refresh) / (in_vrEventTime - lastframetime));
float factor = (refresh / 72.0F) * 10.0f; // adjust positional factor based on refresh rate
@ -908,6 +917,8 @@ static void IN_VRButtons( qboolean isRightController, uint32_t buttons )
vrController_t* controller = isRightController == qtrue ? &rightController : &leftController;
//TODO:
/*
{
if ((buttons & ovrButton_Enter) && !(controller->buttons & ovrButton_Enter)) {
controller->buttons |= ovrButton_Enter;
@ -1117,6 +1128,7 @@ static void IN_VRButtons( qboolean isRightController, uint32_t buttons )
IN_SendButtonAction(action, qfalse, qfalse, 0);
}
}
*/
}
void IN_VRInputFrame( void )
@ -1127,6 +1139,8 @@ void IN_VRInputFrame( void )
controllerInit = qtrue;
}
//TODO:
/*
ovrMobile* ovr = VR_GetEngine()->ovr;
if (!ovr) {
return;
@ -1240,6 +1254,7 @@ void IN_VRInputFrame( void )
lastframetime = in_vrEventTime;
in_vrEventTime = Sys_Milliseconds( );
*/
}
//#endif

View file

@ -4,18 +4,11 @@
#include "../qcommon/q_shared.h"
#include "../qcommon/qcommon.h"
#include "../client/client.h"
#include "../VrApi/Include/VrApi_Types.h"
#include "vr_clientinfo.h"
#include "vr_types.h"
//#include "../SDL2/include/SDL_opengles2_gl2.h"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
#include <VrApi.h>
#include <VrApi_Helpers.h>
#pragma clang diagnostic pop
#include <assert.h>
#include <stdlib.h>
#include <string.h>
@ -67,11 +60,14 @@ void VR_GetResolution(engine_t* engine, int *pWidth, int *pHeight)
if (engine)
{
//TODO:
/*
*pWidth = width = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_WIDTH) * SUPER_SAMPLE;
*pHeight = height = vrapi_GetSystemPropertyInt(&engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_TEXTURE_HEIGHT) * SUPER_SAMPLE;
vr.fov_x = vrapi_GetSystemPropertyInt( &engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_X);
vr.fov_y = vrapi_GetSystemPropertyInt( &engine->java, VRAPI_SYS_PROP_SUGGESTED_EYE_FOV_DEGREES_Y);
*/
}
else
{
@ -87,6 +83,8 @@ void VR_InitRenderer( engine_t* engine ) {
glDebugMessageCallback(VR_GLDebugLog, 0);
#endif
//TODO:
/*
int eyeW, eyeH;
VR_GetResolution(engine, &eyeW, &eyeH);
@ -123,9 +121,12 @@ void VR_InitRenderer( engine_t* engine ) {
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
}
}
*/
}
void VR_DestroyRenderer( engine_t* engine ) {
//TODO:
/*
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye)
{
if (engine->framebuffers[eye].swapchainLength > 0) {
@ -139,7 +140,7 @@ void VR_DestroyRenderer( engine_t* engine ) {
memset(&engine->framebuffers[eye], 0, sizeof(engine->framebuffers[eye]));
}
}
*/
}
@ -150,6 +151,8 @@ void VR_ReInitRenderer()
}
//TODO:
/*
// Assumes landscape cylinder shape.
static ovrMatrix4f CylinderModelMatrix( const int texWidth, const int texHeight,
const ovrVector3f translation,
@ -229,6 +232,7 @@ ovrLayerCylinder2 BuildCylinderLayer(engine_t* engine, const int textureWidth, c
return layer;
}
*/
void VR_ClearFrameBuffer( GLuint frameBuffer, int width, int height)
{
@ -259,6 +263,8 @@ void VR_ClearFrameBuffer( GLuint frameBuffer, int width, int height)
void VR_DrawFrame( engine_t* engine ) {
//TODO
/*
if (!engine->ovr)
{
return;
@ -314,7 +320,7 @@ void VR_DrawFrame( engine_t* engine ) {
const framebuffer_t* framebuffers = engine->framebuffers;
re.SetVRHeadsetParms(&projectionMatrix,
re.SetVRHeadsetParms(projectionMatrix->M,
framebuffers[0].framebuffers[framebuffers[0].swapchainIndex],
framebuffers[1].framebuffers[framebuffers[1].swapchainIndex]);
@ -351,7 +357,7 @@ void VR_DrawFrame( engine_t* engine ) {
VR_ClearFrameBuffer(framebuffers[0].framebuffers[framebuffers[0].swapchainIndex], eyeW, eyeH);
VR_ClearFrameBuffer(framebuffers[1].framebuffers[framebuffers[1].swapchainIndex], eyeW, eyeH);
re.SetVRHeadsetParms(&projectionMatrix,
re.SetVRHeadsetParms(projectionMatrix->M,
framebuffers[0].framebuffers[framebuffers[0].swapchainIndex],
framebuffers[1].framebuffers[framebuffers[1].swapchainIndex]);
@ -375,6 +381,6 @@ void VR_DrawFrame( engine_t* engine ) {
frameDesc.Layers = layers;
vrapi_SubmitFrame2(engine->ovr, &frameDesc);
}
}*/
}

View file

@ -9,26 +9,29 @@
# include <SDL_opengles2.h>
#endif
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wstrict-prototypes"
#include <VrApi.h>
#pragma clang diagnostic pop
#include <jni.h>
typedef struct {
JavaVM* Vm;
jobject ActivityObject;
JNIEnv* Env;
} ovrJava;
typedef struct {
int swapchainLength;
int swapchainIndex;
ovrTextureSwapChain* colorTexture;
//TODO:ovrTextureSwapChain* colorTexture;
GLuint* depthBuffers;
GLuint* framebuffers;
} framebuffer_t;
typedef struct {
uint64_t frameIndex;
ovrMobile* ovr;
//TODO:ovrMobile* ovr;
ovrJava java;
double predictedDisplayTime;
ovrTracking2 tracking;
framebuffer_t framebuffers[VRAPI_FRAME_LAYER_EYE_MAX];
//TODO:ovrTracking2 tracking;
framebuffer_t framebuffers[2];
} engine_t;
typedef enum {

View file

@ -4,8 +4,6 @@
#include <android/log.h>
#include <VrApi.h>
#include <VrApi_Helpers.h>
#include <string>
extern "C" {