Repository: hyprwm/Hyprland
File: src/render/OpenGL.cpp (C++)

Code before:

    useProgram(shader->program);

    if (shader == &m_shaders->m_shCM) {
        shader->setUniformInt(SHADER_TEX_TYPE, texType);
        passCMUniforms(*shader, imageDescription);
    }

    shader->setUniformMatrix3fv(SHADER_PROJ, 1, GL_TRUE, glMatrix.getMatrix());
    shader->setUniformInt(SHADER_TEX, 0);

    if ((usingFinalShader && *PDT == 0) || CRASHING)
        shader->setUniformFloat(SHADER_TIME, m_globalTimer.getSeconds() - shader->initialTime);
    else if (usingFinalShader)
        shader->setUniformFloat(SHADER_TIME, 0.f);

    if (usingFinalShader) {
        shader->setUniformInt(SHADER_WL_OUTPUT, m_renderData.pMonitor->m_id);
        shader->setUniformFloat2(SHADER_FULL_SIZE, m_renderData.pMonitor->m_pixelSize.x, m_renderData.pMonitor->m_pixelSize.y);
    }

    if (usingFinalShader && *PDT == 0) {
        shader->setUniformFloat2(
            SHADER_POINTER,
            g_pInputManager->getMouseCoordsInternal().x / m_renderData.pMonitor->m_pixelSize.x,
            g_pInputManager->getMouseCoordsInternal().y / m_renderData.pMonitor->m_pixelSize.y
        );
    }
    else if (usingFinalShader)
        shader->setUniformFloat2(SHADER_POINTER, 0.f, 0.f);

    if (CRASHING) {
        shader->setUniformFloat(SHADER_DISTORT, g_pHyprRenderer->m_crashingDistort);
        shader->setUniformFloat2(SHADER_FULL_SIZE, m_renderData.pMonitor->m_pixelSize.x, m_renderData.pMonitor->m_pixelSize.y);
    }

    if (!usingFinalShader) {
        shader->setUniformFloat(SHADER_ALPHA, alpha);

        if (discardActive) {
            shader->setUniformInt(SHADER_DISCARD_OPAQUE, !!(m_renderData.discardMode & DISCARD_OPAQUE));
            shader->setUniformInt(SHADER_DISCARD_ALPHA, !!(m_renderData.discardMode & DISCARD_ALPHA));
            shader->setUniformFloat(SHADER_DISCARD_ALPHA_VALUE, m_renderData.discardOpacity);
        } else {
            shader->setUniformInt(SHADER_DISCARD_OPAQUE, 0);
            shader->setUniformInt(SHADER_DISCARD_ALPHA, 0);
        }
    }

    CBox transformedBox = newBox;
    transformedBox.transform(wlTransformToHyprutils(invertTransform(m_renderData.pMonitor->m_transform)), m_renderData.pMonitor->m_transformedSize.x,

Review comment (suggestion):
nuh uh, mouse coords are in logical space. Gl vec would be:
```cpp
g_pInputManager->getMouseCoordsInternal().translate(-pMonitor->vecPosition).scale(pMonitor->scale).transform(pMonitor->transform, pMonitor->vecTransformedSize.x, pMonitor->vecTransformedSize.y);
```
With the transform order I am not sure. Please check it.

Code after:

    useProgram(shader->program);

    if (shader == &m_shaders->m_shCM) {
        shader->setUniformInt(SHADER_TEX_TYPE, texType);
        passCMUniforms(*shader, imageDescription);
    }

    shader->setUniformMatrix3fv(SHADER_PROJ, 1, GL_TRUE, glMatrix.getMatrix());
    shader->setUniformInt(SHADER_TEX, 0);

    if ((usingFinalShader && *PDT == 0) || CRASHING)
        shader->setUniformFloat(SHADER_TIME, m_globalTimer.getSeconds() - shader->initialTime);
    else if (usingFinalShader)
        shader->setUniformFloat(SHADER_TIME, 0.f);

    if (usingFinalShader) {
        shader->setUniformInt(SHADER_WL_OUTPUT, m_renderData.pMonitor->m_id);
        shader->setUniformFloat2(SHADER_FULL_SIZE, m_renderData.pMonitor->m_pixelSize.x, m_renderData.pMonitor->m_pixelSize.y);
    }

    if (usingFinalShader && *PDT == 0) {
        PHLMONITORREF pMonitor = m_renderData.pMonitor;
        Vector2D      p        = ((g_pInputManager->getMouseCoordsInternal() - pMonitor->m_position) * pMonitor->m_scale);
        p                      = p.transform(wlTransformToHyprutils(pMonitor->m_transform), pMonitor->m_pixelSize);
        shader->setUniformFloat2(SHADER_POINTER, p.x / pMonitor->m_pixelSize.x, p.y / pMonitor->m_pixelSize.y);
    } else if (usingFinalShader)
        shader->setUniformFloat2(SHADER_POINTER, 0.f, 0.f);

    if (CRASHING) {
        shader->setUniformFloat(SHADER_DISTORT, g_pHyprRenderer->m_crashingDistort);
        shader->setUniformFloat2(SHADER_FULL_SIZE, m_renderData.pMonitor->m_pixelSize.x, m_renderData.pMonitor->m_pixelSize.y);
    }

    if (!usingFinalShader) {
        shader->setUniformFloat(SHADER_ALPHA, alpha);

        if (discardActive) {
            shader->setUniformInt(SHADER_DISCARD_OPAQUE, !!(m_renderData.discardMode & DISCARD_OPAQUE));
            shader->setUniformInt(SHADER_DISCARD_ALPHA, !!(m_renderData.discardMode & DISCARD_ALPHA));
            shader->setUniformFloat(SHADER_DISCARD_ALPHA_VALUE, m_renderData.discardOpacity);
        } else {
            shader->setUniformInt(SHADER_DISCARD_OPAQUE, 0);
            shader->setUniformInt(SHADER_DISCARD_ALPHA, 0);
        }
    }

    CBox transformedBox = newBox;
    transformedBox.transform(wlTransformToHyprutils(invertTransform(m_renderData.pMonitor->m_transform)), m_renderData.pMonitor->m_transformedSize.x,
                             m_renderData.pMonitor->m_transformedSize.y);