mirror of
https://git.allpurposem.at/mat/WiggleWobble.git
synced 2025-12-23 13:01:28 +01:00
feat: render window texture entirely via OpenGL calls
This commit is contained in:
parent
3cb4b0aa3f
commit
c6e73ad94d
51
src/main.cpp
51
src/main.cpp
@ -30,8 +30,10 @@ class CBindOwnFramebufferPassElement final: public IPassElement {
|
|||||||
|
|
||||||
void draw(const CRegion& damage) override {
|
void draw(const CRegion& damage) override {
|
||||||
m_pFramebuffer->bind();
|
m_pFramebuffer->bind();
|
||||||
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0));
|
|
||||||
g_pHyprOpenGL->m_renderData.currentFB = m_pFramebuffer;
|
g_pHyprOpenGL->m_renderData.currentFB = m_pFramebuffer;
|
||||||
|
|
||||||
|
// TODO: this is not working
|
||||||
|
g_pHyprOpenGL->clear(CHyprColor(0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsLiveBlur() override {
|
bool needsLiveBlur() override {
|
||||||
@ -62,20 +64,57 @@ class CRenderWobblyWindowPassElement final: public IPassElement {
|
|||||||
|
|
||||||
void draw(const CRegion& damage) override {
|
void draw(const CRegion& damage) override {
|
||||||
auto* const pWindowFB = g_pHyprOpenGL->m_renderData.currentFB;
|
auto* const pWindowFB = g_pHyprOpenGL->m_renderData.currentFB;
|
||||||
pWindowFB->getTexture()->bind();
|
|
||||||
|
|
||||||
m_pOldFramebuffer->bind();
|
m_pOldFramebuffer->bind();
|
||||||
g_pHyprOpenGL->m_renderData.currentFB = m_pOldFramebuffer;
|
g_pHyprOpenGL->m_renderData.currentFB = m_pOldFramebuffer;
|
||||||
|
|
||||||
const auto windowBox = m_pWindow->getFullWindowBoundingBox();
|
const auto windowBox = m_pWindow->getFullWindowBoundingBox();
|
||||||
|
|
||||||
g_pHyprOpenGL->m_renderData.primarySurfaceUVTopLeft =
|
CBox newBox = windowBox;
|
||||||
Vector2D {windowBox.x, windowBox.y} / pWindowFB->m_size;
|
g_pHyprOpenGL->m_renderData.renderModif.applyToBox(newBox);
|
||||||
g_pHyprOpenGL->m_renderData.primarySurfaceUVBottomRight =
|
|
||||||
|
// get transform
|
||||||
|
const auto TRANSFORM =
|
||||||
|
wlTransformToHyprutils(invertTransform(g_pHyprOpenGL->m_renderData.pMonitor->m_transform
|
||||||
|
));
|
||||||
|
|
||||||
|
Mat3x3 matrix =
|
||||||
|
g_pHyprOpenGL->m_renderData.monitorProjection.projectBox(newBox, TRANSFORM, newBox.rot);
|
||||||
|
Mat3x3 glMatrix = g_pHyprOpenGL->m_renderData.projection.copy().multiply(matrix);
|
||||||
|
|
||||||
|
SShader* shader = &g_pHyprOpenGL->m_shaders->m_shRGBA;
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
pWindowFB->getTexture()->bind();
|
||||||
|
|
||||||
|
g_pHyprOpenGL->useProgram(shader->program);
|
||||||
|
shader->setUniformMatrix3fv(SHADER_PROJ, 1, GL_TRUE, glMatrix.getMatrix());
|
||||||
|
shader->setUniformInt(SHADER_TEX, 0);
|
||||||
|
glBindVertexArray(shader->uniformLocations[SHADER_SHADER_VAO]);
|
||||||
|
|
||||||
|
const Vector2D UVTopLeft = Vector2D {windowBox.x, windowBox.y} / pWindowFB->m_size;
|
||||||
|
const Vector2D UVBottomRight =
|
||||||
Vector2D {windowBox.x + windowBox.width, windowBox.y + windowBox.height}
|
Vector2D {windowBox.x + windowBox.width, windowBox.y + windowBox.height}
|
||||||
/ pWindowFB->m_size;
|
/ pWindowFB->m_size;
|
||||||
|
|
||||||
g_pHyprOpenGL->renderTexture(pWindowFB->getTexture(), windowBox, 1.0f, 0, 0.f, false, true);
|
const float UVs[] = {
|
||||||
|
(float)UVBottomRight.x,
|
||||||
|
(float)UVTopLeft.y,
|
||||||
|
(float)UVTopLeft.x,
|
||||||
|
(float)UVTopLeft.y,
|
||||||
|
(float)UVBottomRight.x,
|
||||||
|
(float)UVBottomRight.y,
|
||||||
|
(float)UVTopLeft.x,
|
||||||
|
(float)UVBottomRight.y,
|
||||||
|
};
|
||||||
|
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, shader->uniformLocations[SHADER_SHADER_VBO_UV]);
|
||||||
|
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(UVs), UVs);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|
||||||
|
glBindVertexArray(0);
|
||||||
|
pWindowFB->getTexture()->unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool needsLiveBlur() override {
|
bool needsLiveBlur() override {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user