   scene cut of[opengl + c]
  Why is the back of my scene cut off?#include <math.h>#include <gl\glut.h>#include <stdio.h>#include <stdlib.h>#define PI 3.1415926535897932384626433832795#define true 1#define false 0int light = true;int rotation = 0;GLuint texture[1];GLfloat light_pos[] = {0.0, 0.0, 0.0, 0.0};GLfloat LightAmbient[]= { 0.5f, 0.5f, 0.5f, 1.0f };GLfloat LightDiffuse[]= { 1.0f, 1.0f, 1.0f, 1.0f };GLfloat ballPos[] = {0.0, 0.0, 0.0};GLfloat ballDirection[] = {0.0, 0.0, 0.0};GLfloat gravity = 0.1;GLfloat maxSpeed = 0.5;void init(void){    glShadeModel(GL_SMOOTH);    glLightfv(GL_LIGHT0, GL_AMBIENT, LightAmbient);glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);glLightfv(GL_LIGHT0, GL_POSITION, light_pos);    glEnable(GL_LIGHT0);    glEnable(GL_LIGHTING);    glClearColor (0.0, 0.0, 0.0, 0.0);    glEnable(GL_DEPTH_TEST);}void display(void){    int boxRad = 5;GLfloat box_mat_amb_diff[] = {0.2,0.2, 0.4, 0.0};GLfloat box_mat_specular[] = {0.5, 0.5, 0.5, 1.0};GLfloat box_mat_shininess[] = {10.0};GLfloat ball_mat_amb_diff[] = {0.2,0.3, 0.0, 0.0};GLfloat ball_mat_specular[] = {1.0, 1.0, 1.0, 1.0};GLfloat ball_mat_shininess[] = {70.0};glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);    glPushMatrix();   glRotatef(rotation, 0.0, 1.0, 0.0);glMaterialfv(GL_FRONT, GL_SPECULAR, box_mat_specular);glMaterialfv(GL_FRONT, GL_SHININESS, box_mat_shininess);glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, box_mat_amb_diff);glBegin(GL_QUADS);  // Top FaceglNormal3f( 0.0*boxRad, 1.0*boxRad, 0.0*boxRad);  glVertex3f(-1.0*boxRad,  1.0*boxRad, -1.0*boxRad);  glVertex3f(-1.0*boxRad,  1.0*boxRad,  1.0*boxRad);  glVertex3f( 1.0*boxRad,  1.0*boxRad,  1.0*boxRad);  glVertex3f( 1.0*boxRad,  1.0*boxRad, -1.0*boxRad);  // Bottom Face  glNormal3f( 0.0*boxRad, 1.0*boxRad, 0.0f*boxRad);  glVertex3f(-1.0*boxRad, -1.0*boxRad, -1.0*boxRad);  glVertex3f( 1.0*boxRad, -1.0*boxRad, -1.0*boxRad);  glVertex3f( 1.0*boxRad, -1.0*boxRad,  1.0*boxRad);  glVertex3f(-1.0*boxRad, -1.0*boxRad,  1.0*boxRad);   glEnd();glutWireCube(boxRad*2);glMaterialfv(GL_FRONT, GL_SPECULAR, ball_mat_specular);glMaterialfv(GL_FRONT, GL_SHININESS, ball_mat_shininess);glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, ball_mat_amb_diff);glTranslatef(ballPos[0],ballPos[1],ballPos[2]);glutSolidSphere(1.0, 20, 20);    glPopMatrix();    glutSwapBuffers();    glFlush();}void mouse(int button, int state, int x, int y){    //printf("x: %d , y: %d \n", x, y);}void reshape (int w, int h){    glViewport (0, 0, (GLsizei) w, (GLsizei) h);    glMatrixMode (GL_PROJECTION);    glLoadIdentity ();    gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);    glMatrixMode(GL_MODELVIEW);    glLoadIdentity();    gluLookAt(0.0, 0.0, 20.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);}void keyboard (unsigned char key, int x, int y){    switch (key) {case 'a':case 'A':rotation = (rotation + 4) % 360;display();break;case 'd':case 'D':rotation = (rotation - 4) % 360;display();break;case 'l':case 'L':if(light == true){glDisable(GL_LIGHTING);light = false;}else{glEnable(GL_LIGHTING);light = true;}display();break;case 27:  exit(0);  break;   default:  break;    }}void addgravity(){//if()}void animate(void){//addgravity()//checkcollission()display();}int main(int argc, char** argv){   glutInit(&argc, argv);   glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);   glutInitWindowSize (500, 500);   glutInitWindowPosition (0, 0);   glutCreateWindow ("Ball in a box");   init ();   glutDisplayFunc(display);   glutReshapeFunc(reshape);   glutMouseFunc(mouse);   glutKeyboardFunc(keyboard);   glutIdleFunc(animate);   glutMainLoop();   return 0;}
  I'm no openGL expert or anything, but is it possible that your scene objects are past your far plane(which, if i'm correct, is 20.0f)   ;  I think thats it, but Im not sure how to fix it..the 20.0f is the camera distance from 0,0,0   ;  actually i believe its the far plane of the viewing frustum, at least that's what it looks like in the function, try changing it to 100.0f, see if that helps.*EDIT* you wouldn't set the camera distance in the projection matrix, you would do that in the view matrix (MODELVIEW i believe for openGL).  I'm fairly sure that the 20.0f in your gluPerspective function represents the far clipping plane, which explains why anything further from the viewpoint than 20 gets clipped.   ;  aah... sorry.. I thought you meant the 20 from the lookat function.. I changed the value in gluPerspective() and that fixed it :)   ;  oh yeah, sorry I'm studying at the moment, so I just skimmed your code really quick to check for the clipping plane and pretty much disregarded everything else :)   