mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-12 23:54:07 +00:00
OpenXR initialization fixed
This commit is contained in:
parent
f2fefbf708
commit
abeaf04607
2 changed files with 30 additions and 18 deletions
|
@ -49,6 +49,8 @@ cvar_t *vr_weaponSelectorWithHud = NULL;
|
||||||
|
|
||||||
engine_t* VR_Init( ovrJava java )
|
engine_t* VR_Init( ovrJava java )
|
||||||
{
|
{
|
||||||
|
memset(&vr_engine, 0, sizeof(vr_engine));
|
||||||
|
|
||||||
PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR;
|
PFN_xrInitializeLoaderKHR xrInitializeLoaderKHR;
|
||||||
xrGetInstanceProcAddr(
|
xrGetInstanceProcAddr(
|
||||||
XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR);
|
XR_NULL_HANDLE, "xrInitializeLoaderKHR", (PFN_xrVoidFunction*)&xrInitializeLoaderKHR);
|
||||||
|
@ -81,11 +83,21 @@ engine_t* VR_Init( ovrJava java )
|
||||||
instanceCreateInfo.enabledApiLayerNames = NULL;
|
instanceCreateInfo.enabledApiLayerNames = NULL;
|
||||||
instanceCreateInfo.enabledExtensionCount = numRequiredExtensions;
|
instanceCreateInfo.enabledExtensionCount = numRequiredExtensions;
|
||||||
instanceCreateInfo.enabledExtensionNames = requiredExtensionNames;
|
instanceCreateInfo.enabledExtensionNames = requiredExtensionNames;
|
||||||
if (xrCreateInstance(&instanceCreateInfo, &vr_engine.Instance) != XR_SUCCESS) {
|
if (xrCreateInstance(&instanceCreateInfo, &vr_engine.instance) != XR_SUCCESS) {
|
||||||
|
Com_Printf("xrCreateInstance failed");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
XrSystemGetInfo systemGetInfo;
|
||||||
|
memset(&systemGetInfo, 0, sizeof(systemGetInfo));
|
||||||
|
systemGetInfo.type = XR_TYPE_SYSTEM_GET_INFO;
|
||||||
|
systemGetInfo.next = NULL;
|
||||||
|
systemGetInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
|
||||||
|
if (xrGetSystem(vr_engine.instance, &systemGetInfo, &vr_engine.systemId) != XR_SUCCESS) {
|
||||||
|
Com_Printf("xrGetSystem failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(&vr_engine, 0, sizeof(vr_engine));
|
|
||||||
vr_engine.java = java;
|
vr_engine.java = java;
|
||||||
return &vr_engine;
|
return &vr_engine;
|
||||||
}
|
}
|
||||||
|
@ -210,31 +222,26 @@ void VR_InitCvars( void )
|
||||||
void VR_Destroy( engine_t* engine )
|
void VR_Destroy( engine_t* engine )
|
||||||
{
|
{
|
||||||
if (engine == &vr_engine) {
|
if (engine == &vr_engine) {
|
||||||
xrDestroyInstance(engine->Instance);
|
xrDestroyInstance(engine->instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VR_EnterVR( engine_t* engine, ovrJava java ) {
|
void VR_EnterVR( engine_t* engine, ovrJava java ) {
|
||||||
|
|
||||||
XrSystemId systemId;
|
if (engine->session) {
|
||||||
XrSystemGetInfo systemGetInfo;
|
Com_Printf("VR_EnterVR called with existing session");
|
||||||
memset(&systemGetInfo, 0, sizeof(systemGetInfo));
|
return;
|
||||||
systemGetInfo.type = XR_TYPE_SYSTEM_GET_INFO;
|
|
||||||
systemGetInfo.next = NULL;
|
|
||||||
systemGetInfo.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
|
|
||||||
if (xrGetSystem(engine->Instance, &systemGetInfo, &systemId) != XR_SUCCESS) {
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the graphics requirements.
|
// Get the graphics requirements.
|
||||||
PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL;
|
PFN_xrGetOpenGLESGraphicsRequirementsKHR pfnGetOpenGLESGraphicsRequirementsKHR = NULL;
|
||||||
xrGetInstanceProcAddr(
|
xrGetInstanceProcAddr(
|
||||||
engine->Instance,
|
engine->instance,
|
||||||
"xrGetOpenGLESGraphicsRequirementsKHR",
|
"xrGetOpenGLESGraphicsRequirementsKHR",
|
||||||
(PFN_xrVoidFunction*)(&pfnGetOpenGLESGraphicsRequirementsKHR));
|
(PFN_xrVoidFunction*)(&pfnGetOpenGLESGraphicsRequirementsKHR));
|
||||||
XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {};
|
XrGraphicsRequirementsOpenGLESKHR graphicsRequirements = {};
|
||||||
graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR;
|
graphicsRequirements.type = XR_TYPE_GRAPHICS_REQUIREMENTS_OPENGL_ES_KHR;
|
||||||
pfnGetOpenGLESGraphicsRequirementsKHR(engine->Instance, systemId, &graphicsRequirements);
|
pfnGetOpenGLESGraphicsRequirementsKHR(engine->instance, engine->systemId, &graphicsRequirements);
|
||||||
|
|
||||||
// Create the OpenXR Session.
|
// Create the OpenXR Session.
|
||||||
XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {};
|
XrGraphicsBindingOpenGLESAndroidKHR graphicsBindingAndroidGLES = {};
|
||||||
|
@ -249,15 +256,19 @@ void VR_EnterVR( engine_t* engine, ovrJava java ) {
|
||||||
sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO;
|
sessionCreateInfo.type = XR_TYPE_SESSION_CREATE_INFO;
|
||||||
sessionCreateInfo.next = &graphicsBindingAndroidGLES;
|
sessionCreateInfo.next = &graphicsBindingAndroidGLES;
|
||||||
sessionCreateInfo.createFlags = 0;
|
sessionCreateInfo.createFlags = 0;
|
||||||
sessionCreateInfo.systemId = systemId;
|
sessionCreateInfo.systemId = engine->systemId;
|
||||||
|
|
||||||
if (xrCreateSession(engine->Instance, &sessionCreateInfo, &engine->Session) != XR_SUCCESS) {
|
if (xrCreateSession(engine->instance, &sessionCreateInfo, &engine->session) != XR_SUCCESS) {
|
||||||
|
Com_Printf("xrCreateSession failed");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VR_LeaveVR( engine_t* engine ) {
|
void VR_LeaveVR( engine_t* engine ) {
|
||||||
xrDestroySession(engine->Session);
|
if (engine->session) {
|
||||||
|
xrDestroySession(engine->session);
|
||||||
|
engine->session = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
engine_t* VR_GetEngine( void ) {
|
engine_t* VR_GetEngine( void ) {
|
||||||
|
|
|
@ -38,8 +38,9 @@ typedef struct {
|
||||||
double predictedDisplayTime;
|
double predictedDisplayTime;
|
||||||
//TODO:ovrTracking2 tracking;
|
//TODO:ovrTracking2 tracking;
|
||||||
framebuffer_t framebuffers[2];
|
framebuffer_t framebuffers[2];
|
||||||
XrInstance Instance;
|
XrInstance instance;
|
||||||
XrSession Session;
|
XrSession session;
|
||||||
|
XrSystemId systemId;
|
||||||
} engine_t;
|
} engine_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
|
Loading…
Reference in a new issue