title: Can't get Display List to Work
body: <p>First of all, as usual, thanks to all for the great support from the SO community.</p>
  
  <p>So I wrote code to draw 6 gl_quads (to form a cube).  Initially, this code was drawn immediately (explicitly made 24 vertex calls in the display function).  I'd like to put these in a display list.  I read a tutorial about display lists, and gave it a shot.  Problem is, nothing is showing up, and I have a glulookat that definitely points in the direction of the cube (verified in immediate mode).  So basically the code works perfectly when not using display lists, but doesn't when I try to use the list.</p>
  
  <p>Ok, enough of that, let's have a look at the code:</p>
  
  <p><strong>2nd EDIT-</strong> Moved glGenLists call into initGl and it works fine.  Thanks all</p>
  
  <p>*<em>EDIT-</em>*The glGenList call is made globally:</p>
  
  <pre><code>GLuint skybox = glGenLists(1);
  </code></pre>
  
  <p>And I'm still getting the same result.  Nothing is rendering to the screen.</p>
  
  <p><strong>Setup the list (in initgl function):</strong></p>
  
  <pre><code>glViewport(0,0,WINDOW_WIDTH,WINDOW_HEIGHT); 
  glEnable(GL_DEPTH_TEST);    // Enables Depth Testing
  glDepthFunc(GL_LEQUAL);
  
  glMatrixMode(GL_PROJECTION);    //setup the projection matrix
  glLoadIdentity();
  gluPerspective(45, WINDOW_WIDTH/WINDOW_HEIGHT,.1,200.0);
  
  glMatrixMode(GL_MODELVIEW); //switch to modelview
  glLoadIdentity();
  gluLookAt(-2,2,2,0,0,0,0,1,0);
  glClearColor(0, 0, 0, 0);
  
  glNewList(skybox, GL_COMPILE_AND_EXECUTE); //draw the list once to compile/store
  drawEnv(); //draw 6 quads
  glEndList(); //end list
  </code></pre>
  
  <p><strong>display function (irrelevant code ommitted):</strong></p>
  
  <pre><code>/* Clear buffers */
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  
  //-----Draw Skybox------
  glEnable(GL_TEXTURE_2D);
  glPushMatrix();  //save env settings (I've tried removing this push/pop pair with same results
  glCallList(skybox);
  glPopMatrix();
  glDisable(GL_TEXTURE_2D);
  </code></pre>
  
  <p><strong>And the drawEnv() function:</strong></p>
  
  <pre><code>//---------------------------
  //--------RIGHT WALL---------
  //---------------------------
  //This code draws correctly if I move this to the display function (immediate drawing)  
  glBindTexture(GL_TEXTURE_2D,rightTextureId);
  glBegin(GL_QUADS);  
  glTexCoord2f(0.0, 0.0);     glVertex3f( 1.0f, 1.0f, 1.0f);   //V2
  glTexCoord2f(0.0, 1.0);     glVertex3f( 1.0f,-1.0f, 1.0f);   //V1
  glTexCoord2f(1.0, 1.0);     glVertex3f( 1.0f,-1.0f,-1.0f);   //V3
  glTexCoord2f(1.0, 0.0);     glVertex3f( 1.0f, 1.0f,-1.0f);   //V4
  glEnd();
  
  //repeat 5 more times
  </code></pre>