fix: calculate correct window UVs

This commit is contained in:
Matias 2025-07-13 22:32:34 +02:00
parent cb7425cea0
commit 3cb4b0aa3f
No known key found for this signature in database
GPG Key ID: ED35A6AC65A06B69

View File

@ -13,6 +13,7 @@
#include <hyprland/src/render/Renderer.hpp>
#include <hyprutils/math/Box.hpp>
#include <hyprutils/math/Region.hpp>
#include <hyprutils/math/Vector2D.hpp>
#include <map>
#include <optional>
#include <unistd.h>
@ -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<CBindOwnFramebufferPassElement>(&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<CBindOwnFramebufferPassElement>(&windowFB));
}
// then call the original...