From 518d26aad851b5823afdc35f46b979e2052f4ad6 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 21 Oct 2018 08:40:57 -0700 Subject: [PATCH] getDisplayDimensions: Use unsigned ints; Fixes a warning. --- src/api/headset.c | 14 +++++++------- src/headset/fake.c | 9 ++++++--- src/headset/headset.h | 2 +- src/headset/oculus.c | 2 +- src/headset/openvr.c | 2 +- src/headset/webvr.c | 2 +- src/math/mat4.c | 4 ++-- src/resources/lovr.js | 4 ++-- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/api/headset.c b/src/api/headset.c index f192a675..20c47121 100644 --- a/src/api/headset.c +++ b/src/api/headset.c @@ -115,24 +115,24 @@ static int l_lovrHeadsetSetMirrored(lua_State* L) { } static int l_lovrHeadsetGetDisplayWidth(lua_State* L) { - int width, height; + uint32_t width, height; lovrHeadsetDriver->getDisplayDimensions(&width, &height); - lua_pushnumber(L, width); + lua_pushinteger(L, width); return 1; } static int l_lovrHeadsetGetDisplayHeight(lua_State* L) { - int width, height; + uint32_t width, height; lovrHeadsetDriver->getDisplayDimensions(&width, &height); - lua_pushnumber(L, height); + lua_pushinteger(L, height); return 1; } static int l_lovrHeadsetGetDisplayDimensions(lua_State* L) { - int width, height; + uint32_t width, height; lovrHeadsetDriver->getDisplayDimensions(&width, &height); - lua_pushnumber(L, width); - lua_pushnumber(L, height); + lua_pushinteger(L, width); + lua_pushinteger(L, height); return 2; } diff --git a/src/headset/fake.c b/src/headset/fake.c index 5396e4aa..ca30a31c 100644 --- a/src/headset/fake.c +++ b/src/headset/fake.c @@ -113,11 +113,14 @@ static void fakeSetMirrored(bool mirror, HeadsetEye eye) { state.mirrorEye = eye; } -static void fakeGetDisplayDimensions(int* width, int* height) { +static void fakeGetDisplayDimensions(uint32_t* width, uint32_t* height) { updateWindow(); if (state.window) { - glfwGetFramebufferSize(state.window, width, height); + int w, h; + glfwGetFramebufferSize(state.window, &w, &h); + *width = (uint32_t) w; + *height = (uint32_t) h; } } @@ -215,7 +218,7 @@ static void fakeRenderTo(void (*callback)(void*), void* userdata) { return; } - int width, height; + uint32_t width, height; fakeGetDisplayDimensions(&width, &height); bool stereo = state.mirrorEye == EYE_BOTH; Camera camera = { .canvas = NULL, .viewMatrix = { MAT4_IDENTITY }, .stereo = stereo }; diff --git a/src/headset/headset.h b/src/headset/headset.h index 70b4c25a..4f448b86 100644 --- a/src/headset/headset.h +++ b/src/headset/headset.h @@ -73,7 +73,7 @@ typedef struct { bool (*isMounted)(); void (*isMirrored)(bool* mirrored, HeadsetEye* eye); void (*setMirrored)(bool mirror, HeadsetEye eye); - void (*getDisplayDimensions)(int* width, int* height); + void (*getDisplayDimensions)(uint32_t* width, uint32_t* height); void (*getClipDistance)(float* clipNear, float* clipFar); void (*setClipDistance)(float clipNear, float clipFar); void (*getBoundsDimensions)(float* width, float* depth); diff --git a/src/headset/oculus.c b/src/headset/oculus.c index da1af030..547e9977 100644 --- a/src/headset/oculus.c +++ b/src/headset/oculus.c @@ -171,7 +171,7 @@ static void oculusSetMirrored(bool mirror, HeadsetEye eye) { state.mirrorEye = eye; } -static void oculusGetDisplayDimensions(int* width, int* height) { +static void oculusGetDisplayDimensions(uint32_t* width, uint32_t* height) { ovrHmdDesc desc = ovr_GetHmdDesc(state.session); ovrSizei size = ovr_GetFovTextureSize(state.session, ovrEye_Left, desc.DefaultEyeFov[0], 1.0f); diff --git a/src/headset/openvr.c b/src/headset/openvr.c index c68a0206..94fbe4df 100644 --- a/src/headset/openvr.c +++ b/src/headset/openvr.c @@ -295,7 +295,7 @@ static void openvrSetMirrored(bool mirror, HeadsetEye eye) { state.mirrorEye = eye; } -static void openvrGetDisplayDimensions(int* width, int* height) { +static void openvrGetDisplayDimensions(uint32_t* width, uint32_t* height) { state.system->GetRecommendedRenderTargetSize(width, height); } diff --git a/src/headset/webvr.c b/src/headset/webvr.c index c510f835..8473cd81 100644 --- a/src/headset/webvr.c +++ b/src/headset/webvr.c @@ -12,7 +12,7 @@ extern HeadsetOrigin webvrGetOriginType(void); extern bool webvrIsMounted(void); extern bool webvrIsMirrored(void); extern void webvrSetMirrored(bool mirror); -extern void webvrGetDisplayDimensions(int32_t* width, int32_t* height); +extern void webvrGetDisplayDimensions(uint32_t* width, uint32_t* height); extern void webvrGetClipDistance(float* near, float* far); extern void webvrSetClipDistance(float near, float far); extern void webvrGetBoundsDimensions(float* width, float* depth); diff --git a/src/math/mat4.c b/src/math/mat4.c index 3b0350fc..d4288864 100644 --- a/src/math/mat4.c +++ b/src/math/mat4.c @@ -297,7 +297,7 @@ mat4 mat4_orthographic(mat4 m, float left, float right, float top, float bottom, float rl = right - left; float tb = top - bottom; float fn = clipFar - clipNear; - mat4_identity(m); + memset(m, 0, 16 * sizeof(float)); m[0] = 2 / rl; m[5] = 2 / tb; m[10] = -2 / fn; @@ -314,7 +314,7 @@ mat4 mat4_perspective(mat4 m, float clipNear, float clipFar, float fovy, float a float sy = clipNear / range; float sz = -(clipFar + clipNear) / (clipFar - clipNear); float pz = (-2.0f * clipFar * clipNear) / (clipFar - clipNear); - mat4_identity(m); + memset(m, 0, 16 * sizeof(float)); m[0] = sx; m[5] = sy; m[10] = sz; diff --git a/src/resources/lovr.js b/src/resources/lovr.js index 4bf6a5db..0ee75d29 100644 --- a/src/resources/lovr.js +++ b/src/resources/lovr.js @@ -152,8 +152,8 @@ var LibraryLOVR = { }, webvrGetDisplayDimensions: function(width, height) { - HEAP32[width >> 2] = webvr.width; - HEAP32[height >> 2] = webvr.height; + HEAPU32[width >> 2] = webvr.width; + HEAPU32[height >> 2] = webvr.height; }, webvrGetClipDistance: function(clipNear, clipFar) {