creating 3D rect angle using opengl Qt

hi ,iam new to opengl programing. i was created a cube program.the problem is i just given different colors for different faces. among 6 faces 5 faces are showing proper color but the top layer i given green color but is not showing any color. some please help me…here is my code


   void GLWidget::paintGL()
{

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(1.5f,0.0f,-7.0f);
    glRotatef( rquad, 1, 1, 1 );


    glBegin(GL_QUADS);

        glColor3f (0.0f,1.0f,0.0f);          // Set The Color To Green
       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);          // Set The Color To 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);          // Set The Color To 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);          // Set The Color To Yellow
       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)
       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)

       glColor3f(0.0f,0.0f,1.0f);          // Set The Color To 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);          // Set The Color To 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();

}
 

Hi !

Your problem is about the orientation of the first face (quad).

Try this:

glColor3f (0.0f,1.0f,0.0f);          // Set The Color To Green
       glVertex3f( 1.0f, 1.0f,-1.0f);          // Top Right Of The Quad (Top)
       glVertex3f( 1.0f, 1.0f, 1.0f);          // Bottom Right Of The Quad (Top)
       glVertex3f(-1.0f, 1.0f, 1.0f);          // Bottom Left Of The Quad (Top)
       glVertex3f(-1.0f, 1.0f,-1.0f);          // Top Left Of The Quad (Top)

for example.

Your original orientation: Vertex0-1-2-3 defines CounterClockWise orientation,
my example => Vertex0-3-2-1 defines ClockWise (like yours others faces/quads).

Good luck,
YoYOoOo

ps: Sorry for my english (french style :p) !
ps2: for more information about culling (this is your problem), you can look here: glCullFace

Thanks for your reply. i want to add more number of cubes to the scene. for an example i have a front face having co-ordinates
(10,10,0)(30,10,0)(30,30,0)(10,30,0). if i add the cube to the scene is the first point of the cube(10,10) and the scene co ordinates are scene.