Zooming in a 2d game


I’m trying to zoom a parallax background.

I’m using glOrthof:

pGL.glOrthof(0, pCamera.getWidth(), pCamera.getHeight(), 0, -1f, 1f);

where the camera width and height takes into account the zoom factor.

I then draw my various parallax layers.

This works fine apart from the fact the zoom occurs from the top left of the layers. I’d like the zooming to be centered on a sprite whose position is x,y

I assumed that I should apply a translation using glTranslatef before zooming. This doesnt seem to be working.

Any thoughts?

GL transformations are make in the reverse order of the “logic order”
=> have you test to use your glTranslatef after zoomming ?