diff --git a/src/main.cpp b/src/main.cpp index 3281f9b..5114374 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -31,8 +32,6 @@ class CBindOwnFramebufferPassElement final: public IPassElement { m_pFramebuffer->bind(); g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0)); g_pHyprOpenGL->m_renderData.currentFB = m_pFramebuffer; - - std::println("BindOwnFramebufferPassElement"); } bool needsLiveBlur() override { @@ -67,10 +66,16 @@ class CRenderWobblyWindowPassElement final: public IPassElement { m_pOldFramebuffer->bind(); g_pHyprOpenGL->m_renderData.currentFB = m_pOldFramebuffer; - g_pHyprOpenGL - ->renderTexture(pWindowFB->getTexture(), m_pWindow->getFullWindowBoundingBox(), 1.0f); - std::println("RenderWobblyWindowPassElement"); + const auto windowBox = m_pWindow->getFullWindowBoundingBox(); + + g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft = + Vector2D {windowBox.x, windowBox.y} / pWindowFB->m_size; + g_pHyprOpenGL->m_renderData.primarySurfaceUVBottomRight = + Vector2D {windowBox.x + windowBox.width, windowBox.y + windowBox.height} + / pWindowFB->m_size; + + g_pHyprOpenGL->renderTexture(pWindowFB->getTexture(), windowBox, 1.0f, 0, 0.f, false, true); } bool needsLiveBlur() override { @@ -128,7 +133,7 @@ void hkRenderWindow( CHyprRenderer* pRenderer = (CHyprRenderer*)thisptr; const bool shouldWobble = [&]() -> bool { - if (mode == RENDER_PASS_MAIN) { + if (mode == RENDER_PASS_MAIN or mode == RENDER_PASS_ALL) { return true; } @@ -139,14 +144,24 @@ void hkRenderWindow( if (shouldWobble) { PHLWINDOWREF ref {pWindow}; + + const auto windowBox = pWindow->getFullWindowBoundingBox(); + const auto windowSize = Vector2D {windowBox.width, windowBox.height}; + const auto framebufferSize = + Vector2D {windowBox.x + windowBox.width, windowBox.y + windowBox.height}; + if (!g_windowFramebuffers.contains(ref)) { - g_windowFramebuffers[ref] = CFramebuffer {}; - g_windowFramebuffers[ref].alloc(pWindow->m_size.x, pWindow->m_size.y); + g_windowFramebuffers[ref].alloc(framebufferSize.x, framebufferSize.y); } - pRenderer->m_renderPass.add( - makeUnique(&g_windowFramebuffers.at(ref)) - ); + auto&& windowFB = g_windowFramebuffers.at(ref); + + if (windowSize != windowFB.m_size) { + windowFB.release(); + windowFB.alloc(framebufferSize.x, framebufferSize.y); + } + + pRenderer->m_renderPass.add(makeUnique(&windowFB)); } // then call the original...