title: Why does this depth buffer setup not work
body: <p>I've been learning OpenGL (Cocoa) lately. And I've ran into a problem here. When I try to init the depth buffer, the compiler returns <code>GDB: Program received signal: "EXC_BAD_ACCESS".</code> Here's the code:</p>
  
  <pre><code>-(id)init {
  [super init];
  
  [self initGL];
  
  return self;
  }
  
  -(void)initGL {
  glClearDepth( 1.0 );                     // Depth buffer setup
  glEnable( GL_DEPTH_TEST );                // Enable depth testing
  glDepthFunc( GL_LEQUAL );
  }
  -(void) drawRect: (NSRect)bounds {
  
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(60.0f, 1.33333f, 0.1f, 100.0f);
  
  glTranslatef(-1.5f, 0.0f, -6.0f);
  glRotatef(10, 1.0f, 0.0f, 0.0f);
  glRotatef(10, 0.0f, 1.0f, 0.0f);
  glRotatef(10, 0.0f, 0.0f, 1.0f);
  
  glBegin( GL_TRIANGLES );              // Draw a triangle
  glColor3f( 1.0f, 0.0f, 0.0f );        // Set color to red
  glVertex3f(  0.0f,  1.0f, 0.0f );     // Top of front
  glColor3f( 0.0f, 1.0f, 0.0f );        // Set color to green
  glVertex3f( -1.0f, -1.0f, 1.0f );     // Bottom left of front
  glColor3f( 0.0f, 0.0f, 1.0f );        // Set color to blue
  glVertex3f(  1.0f, -1.0f, 1.0f );     // Bottom right of front
  
  glColor3f( 1.0f, 0.0f, 0.0f );        // Red
  glVertex3f( 0.0f, 1.0f, 0.0f );       // Top of right side
  glColor3f( 0.0f, 0.0f, 1.0f );        // Blue
  glVertex3f( 1.0f, -1.0f, 1.0f );      // Left of right side
  glColor3f( 0.0f, 1.0f, 0.0f );        // Green
  glVertex3f( 1.0f, -1.0f, -1.0f );     // Right of right side
  
  glColor3f( 1.0f, 0.0f, 0.0f );        // Red
  glVertex3f( 0.0f, 1.0f, 0.0f );       // Top of back side
  glColor3f( 0.0f, 1.0f, 0.0f );        // Green
  glVertex3f( 1.0f, -1.0f, -1.0f );     // Left of back side
  glColor3f( 0.0f, 0.0f, 1.0f );        // Blue
  glVertex3f( -1.0f, -1.0f, -1.0f );    // Right of back side
  
  glColor3f( 1.0f, 0.0f, 0.0f );        // Red
  glVertex3f( 0.0f, 1.0f, 0.0f );       // Top of left side
  glColor3f( 0.0f, 0.0f, 1.0f );        // Blue
  glVertex3f( -1.0f, -1.0f, -1.0f );    // Left of left side
  glColor3f( 0.0f, 1.0f, 0.0f );        // Green
  glVertex3f( -1.0f, -1.0f, 1.0f );     // Right of left side
  glEnd();
  
  glFlush();
  }
  </code></pre>
  
  <p>If I remove the 3 lines of depth testing, the application opens seamlessly.</p>