mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-05-21 20:28:28 +00:00
Updated SDL high DPI support
We have gotten feedback that abstracting the coordinate system based on the display scale is unexpected and it is difficult to adapt existing applications to the proposed API. The new approach is to provide the coordinate systems that people expect, but provide additional information that will help applications properly handle high DPI situations. The concepts needed for high DPI support are documented in README-highdpi.md. An example of automatically adapting the content to display scale changes can be found in SDL_test_common.c, where auto_scale_content is checked. Also, the SDL_WINDOW_ALLOW_HIGHDPI window flag has been replaced by the SDL_HINT_VIDEO_ENABLE_HIGH_PIXEL_DENSITY hint. Fixes https://github.com/libsdl-org/SDL/issues/7709
This commit is contained in:
parent
0fbb9c779c
commit
c699f3d1d8
51 changed files with 506 additions and 882 deletions
|
@ -140,7 +140,6 @@ typedef enum
|
|||
typedef enum
|
||||
{
|
||||
SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */
|
||||
SDL_LOGICAL_PRESENTATION_MATCH, /**< The rendered content matches the window size in points */
|
||||
SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */
|
||||
SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */
|
||||
SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */
|
||||
|
@ -235,9 +234,8 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(int width, int height, U
|
|||
* need a specific renderer, specify NULL and SDL will attempt to chooes the
|
||||
* best option for you, based on what is available on the user's system.
|
||||
*
|
||||
* By default the rendering size matches the window size in points, but you
|
||||
* can call SDL_SetRenderLogicalPresentation() to enable high DPI rendering or
|
||||
* change the content size and scaling options.
|
||||
* By default the rendering size matches the window size in pixels, but you
|
||||
* can call SDL_SetRenderLogicalPresentation() to change the content size and scaling options.
|
||||
*
|
||||
* \param window the window where rendering is displayed
|
||||
* \param name the name of the rendering driver to initialize, or NULL to
|
||||
|
@ -316,24 +314,6 @@ extern DECLSPEC SDL_Window *SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);
|
|||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_RendererInfo *info);
|
||||
|
||||
/**
|
||||
* Get the output size in points of a rendering context.
|
||||
*
|
||||
* This returns the true output size in points, ignoring any render targets or
|
||||
* logical size and presentation.
|
||||
*
|
||||
* \param renderer the rendering context
|
||||
* \param w a pointer filled in with the width in points
|
||||
* \param h a pointer filled in with the height in points
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetRenderer
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetRenderWindowSize(SDL_Renderer *renderer, int *w, int *h);
|
||||
|
||||
/**
|
||||
* Get the output size in pixels of a rendering context.
|
||||
*
|
||||
|
@ -840,13 +820,9 @@ extern DECLSPEC SDL_Texture *SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer)
|
|||
* render target is created at the specified size and used for rendering and
|
||||
* then copied to the output during presentation.
|
||||
*
|
||||
* When a renderer is created, the logical size is set to match the window
|
||||
* size in points. The actual output size may be higher pixel density, and can
|
||||
* be queried with SDL_GetRenderOutputSize().
|
||||
*
|
||||
* You can disable logical coordinates by setting the mode to
|
||||
* SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full
|
||||
* resolution of the output window.
|
||||
* pixel resolution of the output window.
|
||||
*
|
||||
* You can convert coordinates in an event into rendering coordinates using
|
||||
* SDL_ConvertEventToRenderCoordinates().
|
||||
|
@ -887,8 +863,7 @@ extern DECLSPEC int SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *rende
|
|||
extern DECLSPEC int SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode, SDL_ScaleMode *scale_mode);
|
||||
|
||||
/**
|
||||
* Get a point in render coordinates when given a point in window coordinates
|
||||
* (points).
|
||||
* Get a point in render coordinates when given a point in window coordinates.
|
||||
*
|
||||
* \param renderer the rendering context
|
||||
* \param window_x the x coordinate in window coordinates
|
||||
|
@ -906,8 +881,7 @@ extern DECLSPEC int SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *rende
|
|||
extern DECLSPEC int SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
|
||||
|
||||
/**
|
||||
* Get a point in window coordinates (points) when given a point in render
|
||||
* coordinates.
|
||||
* Get a point in window coordinates when given a point in render coordinates.
|
||||
*
|
||||
* \param renderer the rendering context
|
||||
* \param x the x coordinate in render coordinates
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue