Zooming to point of interest

Posted by user1010005 on Game Development See other posts from Game Development or by user1010005
Published on 2012-04-12T16:38:57Z Indexed on 2012/04/12 17:42 UTC
Read the original article Hit count: 242

Filed under:
|

I have the following variables:

  • Point of interest which is the position(x,y) in pixels of the place to focus.
  • Screen width,height which are the dimensions of the window.
  • Zoom level which sets the zoom level of the camera.

And this is the code I have so far.

void Zoom(int pointOfInterestX,int pointOfInterstY,int screenWidth,
   int screenHeight,int zoomLevel)
{   
glTranslatef( (pointOfInterestX/2 - screenWidth/2), (pointOfInterestY/2 - screenHeight/2),0);
glScalef(zoomLevel,zoomLevel,zoomLevel);
}

And I want to do zoom in/out but keep the point of interest in the middle of the screen. but so far all of my attempts have failed and I would like to ask for some help.

© Game Development or respective owner

Related posts about opengl

Related posts about math