Use the term "points" instead of "screen coordinates"

It turns out that screen coordinates were confusing people, thinking that meant pixels, when instead they are virtual coordinates; device independent units defined as pixels scaled by the display scale. We'll use the term "points" for this going forward, to reduce confusion.
This commit is contained in:
Sam Lantinga
2023-05-15 11:16:46 -07:00
parent 78251f973d
commit 4de7433a9e
7 changed files with 31 additions and 37 deletions

View File

@@ -33,29 +33,26 @@ TODO: Add information regarding App Store requirements such as icons, etc.
Notes -- Retina / High-DPI and window sizes
==============================================================================
Window and display mode sizes in SDL are in "screen coordinates" (or "points",
in Apple's terminology) rather than in pixels. On iOS this means that a window
created on an iPhone 6 will have a size in screen coordinates of 375 x 667,
rather than a size in pixels of 750 x 1334. All iOS apps are expected to
size their content based on screen coordinates / points rather than pixels,
Window and display mode sizes in SDL are in points rather than in pixels.
On iOS this means that a window created on an iPhone 6 will have a size in
points of 375 x 667, rather than a size in pixels of 750 x 1334. All iOS apps
are expected to size their content based on points rather than pixels,
as this allows different iOS devices to have different pixel densities
(Retina versus non-Retina screens, etc.) without apps caring too much.
SDL_GetWindowSize() and mouse coordinates are in screen coordinates rather
than pixels, but the window will have a much greater pixel density when the
device supports it, and the SDL_GetWindowSizeInPixels() can be called to
determine the size in pixels of the drawable screen framebuffer.
SDL_GetWindowSize() and mouse coordinates are in points rather than pixels,
but the window will have a much greater pixel density when the device supports
it, and the SDL_GetWindowSizeInPixels() can be called to determine the size
in pixels of the drawable screen framebuffer.
The SDL 2D rendering API will automatically handle this for you, by default
providing a rendering area in screen coordinates, and you can call
SDL_SetRenderLogicalPresentation() to gain access to the higher density
resolution.
providing a rendering area in points, and you can call SDL_SetRenderLogicalPresentation()
to gain access to the higher density resolution.
Some OpenGL ES functions such as glViewport expect sizes in pixels rather than
sizes in screen coordinates. When doing 2D rendering with OpenGL ES, an
orthographic projection matrix using the size in screen coordinates
(SDL_GetWindowSize()) can be used in order to display content at the same scale
no matter whether a Retina device is used or not.
sizes in points. When doing 2D rendering with OpenGL ES, an orthographic projection
matrix using the size in points (SDL_GetWindowSize()) can be used in order to
display content at the same scale no matter whether a Retina device is used or not.
Notes -- Application events

View File

@@ -668,8 +668,8 @@ here, now. Passing NULL is the same as passing -1 here in SDL2, to signify you w
to decide for you.
When a renderer is created, it will automatically set the logical size to the size of
the window in screen coordinates. For high DPI displays, this will set up scaling from
window coordinates to pixels. You can disable this scaling with:
the window in points. For high DPI displays, this will set up scaling from points to
pixels. You can disable this scaling with:
```c
SDL_SetRenderLogicalPresentation(renderer, 0, 0, SDL_LOGICAL_PRESENTATION_DISABLED, SDL_SCALEMODE_NEAREST);
```