Skip to content

Commit 7e74821

Browse files
committed
Use window aspect ratio for VR preview rather than hardcoded 16:9
1 parent 1551c17 commit 7e74821

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

libraries/display-plugins/src/display-plugins/hmd/HmdDisplayPlugin.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,16 @@ void HmdDisplayPlugin::internalPresent() {
214214
float newWidth = sourceSize.x - shiftLeftBy;
215215

216216
// Experimentally adjusted the region presented in preview to avoid seeing the masked pixels and recenter the center...
217-
static float SCALE_WIDTH = 0.8f;
217+
static float SCALE_WIDTH = 1.0f;
218218
static float SCALE_OFFSET = 2.0f;
219219
newWidth *= SCALE_WIDTH;
220220
shiftLeftBy *= SCALE_OFFSET;
221221

222-
const unsigned int RATIO_Y = 9;
223-
const unsigned int RATIO_X = 16;
224-
glm::uvec2 originalClippedSize { newWidth, newWidth * RATIO_Y / RATIO_X };
222+
auto window = _container->getPrimaryWidget();
223+
224+
auto ratioY = window->size().height();
225+
auto ratioX = window->size().width();
226+
glm::uvec2 originalClippedSize { newWidth, newWidth * ratioY / ratioX };
225227

226228
glm::ivec4 viewport = getViewportForSourceSize(sourceSize);
227229
glm::ivec4 scissor = viewport;
@@ -231,7 +233,6 @@ void HmdDisplayPlugin::internalPresent() {
231233
render([&](gpu::Batch& batch) {
232234

233235
if (_monoPreview) {
234-
auto window = _container->getPrimaryWidget();
235236
float devicePixelRatio = window->devicePixelRatio();
236237
glm::vec2 windowSize = toGlm(window->size());
237238
windowSize *= devicePixelRatio;

0 commit comments

Comments
 (0)