I'm trying to draw a square room in openGL, and I have this:
void drawWalls()
{
glColor3f(1,0,0);
glPushMatrix();
//glRotatef(0,0,0,1);
//glScalef(2,1,2);
glBegin(GL_QUADS);
/* Floor */
glVertex3f(-1,-1,-1);
glVertex3f(1,-1,-1);
glVertex3f(1,-1,1);
glVertex3f(-1,-1,1);
/* Ceiling */
glVertex3f(-1,1,-1);
glVertex3f(1,1,-1);
glVertex3f(1,1,1);
glVertex3f(-1,1,1);
/* Walls */
glVertex3f(-1,-1,1);
glVertex3f(1,-1,1);
glVertex3f(1,1,1);
glVertex3f(-1,1,1);
glVertex3f(-1,-1,-1);
glVertex3f(1,-1,-1);
glVertex3f(1,1,-1);
glVertex3f(-1,1,-1);
glVertex3f(1,1,1);
glVertex3f(1,-1,1);
glVertex3f(1,-1,-1);
glVertex3f(1,1,-1);
glVertex3f(-1,1,1);
glVertex3f(-1,-1,1);
glVertex3f(-1,-1,-1);
glVertex3f(-1,1,-1);
glEnd();
glPopMatrix();
}
For whatever reasons, it's not drawing all of my sides! I've looked through my vector and it appears to be correct... But when you look inside, you see this:

What am I doing wrong? Or if possible, is there a better way to draw a room rather than this? Thanks
Your floor is defined clockwise, while your ceiling is defined counter clockwise (concerning the normals I implied from your description). When culling is enabled every quad that faces away from the camera isn't drawn.
In order to fix this, the floor has to be defined like this:
(-1, -1, -1)
(-1, -1, 1)
(1, -1, 1)
(1, -1, -1)
Do the same with your other walls that don't show up. Just define them counter clockwise, too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With