This is yet another adaption of the famous code from gamedev.net that i use, but with one difference, that coordinates will match windows, making (0,0) top-left edge of the window, and (W, H) will be bottom right edge.

edit: also, my function does not turn off depth test, but relies on you doing it yourself.


Code:
// Dwarf with Axe - GAMEDEV forums: 18 July 2002 6:12:57 PM
//
// There have been thousands of posts along the lines of
// "How do I do 2d in OpenGL" to "Duuuhde, I wunt too maek
// a two dee gaem in ohpun jee el; how do eye set uhp two dee???!?"
//
// I have developed a simple, nice, pretty way for all of you to have your 2D fun.

procedure GlEnable2D;
var
  vport: array[0..3] of integer;
begin
  glGetIntegerv(GL_VIEWPORT, @vPort);

  glMatrixMode(GL_PROJECTION);
  glPushMatrix;
  glLoadIdentity;
  glOrtho(0, vPort[2], 0, -vPort[3], -1, 1);

  glMatrixMode(GL_MODELVIEW);
  glPushMatrix;
  glLoadIdentity;

  // flip Y axis
  glTranslatef(0, -vPort[3], 0);
end;

procedure GlDisable2D;
begin
  glMatrixMode(GL_PROJECTION);
  glPopMatrix;
  glMatrixMode(GL_MODELVIEW);
  glPopMatrix;
end;