mirror of
https://git.allpurposem.at/mat/WiggleWobble.git
synced 2025-12-23 21:11:29 +01:00
fix: improve rendering somewhat but still has damage & order issues
This commit is contained in:
parent
1059a997f3
commit
fd86b84cdf
53
src/main.cpp
53
src/main.cpp
@ -47,14 +47,12 @@ class CBindOwnFramebufferPassElement final: public IPassElement {
|
|||||||
m_pFramebuffer->bind();
|
m_pFramebuffer->bind();
|
||||||
g_pHyprOpenGL->m_renderData.currentFB = m_pFramebuffer;
|
g_pHyprOpenGL->m_renderData.currentFB = m_pFramebuffer;
|
||||||
|
|
||||||
GLCALL(glClearColor(0, 0, 0, 0));
|
GLCALL(glClearColor(1, 0, 0, 0));
|
||||||
GLCALL(glClear(GL_COLOR_BUFFER_BIT));
|
GLCALL(glClear(GL_COLOR_BUFFER_BIT));
|
||||||
|
|
||||||
g_pHyprRenderer->damageMonitor(g_pHyprOpenGL->m_renderData.pMonitor.lock());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsLiveBlur() override {
|
bool needsLiveBlur() override {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsPrecomputeBlur() override {
|
bool needsPrecomputeBlur() override {
|
||||||
@ -66,7 +64,11 @@ class CBindOwnFramebufferPassElement final: public IPassElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::optional<CBox> boundingBox() override {
|
std::optional<CBox> boundingBox() override {
|
||||||
return g_pHyprOpenGL->m_renderData.pMonitor->logicalBox();
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
|
CRegion opaqueRegion() override {
|
||||||
|
return CRegion {};
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -148,6 +150,11 @@ class CWobblyWindow {
|
|||||||
const bool shouldEnd =
|
const bool shouldEnd =
|
||||||
m_windowMovement.size() == 0 and totalVel.size() / m_particles.size() < .001f;
|
m_windowMovement.size() == 0 and totalVel.size() / m_particles.size() < .001f;
|
||||||
|
|
||||||
|
// std::println(
|
||||||
|
// "Top left: {}, totalVel: {}",
|
||||||
|
// m_particles[0].position,
|
||||||
|
// totalVel.size() / m_particles.size()
|
||||||
|
// );
|
||||||
m_windowMovement = Vector2D {};
|
m_windowMovement = Vector2D {};
|
||||||
|
|
||||||
return shouldEnd;
|
return shouldEnd;
|
||||||
@ -223,7 +230,7 @@ class CRenderWobblyWindowPassElement final: public IPassElement {
|
|||||||
auto&& wobble = g_wobblyWindows[m_pWindow];
|
auto&& wobble = g_wobblyWindows[m_pWindow];
|
||||||
|
|
||||||
// TODO: these should never be nan
|
// TODO: these should never be nan
|
||||||
if (not std::isnan(wobble.m_particles[0].position.x)) {
|
// if (not std::isnan(wobble.m_particles[0].position.x)) {
|
||||||
// TODO: we need the particle positions in their own vec, to avoid this copy
|
// TODO: we need the particle positions in their own vec, to avoid this copy
|
||||||
std::vector<float> verts;
|
std::vector<float> verts;
|
||||||
verts.reserve(vertsPerRow * vertsPerRow * 2);
|
verts.reserve(vertsPerRow * vertsPerRow * 2);
|
||||||
@ -233,10 +240,8 @@ class CRenderWobblyWindowPassElement final: public IPassElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLCALL(glBindBuffer(GL_ARRAY_BUFFER, g_VBO));
|
GLCALL(glBindBuffer(GL_ARRAY_BUFFER, g_VBO));
|
||||||
GLCALL(
|
GLCALL(glBufferSubData(GL_ARRAY_BUFFER, 0, verts.size() * sizeof(float), verts.data()));
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, verts.size() * sizeof(float), verts.data())
|
// }
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// restore default verts
|
// restore default verts
|
||||||
GLCALL(glBindBuffer(GL_ARRAY_BUFFER, g_VBO));
|
GLCALL(glBindBuffer(GL_ARRAY_BUFFER, g_VBO));
|
||||||
@ -271,11 +276,16 @@ class CRenderWobblyWindowPassElement final: public IPassElement {
|
|||||||
return g_pHyprOpenGL->m_renderData.pMonitor->logicalBox();
|
return g_pHyprOpenGL->m_renderData.pMonitor->logicalBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CRegion opaqueRegion() override {
|
||||||
|
return CRegion {};
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CFramebuffer* m_pOldFramebuffer;
|
CFramebuffer* m_pOldFramebuffer;
|
||||||
PHLWINDOWREF m_pWindow;
|
PHLWINDOWREF m_pWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// TODO: unregister on close
|
||||||
void registerWindow(PHLWINDOW pWindow) {
|
void registerWindow(PHLWINDOW pWindow) {
|
||||||
g_windowPositions[pWindow] = pWindow->m_realPosition->value();
|
g_windowPositions[pWindow] = pWindow->m_realPosition->value();
|
||||||
}
|
}
|
||||||
@ -336,16 +346,15 @@ void hkRenderWindow(
|
|||||||
g_windowPositions[pWindow] = pos;
|
g_windowPositions[pWindow] = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_wobblyWindows.contains(pWindow)) {
|
return g_wobblyWindows.contains(pWindow);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}();
|
}();
|
||||||
|
|
||||||
auto* const pOldFramebuffer = g_pHyprOpenGL->m_renderData.currentFB;
|
auto* const pOldFramebuffer = g_pHyprOpenGL->m_renderData.currentFB;
|
||||||
|
|
||||||
if (shouldWobble) {
|
if (shouldWobble) {
|
||||||
|
// HACK: this should only damage the wobbly bbox
|
||||||
|
// g_pHyprRenderer->damageMonitor(g_pHyprOpenGL->m_renderData.pMonitor.lock());
|
||||||
|
|
||||||
PHLWINDOWREF ref {pWindow};
|
PHLWINDOWREF ref {pWindow};
|
||||||
|
|
||||||
const auto windowBox = pWindow->getFullWindowBoundingBox();
|
const auto windowBox = pWindow->getFullWindowBoundingBox();
|
||||||
@ -353,15 +362,13 @@ void hkRenderWindow(
|
|||||||
const auto framebufferSize =
|
const auto framebufferSize =
|
||||||
Vector2D {windowBox.x + windowBox.width, windowBox.y + windowBox.height};
|
Vector2D {windowBox.x + windowBox.width, windowBox.y + windowBox.height};
|
||||||
|
|
||||||
if (!g_windowFramebuffers.contains(ref)) {
|
// create it if not exists
|
||||||
g_windowFramebuffers[ref].alloc(framebufferSize.x, framebufferSize.y);
|
auto&& windowFB = g_windowFramebuffers[ref];
|
||||||
}
|
|
||||||
|
|
||||||
auto&& windowFB = g_windowFramebuffers.at(ref);
|
|
||||||
|
|
||||||
if (framebufferSize.x > windowFB.m_size.x or framebufferSize.y > windowFB.m_size.y) {
|
if (framebufferSize.x > windowFB.m_size.x or framebufferSize.y > windowFB.m_size.y) {
|
||||||
windowFB.release();
|
|
||||||
windowFB.alloc(framebufferSize.x, framebufferSize.y);
|
windowFB.alloc(framebufferSize.x, framebufferSize.y);
|
||||||
|
|
||||||
|
std::println("Resizing FB to size {}", framebufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
pRenderer->m_renderPass.add(makeUnique<CBindOwnFramebufferPassElement>(&windowFB));
|
pRenderer->m_renderPass.add(makeUnique<CBindOwnFramebufferPassElement>(&windowFB));
|
||||||
@ -381,7 +388,9 @@ void hkRenderWindow(
|
|||||||
|
|
||||||
if (shouldWobble) {
|
if (shouldWobble) {
|
||||||
std::erase_if(g_wobblyWindows, [&](auto&& wobble) {
|
std::erase_if(g_wobblyWindows, [&](auto&& wobble) {
|
||||||
return g_wobblyWindows[pWindow].step(time);
|
const bool shouldErase = g_wobblyWindows[pWindow].step(time);
|
||||||
|
|
||||||
|
return shouldErase;
|
||||||
});
|
});
|
||||||
|
|
||||||
pRenderer->m_renderPass.add(
|
pRenderer->m_renderPass.add(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user