Page 1 of 1

opengl zoom

PostPosted: Sep 13, 2009 @ 9:23pm
by jrhee
I'm putting together a game where all the graphics must be drawn into 240x208 pixels. Depending on my platform, I'd like to be able to zoom into that space so it fits the width of the screen.

I looked at the PinchZoom demo where it looks like zooming is achieved by blit scaling the edgelib logo. I considered drawing my graphics onto such a surface and scaling it to achieve the desired effect, but then I'd have to upload the surface on each frame, which would impact performance. Would it be possible to adjust the zoom by changing the openGL/view settings instead, while retaining the blending I noticed in the PinchZoom approach?

PostPosted: Sep 14, 2009 @ 8:45am
by edge
Hi,

The function you need is glViewport, it changes the dimension of the viewport and scales up graphics.

Alternatively, you can also use Perspective2D with your resolution (use 240x208 as parameters). This only works if you're using 2D graphics however.

PostPosted: Sep 15, 2009 @ 11:54am
by jrhee

PostPosted: Sep 15, 2009 @ 12:34pm
by edge

PostPosted: Oct 8, 2009 @ 3:29am
by jrhee

PostPosted: Oct 9, 2009 @ 7:47am
by edge
Hi,

The choppiness could be explained by the scaling factor. When scaling 150%, sometimes the character walks 1 pixel, and then 2 pixels. The lines appear because of internal rounding errors in OpenGL.

I'm affraid there is little you can do about this. The recommended approach is to scale up graphics and modify your routine so your entities move properly over the increased tile size. You could also show more of the game area (because more tiles fit on the larger resolution).