# How to make a simple HUD with no library

I am writing a simple game in c++ using opengl in a windows system.

I have the scene and I need some informative text to appeared to the left top/bottom of the screen

I am printing these messages with a little plane and the text on it, but I want them to be aligned at the corners of the screen.

So I've read this question here and I thought it seemed quite good and closer to my needs.

So, this is some of my code already used:

In init function of openGL:

glShadeModel (GL_SMOOTH);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glClearDepth(1);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);


In the Resize function:

if (window_height == 0) window_height = 1;
glViewport(0, 0, window_width, window_height);
glMatrixMode(GL_PROJECTION);
gluPerspective(60.0, (float)window_width/(float) window_height, 1.0, 550.0);


And finally in the render function:

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glTranslatef(0, 0, -250); //is used for making the scene visible
RenderScene();
glutSwapBuffers();


I've tried using the ready3D() and then RenderScene() functions but the scene looked a lot different to what I was aiming.

How can I achieve this simple HUD (printing messages aligned to the window's corners)?

Edit #1:

This is what I see (terrain and message below):

I want the message to be aligned at the bottom left corner as well as other messages.

• Please add some images of what you expect and what you get so we can see whats wrong. Feb 21 '13 at 21:40
• @RoyT.: I've added the current state and a description of how I want it to look like. Feb 21 '13 at 22:29
• Also note that you're using OpenGL in the old/deprecated way. A good read on the new way is this free book arcsynthesis.org/gltut/index.html Feb 22 '13 at 9:15
• @RoyT.: I have been told about it Roy, but this is what we were taught in class. I will surely check this for my next project. Feb 22 '13 at 9:49
• Ah man I hate it when they teach terribly outdated stuff in class. Be sure to tell your teacher that his/her approach is frowned upon for over 5 years now (in a friendly way :P). Feb 22 '13 at 10:34

 glMatrixMode (GL_PROJECTION);