glScalef and glRotatef

I want to use glScalef to zoom, but if after I use glRotatef, the image is cut.

This is the code:

glMatrixMode (GL_MODELVIEW);
**** glLoadIdentity ();
**** glScalef (scale, scale, scale);
**** glRotatef (rot_x, 1.0,0.0,0.0);
**** glRotatef (rot_y, 0.0,1.0,0.0);
**** glRotatef (rot_z, 0.0,0.0,1.0);

What can I do to make them compatible?

Thank you.

Without quite understanding what your issue is, you could try moving the glScalef after the glRotatef commands.


Thank you, but I have the same problem.
My problem is that if I do scale and rotate my image is cut, i can´t see all the image

You probably need to adjust your near + far clipping planes. For more details on OpenGL transformations, see OpenGL Transformation + read about the projection matrix.

I would start out by putting the scaling after the rotations. I’m not sure what you mean by “the image is cut”, but the way you have things set up, currently you will be scaling the rotations that come after it.

I would do zoom on the projection matrix. If you want a perspective matrix, use glFrustum. If you want a orthogonal matrix, use glOrtho.
In both cases, the idea is the same. To zoom in, lower the values for {left, right, bottom, top} by a certain factor of your choice.

If you do want to proceed with your method, the scale function should be the last operation.
You can think of these operations as starting from bottom to top. Scale happens first, then the rotations.
glLoadIdentity ();
**** glRotatef (rot_x, 1.0,0.0,0.0);
**** glRotatef (rot_y, 0.0,1.0,0.0);
**** glRotatef (rot_z, 0.0,0.0,1.0);
**** glScalef (scale, scale, scale);