简体   繁体   中英

'linmath.h': Rotation after translation problem

Using 'linmath.h' , I'm trying to rotate an image after a translation. 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.

You might be looking for the next function, mat4x4_translate_in_place .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM