I´ve been doing some basic code in OpenGL with Mac OS. I´m currently using Xcode 4.0.2 with the integrated OpenGL Framework (I really don´t know which version it is or where to find out)
anyway… I am having hard time to understand (or get to work) the glTranslatef function with z values. Here´s my code:
glLoadIdentity();
glTranslatef(-0.5, 0.0, 0.0);
glBegin(GL_QUADS);
{
//Front
glTexCoord2f(0.0, 0.0);
glVertex3f(-0.5,-0.5,0.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(0.5,-0.5,0.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(0.5,0.5,0.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-0.5,0.5,0.0);
}
glEnd();
glLoadIdentity();
glTranslatef(0.0, 0.0, 1.0);
glRotatef(45.0, 0.0, 0.0, 1.0);
glBegin(GL_QUADS);
{
//Front
glTexCoord2f(0.0, 0.0);
glVertex3f(-0.5,-0.5,0.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(0.5,-0.5,0.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(0.5,0.5,0.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-0.5,0.5,0.0);
}
glEnd();
Now, I change values of the glTranslatef in z, expecting the second square to move either forward or backward (thus, increasing or reducing it´s size since its closer or further from the view and being drawn either in front or in the back of the other square) but all I get is either the same size of the square or no square at all and always in front of the first square… any ideas?
Thanks in advance!