I’ve got 4 cubes made of quads rotating around 0,0,0. The problem is, that the quads appear in the correct order when I render them, but it looks like the cubes are rendered one after the other in a way, that the newly drawn cubes are drawn in front of the old ones.
It’s like no depth sorting was used - but only when rendering the cubes (and not the quads of a cube).
I’ll post a piece of my code (as short as possible), maybe someone will find something I haven’t.
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode( GL_PROJECTION );glPushMatrix();glLoadIdentity();
gluPerspective( 80, 1.3, 0,1000.0 );
gluLookAt(0, 0, 5, 0,0,0, 0,1,0);
In the init() I also wrote:
I ‘stole’ the normals and the vertices’ data from the NeHe ‘Missile mapping’ lesson, so, they should be correct:
x1= 0+x; y1= 0+y; z1=5;
x2= 5+x; y2= 0+y; z2=5;
x3= 5+x; y3= 5+y; z3=5;
x4= 0+x; y4= 5+y; z4=5;
x1= 0+x; y1= 0+y; z1= 0;
x2= 0+x; y2= 5+y; z2= 0;
x3= 5+x; y3= 5+y; z3= 0;
x4= 5+x; y4= 0+y; z4= 0;
And so on…
I know, that drawing 2 cubes is a basic thing to do and I’ve done harder tricks already, but now, I’m really stuck… I think I missed someting.
Please, someone help me