PDA

View Full Version : glScalef and glRotatef



SilviaLollipop
07-03-2013, 06:45 AM
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.

elFarto
07-03-2013, 07:05 AM
Without quite understanding what your issue is, you could try moving the glScalef after the glRotatef commands.

Regards
elFarto

SilviaLollipop
07-03-2013, 07:27 AM
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

Dan Bartlett
07-03-2013, 09:14 AM
You probably need to adjust your near + far clipping planes. For more details on OpenGL transformations, see http://www.songho.ca/opengl/gl_transform.html + read about the projection matrix.

marcClintDion
07-03-2013, 11:02 PM
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.

V-man
07-04-2013, 09:18 AM
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);