mirror of https://github.com/bjornbytes/lovr.git
Add overlay parameter to headset init
This commit is contained in:
parent
909b43f34a
commit
70ef04e595
|
@ -122,6 +122,7 @@ static int l_lovrHeadsetInit(lua_State* L) {
|
||||||
float supersample = 1.f;
|
float supersample = 1.f;
|
||||||
float offset = 1.7f;
|
float offset = 1.7f;
|
||||||
int msaa = 4;
|
int msaa = 4;
|
||||||
|
bool overlay = false;
|
||||||
|
|
||||||
if (lua_istable(L, -1)) {
|
if (lua_istable(L, -1)) {
|
||||||
|
|
||||||
|
@ -154,10 +155,15 @@ static int l_lovrHeadsetInit(lua_State* L) {
|
||||||
lua_getfield(L, -1, "msaa");
|
lua_getfield(L, -1, "msaa");
|
||||||
msaa = luaL_optinteger(L, -1, 4);
|
msaa = luaL_optinteger(L, -1, 4);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
// Overlay
|
||||||
|
lua_getfield(L, -1, "overlay");
|
||||||
|
overlay = lua_toboolean(L, -1);
|
||||||
|
lua_pop(L, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
luax_atexit(L, lovrHeadsetDestroy); // Always make sure the headset module gets cleaned up
|
luax_atexit(L, lovrHeadsetDestroy); // Always make sure the headset module gets cleaned up
|
||||||
lovrHeadsetInit(drivers, driverCount, supersample, offset, msaa);
|
lovrHeadsetInit(drivers, driverCount, supersample, offset, msaa, overlay);
|
||||||
|
|
||||||
lua_pop(L, 2);
|
lua_pop(L, 2);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -5,7 +5,7 @@ HeadsetInterface* lovrHeadsetDisplayDriver = NULL;
|
||||||
HeadsetInterface* lovrHeadsetTrackingDrivers = NULL;
|
HeadsetInterface* lovrHeadsetTrackingDrivers = NULL;
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
|
|
||||||
bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float supersample, float offset, uint32_t msaa) {
|
bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float supersample, float offset, uint32_t msaa, bool overlay) {
|
||||||
if (initialized) return false;
|
if (initialized) return false;
|
||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float supersample, fl
|
||||||
bool hasDisplay = interface->renderTo != NULL;
|
bool hasDisplay = interface->renderTo != NULL;
|
||||||
bool shouldInitialize = !hasDisplay || !lovrHeadsetDisplayDriver;
|
bool shouldInitialize = !hasDisplay || !lovrHeadsetDisplayDriver;
|
||||||
|
|
||||||
if (shouldInitialize && interface->init(supersample, offset, msaa)) {
|
if (shouldInitialize && interface->init(supersample, offset, msaa, overlay)) {
|
||||||
if (hasDisplay) {
|
if (hasDisplay) {
|
||||||
lovrHeadsetDisplayDriver = interface;
|
lovrHeadsetDisplayDriver = interface;
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,7 +112,7 @@ typedef enum {
|
||||||
typedef struct HeadsetInterface {
|
typedef struct HeadsetInterface {
|
||||||
struct HeadsetInterface* next;
|
struct HeadsetInterface* next;
|
||||||
HeadsetDriver driverType;
|
HeadsetDriver driverType;
|
||||||
bool (*init)(float supersample, float offset, uint32_t msaa);
|
bool (*init)(float supersample, float offset, uint32_t msaa, bool overlay);
|
||||||
void (*destroy)(void);
|
void (*destroy)(void);
|
||||||
bool (*getName)(char* name, size_t length);
|
bool (*getName)(char* name, size_t length);
|
||||||
HeadsetOrigin (*getOriginType)(void);
|
HeadsetOrigin (*getOriginType)(void);
|
||||||
|
@ -157,5 +157,5 @@ extern HeadsetInterface* lovrHeadsetTrackingDrivers;
|
||||||
#define FOREACH_TRACKING_DRIVER(i)\
|
#define FOREACH_TRACKING_DRIVER(i)\
|
||||||
for (HeadsetInterface* i = lovrHeadsetTrackingDrivers; i != NULL; i = i->next)
|
for (HeadsetInterface* i = lovrHeadsetTrackingDrivers; i != NULL; i = i->next)
|
||||||
|
|
||||||
bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float supersample, float offset, uint32_t msaa);
|
bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float supersample, float offset, uint32_t msaa, bool overlay);
|
||||||
void lovrHeadsetDestroy(void);
|
void lovrHeadsetDestroy(void);
|
||||||
|
|
|
@ -31,7 +31,7 @@ static struct {
|
||||||
float yaw;
|
float yaw;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
static bool desktop_init(float supersample, float offset, uint32_t msaa) {
|
static bool desktop_init(float supersample, float offset, uint32_t msaa, bool overlay) {
|
||||||
state.offset = offset;
|
state.offset = offset;
|
||||||
state.clipNear = .1f;
|
state.clipNear = .1f;
|
||||||
state.clipFar = 100.f;
|
state.clipFar = 100.f;
|
||||||
|
|
|
@ -83,7 +83,8 @@ static ovrInputState *refreshButtons(void) {
|
||||||
return &is;
|
return &is;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool oculus_init(float supersample, float offset, uint32_t msaa) {
|
|
||||||
|
static bool oculus_init(float supersample, float offset, uint32_t msaa, bool overlay) {
|
||||||
arr_init(&state.textures, realloc);
|
arr_init(&state.textures, realloc);
|
||||||
|
|
||||||
ovrResult result = ovr_Initialize(NULL);
|
ovrResult result = ovr_Initialize(NULL);
|
||||||
|
|
|
@ -112,7 +112,7 @@ static TrackedDeviceIndex_t getDeviceIndex(Device device) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool openvr_getName(char* name, size_t length);
|
static bool openvr_getName(char* name, size_t length);
|
||||||
static bool openvr_init(float supersample, float offset, uint32_t msaa) {
|
static bool openvr_init(float supersample, float offset, uint32_t msaa, bool overlay) {
|
||||||
if (!VR_IsHmdPresent() || !VR_IsRuntimeInstalled()) {
|
if (!VR_IsHmdPresent() || !VR_IsRuntimeInstalled()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -168,7 +168,7 @@ static bool hasExtension(XrExtensionProperties* extensions, uint32_t count, cons
|
||||||
|
|
||||||
static void openxr_destroy();
|
static void openxr_destroy();
|
||||||
|
|
||||||
static bool openxr_init(float supersample, float offset, uint32_t msaa) {
|
static bool openxr_init(float supersample, float offset, uint32_t msaa, bool overlay) {
|
||||||
state.msaa = msaa;
|
state.msaa = msaa;
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
|
|
|
@ -234,7 +234,7 @@ static struct {
|
||||||
void* renderUserdata;
|
void* renderUserdata;
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
static bool pico_init(float supersample, float offset, uint32_t msaa) {
|
static bool pico_init(float supersample, float offset, uint32_t msaa, bool overlay) {
|
||||||
state.offset = offset;
|
state.offset = offset;
|
||||||
state.clipNear = .1f;
|
state.clipNear = .1f;
|
||||||
state.clipFar = 100.f;
|
state.clipFar = 100.f;
|
||||||
|
|
|
@ -52,7 +52,7 @@ static struct {
|
||||||
float hapticDuration[2];
|
float hapticDuration[2];
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
static bool vrapi_init(float supersample, float offset, uint32_t msaa) {
|
static bool vrapi_init(float supersample, float offset, uint32_t msaa, bool overlay) {
|
||||||
ANativeActivity* activity = os_get_activity();
|
ANativeActivity* activity = os_get_activity();
|
||||||
JNIEnv* jni = os_get_jni();
|
JNIEnv* jni = os_get_jni();
|
||||||
state.java.Vm = activity->vm;
|
state.java.Vm = activity->vm;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "headset/headset.h"
|
#include "headset/headset.h"
|
||||||
|
|
||||||
extern bool webxr_init(float supersample, float offset, uint32_t msaa);
|
extern bool webxr_init(float supersample, float offset, uint32_t msaa, bool overlay);
|
||||||
extern void webxr_destroy(void);
|
extern void webxr_destroy(void);
|
||||||
extern bool webxr_getName(char* name, size_t length);
|
extern bool webxr_getName(char* name, size_t length);
|
||||||
extern HeadsetOrigin webxr_getOriginType(void);
|
extern HeadsetOrigin webxr_getOriginType(void);
|
||||||
|
|
|
@ -124,7 +124,8 @@ function lovr.boot()
|
||||||
drivers = { 'openxr', 'oculus', 'vrapi', 'pico', 'openvr', 'webxr', 'desktop' },
|
drivers = { 'openxr', 'oculus', 'vrapi', 'pico', 'openvr', 'webxr', 'desktop' },
|
||||||
supersample = false,
|
supersample = false,
|
||||||
offset = 1.7,
|
offset = 1.7,
|
||||||
msaa = 4
|
msaa = 4,
|
||||||
|
overlay = false
|
||||||
},
|
},
|
||||||
math = {
|
math = {
|
||||||
globals = true
|
globals = true
|
||||||
|
|
|
@ -48,7 +48,7 @@ var webxr = {
|
||||||
},
|
},
|
||||||
|
|
||||||
webxr_init__deps: ['$buttons', '$axes'],
|
webxr_init__deps: ['$buttons', '$axes'],
|
||||||
webxr_init: function(supersample, offset, msaa) {
|
webxr_init: function(supersample, offset, msaa, overlay) {
|
||||||
if (!navigator.xr) {
|
if (!navigator.xr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue