[英]'linmath.h': Rotation after translation problem
Using 'linmath.h' , I'm trying to rotate an image after a translation.使用'linmath.h' ,我试图在翻译后旋转图像。 However, after the translation, the image doesn't move at all.但是,翻译后,图像根本不动。
In the vextex shader, I have在顶点着色器中,我有
gl_Position = transform * vec4(aPos, 1.0);
and in the program, I have在程序中,我有
mat4x4 transform;
mat4x4_identity(transform);
mat4x4_rotate(transform, transform, 0.0f, 0.0f, 1.0f, (float) glfwGetTime());
mat4x4_translate(transform, 0.5f, -0.5f, 0.0f);
I want to point out that translating an image after a rotation (ie, swapping the last two lines) works fine, so I don't know what could be wrong.我想指出,在旋转后翻译图像(即交换最后两行)效果很好,所以我不知道可能出了什么问题。
If you take a peek at the source for mat4x4_translate
, you can see it resets the matrix to identity first.如果您查看mat4x4_translate
的源代码,您可以看到它首先将矩阵重置为恒等式。
You might be looking for the next function, mat4x4_translate_in_place
.您可能正在寻找下一个 function, mat4x4_translate_in_place
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.