User Tools

Site Tools


Revisiting Scaling

I want to go a little more in detail about what PenjinPrescale is actually doing. When scaling an image you have a few alternatives depending on the graphics API used and so on. In PenjinTwo I have included Scale2X if using SDL, you can change the display port size if using OpenGL/GLES and I also provide the option to use prescaling.

What is Prescaling

Prescaling is resizing the sprites/images at load time. PenjinTwo is setup to use states. In code written in this intended format you load the sprites when the state is created. While the sprite is loading if PenjinPrescale or PokeScale is active it will resize all images, text glyphs in this loading period.

How it Works

In the PenjinTwo config file you can set a BaseResolution which is the native resolution of your application. You can set this up in code an it will be written to the config on startup or shutdown. You can also set a Resolution which is a target resolution. From the BaseResolution and target resolution we can calculate a horizontal and vertical scale factor and using the scale factor we can ensure that all images are scaled correctly at load time (Using an optional smoothing filter).

How it affects game logic or physics

Generally I have tried to ensure that game logic is kept the same irrespective of the scaled output, where internal classes have been used, they know to take the scale factor into consideration. In some cases you may need to work around scaling problems and the scale factor can be obtained from the GPU object.

You could leave a comment if you were logged in.
devblogs/pokeparadox/revisiting_scaling.txt · Last modified: 2014/08/05 11:45 by pokeparadox