mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 16:13:21 +02:00
fix: move to Mat3x3 from hyprutils
This commit is contained in:
parent
ddfea3a29c
commit
98c006aeae
2 changed files with 25 additions and 30 deletions
|
@ -4,6 +4,8 @@ authors = "Virt"
|
||||||
commit_pins = [
|
commit_pins = [
|
||||||
# v Hyprland v hypr-dynamic-cursors
|
# v Hyprland v hypr-dynamic-cursors
|
||||||
["918d8340afd652b011b937d29d5eea0be08467f5", "f0409be76564171a97a792deabab3bd0528fe40c"], # v0.41.2
|
["918d8340afd652b011b937d29d5eea0be08467f5", "f0409be76564171a97a792deabab3bd0528fe40c"], # v0.41.2
|
||||||
|
["9a09eac79b85c846e3a865a9078a3f8ff65a9259", "ddfea3a29c9badf6dabe12be86e4c5ba6d5507ad"], # v0.42.0
|
||||||
|
["0f594732b063a90d44df8c5d402d658f27471dfe", "ddfea3a29c9badf6dabe12be86e4c5ba6d5507ad"], # v0.43.0
|
||||||
]
|
]
|
||||||
|
|
||||||
[dynamic-cursors]
|
[dynamic-cursors]
|
||||||
|
|
|
@ -15,43 +15,38 @@
|
||||||
/*
|
/*
|
||||||
This is the projectBox method from hyprland, but with support for rotation around a point, the hotspot.
|
This is the projectBox method from hyprland, but with support for rotation around a point, the hotspot.
|
||||||
*/
|
*/
|
||||||
void projectCursorBox(float mat[9], CBox& box, eTransform transform, float rotation, const float projection[9], Vector2D hotspot, float stretchAngle, Vector2D stretch) {
|
Mat3x3 projectCursorBox(CBox& box, eTransform transform, float rotation, const Mat3x3& projection, Vector2D hotspot, float stretchAngle, Vector2D stretch) {
|
||||||
double x = box.x;
|
auto mat = Mat3x3::identity();
|
||||||
double y = box.y;
|
mat.translate(box.pos());
|
||||||
double width = box.width;
|
|
||||||
double height = box.height;
|
|
||||||
|
|
||||||
matrixIdentity(mat);
|
|
||||||
matrixTranslate(mat, x, y);
|
|
||||||
|
|
||||||
if (stretch != Vector2D{1,1}) {
|
if (stretch != Vector2D{1,1}) {
|
||||||
// center to origin, rotate, shift up, scale, undo
|
// center to origin, rotate, shift up, scale, undo
|
||||||
// we do the shifting up so the stretch is "only to one side"
|
// we do the shifting up so the stretch is "only to one side"
|
||||||
|
|
||||||
matrixTranslate(mat, box.w / 2, box.h / 2);
|
mat.translate({box.w / 2, box.h / 2});
|
||||||
matrixRotate(mat, stretchAngle);
|
mat.rotate(stretchAngle);
|
||||||
matrixTranslate(mat, 0, box.h / 2);
|
mat.translate({0.f, box.h / 2});
|
||||||
matrixScale(mat, stretch.x, stretch.y);
|
mat.scale(stretch);
|
||||||
matrixTranslate(mat, 0, box.h / -2);
|
mat.translate({0.f, box.h / -2});
|
||||||
matrixRotate(mat, -stretchAngle);
|
mat.rotate(-stretchAngle);
|
||||||
matrixTranslate(mat, box.w / -2, box.h / -2);
|
mat.translate({box.w / -2, box.h / -2});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rotation != 0) {
|
if (rotation != 0) {
|
||||||
matrixTranslate(mat, hotspot.x, hotspot.y);
|
mat.translate(hotspot);
|
||||||
matrixRotate(mat, rotation);
|
mat.rotate(rotation);
|
||||||
matrixTranslate(mat, -hotspot.x, -hotspot.y);
|
mat.translate(-hotspot);
|
||||||
}
|
}
|
||||||
|
|
||||||
matrixScale(mat, width, height);
|
mat.scale(box.size());
|
||||||
|
|
||||||
if (transform != HYPRUTILS_TRANSFORM_NORMAL) {
|
if (transform != HYPRUTILS_TRANSFORM_NORMAL) {
|
||||||
matrixTranslate(mat, 0.5, 0.5);
|
mat.translate({0.5, 0.5});
|
||||||
matrixTransform(mat, transform);
|
mat.transform(transform);
|
||||||
matrixTranslate(mat, -0.5, -0.5);
|
mat.translate({-0.5, -0.5});
|
||||||
}
|
}
|
||||||
|
|
||||||
matrixMultiply(mat, projection, mat);
|
return projection.copy().multiply(mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -77,11 +72,9 @@ void renderCursorTextureInternalWithDamage(SP<CTexture> tex, CBox* pBox, CRegion
|
||||||
|
|
||||||
// get transform
|
// get transform
|
||||||
const auto TRANSFORM = wlTransformToHyprutils(invertTransform(!g_pHyprOpenGL->m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : g_pHyprOpenGL->m_RenderData.pMonitor->transform));
|
const auto TRANSFORM = wlTransformToHyprutils(invertTransform(!g_pHyprOpenGL->m_bEndFrame ? WL_OUTPUT_TRANSFORM_NORMAL : g_pHyprOpenGL->m_RenderData.pMonitor->transform));
|
||||||
float matrix[9];
|
Mat3x3 matrix = projectCursorBox(newBox, TRANSFORM, newBox.rot, g_pHyprOpenGL->m_RenderData.monitorProjection, hotspot, stretchAngle, stretch);
|
||||||
projectCursorBox(matrix, newBox, TRANSFORM, newBox.rot, g_pHyprOpenGL->m_RenderData.monitorProjection.data(), hotspot, stretchAngle, stretch);
|
|
||||||
|
|
||||||
float glMatrix[9];
|
Mat3x3 glMatrix = g_pHyprOpenGL->m_RenderData.projection.copy().multiply(matrix);
|
||||||
matrixMultiply(glMatrix, g_pHyprOpenGL->m_RenderData.projection, matrix);
|
|
||||||
|
|
||||||
CShader* shader = nullptr;
|
CShader* shader = nullptr;
|
||||||
|
|
||||||
|
@ -106,11 +99,11 @@ void renderCursorTextureInternalWithDamage(SP<CTexture> tex, CBox* pBox, CRegion
|
||||||
glUseProgram(shader->program);
|
glUseProgram(shader->program);
|
||||||
|
|
||||||
#ifndef GLES2
|
#ifndef GLES2
|
||||||
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix);
|
glUniformMatrix3fv(shader->proj, 1, GL_TRUE, glMatrix.getMatrix().data());
|
||||||
#else
|
#else
|
||||||
matrixTranspose(glMatrix, glMatrix);
|
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix.transpose().getMatrix().data());
|
||||||
glUniformMatrix3fv(shader->proj, 1, GL_FALSE, glMatrix);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
glUniform1i(shader->tex, 0);
|
glUniform1i(shader->tex, 0);
|
||||||
glUniform1f(shader->alpha, alpha);
|
glUniform1f(shader->alpha, alpha);
|
||||||
glUniform1i(shader->discardOpaque, 0);
|
glUniform1i(shader->discardOpaque, 0);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue