Skip to content

Commit 1fd1d51

Browse files
authored
Merge pull request #1571 from ada-tv/fix/vr-preview-aspect-ratio
Use window aspect ratio for VR preview rather than hardcoded 16:9
2 parents 531c52c + 120052e commit 1fd1d51

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,11 @@ void HmdDisplayPlugin::internalPresent() {
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)