mirror of
https://git.allpurposem.at/mat/WiggleWobble.git
synced 2025-12-23 13:01:28 +01:00
fix: calculate correct window UVs
This commit is contained in:
parent
cb7425cea0
commit
3cb4b0aa3f
37
src/main.cpp
37
src/main.cpp
@ -13,6 +13,7 @@
|
|||||||
#include <hyprland/src/render/Renderer.hpp>
|
#include <hyprland/src/render/Renderer.hpp>
|
||||||
#include <hyprutils/math/Box.hpp>
|
#include <hyprutils/math/Box.hpp>
|
||||||
#include <hyprutils/math/Region.hpp>
|
#include <hyprutils/math/Region.hpp>
|
||||||
|
#include <hyprutils/math/Vector2D.hpp>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -31,8 +32,6 @@ class CBindOwnFramebufferPassElement final: public IPassElement {
|
|||||||
m_pFramebuffer->bind();
|
m_pFramebuffer->bind();
|
||||||
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0));
|
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0));
|
||||||
g_pHyprOpenGL->m_renderData.currentFB = m_pFramebuffer;
|
g_pHyprOpenGL->m_renderData.currentFB = m_pFramebuffer;
|
||||||
|
|
||||||
std::println("BindOwnFramebufferPassElement");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsLiveBlur() override {
|
bool needsLiveBlur() override {
|
||||||
@ -67,10 +66,16 @@ class CRenderWobblyWindowPassElement final: public IPassElement {
|
|||||||
|
|
||||||
m_pOldFramebuffer->bind();
|
m_pOldFramebuffer->bind();
|
||||||
g_pHyprOpenGL->m_renderData.currentFB = m_pOldFramebuffer;
|
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 {
|
bool needsLiveBlur() override {
|
||||||
@ -128,7 +133,7 @@ void hkRenderWindow(
|
|||||||
CHyprRenderer* pRenderer = (CHyprRenderer*)thisptr;
|
CHyprRenderer* pRenderer = (CHyprRenderer*)thisptr;
|
||||||
|
|
||||||
const bool shouldWobble = [&]() -> bool {
|
const bool shouldWobble = [&]() -> bool {
|
||||||
if (mode == RENDER_PASS_MAIN) {
|
if (mode == RENDER_PASS_MAIN or mode == RENDER_PASS_ALL) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,14 +144,24 @@ void hkRenderWindow(
|
|||||||
|
|
||||||
if (shouldWobble) {
|
if (shouldWobble) {
|
||||||
PHLWINDOWREF ref {pWindow};
|
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)) {
|
if (!g_windowFramebuffers.contains(ref)) {
|
||||||
g_windowFramebuffers[ref] = CFramebuffer {};
|
g_windowFramebuffers[ref].alloc(framebufferSize.x, framebufferSize.y);
|
||||||
g_windowFramebuffers[ref].alloc(pWindow->m_size.x, pWindow->m_size.y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pRenderer->m_renderPass.add(
|
auto&& windowFB = g_windowFramebuffers.at(ref);
|
||||||
makeUnique<CBindOwnFramebufferPassElement>(&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...
|
// then call the original...
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user