Problems just resizing a cube

Hi,

i have found the code below to draw a cube.

Then i have modified the code to draw a another cube but ten times bigger.

The original code shows a very little cube without problems.

But the second code i have write dont show anything at all…

This is the original code:

glBegin(GL_QUADS); // Draw The Cube Using quads
glColor3f(0.0f,1.0f,0.0f); // Color Blue
glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Top)
glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Top)
glVertex3f(-1.0f, 1.0f, 1.0f); // Bottom Left Of The Quad (Top)
glVertex3f( 1.0f, 1.0f, 1.0f); // Bottom Right Of The Quad (Top)
glColor3f(1.0f,0.5f,0.0f); // Color Orange
glVertex3f( 1.0f,-1.0f, 1.0f); // Top Right Of The Quad (Bottom)
glVertex3f(-1.0f,-1.0f, 1.0f); // Top Left Of The Quad (Bottom)
glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad (Bottom)
glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad (Bottom)
glColor3f(1.0f,0.0f,0.0f); // Color Red
glVertex3f( 1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Front)
glVertex3f(-1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Front)
glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad (Front)
glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad (Front)
glColor3f(1.0f,1.0f,0.0f); // Color Yellow
glVertex3f( 1.0f,-1.0f,-1.0f); // Top Right Of The Quad (Back)
glVertex3f(-1.0f,-1.0f,-1.0f); // Top Left Of The Quad (Back)
glVertex3f(-1.0f, 1.0f,-1.0f); // Bottom Left Of The Quad (Back)
glVertex3f( 1.0f, 1.0f,-1.0f); // Bottom Right Of The Quad (Back)
glColor3f(0.0f,0.0f,1.0f); // Color Blue
glVertex3f(-1.0f, 1.0f, 1.0f); // Top Right Of The Quad (Left)
glVertex3f(-1.0f, 1.0f,-1.0f); // Top Left Of The Quad (Left)
glVertex3f(-1.0f,-1.0f,-1.0f); // Bottom Left Of The Quad (Left)
glVertex3f(-1.0f,-1.0f, 1.0f); // Bottom Right Of The Quad (Left)
glColor3f(1.0f,0.0f,1.0f); // Color Violet
glVertex3f( 1.0f, 1.0f,-1.0f); // Top Right Of The Quad (Right)
glVertex3f( 1.0f, 1.0f, 1.0f); // Top Left Of The Quad (Right)
glVertex3f( 1.0f,-1.0f, 1.0f); // Bottom Left Of The Quad (Right)
glVertex3f( 1.0f,-1.0f,-1.0f); // Bottom Right Of The Quad (Right)
glEnd();

This is the code i have modified to make the cube 10 times bigger.

// Draw a filled rectangle with current color
glBegin(GL_QUADS); // Draw The Cube Using quads
glColor3f(0.0f,10.0f,0.0f); // Color Blue
glVertex3f( 10.0f, 10.0f,-10.0f); // Top Right Of The Quad (Top)
glVertex3f(-10.0f, 10.0f,-10.0f); // Top Left Of The Quad (Top)
glVertex3f(-10.0f, 10.0f, 10.0f); // Bottom Left Of The Quad (Top)
glVertex3f( 10.0f, 10.0f, 10.0f); // Bottom Right Of The Quad (Top)
glColor3f(10.0f, 0.5f,0.0f); // Color Orange
glVertex3f( 10.0f,-10.0f, 10.0f); // Top Right Of The Quad (Bottom)
glVertex3f(-10.0f,-10.0f, 10.0f); // Top Left Of The Quad (Bottom)
glVertex3f(-10.0f,-10.0f,-10.0f); // Bottom Left Of The Quad (Bottom)
glVertex3f( 10.0f,-10.0f,-10.0f); // Bottom Right Of The Quad (Bottom)
glColor3f(10.0f,0.0f,0.0f); // Color Red
glVertex3f( 10.0f, 10.0f, 10.0f); // Top Right Of The Quad (Front)
glVertex3f(-10.0f, 10.0f, 10.0f); // Top Left Of The Quad (Front)
glVertex3f(-10.0f,-10.0f, 10.0f); // Bottom Left Of The Quad (Front)
glVertex3f( 10.0f,-10.0f, 10.0f); // Bottom Right Of The Quad (Front)
glColor3f(10.0f,10.0f,0.0f); // Color Yellow
glVertex3f( 10.0f,-10.0f,-10.0f); // Top Right Of The Quad (Back)
glVertex3f(-10.0f,-10.0f,-10.0f); // Top Left Of The Quad (Back)
glVertex3f(-10.0f, 10.0f,-10.0f); // Bottom Left Of The Quad (Back)
glVertex3f( 10.0f, 10.0f,-10.0f); // Bottom Right Of The Quad (Back)
glColor3f(0.0f,0.0f,1.0f); // Color Blue
glVertex3f(-10.0f, 10.0f, 10.0f); // Top Right Of The Quad (Left)
glVertex3f(-10.0f, 10.0f,-10.0f); // Top Left Of The Quad (Left)
glVertex3f(-10.0f,-10.0f,-10.0f); // Bottom Left Of The Quad (Left)
glVertex3f(-10.0f,-10.0f, 10.0f); // Bottom Right Of The Quad (Left)
glColor3f(10.0f,0.0f,10.0f); // Color Violet
glVertex3f( 10.0f, 10.0f,-10.0f); // Top Right Of The Quad (Right)

And ten times more colorful as well, eh?
glColor3f(0.0f,10.0f,0.0f); // Color Blue
That’s green. :wink:

What about the missing glEnd()?

Depending on your matrix setup the cube might not even be inside the frustum but around it.

it is true… :slight_smile:

anyway, glEnd() is written also.

I dont know it is inside of the frustum. Im gonna look for more information.

Check the code for occurances of:
glMatrixMode, GL_PROJECTION, GL_MODELVIEW,
gluPerspective, glFrustum, glOrtho.

All these affect your viewing setup. You should read their manuals and also check the OpenGL Programming Guide on transformations. There is a redbook.pdf to be found on the internet.

If you’re lost, put this code in front of your rendering call above and the big cube will definitely appear in the center:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, 1.0, 1.0, 39.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -20.0f);
// Now your drawing calls
glBegin…

If you’re unsure if you rendered black-on-black, it’s always a good idea to set the glClearColor() to something different than the default black.