From 7932e425072bd9f57af323d15265b66b2cf139f3 Mon Sep 17 00:00:00 2001 From: vaxerski Date: Sat, 10 Jun 2023 16:10:26 +0200 Subject: [PATCH] screenshader: add output uniform --- src/render/OpenGL.cpp | 15 ++++++++++----- src/render/Shader.hpp | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp index fc45663e..545b1250 100644 --- a/src/render/OpenGL.cpp +++ b/src/render/OpenGL.cpp @@ -158,8 +158,9 @@ void CHyprOpenGLImpl::end() { wlr_box monbox = {0, 0, m_RenderData.pMonitor->vecTransformedSize.x, m_RenderData.pMonitor->vecTransformedSize.y}; if (m_RenderData.mouseZoomFactor != 1.f) { - const auto ZOOMCENTER = - (m_RenderData.mouseZoomUseMouse ? g_pInputManager->getMouseCoordsInternal() - m_RenderData.pMonitor->vecPosition : m_RenderData.pMonitor->vecTransformedSize / 2.f) * m_RenderData.pMonitor->scale; + const auto ZOOMCENTER = (m_RenderData.mouseZoomUseMouse ? g_pInputManager->getMouseCoordsInternal() - m_RenderData.pMonitor->vecPosition : + m_RenderData.pMonitor->vecTransformedSize / 2.f) * + m_RenderData.pMonitor->scale; monbox.x -= ZOOMCENTER.x; monbox.y -= ZOOMCENTER.y; scaleBox(&monbox, m_RenderData.mouseZoomFactor); @@ -351,9 +352,10 @@ void CHyprOpenGLImpl::applyScreenShader(const std::string& path) { return; } - m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj"); - m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex"); - m_sFinalScreenShader.time = glGetUniformLocation(m_sFinalScreenShader.program, "time"); + m_sFinalScreenShader.proj = glGetUniformLocation(m_sFinalScreenShader.program, "proj"); + m_sFinalScreenShader.tex = glGetUniformLocation(m_sFinalScreenShader.program, "tex"); + m_sFinalScreenShader.time = glGetUniformLocation(m_sFinalScreenShader.program, "time"); + m_sFinalScreenShader.output = glGetUniformLocation(m_sFinalScreenShader.program, "output"); if (m_sFinalScreenShader.time != -1 && g_pConfigManager->getInt("debug:damage_tracking") != 0 && !g_pHyprRenderer->m_bCrashingInProgress) { // The screen shader uses the "time" uniform // Since the screen shader could change every frame, damage tracking *needs* to be disabled @@ -605,6 +607,9 @@ void CHyprOpenGLImpl::renderTextureInternalWithDamage(const CTexture& tex, wlr_b glUniform1f(shader->time, 0.f); } + if (usingFinalShader && shader->output > 0) + glUniform1i(shader->output, m_RenderData.pMonitor->ID); + if (CRASHING) { glUniform1f(shader->distort, g_pHyprRenderer->m_fCrashingDistort); glUniform2f(shader->fullSize, m_RenderData.pMonitor->vecPixelSize.x, m_RenderData.pMonitor->vecPixelSize.y); diff --git a/src/render/Shader.hpp b/src/render/Shader.hpp index 04bf9259..416e62fe 100644 --- a/src/render/Shader.hpp +++ b/src/render/Shader.hpp @@ -40,6 +40,7 @@ class CShader { GLint time; GLint distort; + GLint output; GLint getUniformLocation(const std::string&);