Archived

This topic is now archived and is closed to further replies.

branhield

Cube....

Recommended Posts

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();

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites