the program is drawing in the order of the code, not of the Z-value
im trying to draw cube/map/cube
output is cube/cube/map
quard(int x1,int x2, int y1, int y2, int add)
add is the Z-value
any idea?
Code: Select all
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,640,0,480,10,-10);
glMatrixMode( GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glClearDepth (1.0f);
glEnable(GL_TEXTURE_2D);
glShadeModel(GL_FLAT);
while (1)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, tex_cube.id); //z=3 cube
quard(200,440, 360, 120, 3);
glBindTexture(GL_TEXTURE_2D, tex_cube.id); //z=1 cube
quard(200,440, 360, 120, 1);
glBindTexture(GL_TEXTURE_2D, tex_map.id); //z=2 map
quard(64,576, 440, 40, 2);
glutSwapBuffers();
Code: Select all
void quard(int x1,int x2, int y1, int y2, int add){
glBegin(GL_QUADS);
glColor4f(1.0,1.0,1.0,1.0f);
glTexCoord2f(0,1);
glVertex3f(x1,y1,add);
glTexCoord2f(1,1);
glVertex3f(x2,y1,add);
glTexCoord2f(1,0);
glVertex3f(x2,y2,add);
glTexCoord2f(0,0);
glVertex3f(x1,y2,add);
glEnd();
}