diff --git a/src/main.cpp b/src/main.cpp index 1e39a33..e69ada5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,14 +47,12 @@ class CBindOwnFramebufferPassElement final: public IPassElement { m_pFramebuffer->bind(); 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)); - - g_pHyprRenderer->damageMonitor(g_pHyprOpenGL->m_renderData.pMonitor.lock()); } bool needsLiveBlur() override { - return true; + return false; } bool needsPrecomputeBlur() override { @@ -66,7 +64,11 @@ class CBindOwnFramebufferPassElement final: public IPassElement { } std::optional boundingBox() override { - return g_pHyprOpenGL->m_renderData.pMonitor->logicalBox(); + return std::nullopt; + } + + CRegion opaqueRegion() override { + return CRegion {}; } private: @@ -148,6 +150,11 @@ class CWobblyWindow { const bool shouldEnd = 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 {}; return shouldEnd; @@ -223,20 +230,18 @@ class CRenderWobblyWindowPassElement final: public IPassElement { auto&& wobble = g_wobblyWindows[m_pWindow]; // TODO: these should never be nan - if (not std::isnan(wobble.m_particles[0].position.x)) { - // TODO: we need the particle positions in their own vec, to avoid this copy - std::vector verts; - verts.reserve(vertsPerRow * vertsPerRow * 2); - for (auto&& particle : wobble.m_particles) { - verts.push_back(particle.position.x); - verts.push_back(particle.position.y); - } - - GLCALL(glBindBuffer(GL_ARRAY_BUFFER, g_VBO)); - GLCALL( - glBufferSubData(GL_ARRAY_BUFFER, 0, verts.size() * sizeof(float), verts.data()) - ); + // if (not std::isnan(wobble.m_particles[0].position.x)) { + // TODO: we need the particle positions in their own vec, to avoid this copy + std::vector verts; + verts.reserve(vertsPerRow * vertsPerRow * 2); + for (auto&& particle : wobble.m_particles) { + verts.push_back(particle.position.x); + verts.push_back(particle.position.y); } + + GLCALL(glBindBuffer(GL_ARRAY_BUFFER, g_VBO)); + GLCALL(glBufferSubData(GL_ARRAY_BUFFER, 0, verts.size() * sizeof(float), verts.data())); + // } } else { // restore default verts GLCALL(glBindBuffer(GL_ARRAY_BUFFER, g_VBO)); @@ -271,11 +276,16 @@ class CRenderWobblyWindowPassElement final: public IPassElement { return g_pHyprOpenGL->m_renderData.pMonitor->logicalBox(); } + CRegion opaqueRegion() override { + return CRegion {}; + } + private: CFramebuffer* m_pOldFramebuffer; PHLWINDOWREF m_pWindow; }; +// TODO: unregister on close void registerWindow(PHLWINDOW pWindow) { g_windowPositions[pWindow] = pWindow->m_realPosition->value(); } @@ -336,16 +346,15 @@ void hkRenderWindow( g_windowPositions[pWindow] = pos; } - if (g_wobblyWindows.contains(pWindow)) { - return true; - } - - return true; + return g_wobblyWindows.contains(pWindow); }(); auto* const pOldFramebuffer = g_pHyprOpenGL->m_renderData.currentFB; if (shouldWobble) { + // HACK: this should only damage the wobbly bbox + // g_pHyprRenderer->damageMonitor(g_pHyprOpenGL->m_renderData.pMonitor.lock()); + PHLWINDOWREF ref {pWindow}; const auto windowBox = pWindow->getFullWindowBoundingBox(); @@ -353,15 +362,13 @@ void hkRenderWindow( const auto framebufferSize = Vector2D {windowBox.x + windowBox.width, windowBox.y + windowBox.height}; - if (!g_windowFramebuffers.contains(ref)) { - g_windowFramebuffers[ref].alloc(framebufferSize.x, framebufferSize.y); - } - - auto&& windowFB = g_windowFramebuffers.at(ref); + // create it if not exists + auto&& windowFB = g_windowFramebuffers[ref]; if (framebufferSize.x > windowFB.m_size.x or framebufferSize.y > windowFB.m_size.y) { - windowFB.release(); windowFB.alloc(framebufferSize.x, framebufferSize.y); + + std::println("Resizing FB to size {}", framebufferSize); } pRenderer->m_renderPass.add(makeUnique(&windowFB)); @@ -381,7 +388,9 @@ void hkRenderWindow( if (shouldWobble) { 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(