Just translating some simple C++/glm/opengl tutorial code to D/gl3n/opengl and I'm coming across more friction than I expected. I've got a square centered at my window which is rotated by 45 degrees (counter clockwise) and then moved to the lower right quadrant.

// C++ glm opengl code
glm::mat4 transform;
transform = glm::translate(transform, glm::vec3(0.0f, -0.5f, 0.0f)); transform = glm::rotate(transform, 45.0f, vec3(0.0f, 0.0f, 1.0f)); // degrees


// D gl3n opengl code
mat4 transform = mat4.identity;
transform = transform.translation(vec3(0.5f, -0.5f, 0.0f));
transform = transform.rotate(0.78539, vec3(0.0f, 0.0f, 1.0f)); // radians

My D code performs the operations fine, but in the _opposite_ order.

I thought just swapping the order would fix things:

transform = transform.rotate(0.78539, vec3(0.0f, 0.0f, 1.0f));
transform = transform.translation(vec3(0.5f, -0.5f, 0.0f));

but now the square is moved to the lower right corner but no rotation happened?

So am I using gl3n incorrectly? Are there tricks or techniques I' missing? Is gl3n not a direct replacement for glm?

Any advice is greatly appreciated. Thanks.


Reply via email to