Instead of using glTranslate to move all objects, you should try glOrtho . As parameters, the required left coordinates, correct coordinates, lower coordinates, upper coordinates and minimum / maximum depth are required.
For example, if you call glOrtho (-5, 5, -2, 2, ...); all points whose coordinates are inside the rectangle going from (-5,2) to (5, -2) will be displayed on your screen. The advantage is that you can easily adjust the zoom level.
If you do not multiply by any kind of view / projection matrix (I assume that it is), the standard screen coordinates range from (-1.1) to (1, -1).
But in your project it can be very useful to control the camera. Call this before you draw any object instead of glTranslate:
float left = cameraX - zoomLevel * 2; float right = cameraX + zoomLevel * 2; float top = cameraY + zoomLevel * 2; float bottom = cameraY - zoomLevel * 2; glOrtho(left, right, bottom, top, -1.f, 1.f);
Note that cameraX and cameraY now represent the center of the screen.
Now, when you zoom in on a point, you just need to do something like this:
cameraX += (cameraX - screenX) * 0.5f; cameraY += (cameraY - screenY) * 0.5f; zoomLevel += 0.5f;