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 offset = 1.7f;
|
||||
int msaa = 4;
|
||||
bool overlay = false;
|
||||
|
||||
if (lua_istable(L, -1)) {
|
||||
|
||||
|
@ -154,10 +155,15 @@ static int l_lovrHeadsetInit(lua_State* L) {
|
|||
lua_getfield(L, -1, "msaa");
|
||||
msaa = luaL_optinteger(L, -1, 4);
|
||||
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
|
||||
lovrHeadsetInit(drivers, driverCount, supersample, offset, msaa);
|
||||
lovrHeadsetInit(drivers, driverCount, supersample, offset, msaa, overlay);
|
||||
|
||||
lua_pop(L, 2);
|
||||
return 0;
|
||||
|
|
|
@ -5,7 +5,7 @@ HeadsetInterface* lovrHeadsetDisplayDriver = NULL;
|
|||
HeadsetInterface* lovrHeadsetTrackingDrivers = NULL;
|
||||
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;
|
||||
initialized = true;
|
||||
|
||||
|
@ -42,7 +42,7 @@ bool lovrHeadsetInit(HeadsetDriver* drivers, size_t count, float supersample, fl
|
|||
bool hasDisplay = interface->renderTo != NULL;
|
||||
bool shouldInitialize = !hasDisplay || !lovrHeadsetDisplayDriver;
|
||||
|
||||
if (shouldInitialize && interface->init(supersample, offset, msaa)) {
|
||||
if (shouldInitialize && interface->init(supersample, offset, msaa, overlay)) {
|
||||
if (hasDisplay) {
|
||||
lovrHeadsetDisplayDriver = interface;
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ typedef enum {
|
|||
typedef struct HeadsetInterface {
|
||||
struct HeadsetInterface* next;
|
||||
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);
|
||||
bool (*getName)(char* name, size_t length);
|
||||
HeadsetOrigin (*getOriginType)(void);
|
||||
|
@ -157,5 +157,5 @@ extern HeadsetInterface* lovrHeadsetTrackingDrivers;
|
|||
#define FOREACH_TRACKING_DRIVER(i)\
|
||||
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);
|
||||
|
|
|
@ -31,7 +31,7 @@ static struct {
|
|||
float yaw;
|
||||
} 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.clipNear = .1f;
|
||||
state.clipFar = 100.f;
|
||||
|
|
|
@ -83,7 +83,8 @@ static ovrInputState *refreshButtons(void) {
|
|||
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);
|
||||
|
||||
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_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()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,7 @@ static bool hasExtension(XrExtensionProperties* extensions, uint32_t count, cons
|
|||
|
||||
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;
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
|
|
@ -234,7 +234,7 @@ static struct {
|
|||
void* renderUserdata;
|
||||
} 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.clipNear = .1f;
|
||||
state.clipFar = 100.f;
|
||||
|
|
|
@ -52,7 +52,7 @@ static struct {
|
|||
float hapticDuration[2];
|
||||
} 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();
|
||||
JNIEnv* jni = os_get_jni();
|
||||
state.java.Vm = activity->vm;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#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 bool webxr_getName(char* name, size_t length);
|
||||
extern HeadsetOrigin webxr_getOriginType(void);
|
||||
|
|
|
@ -124,7 +124,8 @@ function lovr.boot()
|
|||
drivers = { 'openxr', 'oculus', 'vrapi', 'pico', 'openvr', 'webxr', 'desktop' },
|
||||
supersample = false,
|
||||
offset = 1.7,
|
||||
msaa = 4
|
||||
msaa = 4,
|
||||
overlay = false
|
||||
},
|
||||
math = {
|
||||
globals = true
|
||||
|
|
|
@ -48,7 +48,7 @@ var webxr = {
|
|||
},
|
||||
|
||||
webxr_init__deps: ['$buttons', '$axes'],
|
||||
webxr_init: function(supersample, offset, msaa) {
|
||||
webxr_init: function(supersample, offset, msaa, overlay) {
|
||||
if (!navigator.xr) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue