OpenGL ES 2 - Zoom

Well, it’s probably a problem with my ScrollEngine and not with the projection matrix but I have to ask this question since I’m trying to implement zoom correctly for a few days now :slight_smile:

This is what I use for updating the projection matrix according to a zoom factor:

float width = (float)this->getScreenWidth();
float height = (float)this->getScreenHeight();
mProjectionMatrix = glm::ortho(0.0f, width / mZoomFactor, 0.0f, height / mZoomFactor, -1.0f, 1.0f);

Note that I’m expanding the view in my engine according to the zoom like so:

mViewW = mViewOrigW / mZoomFactor;
mViewH = mViewOrigH / mZoomFactor;
mViewX = mViewCX - (mViewW / 2.0f);
mViewY = mViewCY - (mViewH / 2.0f);

ViewCX and ViewCY are the coordinate of the center of the view.

The problem is when I zoom-in, all the view goes downward, as shown in the image below, but it still centered on the x-axis. I’d like it to be centered on the y-axis as well.

This forum doesn’t let me add an image URL:
http : // i . imgur . com / KYUOxhD.png