SDL on iphone & retina display

I’m trying to understand how SDL handles the retina display.

Apple to take care of backward compatibility did a simple and horrible
thing, it changed the size of the CGRect of the main UIScreen of the phone
from pixels to points, specifying that a retina display is a display where a
POINT contains two pixels.

How does SDL handle this? It works if you do not rotate the display, if you
do not query the displaymode database and if you ignore the fact you have a
retina display :slight_smile:

If you list the display modes you get:


If you try to open a window of 640x960 with SDL_CreateWindow() your input
coordinates are ignored, and you’ll get a 320x480 one. If you rotate your
phone 90 degrees: the system will remember your real display size and you’ll
end having a small square filling 1/4 of the screen surface with your
graphics inside and with broken input.

The problems are also easily reproductable with the simulator changing
device type to “iphone (Retina)”

I’m trying to figure out how to fix things since I’d like to use the full
resolution of the display, but my attempts are not going very well for

I still have to understand what sizes are to be given in points and what
sizes are to be given in pixels…

There is a quite complex hierarchy of classes for create something that
should behave somewhat like a “simple” framebuffer :slight_smile:

If someone already solved those problems please point me a patch or a post
somewhere, I’ve searched on the net without much luck…–

The way this is handled is that for Retina devices the resolution is still 320x480. The solution here is to get the scale of the current UIScreen.
Unfortunately SDL does not have a function like this by default, so you need to add one. I made a gist on Github doing exactly this: