Rotation problem

Hello,
I loaded my model from an STL file, I don`t have any problem to display and translate it, the problem is when I try to rotate.
My gl_postion is:

gl_Position = projection * rotation * translation * model * position;

Where projection is orthographic matrix, rotation is a simple rotation around Y, translation is a matrix translation of (400, 300, 0) as my window is 800x600, and model is a simple identity matrix.

I think the problem is about axis rotation, I thought that a simple translation to the center could resolve the problem, but it isn`t that.

Could someone help me?

Thank you

The viewport transformation will place the clip-space origin in the centre of the viewport. Normally, you’d define the projection matrix so that the eye-space origin is also in the centre of the window (e.g. for an orthographic projection, you’d make the left and right edges equal and opposite, e.g. left=-400 and right=400).

If you can’t do that (e.g. because the eye-space origin needs to be in one corner of the window), the translation should come after the projection transformation and before the rotation.

Thank you GClements for your answer,
now my ortho trasnformation is (-400, 400, -300, 300, -1.0f, 100.0f);

and my gl_postion is

rotation * projection * translation * model * position; --------> translation is 0 now

But the problem remain, seems as the model don`t rotate around its origin but around something else.

Thank you

If I rotate around Z seems OK, if I rotate for example around Y the model is stretched.
Tried some translation in Z, but no solution…