anhyeuem2004
03-31-2004, 09:43 AM
Hi folks,
I am very newbie in OpenGL programming. Currently, I am trying to make a moving cube (forward/backward along z axis and rotate left/right around y axis). My code in display functions as follows:
void display()
{
glLoadIdentity();
glRotatef(spin_y, 0, 1, 0);
glTranslatef(0, 0, dist_z);
glutWireCube(1.0);
glFlush();
}
where spin_y and dist_z can be changed according to key presses. The problem is that If I move the cube forward ot backward then rotate it, then it seems that the cube will not rotate around itself. Rather, it rotates around the "original" origin which is not I expect.
Can anyone have a solution for this problem please?
Thank you very much.
DND
PS: I would like to know how to put 2D texture on 1 surface of my cube created using glutWireCube(). There is no command to specify vertex here, thus I do not know how to put texture coordinate.
I am very newbie in OpenGL programming. Currently, I am trying to make a moving cube (forward/backward along z axis and rotate left/right around y axis). My code in display functions as follows:
void display()
{
glLoadIdentity();
glRotatef(spin_y, 0, 1, 0);
glTranslatef(0, 0, dist_z);
glutWireCube(1.0);
glFlush();
}
where spin_y and dist_z can be changed according to key presses. The problem is that If I move the cube forward ot backward then rotate it, then it seems that the cube will not rotate around itself. Rather, it rotates around the "original" origin which is not I expect.
Can anyone have a solution for this problem please?
Thank you very much.
DND
PS: I would like to know how to put 2D texture on 1 surface of my cube created using glutWireCube(). There is no command to specify vertex here, thus I do not know how to put texture coordinate.