PDA

View Full Version : glRotatef()

simmosn
12-14-2002, 11:48 AM
when i use the following to rotate it works:
glRotatef(45.0, 0.0, 0.0, 1.0);

however, when i rotate in any of the other axies, nothing. ie the following doesn't do anything:
glRotatef(0.0, 0.0, 45.0, 1.0),

Brian Jones
12-14-2002, 12:46 PM
Originally posted by simmosn:
however, when i rotate in any of the other axies, nothing. ie the following doesn't do anything:
glRotatef(0.0, 0.0, 45.0, 1.0),

The first argument specifies how many degree you want to rotate around an axis. The following three argument specifiy the x, y, z axis to rotate, respectively. In that statement, you're rotating the y and z axis 0 degrees. Thats why you don't see any change. Also, the last three parameters are clamped to the range of [0, 1].

honny
12-14-2002, 12:48 PM
your error is this i think :

glRotatef(angle,x,y,z);

the first parameter is the angle, the others are the axis on wich you want to rotate.

if u want to rotate set the axis to 1.0

//rotate 45 on x axis
glRotatef(45.0, 1.0, 0.0, 0.0);

//rotate 45 on y axis
glRotatef(45.0, 0.0, 1.0, 0.0);

//rotate 45 on z axis
glRotatef(45.0, 0.0, 0.0, 1.0);

Brian Jones
12-14-2002, 12:51 PM
Do something like this:
void Render()
{

glClear(GL_COLOR_BUFFER_BIT);
static float angle; // initializes angle to 0.0f

glRotatef(angle, 0.0f, 1.0f, 1.0f); // Rotate around the y and z axis.

glTranslatef(0.0f, 0.0f, -100.0f);

DrawSomeCube();

angle++;

if(angle >= 360.0f)
angle = 0.0f;

glFlush();
}

simmosn
12-14-2002, 01:18 PM
thanks for your help. i was being a bit thick, but all part of the learning process