title: In openGL, how can you get items to draw back to front?
body: <p>By default it seems that objects are drawn front to back.  I am drawing a 2-D UI object and would like to create it back to front. For example I could create a white square first then create a slightly smaller black square on top of it thus creating a black pane with a white border.  <a href="http://gpwiki.org/index.php/OpenGL:Tutorials:Tutorial_Framework:Ortho_and_Alpha" rel="noreferrer">This post</a> had some discussion on it and described this order as the "Painter's Algorithm" but ultimately the example they gave simply rendered the objects in reverse order to get the desired effect.  I figure back to front (first objects go in back, subsequent objects get draw on top) rendering can be achieved via some transformation (gOrtho?) ?</p>
  
  <p>I will also mention that I am not interested in a solution using a wrapper library such as GLUT.  </p>
  
  <p>I have also found that the default behavior on the Mac using the Cocoa NSOpenGLView appears to draw back to front, where as in windows I cannot get this behavior.  The setup code in windows I am using is this:</p>
  
  <pre><code>glViewport (0, 0, wd, ht);
  glMatrixMode(GL_PROJECTION);           
  glLoadIdentity();                      
  glOrtho (0.0f, wd, ht, 0.0f, -1.0f, 1.0f);
  glMatrixMode(GL_MODELVIEW);             
  glLoadIdentity();                       
  </code></pre>