Just started working with OpenGL (legacy 1.5) and am working to port an existing application to mobile. While going through the code, I found the following block:
/* Place raster position in lower left corner. */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glRasterPos2f(-1, -1);
glPopMatrix();
I see that the first two lines work to set the projection matrix back to an identity matrix, pretty easy. The five lines after that, though, have me scratching my head.
I see that the code works with the modelview matrix, but from my (admittedly new and shallow) understanding of pushing and popping matrices from the stack, the code makes a copy of the original matrix, overwrites it with new data, and then reloads the unmodified copy. This seems like wasted effort as it doesn’t accomplish anything. Is this the case?