PDA

View Full Version : Zooming in a 2d game



transparent
05-08-2011, 04:06 AM
Hi,

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?

The Little Body
05-08-2011, 04:30 AM
GL transformations are make in the reverse order of the "logic order"
=> have you test to use your glTranslatef after zoomming ?