View Full Version : simple rotation

01-10-2012, 07:31 AM
Maybe it's too late....I simply want to flip that triangle 180' so I can see it from behind. Now I've tried to add 180 to the rotations below (mpPsi+180 etc.)without success:

glBegin(GL_TRIANGLES); //position glTranslatef(floc3DX, floc3DY, floc3DZ);
glRotatef( mpPsi, 0.0f, -1.0f, 0.0f ); //heading?
glRotatef( mpTheta, 1.0f, 0.0f, 0.0f); //pitch?
glRotatef( mpPhi, 0.0f, 0.0f, -1.0f); //roll

glColor3f(0.0, 0.0, 1.0); /* blue */
glVertex3f(floc3DX, floc3DY, floc3DZ-2);
glColor3f(0.0, 1.0, 0.0); /* green */
glVertex3f(floc3DX+1, floc3DY+1, floc3DZ-2);
glColor3f(1.0, 0.0, 0.0); /* red */
glVertex3f(floc3DX-1, floc3DY+1, floc3DZ-1);

Many thanks

01-10-2012, 12:15 PM
Do not put your glTranslate & glRotate calls inside your glBegin glEnd code block. Move them before the glBegin.

01-11-2012, 12:40 AM
if i do that nothing is visible, probably drawn to far away.
if i only move glrotate before glbegin triangles are drawn randomly around (for loop but those x,y,z values do not change)
but anyway the rotations etc. are not done at all.

01-11-2012, 10:30 AM
Start mpPs etc at 0.0, and ingrement by small values.

The location you have these is close to the polygon and is in the correct location to rotate the triangle .

Remember that the modelview matrix is state and is persistent over time, it will begin where you left it at the end of the previous frame.

You should be using:

To manage which matrix you edit and ensure you start with a clean slate each frame.