Zooming to point of interest
- by user1010005
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.