From ce2dfb523e0bf66eec9b225edfd448f839df0600 Mon Sep 17 00:00:00 2001 From: bjorn Date: Wed, 29 Aug 2018 20:57:30 -0700 Subject: [PATCH] Make window mono by default; The window is now mono by default to make the error screen better and better enable non-stereo uses. The Camera can now request that the window be treated as stereo. --- src/graphics/graphics.c | 3 ++- src/graphics/graphics.h | 1 + src/headset/fake.c | 2 +- src/headset/webvr.c | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/graphics/graphics.c b/src/graphics/graphics.c index 3800d9a8..bb23225c 100644 --- a/src/graphics/graphics.c +++ b/src/graphics/graphics.c @@ -137,6 +137,7 @@ void lovrGraphicsSetCamera(Camera* camera, bool clear) { if (!camera) { state.camera.canvas = NULL; + state.camera.stereo = false; for (int i = 0; i < 2; i++) { mat4_identity(state.camera.viewMatrix[i]); mat4_perspective(state.camera.projection[i], .01f, 100.f, 67 * M_PI / 180., (float) state.width / state.height); @@ -414,7 +415,7 @@ void lovrGraphicsDraw(DrawOptions* draw) { } Canvas* canvas = state.pipelines[state.pipeline].canvas ? state.pipelines[state.pipeline].canvas : state.camera.canvas; - bool stereo = !draw->forceMono && (!canvas || lovrCanvasIsStereo(canvas)); + bool stereo = !draw->forceMono && (canvas ? lovrCanvasIsStereo(canvas) : state.camera.stereo); float w = (canvas ? lovrCanvasGetWidth(canvas) : state.width) >> stereo; float h = canvas ? lovrCanvasGetHeight(canvas) : state.height; int viewportCount = 1 + stereo; diff --git a/src/graphics/graphics.h b/src/graphics/graphics.h index 2416e0d4..1e6d36f6 100644 --- a/src/graphics/graphics.h +++ b/src/graphics/graphics.h @@ -95,6 +95,7 @@ typedef struct { } GraphicsStats; typedef struct { + bool stereo; Canvas* canvas; float viewMatrix[2][16]; float projection[2][16]; diff --git a/src/headset/fake.c b/src/headset/fake.c index 92311771..35aa67e5 100644 --- a/src/headset/fake.c +++ b/src/headset/fake.c @@ -282,7 +282,7 @@ static void fakeRenderTo(void (*callback)(void*), void* userdata) { int width, height; fakeGetDisplayDimensions(&width, &height); - Camera camera = { .canvas = NULL }; + Camera camera = { .canvas = NULL, .stereo = true }; mat4_perspective(camera.projection[0], state.clipNear, state.clipFar, 67 * M_PI / 180., (float) width / 2 / height); mat4_identity(camera.viewMatrix[0]); mat4_translate(camera.viewMatrix[0], 0, state.offset, 0); diff --git a/src/headset/webvr.c b/src/headset/webvr.c index 23064887..515667d7 100644 --- a/src/headset/webvr.c +++ b/src/headset/webvr.c @@ -90,7 +90,7 @@ static void onFrame(float* leftView, float* rightView, float* leftProjection, fl int width, height; webvrGetDisplayDimensions(&width, &height); - Camera camera = { .canvas = NULL }; + Camera camera = { .canvas = NULL, .stereo = true }; memcpy(camera.projection[0], leftProjection, 16 * sizeof(float)); memcpy(camera.projection[1], rightProjection, 16 * sizeof(float)); memcpy(camera.viewMatrix[0], leftView, 16 * sizeof(float));