History

Exploring how to solve the mirror fullscreen bug

samcake committed 10 years ago

Commit 1ddbc151 parent 28d28682 files · +36 −6Browse files

Showing the changes to interface/src/Application.cpp (1 of 2 files). Show all

Unified · Split

interface/src/Application.cpp+34−4
@@ -1273,6 +1273,9 @@ void Application::paintGL() { · 1272 unmodified lines
12731273 // Primary rendering pass
12741274 auto framebufferCache = DependencyManager::get<FramebufferCache>();
12751275 const QSize size = framebufferCache->getFrameBufferSize();
1276+
1277+ auto finalFramebuffer = framebufferCache->getFramebuffer();
1278+
12761279 {
12771280 PROFILE_RANGE(__FUNCTION__ "/mainRender");
12781281 PerformanceTimer perfTimer("mainRender");
@@ -1326,9 +1329,34 @@ void Application::paintGL() { · 47 unmodified lines
13261329 }
13271330 displaySide(&renderArgs, _myCamera);
13281331 renderArgs._context->enableStereo(false);
1329− gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) {
1332+ /* gpu::doInBatch(renderArgs._context, [](gpu::Batch& batch) {
13301333 batch.setFramebuffer(nullptr);
13311334 });
1335+ */
1336+ float ratio = ((float)QApplication::desktop()->windowHandle()->devicePixelRatio() * getRenderResolutionScale());
1337+ // Flip the src and destination rect horizontally to do the mirror
1338+ auto mirrorRect = glm::ivec4(0, 0, _mirrorViewRect.width() * ratio, _mirrorViewRect.height() * ratio);
1339+ auto mirrorRectDest = glm::ivec4(mirrorRect.z, mirrorRect.y, mirrorRect.x, mirrorRect.w);
1340+
1341+ auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
1342+ /**
1343+ gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1344+ batch.setFramebuffer(finalFramebuffer);
1345+ batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
1346+ batch.blit(primaryFbo, mirrorRect, finalFramebuffer, mirrorRectDest);
1347+ batch.setFramebuffer(nullptr);
1348+ });
1349+ */
1350+ gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
1351+ gpu::Vec4i rect;
1352+ rect.z = size.width();
1353+ rect.w = size.height();
1354+ batch.setFramebuffer(finalFramebuffer);
1355+ batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
1356+ batch.blit(primaryFbo, rect, finalFramebuffer, rect);
1357+ // batch.setFramebuffer(nullptr);
1358+ });
1359+
13321360 }
13331361
13341362 // Overlay Composition, needs to occur after screen space effects have completed
@@ -1336,7 +1364,8 @@ void Application::paintGL() { · 1 unmodified line
13361364 {
13371365 PROFILE_RANGE(__FUNCTION__ "/compositor");
13381366 PerformanceTimer perfTimer("compositor");
1339− auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
1367+ // auto primaryFbo = framebufferCache->getPrimaryFramebuffer();
1368+ auto primaryFbo = finalFramebuffer;
13401369 glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gpu::GLBackend::getFramebufferID(primaryFbo));
13411370 if (displayPlugin->isStereo()) {
13421371 QRect currentViewport(QPoint(0, 0), QSize(size.width() / 2, size.height()));
@@ -1361,7 +1390,8 @@ void Application::paintGL() { · 18 unmodified lines
13611390 {
13621391 PROFILE_RANGE(__FUNCTION__ "/pluginOutput");
13631392 PerformanceTimer perfTimer("pluginOutput");
1364− auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer();
1393+ auto scratchFramebuffer = finalFramebuffer;
1394+ /* auto primaryFramebuffer = framebufferCache->getPrimaryFramebuffer();
13651395 auto scratchFramebuffer = framebufferCache->getFramebuffer();
13661396 gpu::doInBatch(renderArgs._context, [=](gpu::Batch& batch) {
13671397 gpu::Vec4i rect;
@@ -1371,7 +1401,7 @@ void Application::paintGL() { · 3 unmodified lines
13711401 batch.clearColorFramebuffer(gpu::Framebuffer::BUFFER_COLOR0, glm::vec4(0.0f, 0.0f, 0.0f, 0.0f));
13721402 batch.blit(primaryFramebuffer, rect, scratchFramebuffer, rect);
13731403 batch.setFramebuffer(nullptr);
1374− });
1404+ });*/
13751405 auto finalTexturePointer = scratchFramebuffer->getRenderBuffer(0);
13761406 GLuint finalTexture = gpu::GLBackend::getTextureID(finalTexturePointer);
13771407 Q_ASSERT(0 != finalTexture);