Cube....
is there anything wrong with this code?? its supposed to make a cube....but when i rotate it around the walls like dissappear and then show up again...
glBegin(GL_QUADS);
//top
glColor3f(0.0, 0.0, 0.4);
glVertex3f(1.0, 1.0, -1.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(-1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
//left
glColor3f(0.5, 0.5, 0.5);
glVertex3f(-1.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(-1.0, -1.0, -1.0);
glVertex3f(-1.0, -1.0, 1.0);
//front
glColor3f(1.0, 1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glVertex3f(-1.0, 1.0, 1.0);
glVertex3f(-1.0, -1.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
//bottom
glColor3f(0.0, 0.0, 0.4);
glVertex3f(1.0, -1.0, -1.0);
glVertex3f(-1.0, -1.0, -1.0);
glVertex3f(-1.0, -1.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
//back
glColor3f(1.0, 1.0, 1.0);
glVertex3f(1.0, -1.0, -1.0);
glVertex3f(-1.0, -1.0, -1.0);
glVertex3f(-1.0, 1.0, -1.0);
glVertex3f(1.0, 1.0, -1.0);
//right
glColor3f(0.5, 0.5, 0.5);
glVertex3f(1.0, 1.0, -1.0);
glVertex3f(1.0, 1.0, 1.0);
glVertex3f(1.0, -1.0, 1.0);
glVertex3f(1.0, -1.0, -1.0);
glEnd();
It might be that the cube is too close to the camera. So you may try moving it in the the negative z direction.
Try putting something like:
glTranslatef(0.0f, 0.0f, -5.0f);
before drawing the cube.
A CRPG in development...
Need help? Well, go FAQ yourself.
Edited by - Nazrix on February 17, 2002 6:46:00 PM
Try putting something like:
glTranslatef(0.0f, 0.0f, -5.0f);
before drawing the cube.
A CRPG in development...
Need help? Well, go FAQ yourself.
Edited by - Nazrix on February 17, 2002 6:46:00 PM
also if all your vertex calls you didnt put the f after the numbers eg 0.0f, this indicates to the compiler is floating point
It could be to do with backface culling. Try putting in a "glDisable(GL_CULL_FACE);" and see if that solves it. If so, make sure you specify your vertices in the correct order (anti-clockwise = facing towards you, clockwise = facing away).
Alimonster
There are no stupid questions, but there are a lot of inquisitive idiots.
Alimonster
There are no stupid questions, but there are a lot of inquisitive idiots.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement