Lab 5 - October 1st, 2007

This code gives an example of how to place bitmap text on exact screen coordinates if your regular projection matrix is not set to match screen coordinates:

First possibility - change the projection matrix to render the text:

(:source lang=C++ :) //we want to change the projection matrix glMatrixMode(GL_PROJECTION); //but first we need to save the previous one in case it's needed again later glPushMatrix(); //then load a clean matrix glLoadIdentity(); //change the projection to match screen coordinates (width, height of window) gluOrtho2D(0.0, (GLfloat) width, 0.0, (GLfloat) height);

//now we can render the text (see previous tutorials) //but we do that with respect to the modelview matrix glMatrixMode(GL_MODELVIEW); renderBitmapString(0.0, 25.0, font, "Dragon Fractal"); renderBitmapString(0.0, 5.0, font, "Lecture 5");

//now we're done rendering the text and need to set the projection matrix back //so back to projection mode glMatrixMode(GL_PROJECTION); //and popping the current matrix off the stack to get the old one back glPopMatrix(); //now we want to continue rendering so back to the modelview mode glMatrixMode(GL_MODELVIEW);