Seems to me that the call to glOrtho should be replaced by a call to glViewport(x,y,width,height) and glDepthRange(near,far). Since your vertices are already in viewport coordinates, according to the comment in the code, how does something like the following work for you:
glViewport(X, Y, width, height); checkGLcall("glViewport"); /* depth ranges will be clamped to [0, 1] */ glDepthRange(minZ, maxZ); checkGLcall("glDepthRange");
That code breaks half-life. The hl console is only dark brown rectangle in the top right quarter, the in-game graphics isn't drawn.
What's the difference between glOrtho and glViewport/glDepthRange? I've expected the code to be equal to the glOrtho call.