Hello everyone.
Im trying to construct a cube using quads.ie translate and rotate quads.
Now i want to rotate the cube as well.Im not able to figure out how i can achieve that.Can anyone please help?
Thanks in advance.
void Cube()
{
glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(X += 10 , 1, 0, 1);
for(int i = 1; i <= 6; i++)
DrawCube(i);
Sleep(1000);
}
void DrawCube(int side)
{
if(side == 1){
glTranslatef(0 , 10, 0);
glRotatef(90 , 1, 0, 0);
}
if(side == 2){
glTranslatef(0 , -10, 0);
glRotatef(90 , 1, 0, 0);
}else if(side == 3){
glTranslatef(-10 , 0, 0);
glRotatef(90 , 0, 1, 0);
}else if(side == 4){
glTranslatef(10 , 0, 0);
glRotatef(90 , 0, 1, 0);
}else if(side == 5){
glTranslatef(0 , 0, 10);
}else if(side == 6){
glTranslatef(0 , 0, -10);
}
glColor3f(1, 1 , 0);
glBegin(GL_QUADS);
glVertex3i(-10, -10, 0);
glColor3f(1, 1 , 0);
glVertex3i(-10, 10, 0);
glColor3f(1, 0 , 1);
glVertex3i(10, 10, 0);
glColor3f(1, 0 , 0);
glVertex3i(10, -10, 0);
glEnd();
glFlush();
glLoadIdentity();
}
Cube() is my idle function.So basically, i want to rotate the cube.( a 20x20x20 cube)