Original Post
I'm working on a basic mapping program (kind of like Google Maps but a billion times simpler) using OpenGL. I have given the user the capability to pan and zoom. However, I'm not sure how to properly set up the modelview and projection matrices to handle this. I've been able to get panning working, but when I zoom, it scales the map from 0,0 instead of from the center of your current view. Any help on how to set up the matrices would be much appreciated, thanks!
// basex/basey = initial translation offset
// basescale = initial scale factor
glViewport(ClientRectangle.Left, ClientRectangle.Top, ClientRectangle.Width, ClientRectangle.Height);
glMatrixMode(gl.GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(gl.GL_PROJECTION);
glLoadIdentity();
glOrthof(0, ClientSize.Width, 0, ClientSize.Height, 1.0f, -1.0f);
glTranslatef(basex + xpos, basex + ypos, 0.0f); // This works!
glScalef(basescale * xscale, basescale * yscale, 1.0f); // Oh no!