chrismear / renios

Ren'iOS helps you package a Ren'Py game into an app that will run on iOS.
Other
35 stars 3 forks source link

Automatic Retina display support #46

Open chrismear opened 11 years ago

chrismear commented 11 years ago

Can we automatically render some things at a Retina resolution if we find ourselves on a device with a Retina display?

chrismear commented 11 years ago

Some notes from various experiments...

On a Retina iPad, SDL is aware of the full 2048x1536 physical resolution, and images that Ren'Py renders can use the full resolution of the screen, as long as they are scaled down in Ren'Py.

For instance, suppose a game is set to use a resolution of 1024x768. If a 200x200 image is loaded in, and Ren'Py is told to display it at 100x100, then the graphics engine will actually render the image pixel-for-pixel onto the display, resulting in a Retina resolution image appearing.

This suggests that we wouldn't have to do anything too special to render Retina resolution images. Indeed, we could do it right now (with no changes to the engine) by making the game creator provide high-resolution images, and specifying a smaller image size in their code (so that the images get scaled down when rendering). But this is extra work for the creator, and also it means non-Retina devices are forced to deal with double-sized textures for no benefit.

Ideally, the creator could supply additional image files marked "@2x" in the filename, and the engine would automatically use them instead when it detects it's running on a Retina device.

Note that all of the above discussion assumes the game is set to run at 1024x768 resolution. If a higher or lower game resolution is used, the scale factor needed to ensure 1-to-1 pixel rendering of images is no longer 2. Is this something Ren'iOS should be trying to deal with? Or if a creator is targeting iOS, can we reasonably expect them to organise their game around a 1024x768 resolution in order to get a full-screen display on an iPad. What about if they're targeting iPads and iPhones?

chrismear commented 11 years ago

Text: on the renpy-6.14.1-retina branch is an experiment with automatically rendering text at 2x resolution. This works surprisingly well for such a quick hack (there are some bugs involving certain layouts shifting out of place, and when an effect is applied to a piece of text the rendering engine brings it back to game resolution rather than keeping at device/Retina resolution; otherwise, normal text rendering essentially just works).

Again, we need to consider the question of calculating the scale factor when the game resolution is not exactly one-half of the device resolution,

chrismear commented 11 years ago

To get a better idea of what I'm talking about, here's a screenshot from Analogue: A Hate Story, running at Retina resolution on an iPad. The game's resolution is 1024x640, so simple 2x transforms just work on a Retina iPad.

It was this screen that made me realise we might be able to do some sort of automatic Retina rendering; the game is using a character image here with a zoom setting of < 1, so it rendered at Retina resolution already without me having to do anything.

The screenshot also includes the Retina text hack mentioned in the previous comment.

img_0478