This might not be the right place to ask this, but I am really frustrated at the moment.

I have some OpenGL code that draws a cube. The problem is that some of the faces end up being partially see-through, or not visible at all from the outside. When I move inside the cube, all faces can be seen, but a second cube I placed can be seen through them.

I tried making the faces drawn anticlockwise, clockwise, I tried setting glFrontFace() to GL_CW and GL_CCW, and it changes absolutely nothing.

This exact code is also used in another of my projects and it displays fine!

What's going on?

Here is the code:

const float HALFSIZE = 8.f;

glBegin(GL_QUADS);

glTexCoord2f(0.f, 0.f); glVertex3f(-HALFSIZE, -HALFSIZE, -HALFSIZE);

glTexCoord2f(0.f, 1.f); glVertex3f(-HALFSIZE, HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 1.f); glVertex3f( HALFSIZE, HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 0.f); glVertex3f( HALFSIZE, -HALFSIZE, -HALFSIZE);

glTexCoord2f(0.f, 0.f); glVertex3f(-HALFSIZE, -HALFSIZE, HALFSIZE);

glTexCoord2f(0.f, 1.f); glVertex3f(-HALFSIZE, HALFSIZE, HALFSIZE);

glTexCoord2f(1.f, 1.f); glVertex3f( HALFSIZE, HALFSIZE, HALFSIZE);

glTexCoord2f(1.f, 0.f); glVertex3f( HALFSIZE, -HALFSIZE, HALFSIZE);

glTexCoord2f(0.f, 0.f); glVertex3f(-HALFSIZE, -HALFSIZE, -HALFSIZE);

glTexCoord2f(0.f, 1.f); glVertex3f(-HALFSIZE, HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 1.f); glVertex3f(-HALFSIZE, HALFSIZE, HALFSIZE);

glTexCoord2f(1.f, 0.f); glVertex3f(-HALFSIZE, -HALFSIZE, HALFSIZE);

glTexCoord2f(0.f, 0.f); glVertex3f(HALFSIZE, -HALFSIZE, -HALFSIZE);

glTexCoord2f(0.f, 1.f); glVertex3f(HALFSIZE, HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 1.f); glVertex3f(HALFSIZE, HALFSIZE, HALFSIZE);

glTexCoord2f(1.f, 0.f); glVertex3f(HALFSIZE, -HALFSIZE, HALFSIZE);

//this is the magenta face

glTexCoord2f(0.f, 0.f); glVertex3f(-HALFSIZE, -HALFSIZE, HALFSIZE);

glTexCoord2f(0.f, 1.f); glVertex3f(-HALFSIZE, -HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 1.f); glVertex3f( HALFSIZE, -HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 0.f); glVertex3f( HALFSIZE, -HALFSIZE, HALFSIZE);

//This is the cyan face

glTexCoord2f(0.f, 0.f); glVertex3f(-HALFSIZE, HALFSIZE, HALFSIZE);

glTexCoord2f(0.f, 1.f); glVertex3f(-HALFSIZE, HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 1.f); glVertex3f( HALFSIZE, HALFSIZE, -HALFSIZE);

glTexCoord2f(1.f, 0.f); glVertex3f( HALFSIZE, HALFSIZE, HALFSIZE);

glEnd();

And some screenshots of the problem (the faces have been coloured for your convenience - magenta is the front of the cube, cyan is the back):

http://oi56.tinypic.com/2sb6102.jpg (magenta should be in front, it's not)

http://oi55.tinypic.com/11tyfb8.jpghttp://oi56.tinypic.com/21jajp4.jpghttp://oi52.tinypic.com/5x4k0i.jpg (cyan is always in front. This is looking at the back - it looks as it should)

Note that the only face displaying correctly is the cyan one. What's different about it?

Thanks for any help, I'm really stumped by this.