summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvaxerski <43317083+vaxerski@users.noreply.github.com>2022-06-28 11:30:07 +0200
committervaxerski <43317083+vaxerski@users.noreply.github.com>2022-06-28 11:30:07 +0200
commit8b4a373efa01ce2c685734cf85237456f8885944 (patch)
treebec57f8dc3763d4517aeed9b39d81d15206662f7 /src
parentc6f7eecf0f3f395a73a84526e5f41974409d5e2a (diff)
update wlroots dep
Diffstat (limited to 'src')
-rw-r--r--src/helpers/MiscFunctions.cpp58
-rw-r--r--src/helpers/MiscFunctions.hpp4
-rw-r--r--src/render/OpenGL.cpp2
3 files changed, 61 insertions, 3 deletions
diff --git a/src/helpers/MiscFunctions.cpp b/src/helpers/MiscFunctions.cpp
index d082799f..d5eece67 100644
--- a/src/helpers/MiscFunctions.cpp
+++ b/src/helpers/MiscFunctions.cpp
@@ -4,6 +4,41 @@
#include "../Compositor.hpp"
#include <sys/utsname.h>
+static const float transforms[][9] = {{
+ 1.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },{
+ 0.0f, 1.0f, 0.0f,
+ -1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },{
+ -1.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },{
+ 0.0f, -1.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },{
+ -1.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },{
+ 0.0f, 1.0f, 0.0f,
+ 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },{
+ 1.0f, 0.0f, 0.0f,
+ 0.0f, -1.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },{
+ 0.0f, -1.0f, 0.0f,
+ -1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f,
+ },
+};
+
void addWLSignal(wl_signal* pSignal, wl_listener* pListener, void* pOwner, std::string ownerString) {
ASSERT(pSignal);
ASSERT(pListener);
@@ -264,4 +299,25 @@ void logSystemInfo() {
Debug::log(LOG, "os-release:");
Debug::log(NONE, "%s", execAndGet("cat /etc/os-release").c_str());
-} \ No newline at end of file
+}
+
+void matrixProjection(float mat[9], int w, int h, wl_output_transform tr) {
+ memset(mat, 0, sizeof(*mat) * 9);
+
+ const float* t = transforms[tr];
+ float x = 2.0f / w;
+ float y = 2.0f / h;
+
+ // Rotation + reflection
+ mat[0] = x * t[0];
+ mat[1] = x * t[1];
+ mat[3] = y * -t[3];
+ mat[4] = y * -t[4];
+
+ // Translation
+ mat[2] = -copysign(1.0f, mat[0] + mat[1]);
+ mat[5] = -copysign(1.0f, mat[3] + mat[4]);
+
+ // Identity
+ mat[8] = 1.0f;
+}
diff --git a/src/helpers/MiscFunctions.hpp b/src/helpers/MiscFunctions.hpp
index 733b7ca9..108ac7f7 100644
--- a/src/helpers/MiscFunctions.hpp
+++ b/src/helpers/MiscFunctions.hpp
@@ -14,4 +14,6 @@ float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Ve
void logSystemInfo();
std::string execAndGet(const char*);
-float getPlusMinusKeywordResult(std::string in, float relative); \ No newline at end of file
+float getPlusMinusKeywordResult(std::string in, float relative);
+
+void matrixProjection(float mat[9], int w, int h, wl_output_transform tr); \ No newline at end of file
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index efd5476a..2111dca0 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -144,7 +144,7 @@ void CHyprOpenGLImpl::begin(SMonitor* pMonitor, pixman_region32_t* pDamage, bool
glViewport(0, 0, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y);
- wlr_matrix_projection(m_RenderData.projection, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, WL_OUTPUT_TRANSFORM_NORMAL); // TODO: this is deprecated
+ matrixProjection(m_RenderData.projection, pMonitor->vecPixelSize.x, pMonitor->vecPixelSize.y, WL_OUTPUT_TRANSFORM_NORMAL);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);