Renderer logical size is now implemented as a render target

This fixes rounding errors with coordinate scaling and gives more flexibility in the presentation, as well as making it easy to maintain device independent resolution as windows move between different pixel density displays.

By default when a renderer is created, it will match the window size so window coordinates and render coordinates are 1-1.

Mouse and touch events are no longer filtered to change their coordinates, instead you can call SDL_ConvertEventToRenderCoordinates() to explicitly map event coordinates into the rendering viewport.

SDL_RenderWindowToLogical() and SDL_RenderLogicalToWindow() have been renamed SDL_RenderCoordinatesFromWindow() and SDL_RenderCoordinatesToWindow() and take floating point coordinates in both directions.

The viewport, clipping state, and scale for render targets are now persistent and will remain set whenever they are active.
This commit is contained in:
Sam Lantinga 2023-02-03 12:25:46 -08:00
parent 93fc72a405
commit dcd17f5473
28 changed files with 1113 additions and 910 deletions

View File

@ -294,9 +294,12 @@ expression e1, e2, e3;
@@
typedef PFN_vkGetInstanceProcAddr;
@@
(
(PFN_vkGetInstanceProcAddr)SDL_Vulkan_GetVkGetInstanceProcAddr()
|
+ (PFN_vkGetInstanceProcAddr)
SDL_Vulkan_GetVkGetInstanceProcAddr()
)
// SDL_PauseAudioDevice / SDL_PlayAudioDevice
@@
@ -716,7 +719,8 @@ expression e1, e2, e3, e4, e5, e6, e7, e8, e9;
@@
// SDL_CreateRenderer:
// 2nd argument changed from int (default=-1) to const char* (default=NULL)
expression e1, e2, e3;
expression e1, e3;
int e2;
@@
(
@ -1774,15 +1778,12 @@ typedef SDL_GameControllerButtonBind, SDL_GamepadBinding;
+ SDL_GetRenderClipRect
(...)
@@
SDL_Renderer *renderer;
int *w;
int *h;
@@
- SDL_RenderGetIntegerScale
+ SDL_GetRenderIntegerScale
(...)
@@
@@
- SDL_RenderGetLogicalSize
+ SDL_GetRenderLogicalSize
(...)
- SDL_RenderGetLogicalSize(renderer, w, h)
+ SDL_GetRenderLogicalPresentation(renderer, w, h, NULL, NULL)
@@
@@
- SDL_RenderGetMetalCommandEncoder
@ -1819,15 +1820,17 @@ typedef SDL_GameControllerButtonBind, SDL_GamepadBinding;
+ SDL_SetRenderClipRect
(...)
@@
SDL_Renderer *renderer;
expression w;
expression h;
@@
- SDL_RenderSetIntegerScale
+ SDL_SetRenderIntegerScale
(...)
@@
@@
- SDL_RenderSetLogicalSize
+ SDL_SetRenderLogicalSize
(...)
(
- SDL_RenderSetLogicalSize(renderer, 0, 0)
+ SDL_SetRenderLogicalPresentation(renderer, 0, 0, SDL_LOGICAL_PRESENTATION_DISABLED, SDL_ScaleModeNearest)
|
- SDL_RenderSetLogicalSize(renderer, w, h)
+ SDL_SetRenderLogicalPresentation(renderer, w, h, SDL_LOGICAL_PRESENTATION_LETTERBOX, SDL_ScaleModeLinear)
)
@@
@@
- SDL_RenderSetScale
@ -2328,10 +2331,6 @@ expression e;
(...)
@@
@@
- SDL_WINDOW_FULLSCREEN
+ SDL_WINDOW_FULLSCREEN_EXCLUSIVE
@@
@@
- SDL_WINDOW_INPUT_GRABBED
+ SDL_WINDOW_MOUSE_GRABBED
@@
@ -2374,3 +2373,18 @@ SDL_DisplayMode e;
- SDL_GetClosestDisplayMode
+ SDL_GetClosestFullscreenDisplayMode
(...)
@@
@@
- SDL_GetRendererOutputSize
+ SDL_GetCurrentRenderOutputSizeInPixels
(...)
@@
@@
- SDL_RenderWindowToLogical
+ SDL_RenderCoordinatesFromWindow
(...)
@@
@@
- SDL_RenderLogicalToWindow
+ SDL_RenderCoordinatesToWindow
(...)

View File

@ -41,16 +41,15 @@ size their content based on screen coordinates / 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.
By default SDL will not use the full pixel density of the screen on
Retina/high-dpi capable devices. Use the SDL_WINDOW_ALLOW_HIGHDPI flag when
creating your window to enable high-dpi support.
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.
When high-dpi support is enabled, SDL_GetWindowSize() and display mode sizes
will still be 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() or SDL_GetRendererOutputSize() functions (depending
on whether the SDL_Render API is used) can be queried 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.
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

View File

@ -341,10 +341,12 @@ functionality to your app and aid migration. That is located in the
SDL_AddHintCallback() now returns a standard int result instead of void, returning 0 if the function succeeds or a negative error code if there was an error.
The following hints have been removed:
* SDL_HINT_IDLE_TIMER_DISABLED (use SDL_DisableScreenSaver instead)
* SDL_HINT_VIDEO_X11_FORCE_EGL (use SDL_HINT_VIDEO_FORCE_EGL instead)
* SDL_HINT_VIDEO_X11_XINERAMA (Xinerama no longer supported by the X11 backend)
* SDL_HINT_VIDEO_X11_XVIDMODE (Xvidmode no longer supported by the X11 backend)
* SDL_HINT_IDLE_TIMER_DISABLED - use SDL_DisableScreenSaver instead
* SDL_HINT_MOUSE_RELATIVE_SCALING - mouse coordinates are no longer automatically scaled by the SDL renderer
* SDL_HINT_RENDER_LOGICAL_SIZE_MODE - the logical size mode is explicitly set with SDL_SetRenderLogicalPresentation()
* SDL_HINT_VIDEO_X11_FORCE_EGL - use SDL_HINT_VIDEO_FORCE_EGL instead
* SDL_HINT_VIDEO_X11_XINERAMA - Xinerama no longer supported by the X11 backend
* SDL_HINT_VIDEO_X11_XVIDMODE - Xvidmode no longer supported by the X11 backend
* Renamed hints SDL_HINT_VIDEODRIVER and SDL_HINT_AUDIODRIVER to SDL_HINT_VIDEO_DRIVER and SDL_HINT_AUDIO_DRIVER
* Renamed environment variables SDL_VIDEODRIVER and SDL_AUDIODRIVER to SDL_VIDEO_DRIVER and SDL_AUDIO_DRIVER
@ -594,9 +596,16 @@ which index is the "opengl" or whatnot driver, you can just pass that string dir
here, now. Passing NULL is the same as passing -1 here in SDL2, to signify you want SDL
to decide for you.
SDL_RenderWindowToLogical() and SDL_RenderLogicalToWindow() take floating point coordinates in both directions.
Mouse and touch events are no longer filtered to change their coordinates, instead you
can call SDL_ConvertEventToRenderCoordinates() to explicitly map event coordinates into
the rendering viewport.
SDL_RenderWindowToLogical() and SDL_RenderLogicalToWindow() have been renamed SDL_RenderCoordinatesFromWindow() and SDL_RenderCoordinatesToWindow() and take floating point coordinates in both directions.
The viewport, clipping state, and scale for render targets are now persistent and will remain set whenever they are active.
The following functions have been renamed:
* SDL_GetRendererOutputSize() => SDL_GetCurrentRenderOutputSize()
* SDL_RenderCopyExF() => SDL_RenderTextureRotated()
* SDL_RenderCopyF() => SDL_RenderTexture()
* SDL_RenderDrawLineF() => SDL_RenderLine()
@ -609,19 +618,21 @@ The following functions have been renamed:
* SDL_RenderFillRectsF() => SDL_RenderFillRects()
* SDL_RenderGetClipRect() => SDL_GetRenderClipRect()
* SDL_RenderGetIntegerScale() => SDL_GetRenderIntegerScale()
* SDL_RenderGetLogicalSize() => SDL_GetRenderLogicalSize()
* SDL_RenderGetLogicalSize() => SDL_GetRenderLogicalPresentation()
* SDL_RenderGetMetalCommandEncoder() => SDL_GetRenderMetalCommandEncoder()
* SDL_RenderGetMetalLayer() => SDL_GetRenderMetalLayer()
* SDL_RenderGetScale() => SDL_GetRenderScale()
* SDL_RenderGetViewport() => SDL_GetRenderViewport()
* SDL_RenderGetWindow() => SDL_GetRenderWindow()
* SDL_RenderIsClipEnabled() => SDL_RenderClipEnabled()
* SDL_RenderLogicalToWindow() => SDL_RenderCoordinatesToWindow()
* SDL_RenderSetClipRect() => SDL_SetRenderClipRect()
* SDL_RenderSetIntegerScale() => SDL_SetRenderIntegerScale()
* SDL_RenderSetLogicalSize() => SDL_SetRenderLogicalSize()
* SDL_RenderSetLogicalSize() => SDL_SetRenderLogicalPresentation()
* SDL_RenderSetScale() => SDL_SetRenderScale()
* SDL_RenderSetVSync() => SDL_SetRenderVSync()
* SDL_RenderSetViewport() => SDL_SetRenderViewport()
* SDL_RenderWindowToLogical() => SDL_RenderCoordinatesFromWindow()
The following functions have been removed:
* SDL_RenderCopy()
@ -634,6 +645,9 @@ The following functions have been removed:
* SDL_RenderDrawRects()
* SDL_RenderFillRect()
* SDL_RenderFillRects()
* SDL_RenderGetIntegerScale()
* SDL_RenderSetIntegerScale() - this is now explicit with SDL_LOGICAL_PRESENTATION_INTEGER_SCALE
* SDL_RenderTargetSupported() - render targets are always supported
## SDL_rwops.h

View File

@ -1143,17 +1143,6 @@ extern "C" {
*/
#define SDL_HINT_MOUSE_RELATIVE_MODE_WARP "SDL_MOUSE_RELATIVE_MODE_WARP"
/**
* \brief A variable controlling whether relative mouse motion is affected by renderer scaling
*
* This variable can be set to the following values:
* "0" - Relative motion is unaffected by display scale or renderer's logical size
* "1" - Relative motion is scaled according to display scale scaling and logical size
*
* By default relative mouse deltas are affected by display scale and renderer scaling
*/
#define SDL_HINT_MOUSE_RELATIVE_SCALING "SDL_MOUSE_RELATIVE_SCALING"
/**
* \brief A variable setting the scale for mouse motion, in floating point, when the mouse is in relative mode
*/
@ -1399,17 +1388,6 @@ extern "C" {
*/
#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER"
/**
* \brief A variable controlling the scaling policy for SDL_SetRenderLogicalSize.
*
* This variable can be set to the following values:
* "0" or "letterbox" - Uses letterbox/sidebars to fit the entire rendering on screen
* "1" or "overscan" - Will zoom the rendering so it fills the entire screen, allowing edges to be drawn offscreen
*
* By default letterbox is used
*/
#define SDL_HINT_RENDER_LOGICAL_SIZE_MODE "SDL_RENDER_LOGICAL_SIZE_MODE"
/**
* \brief A variable controlling whether the OpenGL render driver uses shaders if they are available.
*

View File

@ -345,6 +345,7 @@
#define SDL_UnionRect SDL_GetRectUnion
/* ##SDL_render.h */
#define SDL_GetRendererOutputSize SDL_GetCurrentRenderOutputSize
#define SDL_RenderCopyExF SDL_RenderTextureRotated
#define SDL_RenderCopyF SDL_RenderTexture
#define SDL_RenderDrawLineF SDL_RenderLine
@ -356,20 +357,20 @@
#define SDL_RenderFillRectF SDL_RenderFillRect
#define SDL_RenderFillRectsF SDL_RenderFillRects
#define SDL_RenderGetClipRect SDL_GetRenderClipRect
#define SDL_RenderGetIntegerScale SDL_GetRenderIntegerScale
#define SDL_RenderGetLogicalSize SDL_GetRenderLogicalSize
#define SDL_RenderGetLogicalSize SDL_GetRenderLogicalPresentation
#define SDL_RenderGetMetalCommandEncoder SDL_GetRenderMetalCommandEncoder
#define SDL_RenderGetMetalLayer SDL_GetRenderMetalLayer
#define SDL_RenderGetScale SDL_GetRenderScale
#define SDL_RenderGetViewport SDL_GetRenderViewport
#define SDL_RenderGetWindow SDL_GetRenderWindow
#define SDL_RenderIsClipEnabled SDL_RenderClipEnabled
#define SDL_RenderLogicalToWindow SDL_RenderCoordinatesToWindow
#define SDL_RenderSetClipRect SDL_SetRenderClipRect
#define SDL_RenderSetIntegerScale SDL_SetRenderIntegerScale
#define SDL_RenderSetLogicalSize SDL_SetRenderLogicalSize
#define SDL_RenderSetLogicalSize SDL_SetRenderLogicalPresentation
#define SDL_RenderSetScale SDL_SetRenderScale
#define SDL_RenderSetVSync SDL_SetRenderVSync
#define SDL_RenderSetViewport SDL_SetRenderViewport
#define SDL_RenderWindowToLogical SDL_RenderCoordinatesFromWindow
/* ##SDL_rwops.h */
#define RW_SEEK_CUR SDL_RW_SEEK_CUR
@ -730,6 +731,7 @@
#define SDL_UnionRect SDL_UnionRect_renamed_SDL_GetRectUnion
/* ##SDL_render.h */
#define SDL_GetRendererOutputSize SDL_GetRendererOutputSize_renamed_SDL_GetCurrentRenderOutputSize
#define SDL_RenderCopyExF SDL_RenderCopyExF_renamed_SDL_RenderTextureRotated
#define SDL_RenderCopyF SDL_RenderCopyF_renamed_SDL_RenderTexture
#define SDL_RenderDrawLineF SDL_RenderDrawLineF_renamed_SDL_RenderLine
@ -741,20 +743,20 @@
#define SDL_RenderFillRectF SDL_RenderFillRectF_renamed_SDL_RenderFillRect
#define SDL_RenderFillRectsF SDL_RenderFillRectsF_renamed_SDL_RenderFillRects
#define SDL_RenderGetClipRect SDL_RenderGetClipRect_renamed_SDL_GetRenderClipRect
#define SDL_RenderGetIntegerScale SDL_RenderGetIntegerScale_renamed_SDL_GetRenderIntegerScale
#define SDL_RenderGetLogicalSize SDL_RenderGetLogicalSize_renamed_SDL_GetRenderLogicalSize
#define SDL_RenderGetLogicalSize SDL_RenderGetLogicalSize_renamed_SDL_GetRenderLogicalPresentation
#define SDL_RenderGetMetalCommandEncoder SDL_RenderGetMetalCommandEncoder_renamed_SDL_GetRenderMetalCommandEncoder
#define SDL_RenderGetMetalLayer SDL_RenderGetMetalLayer_renamed_SDL_GetRenderMetalLayer
#define SDL_RenderGetScale SDL_RenderGetScale_renamed_SDL_GetRenderScale
#define SDL_RenderGetViewport SDL_RenderGetViewport_renamed_SDL_GetRenderViewport
#define SDL_RenderGetWindow SDL_RenderGetWindow_renamed_SDL_GetRenderWindow
#define SDL_RenderIsClipEnabled SDL_RenderIsClipEnabled_renamed_SDL_RenderClipEnabled
#define SDL_RenderLogicalToWindow SDL_RenderLogicalToWindow_renamed_SDL_RenderCoordinatesToWindow
#define SDL_RenderSetClipRect SDL_RenderSetClipRect_renamed_SDL_SetRenderClipRect
#define SDL_RenderSetIntegerScale SDL_RenderSetIntegerScale_renamed_SDL_SetRenderIntegerScale
#define SDL_RenderSetLogicalSize SDL_RenderSetLogicalSize_renamed_SDL_SetRenderLogicalSize
#define SDL_RenderSetLogicalSize SDL_RenderSetLogicalSize_renamed_SDL_SetRenderLogicalPresentation
#define SDL_RenderSetScale SDL_RenderSetScale_renamed_SDL_SetRenderScale
#define SDL_RenderSetVSync SDL_RenderSetVSync_renamed_SDL_SetRenderVSync
#define SDL_RenderSetViewport SDL_RenderSetViewport_renamed_SDL_SetRenderViewport
#define SDL_RenderWindowToLogical SDL_RenderWindowToLogical_renamed_SDL_RenderCoordinatesFromWindow
/* ##SDL_rwops.h */
#define RW_SEEK_CUR RW_SEEK_CUR_renamed_SDL_RW_SEEK_CUR

View File

@ -68,8 +68,6 @@ typedef enum
acceleration */
SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized
with the refresh rate */
SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports
rendering to texture */
} SDL_RendererFlags;
/**
@ -135,6 +133,19 @@ typedef enum
SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */
} SDL_RendererFlip;
/**
* How the logical size is mapped to the output
*/
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 screen coordinates */
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 */
SDL_LOGICAL_PRESENTATION_INTEGER_SCALE, /**< The rendered content is scaled up by integer multiples to fit the output resolution */
} SDL_RendererLogicalPresentation;
/**
* A structure representing rendering state
*/
@ -223,6 +234,10 @@ 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 screen coordinates,
* but you can call SDL_SetRenderLogicalPresentation() to enable high DPI
* rendering or 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
* initialize the first one supporting the requested flags
@ -301,15 +316,14 @@ 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 pixels of a rendering context.
* Get the output size in screen coordinates of a rendering context.
*
* Due to high-dpi displays, you might end up with a rendering context that
* has more pixels than the window that contains it, so use this instead of
* SDL_GetWindowSize() to decide how much drawing area you have.
* This returns the true output size in screen coordinates, ignoring any
* render targets or logical size and presentation.
*
* \param renderer the rendering context
* \param w an int filled with the width
* \param h an int filled with the height
* \param w a pointer filled in with the width in screen coordinates
* \param h a pointer filled in with the height in screen coordinates
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
@ -317,7 +331,46 @@ extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_Rend
*
* \sa SDL_GetRenderer
*/
extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer *renderer, int *w, int *h);
extern DECLSPEC int SDLCALL SDL_GetRenderWindowSize(SDL_Renderer *renderer, int *w, int *h);
/**
* Get the output size in pixels of a rendering context.
*
* This returns the true output size in pixels, ignoring any render targets
* or logical size and presentation.
*
* \param renderer the rendering context
* \param w a pointer filled in with the width in pixels
* \param h a pointer filled in with the height in pixels
* \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_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
/**
* Get the current output size in pixels of a rendering context.
*
* If a rendering target is active, this will return the size of the
* rendering target in pixels, otherwise if a logical size is set, it will
* return the logical size, otherwise it will return the value of
* SDL_GetRenderOutputSize().
*
* \param renderer the rendering context
* \param w a pointer filled in with the current width
* \param h a pointer filled in with the current height
* \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_GetRenderOutputSize
* \sa SDL_GetRenderer
*/
extern DECLSPEC int SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
/**
* Create a texture for a rendering context.
@ -736,18 +789,6 @@ extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
*/
extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
/**
* Determine whether a renderer supports the use of render targets.
*
* \param renderer the renderer that will be checked
* \returns SDL_TRUE if supported or SDL_FALSE if not.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetRenderTarget
*/
extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
/**
* Set a texture as the current rendering target.
*
@ -788,92 +829,116 @@ extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Text
extern DECLSPEC SDL_Texture *SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
/**
* Set a device independent resolution for rendering.
* Set a device independent resolution and presentation mode for rendering.
*
* This function uses the viewport and scaling functionality to allow a fixed
* logical resolution for rendering, regardless of the actual output
* resolution. If the actual output resolution doesn't have the same aspect
* ratio the output rendering will be centered within the output display.
* This function sets the width and height of the logical rendering output.
* A render target is created at the specified size and used for rendering
* and then copied to the output during presentation.
*
* If the output display is a window, mouse and touch events in the window
* will be filtered and scaled so they seem to arrive within the logical
* resolution. The SDL_HINT_MOUSE_RELATIVE_SCALING hint controls whether
* relative motion events are also scaled.
* When a renderer is created, the logical size is set to match the window
* size in screen coordinates. The actual output size may be higher pixel
* density, and can be queried with SDL_GetRenderOutputSize().
*
* If this function results in scaling or subpixel drawing by the rendering
* backend, it will be handled using the appropriate quality hints.
* 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.
*
* \param renderer the renderer for which resolution should be set
* You can convert coordinates in an event into rendering coordinates using
* SDL_ConvertEventToRenderCoordinates().
*
* \param renderer the rendering context
* \param w the width of the logical resolution
* \param h the height of the logical resolution
* \param mode the presentation mode used
* \param scale_mode the scale mode used
* \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_GetRenderLogicalSize
* \sa SDL_ConvertEventToRenderCoordinates
* \sa SDL_GetRenderLogicalPresentation
*/
extern DECLSPEC int SDLCALL SDL_SetRenderLogicalSize(SDL_Renderer *renderer, int w, int h);
extern DECLSPEC int SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode, SDL_ScaleMode scale_mode);
/**
* Get device independent resolution for rendering.
* Get device independent resolution and presentation mode for rendering.
*
* When using the main rendering target (eg no target texture is set): this
* may return 0 for `w` and `h` if the SDL_Renderer has never had its logical
* size set by SDL_SetRenderLogicalSize(). Otherwise it returns the logical
* width and height.
* This function gets the width and height of the logical rendering output,
* or the output size in pixels if a logical resolution is not enabled.
*
* When using a target texture: Never return 0 for `w` and `h` at first. Then
* it returns the logical width and height that are set.
*
* \param renderer a rendering context
* \param renderer the rendering context
* \param w an int to be filled with the width
* \param h an int to be filled with the height
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_SetRenderLogicalSize
*/
extern DECLSPEC void SDLCALL SDL_GetRenderLogicalSize(SDL_Renderer *renderer, int *w, int *h);
/**
* Set whether to force integer scales for resolution-independent rendering.
*
* This function restricts the logical viewport to integer values - that is,
* when a resolution is between two multiples of a logical size, the viewport
* size is rounded down to the lower multiple.
*
* \param renderer the renderer for which integer scaling should be set
* \param enable enable or disable the integer scaling for rendering
* \param mode a pointer filled in with the presentation mode
* \param scale_mode a pointer filled in with the scale mode
* \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_GetRenderIntegerScale
* \sa SDL_SetRenderLogicalSize
* \sa SDL_SetRenderLogicalPresentation
*/
extern DECLSPEC int SDLCALL SDL_SetRenderIntegerScale(SDL_Renderer *renderer, SDL_bool enable);
extern DECLSPEC int SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode, SDL_ScaleMode *scale_mode);
/**
* Get whether integer scales are forced for resolution-independent rendering.
* Get a point in render coordinates when given a point in window coordinates.
*
* \param renderer the renderer from which integer scaling should be queried
* \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on
* failure; call SDL_GetError() for more information.
* \param renderer the rendering context
* \param window_x the x coordinate in window coordinates
* \param window_y the y coordinate in window coordinates
* \param x a pointer filled with the x coordinate in render coordinates
* \param y a pointer filled with the y coordinate in render coordinates
* \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_SetRenderIntegerScale
* \sa SDL_SetRenderLogicalPresentation
* \sa SDL_SetRenderScale
*/
extern DECLSPEC SDL_bool SDLCALL SDL_GetRenderIntegerScale(SDL_Renderer *renderer);
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 when given a point in render coordinates.
*
* \param renderer the rendering context
* \param x the x coordinate in render coordinates
* \param y the y coordinate in render coordinates
* \param window_x a pointer filled with the x coordinate in window coordinates
* \param window_y a pointer filled with the y coordinate in window coordinates
* \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_SetRenderLogicalPresentation
* \sa SDL_SetRenderScale
*/
extern DECLSPEC int SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
/**
* Convert the coordinates in an event to render coordinates.
*
* Touch coordinates are converted from normalized coordinates in the window
* to non-normalized rendering coordinates.
*
* Once converted, the coordinates may be outside the rendering area.
*
* \param renderer the rendering context
* \param event the event to modify
* \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_GetRenderCoordinatesFromWindowCoordinates
*/
extern DECLSPEC int SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
/**
* Set the drawing area for rendering on the current target.
*
* When the window is resized, the viewport is reset to fill the entire new
* window size.
*
* \param renderer the rendering context
* \param rect the SDL_Rect structure representing the drawing area, or NULL
* to set the viewport to the entire target
@ -891,18 +956,19 @@ extern DECLSPEC int SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const
*
* \param renderer the rendering context
* \param rect an SDL_Rect structure filled in with the current drawing area
* \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_SetRenderViewport
*/
extern DECLSPEC void SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
/**
* Set the clip rectangle for rendering on the specified target.
*
* \param renderer the rendering context for which clip rectangle should be
* set
* \param renderer the rendering context
* \param rect an SDL_Rect structure representing the clip area, relative to
* the viewport, or NULL to disable clipping
* \returns 0 on success or a negative error code on failure; call
@ -918,22 +984,23 @@ extern DECLSPEC int SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const
/**
* Get the clip rectangle for the current target.
*
* \param renderer the rendering context from which clip rectangle should be
* queried
* \param renderer the rendering context
* \param rect an SDL_Rect structure filled in with the current clipping area
* or an empty rectangle if clipping is disabled
* \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_RenderClipEnabled
* \sa SDL_SetRenderClipRect
*/
extern DECLSPEC void SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
extern DECLSPEC int SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
/**
* Get whether clipping is enabled on the given renderer.
*
* \param renderer the renderer from which clip state should be queried
* \param renderer the rendering context
* \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
* SDL_GetError() for more information.
*
@ -944,7 +1011,6 @@ extern DECLSPEC void SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_R
*/
extern DECLSPEC SDL_bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
/**
* Set the drawing scale for rendering on the current target.
*
@ -956,7 +1022,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
* will be handled using the appropriate quality hints. For best results use
* integer scaling factors.
*
* \param renderer a rendering context
* \param renderer the rendering context
* \param scaleX the horizontal scaling factor
* \param scaleY the vertical scaling factor
* \returns 0 on success or a negative error code on failure; call
@ -965,73 +1031,23 @@ extern DECLSPEC SDL_bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetRenderScale
* \sa SDL_SetRenderLogicalSize
*/
extern DECLSPEC int SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
/**
* Get the drawing scale for the current target.
*
* \param renderer the renderer from which drawing scale should be queried
* \param renderer the rendering context
* \param scaleX a pointer filled in with the horizontal scaling factor
* \param scaleY a pointer filled in with the vertical scaling factor
* \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_SetRenderScale
*/
extern DECLSPEC void SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
/**
* Get logical coordinates of point in renderer when given real coordinates of
* point in window.
*
* Logical coordinates will differ from real coordinates when render is scaled
* and logical renderer size set
*
* \param renderer the renderer from which the logical coordinates should be
* calculated
* \param windowX the real X coordinate in the window
* \param windowY the real Y coordinate in the window
* \param logicalX the pointer filled with the logical x coordinate
* \param logicalY the pointer filled with the logical y coordinate
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetRenderScale
* \sa SDL_SetRenderScale
* \sa SDL_GetRenderLogicalSize
* \sa SDL_SetRenderLogicalSize
*/
extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer *renderer,
float windowX, float windowY,
float *logicalX, float *logicalY);
/**
* Get real coordinates of point in window when given logical coordinates of
* point in renderer.
*
* Logical coordinates will differ from real coordinates when render is scaled
* and logical renderer size set
*
* \param renderer the renderer from which the window coordinates should be
* calculated
* \param logicalX the logical x coordinate
* \param logicalY the logical y coordinate
* \param windowX the pointer filled with the real X coordinate in the window
* \param windowY the pointer filled with the real Y coordinate in the window
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetRenderScale
* \sa SDL_SetRenderScale
* \sa SDL_GetRenderLogicalSize
* \sa SDL_SetRenderLogicalSize
*/
extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer *renderer,
float logicalX, float logicalY,
float *windowX, float *windowY);
extern DECLSPEC int SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
/**
* Set the color used for drawing operations (Rect, Line and Clear).
@ -1356,8 +1372,8 @@ extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
* Bitmap data pads all rows to multiples of 4 bytes).
*
* \param renderer the rendering context
* \param rect an SDL_Rect structure representing the area to read, or NULL
* for the entire render target
* \param rect an SDL_Rect structure representing the area in pixels relative
* to the to current viewport, or NULL for the entire viewport
* \param format an SDL_PixelFormatEnum value of the desired format of the
* pixel data, or 0 to use the format of the rendering target
* \param pixels a pointer to the pixel data to copy into

View File

@ -77,6 +77,8 @@ typedef struct
int window_maxH;
int logical_w;
int logical_h;
SDL_RendererLogicalPresentation logical_presentation;
SDL_ScaleMode logical_scale_mode;
float scale;
int depth;
float refresh_rate;

View File

@ -631,10 +631,10 @@ extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window *window);
* The window size in pixels may differ from its size in screen coordinates if
* the window is on a high density display (one with an OS scaling factor).
* Use SDL_GetWindowSize() to query the client area's size in screen
* coordinates, and SDL_GetWindowSizeInPixels() or SDL_GetRendererOutputSize()
* coordinates, and SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize()
* to query the drawable size in pixels. Note that the drawable size can vary
* after the window is created and should be queried again when the window is
* resized or moved between displays.
* after the window is created and should be queried again if you get an
* SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED event.
*
* If the window is set fullscreen, the width and height parameters `w` and
* `h` will not be used. However, invalid size parameters (e.g. too large) may
@ -868,7 +868,7 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h)
*
* The window size in screen coordinates may differ from the size in pixels if
* the window is on a high density display (one with an OS scaling factor).
* Use SDL_GetWindowSizeInPixels() or SDL_GetRendererOutputSize() to get the
* Use SDL_GetWindowSizeInPixels() or SDL_GetRenderOutputSize() to get the
* real client area size in pixels.
*
* \param window the window to query the width and height from
@ -877,8 +877,8 @@ extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window *window, int w, int h)
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetRenderOutputSize
* \sa SDL_GetWindowSizeInPixels
* \sa SDL_GetRendererOutputSize
* \sa SDL_SetWindowSize
*/
extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window *window, int *w, int *h);

View File

@ -295,17 +295,15 @@ SDL3_0.0.0 {
SDL_GetRenderDrawBlendMode;
SDL_GetRenderDrawColor;
SDL_GetRenderDriver;
SDL_GetRenderIntegerScale;
SDL_GetRenderLogicalSize;
SDL_GetRenderLogicalPresentation;
SDL_GetRenderMetalCommandEncoder;
SDL_GetRenderMetalLayer;
SDL_GetRenderScale;
SDL_GetRenderTarget;
SDL_GetRenderViewport;
SDL_GetRenderWindow;
SDL_GetRenderer;
SDL_GetRendererInfo;
SDL_GetRendererOutputSize;
SDL_GetCurrentRenderOutputSize;
SDL_GetRevision;
SDL_GetScancodeFromKey;
SDL_GetScancodeFromName;
@ -526,17 +524,16 @@ SDL3_0.0.0 {
SDL_RenderGetD3D12Device;
SDL_RenderLine;
SDL_RenderLines;
SDL_RenderLogicalToWindow;
SDL_RenderCoordinatesToWindow;
SDL_RenderPoint;
SDL_RenderPoints;
SDL_RenderPresent;
SDL_RenderReadPixels;
SDL_RenderRect;
SDL_RenderRects;
SDL_RenderTargetSupported;
SDL_RenderTexture;
SDL_RenderTextureRotated;
SDL_RenderWindowToLogical;
SDL_RenderCoordinatesFromWindow;
SDL_ReportAssertion;
SDL_ResetAssertionReport;
SDL_ResetHint;
@ -587,9 +584,7 @@ SDL3_0.0.0 {
SDL_SetRenderClipRect;
SDL_SetRenderDrawBlendMode;
SDL_SetRenderDrawColor;
SDL_SetRenderIntegerScale;
SDL_SetRenderLogicalSize;
SDL_SetRenderScale;
SDL_SetRenderLogicalPresentation;
SDL_SetRenderTarget;
SDL_SetRenderVSync;
SDL_SetRenderViewport;
@ -839,6 +834,11 @@ SDL3_0.0.0 {
SDL_GetPrimaryDisplay;
SDL_GetFullscreenDisplayModes;
SDL_GetClosestFullscreenDisplayMode;
SDL_GetRenderOutputSize;
SDL_ConvertEventToRenderCoordinates;
SDL_SetRenderScale;
SDL_GetRenderScale;
SDL_GetRenderWindowSize;
# extra symbols go here (don't modify this line)
local: *;
};

View File

@ -320,17 +320,15 @@
#define SDL_GetRenderDrawBlendMode SDL_GetRenderDrawBlendMode_REAL
#define SDL_GetRenderDrawColor SDL_GetRenderDrawColor_REAL
#define SDL_GetRenderDriver SDL_GetRenderDriver_REAL
#define SDL_GetRenderIntegerScale SDL_GetRenderIntegerScale_REAL
#define SDL_GetRenderLogicalSize SDL_GetRenderLogicalSize_REAL
#define SDL_GetRenderLogicalPresentation SDL_GetRenderLogicalPresentation_REAL
#define SDL_GetRenderMetalCommandEncoder SDL_GetRenderMetalCommandEncoder_REAL
#define SDL_GetRenderMetalLayer SDL_GetRenderMetalLayer_REAL
#define SDL_GetRenderScale SDL_GetRenderScale_REAL
#define SDL_GetRenderTarget SDL_GetRenderTarget_REAL
#define SDL_GetRenderViewport SDL_GetRenderViewport_REAL
#define SDL_GetRenderWindow SDL_GetRenderWindow_REAL
#define SDL_GetRenderer SDL_GetRenderer_REAL
#define SDL_GetRendererInfo SDL_GetRendererInfo_REAL
#define SDL_GetRendererOutputSize SDL_GetRendererOutputSize_REAL
#define SDL_GetCurrentRenderOutputSize SDL_GetCurrentRenderOutputSize_REAL
#define SDL_GetRevision SDL_GetRevision_REAL
#define SDL_GetScancodeFromKey SDL_GetScancodeFromKey_REAL
#define SDL_GetScancodeFromName SDL_GetScancodeFromName_REAL
@ -551,17 +549,16 @@
#define SDL_RenderGetD3D12Device SDL_RenderGetD3D12Device_REAL
#define SDL_RenderLine SDL_RenderLine_REAL
#define SDL_RenderLines SDL_RenderLines_REAL
#define SDL_RenderLogicalToWindow SDL_RenderLogicalToWindow_REAL
#define SDL_RenderCoordinatesToWindow SDL_RenderCoordinatesToWindow_REAL
#define SDL_RenderPoint SDL_RenderPoint_REAL
#define SDL_RenderPoints SDL_RenderPoints_REAL
#define SDL_RenderPresent SDL_RenderPresent_REAL
#define SDL_RenderReadPixels SDL_RenderReadPixels_REAL
#define SDL_RenderRect SDL_RenderRect_REAL
#define SDL_RenderRects SDL_RenderRects_REAL
#define SDL_RenderTargetSupported SDL_RenderTargetSupported_REAL
#define SDL_RenderTexture SDL_RenderTexture_REAL
#define SDL_RenderTextureRotated SDL_RenderTextureRotated_REAL
#define SDL_RenderWindowToLogical SDL_RenderWindowToLogical_REAL
#define SDL_RenderCoordinatesFromWindow SDL_RenderCoordinatesFromWindow_REAL
#define SDL_ReportAssertion SDL_ReportAssertion_REAL
#define SDL_ResetAssertionReport SDL_ResetAssertionReport_REAL
#define SDL_ResetHint SDL_ResetHint_REAL
@ -612,9 +609,7 @@
#define SDL_SetRenderClipRect SDL_SetRenderClipRect_REAL
#define SDL_SetRenderDrawBlendMode SDL_SetRenderDrawBlendMode_REAL
#define SDL_SetRenderDrawColor SDL_SetRenderDrawColor_REAL
#define SDL_SetRenderIntegerScale SDL_SetRenderIntegerScale_REAL
#define SDL_SetRenderLogicalSize SDL_SetRenderLogicalSize_REAL
#define SDL_SetRenderScale SDL_SetRenderScale_REAL
#define SDL_SetRenderLogicalPresentation SDL_SetRenderLogicalPresentation_REAL
#define SDL_SetRenderTarget SDL_SetRenderTarget_REAL
#define SDL_SetRenderVSync SDL_SetRenderVSync_REAL
#define SDL_SetRenderViewport SDL_SetRenderViewport_REAL
@ -866,3 +861,8 @@
#define SDL_GetPrimaryDisplay SDL_GetPrimaryDisplay_REAL
#define SDL_GetFullscreenDisplayModes SDL_GetFullscreenDisplayModes_REAL
#define SDL_GetClosestFullscreenDisplayMode SDL_GetClosestFullscreenDisplayMode_REAL
#define SDL_GetRenderOutputSize SDL_GetRenderOutputSize_REAL
#define SDL_ConvertEventToRenderCoordinates SDL_ConvertEventToRenderCoordinates_REAL
#define SDL_SetRenderScale SDL_SetRenderScale_REAL
#define SDL_GetRenderScale SDL_GetRenderScale_REAL
#define SDL_GetRenderWindowSize SDL_GetRenderWindowSize_REAL

View File

@ -388,21 +388,19 @@ SDL_DYNAPI_PROC(void,SDL_GetRectUnion,(const SDL_Rect *a, const SDL_Rect *b, SDL
SDL_DYNAPI_PROC(void,SDL_GetRectUnionFloat,(const SDL_FRect *a, const SDL_FRect *b, SDL_FRect *c),(a,b,c),)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRelativeMouseMode,(void),(),return)
SDL_DYNAPI_PROC(Uint32,SDL_GetRelativeMouseState,(float *a, float *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_GetRenderClipRect,(SDL_Renderer *a, SDL_Rect *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_GetRenderClipRect,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderDrawColor,(SDL_Renderer *a, Uint8 *b, Uint8 *c, Uint8 *d, Uint8 *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(const char*,SDL_GetRenderDriver,(int a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_GetRenderIntegerScale,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GetRenderLogicalSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),)
SDL_DYNAPI_PROC(int,SDL_GetRenderLogicalPresentation,(SDL_Renderer *a, int *b, int *c, SDL_RendererLogicalPresentation *d, SDL_ScaleMode *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(void*,SDL_GetRenderMetalCommandEncoder,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(void*,SDL_GetRenderMetalLayer,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GetRenderScale,(SDL_Renderer *a, float *b, float *c),(a,b,c),)
SDL_DYNAPI_PROC(SDL_Texture*,SDL_GetRenderTarget,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(void,SDL_GetRenderViewport,(SDL_Renderer *a, SDL_Rect *b),(a,b),)
SDL_DYNAPI_PROC(int,SDL_GetRenderViewport,(SDL_Renderer *a, SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Window*,SDL_GetRenderWindow,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_GetRenderer,(SDL_Window *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_GetRendererInfo,(SDL_Renderer *a, SDL_RendererInfo *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_GetRendererOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetCurrentRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(const char*,SDL_GetRevision,(void),(),return)
SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromKey,(SDL_Keycode a),(a),return)
SDL_DYNAPI_PROC(SDL_Scancode,SDL_GetScancodeFromName,(const char *a),(a),return)
@ -607,17 +605,16 @@ SDL_DYNAPI_PROC(int,SDL_RenderGeometry,(SDL_Renderer *a, SDL_Texture *b, const S
SDL_DYNAPI_PROC(int,SDL_RenderGeometryRaw,(SDL_Renderer *a, SDL_Texture *b, const float *c, int d, const SDL_Color *e, int f, const float *g, int h, int i, const void *j, int k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
SDL_DYNAPI_PROC(int,SDL_RenderLine,(SDL_Renderer *a, float b, float c, float d, float e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_RenderLines,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_RenderLogicalToWindow,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(int,SDL_RenderCoordinatesToWindow,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_RenderPoint,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_RenderPoints,(SDL_Renderer *a, const SDL_FPoint *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(void,SDL_RenderPresent,(SDL_Renderer *a),(a),)
SDL_DYNAPI_PROC(int,SDL_RenderReadPixels,(SDL_Renderer *a, const SDL_Rect *b, Uint32 c, void *d, int e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_RenderRect,(SDL_Renderer *a, const SDL_FRect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_RenderRects,(SDL_Renderer *a, const SDL_FRect *b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_RenderTargetSupported,(SDL_Renderer *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_RenderTexture,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_RenderTextureRotated,(SDL_Renderer *a, SDL_Texture *b, const SDL_Rect *c, const SDL_FRect *d, const double e, const SDL_FPoint *f, const SDL_RendererFlip g),(a,b,c,d,e,f,g),return)
SDL_DYNAPI_PROC(void,SDL_RenderWindowToLogical,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),)
SDL_DYNAPI_PROC(int,SDL_RenderCoordinatesFromWindow,(SDL_Renderer *a, float b, float c, float *d, float *e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(SDL_AssertState,SDL_ReportAssertion,(SDL_AssertData *a, const char *b, const char *c, int d),(a,b,c,d),return)
SDL_DYNAPI_PROC(void,SDL_ResetAssertionReport,(void),(),)
SDL_DYNAPI_PROC(SDL_bool,SDL_ResetHint,(const char *a),(a),return)
@ -667,9 +664,7 @@ SDL_DYNAPI_PROC(int,SDL_SetRelativeMouseMode,(SDL_bool a),(a),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderClipRect,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderDrawBlendMode,(SDL_Renderer *a, SDL_BlendMode b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderDrawColor,(SDL_Renderer *a, Uint8 b, Uint8 c, Uint8 d, Uint8 e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderIntegerScale,(SDL_Renderer *a, SDL_bool b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderLogicalSize,(SDL_Renderer *a, int b, int c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderScale,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderLogicalPresentation,(SDL_Renderer *a, int b, int c, SDL_RendererLogicalPresentation d, SDL_ScaleMode e),(a,b,c,d,e),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderTarget,(SDL_Renderer *a, SDL_Texture *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderVSync,(SDL_Renderer *a, int b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderViewport,(SDL_Renderer *a, const SDL_Rect *b),(a,b),return)
@ -911,3 +906,8 @@ SDL_DYNAPI_PROC(SDL_DisplayID*,SDL_GetDisplays,(int *a),(a),return)
SDL_DYNAPI_PROC(SDL_DisplayID,SDL_GetPrimaryDisplay,(void),(),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode**,SDL_GetFullscreenDisplayModes,(SDL_DisplayID a, int *b),(a,b),return)
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetClosestFullscreenDisplayMode,(SDL_DisplayID a, int b, int c, float d),(a,b,c,d),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderOutputSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_ConvertEventToRenderCoordinates,(SDL_Renderer *a, SDL_Event *b),(a,b),return)
SDL_DYNAPI_PROC(int,SDL_SetRenderScale,(SDL_Renderer *a, float b, float c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderScale,(SDL_Renderer *a, float *b, float *c),(a,b,c),return)
SDL_DYNAPI_PROC(int,SDL_GetRenderWindowSize,(SDL_Renderer *a, int *b, int *c),(a,b,c),return)

1162
src/render/SDL_render.c Normal file → Executable file

File diff suppressed because it is too large Load Diff

View File

@ -45,18 +45,31 @@ typedef struct SDL_DRect
typedef struct SDL_RenderDriver SDL_RenderDriver;
/* Rendering view state */
typedef struct SDL_RenderViewState
{
int pixel_w;
int pixel_h;
SDL_Rect viewport;
SDL_Rect clip_rect;
SDL_bool clipping_enabled;
SDL_FPoint scale;
} SDL_RenderViewState;
/* Define the SDL texture structure */
struct SDL_Texture
{
const void *magic;
Uint32 format; /**< The pixel format of the texture */
int access; /**< SDL_TextureAccess */
int w; /**< The width of the texture */
int h; /**< The height of the texture */
int modMode; /**< The texture modulation mode */
SDL_BlendMode blendMode; /**< The texture blend mode */
SDL_ScaleMode scaleMode; /**< The texture scale mode */
SDL_Color color; /**< Texture modulation values */
Uint32 format; /**< The pixel format of the texture */
int access; /**< SDL_TextureAccess */
int w; /**< The width of the texture */
int h; /**< The height of the texture */
int modMode; /**< The texture modulation mode */
SDL_BlendMode blendMode; /**< The texture blend mode */
SDL_ScaleMode scaleMode; /**< The texture scale mode */
SDL_Color color; /**< Texture modulation values */
SDL_RenderViewState view; /**< Target texture view state */
SDL_Renderer *renderer;
@ -212,37 +225,19 @@ struct SDL_Renderer
Uint64 simulate_vsync_interval_ns;
Uint64 last_present;
/* The logical resolution for rendering */
int logical_w;
int logical_h;
int logical_w_backup;
int logical_h_backup;
/* Support for logical output coordinates */
SDL_Texture *logical_target;
SDL_RendererLogicalPresentation logical_presentation_mode;
SDL_ScaleMode logical_scale_mode;
SDL_Rect logical_src_rect;
SDL_FRect logical_dst_rect;
/* Whether or not to force the viewport to even integer intervals */
SDL_bool integer_scale;
SDL_RenderViewState *view;
SDL_RenderViewState main_view;
/* The drawable area within the window */
SDL_DRect viewport;
SDL_DRect viewport_backup;
/* The clip rectangle within the window */
SDL_DRect clip_rect;
SDL_DRect clip_rect_backup;
/* Whether or not the clipping rectangle is used. */
SDL_bool clipping_enabled;
SDL_bool clipping_enabled_backup;
/* The render output coordinate scale */
SDL_FPoint scale;
SDL_FPoint scale_backup;
/* The pixel to point coordinate scale */
/* The window pixel to point coordinate scale */
SDL_FPoint dpi_scale;
/* Whether or not to scale relative mouse motion */
SDL_bool relative_scaling;
/* The method of drawing lines */
SDL_RenderLineMethod line_method;
@ -264,8 +259,8 @@ struct SDL_Renderer
SDL_RenderCommand *render_commands_pool;
Uint32 render_command_generation;
Uint32 last_queued_color;
SDL_DRect last_queued_viewport;
SDL_DRect last_queued_cliprect;
SDL_Rect last_queued_viewport;
SDL_Rect last_queued_cliprect;
SDL_bool last_queued_cliprect_enabled;
SDL_bool color_queued;
SDL_bool viewport_queued;

View File

@ -337,12 +337,6 @@ static void D3D_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event
}
}
static int D3D_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
{
SDL_GetWindowSizeInPixels(renderer->window, w, h);
return 0;
}
static D3DBLEND GetBlendFunc(SDL_BlendFactor factor)
{
switch (factor) {
@ -1586,7 +1580,6 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
}
renderer->WindowEvent = D3D_WindowEvent;
renderer->GetOutputSize = D3D_GetOutputSize;
renderer->SupportsBlendMode = D3D_SupportsBlendMode;
renderer->CreateTexture = D3D_CreateTexture;
renderer->UpdateTexture = D3D_UpdateTexture;
@ -1609,7 +1602,7 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->DestroyRenderer = D3D_DestroyRenderer;
renderer->SetVSync = D3D_SetVSync;
renderer->info = D3D_RenderDriver.info;
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data;
SDL_GetWindowSizeInPixels(window, &w, &h);
@ -1727,7 +1720,7 @@ D3D_CreateRenderer(SDL_Window *window, Uint32 flags)
SDL_RenderDriver D3D_RenderDriver = {
D3D_CreateRenderer,
{ "direct3d",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
1,
{ SDL_PIXELFORMAT_ARGB8888 },
0,

View File

@ -1033,14 +1033,6 @@ static void D3D11_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve
}
}
#if !defined(__WINRT__)
static int D3D11_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
{
SDL_GetWindowSizeInPixels(renderer->window, w, h);
return 0;
}
#endif
static SDL_bool D3D11_SupportsBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode)
{
SDL_BlendFactor srcColorFactor = SDL_GetBlendModeSrcColorFactor(blendMode);
@ -2324,9 +2316,6 @@ D3D11_CreateRenderer(SDL_Window *window, Uint32 flags)
data->identity = MatrixIdentity();
renderer->WindowEvent = D3D11_WindowEvent;
#if !defined(__WINRT__)
renderer->GetOutputSize = D3D11_GetOutputSize;
#endif
renderer->SupportsBlendMode = D3D11_SupportsBlendMode;
renderer->CreateTexture = D3D11_CreateTexture;
renderer->UpdateTexture = D3D11_UpdateTexture;
@ -2349,7 +2338,7 @@ D3D11_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->DestroyTexture = D3D11_DestroyTexture;
renderer->DestroyRenderer = D3D11_DestroyRenderer;
renderer->info = D3D11_RenderDriver.info;
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data;
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
@ -2394,12 +2383,10 @@ SDL_RenderDriver D3D11_RenderDriver = {
D3D11_CreateRenderer,
{
"direct3d11",
(
SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTVSYNC |
SDL_RENDERER_TARGETTEXTURE), /* flags. see SDL_RendererFlags */
6, /* num_texture_formats */
{ /* texture_formats */
(SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTVSYNC), /* flags. see SDL_RendererFlags */
6, /* num_texture_formats */
{ /* texture_formats */
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_YV12,

View File

@ -502,12 +502,6 @@ static void D3D12_DestroyRenderer(SDL_Renderer *renderer)
SDL_free(renderer);
}
static int D3D12_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
{
SDL_GetWindowSizeInPixels(renderer->window, w, h);
return 0;
}
static D3D12_BLEND GetBlendFunc(SDL_BlendFactor factor)
{
switch (factor) {
@ -2972,7 +2966,6 @@ D3D12_CreateRenderer(SDL_Window *window, Uint32 flags)
data->identity = MatrixIdentity();
renderer->WindowEvent = D3D12_WindowEvent;
renderer->GetOutputSize = D3D12_GetOutputSize;
renderer->SupportsBlendMode = D3D12_SupportsBlendMode;
renderer->CreateTexture = D3D12_CreateTexture;
renderer->UpdateTexture = D3D12_UpdateTexture;
@ -2995,7 +2988,7 @@ D3D12_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->DestroyTexture = D3D12_DestroyTexture;
renderer->DestroyRenderer = D3D12_DestroyRenderer;
renderer->info = D3D12_RenderDriver.info;
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data;
if ((flags & SDL_RENDERER_PRESENTVSYNC)) {
@ -3025,12 +3018,10 @@ SDL_RenderDriver D3D12_RenderDriver = {
D3D12_CreateRenderer,
{
"direct3d12",
(
SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTVSYNC |
SDL_RENDERER_TARGETTEXTURE), /* flags. see SDL_RendererFlags */
6, /* num_texture_formats */
{ /* texture_formats */
(SDL_RENDERER_ACCELERATED |
SDL_RENDERER_PRESENTVSYNC), /* flags. see SDL_RendererFlags */
6, /* num_texture_formats */
{ /* texture_formats */
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_YV12,

View File

@ -1911,7 +1911,7 @@ static SDL_Renderer *METAL_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->GetMetalCommandEncoder = METAL_GetMetalCommandEncoder;
renderer->info = METAL_RenderDriver.info;
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->always_batch = SDL_TRUE;
@ -1972,7 +1972,7 @@ SDL_RenderDriver METAL_RenderDriver = {
METAL_CreateRenderer,
{
"metal",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
6,
{ SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_ABGR8888,

View File

@ -331,12 +331,6 @@ static void GL_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *event)
}
}
static int GL_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
{
SDL_GetWindowSizeInPixels(renderer->window, w, h);
return 0;
}
static GLenum GetBlendFunc(SDL_BlendFactor factor)
{
switch (factor) {
@ -1440,7 +1434,7 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
return SDL_OutOfMemory();
}
SDL_GetRendererOutputSize(renderer, &w, &h);
SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
data->glPixelStorei(GL_PACK_ALIGNMENT, 1);
data->glPixelStorei(GL_PACK_ROW_LENGTH,
@ -1749,7 +1743,6 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags)
}
renderer->WindowEvent = GL_WindowEvent;
renderer->GetOutputSize = GL_GetOutputSize;
renderer->SupportsBlendMode = GL_SupportsBlendMode;
renderer->CreateTexture = GL_CreateTexture;
renderer->UpdateTexture = GL_UpdateTexture;
@ -1935,9 +1928,13 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags)
SDL_GL_GetProcAddress("glBindFramebufferEXT");
data->glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)
SDL_GL_GetProcAddress("glCheckFramebufferStatusEXT");
renderer->info.flags |= SDL_RENDERER_TARGETTEXTURE;
} else {
SDL_SetError("Can't create render targets, GL_EXT_framebuffer_object not available");
SDL_GL_DeleteContext(data->context);
SDL_free(renderer);
SDL_free(data);
goto error;
}
data->framebuffers = NULL;
/* Set up parameters for rendering */
data->glMatrixMode(GL_MODELVIEW);
@ -1972,7 +1969,7 @@ error:
SDL_RenderDriver GL_RenderDriver = {
GL_CreateRenderer,
{ "opengl",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
4,
{ SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_ABGR8888,

View File

@ -311,12 +311,6 @@ static void GLES2_WindowEvent(SDL_Renderer *renderer, const SDL_WindowEvent *eve
}
}
static int GLES2_GetOutputSize(SDL_Renderer *renderer, int *w, int *h)
{
SDL_GetWindowSizeInPixels(renderer->window, w, h);
return 0;
}
static GLenum GetBlendFunc(SDL_BlendFactor factor)
{
switch (factor) {
@ -1935,7 +1929,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect,
return SDL_OutOfMemory();
}
SDL_GetRendererOutputSize(renderer, &w, &h);
SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
data->glReadPixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h,
rect->w, rect->h, GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels);
@ -2109,7 +2103,7 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
goto error;
}
renderer->info = GLES2_RenderDriver.info;
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data;
renderer->window = window;
@ -2190,7 +2184,6 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
/* Populate the function pointers for the module */
renderer->WindowEvent = GLES2_WindowEvent;
renderer->GetOutputSize = GLES2_GetOutputSize;
renderer->SupportsBlendMode = GLES2_SupportsBlendMode;
renderer->CreateTexture = GLES2_CreateTexture;
renderer->UpdateTexture = GLES2_UpdateTexture;
@ -2272,7 +2265,7 @@ error:
SDL_RenderDriver GLES2_RenderDriver = {
GLES2_CreateRenderer,
{ "opengles2",
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE),
(SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
4,
{ SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_ABGR8888,

View File

@ -665,7 +665,7 @@ SDL_RenderDriver PS2_RenderDriver = {
.CreateRenderer = PS2_CreateRenderer,
.info = {
.name = "PS2 gsKit",
.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
.num_texture_formats = 2,
.texture_formats = {
[0] = SDL_PIXELFORMAT_ABGR1555,

View File

@ -1333,7 +1333,7 @@ PSP_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->DestroyRenderer = PSP_DestroyRenderer;
renderer->SetVSync = PSP_SetVSync;
renderer->info = PSP_RenderDriver.info;
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data;
renderer->window = window;
@ -1407,7 +1407,7 @@ SDL_RenderDriver PSP_RenderDriver = {
.CreateRenderer = PSP_CreateRenderer,
.info = {
.name = "PSP",
.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
.num_texture_formats = 4,
.texture_formats = {
[0] = SDL_PIXELFORMAT_BGR565,

View File

@ -1175,7 +1175,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags)
SDL_RenderDriver SW_RenderDriver = {
SW_CreateRenderer,
{ "software",
SDL_RENDERER_SOFTWARE | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
(SDL_RENDERER_SOFTWARE | SDL_RENDERER_PRESENTVSYNC),
0,
{ /* formats filled in later */
SDL_PIXELFORMAT_UNKNOWN },

View File

@ -102,7 +102,7 @@ SDL_RenderDriver VITA_GXM_RenderDriver = {
.CreateRenderer = VITA_GXM_CreateRenderer,
.info = {
.name = "VITA gxm",
.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC),
.num_texture_formats = 8,
.texture_formats = {
[0] = SDL_PIXELFORMAT_ABGR8888,
@ -253,7 +253,7 @@ VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags)
renderer->SetVSync = VITA_GXM_SetVSync;
renderer->info = VITA_GXM_RenderDriver.info;
renderer->info.flags = (SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
renderer->info.flags = SDL_RENDERER_ACCELERATED;
renderer->driverdata = data;
renderer->window = window;
@ -1106,7 +1106,7 @@ static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rec
return SDL_OutOfMemory();
}
SDL_GetRendererOutputSize(renderer, &w, &h);
SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
read_pixels(rect->x, renderer->target ? rect->y : (h - rect->y) - rect->h,
rect->w, rect->h, temp_pixels);

View File

@ -30,6 +30,8 @@ static const char *video_usage[] = {
"[--fullscreen | --fullscreen-desktop | --windows N]", "[--title title]",
"[--icon icon.bmp]", "[--center | --position X,Y]", "[--geometry WxH]",
"[--min-geometry WxH]", "[--max-geometry WxH]", "[--logical WxH]",
"[--logical-presentation disabled|match|stretch|letterbox|overscan|integer_scale]",
"[--logical-scale-quality nearest|linear|best]",
"[--scale N]", "[--depth N]", "[--refresh R]", "[--vsync]", "[--noframe]",
"[--resizable]", "[--minimize]", "[--maximize]", "[--grab]", "[--keyboard-grab]",
"[--hidden]", "[--input-focus]", "[--mouse-focus]",
@ -83,6 +85,8 @@ SDLTest_CommonCreateState(char **argv, Uint32 flags)
state->window_y = SDL_WINDOWPOS_UNDEFINED;
state->window_w = DEFAULT_WINDOW_WIDTH;
state->window_h = DEFAULT_WINDOW_HEIGHT;
state->logical_presentation = SDL_LOGICAL_PRESENTATION_MATCH;
state->logical_scale_mode = SDL_ScaleModeLinear;
state->num_windows = 1;
state->audiospec.freq = 22050;
state->audiospec.format = AUDIO_S16;
@ -399,6 +403,56 @@ int SDLTest_CommonArg(SDLTest_CommonState *state, int index)
state->logical_h = SDL_atoi(h);
return 2;
}
if (SDL_strcasecmp(argv[index], "--logical-presentation") == 0) {
++index;
if (!argv[index]) {
return -1;
}
if (SDL_strcasecmp(argv[index], "disabled") == 0) {
state->logical_presentation = SDL_LOGICAL_PRESENTATION_DISABLED;
return 2;
}
if (SDL_strcasecmp(argv[index], "match") == 0) {
state->logical_presentation = SDL_LOGICAL_PRESENTATION_MATCH;
return 2;
}
if (SDL_strcasecmp(argv[index], "stretch") == 0) {
state->logical_presentation = SDL_LOGICAL_PRESENTATION_STRETCH;
return 2;
}
if (SDL_strcasecmp(argv[index], "letterbox") == 0) {
state->logical_presentation = SDL_LOGICAL_PRESENTATION_LETTERBOX;
return 2;
}
if (SDL_strcasecmp(argv[index], "overscan") == 0) {
state->logical_presentation = SDL_LOGICAL_PRESENTATION_OVERSCAN;
return 2;
}
if (SDL_strcasecmp(argv[index], "integer_scale") == 0) {
state->logical_presentation = SDL_LOGICAL_PRESENTATION_INTEGER_SCALE;
return 2;
}
return -1;
}
if (SDL_strcasecmp(argv[index], "--logical-scale-quality") == 0) {
++index;
if (!argv[index]) {
return -1;
}
if (SDL_strcasecmp(argv[index], "nearest") == 0) {
state->logical_scale_mode = SDL_ScaleModeNearest;
return 2;
}
if (SDL_strcasecmp(argv[index], "linear") == 0) {
state->logical_scale_mode = SDL_ScaleModeLinear;
return 2;
}
if (SDL_strcasecmp(argv[index], "best") == 0) {
state->logical_scale_mode = SDL_ScaleModeBest;
return 2;
}
return -1;
}
if (SDL_strcasecmp(argv[index], "--scale") == 0) {
++index;
if (!argv[index]) {
@ -803,9 +857,6 @@ static void SDLTest_PrintRendererFlag(char *text, size_t maxlen, Uint32 flag)
case SDL_RENDERER_PRESENTVSYNC:
SDL_snprintfcat(text, maxlen, "PresentVSync");
break;
case SDL_RENDERER_TARGETTEXTURE:
SDL_snprintfcat(text, maxlen, "TargetTexturesSupported");
break;
default:
SDL_snprintfcat(text, maxlen, "0x%8.8x", flag);
break;
@ -920,6 +971,51 @@ static void SDLTest_PrintPixelFormat(char *text, size_t maxlen, Uint32 format)
}
}
static void SDLTest_PrintLogicalPresentation(char *text, size_t maxlen, SDL_RendererLogicalPresentation logical_presentation)
{
switch (logical_presentation) {
case SDL_LOGICAL_PRESENTATION_DISABLED:
SDL_snprintfcat(text, maxlen, "DISABLED");
break;
case SDL_LOGICAL_PRESENTATION_MATCH:
SDL_snprintfcat(text, maxlen, "MATCH");
break;
case SDL_LOGICAL_PRESENTATION_STRETCH:
SDL_snprintfcat(text, maxlen, "STRETCH");
break;
case SDL_LOGICAL_PRESENTATION_LETTERBOX:
SDL_snprintfcat(text, maxlen, "LETTERBOX");
break;
case SDL_LOGICAL_PRESENTATION_OVERSCAN:
SDL_snprintfcat(text, maxlen, "OVERSCAN");
break;
case SDL_LOGICAL_PRESENTATION_INTEGER_SCALE:
SDL_snprintfcat(text, maxlen, "INTEGER_SCALE");
break;
default:
SDL_snprintfcat(text, maxlen, "0x%8.8x", logical_presentation);
break;
}
}
static void SDLTest_PrintScaleMode(char *text, size_t maxlen, SDL_ScaleMode scale_mode)
{
switch (scale_mode) {
case SDL_ScaleModeNearest:
SDL_snprintfcat(text, maxlen, "NEAREST");
break;
case SDL_ScaleModeLinear:
SDL_snprintfcat(text, maxlen, "LINEAR");
break;
case SDL_ScaleModeBest:
SDL_snprintfcat(text, maxlen, "BEST");
break;
default:
SDL_snprintfcat(text, maxlen, "0x%8.8x", scale_mode);
break;
}
}
static void SDLTest_PrintRenderer(SDL_RendererInfo *info)
{
int i, count;
@ -1298,9 +1394,15 @@ SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_GetError());
return SDL_FALSE;
}
if (state->logical_w && state->logical_h) {
SDL_SetRenderLogicalSize(state->renderers[i], state->logical_w, state->logical_h);
} else if (state->scale != 0.) {
if (state->logical_w == 0 || state->logical_h == 0) {
state->logical_w = state->window_w;
state->logical_h = state->window_h;
}
if (SDL_SetRenderLogicalPresentation(state->renderers[i], state->logical_w, state->logical_h, state->logical_presentation, state->logical_scale_mode) < 0) {
SDL_Log("Couldn't set logical presentation: %s\n", SDL_GetError());
return SDL_FALSE;
}
if (state->scale != 0.0f) {
SDL_SetRenderScale(state->renderers[i], state->scale, state->scale);
}
if (state->verbose & VERBOSE_RENDER) {
@ -2204,6 +2306,8 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
Uint32 flags;
SDL_DisplayID windowDisplayID = SDL_GetDisplayForWindow(window);
SDL_RendererInfo info;
SDL_RendererLogicalPresentation logical_presentation;
SDL_ScaleMode logical_scale_mode;
/* Video */
@ -2231,8 +2335,14 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
textY += lineHeight;
}
if (0 == SDL_GetRendererOutputSize(renderer, &w, &h)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetRendererOutputSize: %dx%d", w, h);
if (0 == SDL_GetRenderOutputSize(renderer, &w, &h)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetRenderOutputSize: %dx%d", w, h);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
if (0 == SDL_GetCurrentRenderOutputSize(renderer, &w, &h)) {
(void)SDL_snprintf(text, sizeof text, "SDL_GetCurrentRenderOutputSize: %dx%d", w, h);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
}
@ -2244,13 +2354,16 @@ void SDLTest_CommonDrawWindowInfo(SDL_Renderer *renderer, SDL_Window *window, fl
textY += lineHeight;
SDL_GetRenderScale(renderer, &scaleX, &scaleY);
(void)SDL_snprintf(text, sizeof text, "SDL_GetRenderScale: %f,%f",
(void)SDL_snprintf(text, sizeof text, "SDL_GetRenderScale: %g,%g",
scaleX, scaleY);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;
SDL_GetRenderLogicalSize(renderer, &w, &h);
(void)SDL_snprintf(text, sizeof text, "SDL_GetRenderLogicalSize: %dx%d", w, h);
SDL_GetRenderLogicalPresentation(renderer, &w, &h, &logical_presentation, &logical_scale_mode);
(void)SDL_snprintf(text, sizeof text, "SDL_GetRenderLogicalPresentation: %dx%d ", w, h);
SDLTest_PrintLogicalPresentation(text, sizeof text, logical_presentation);
SDL_snprintfcat(text, sizeof text, ", ");
SDLTest_PrintScaleMode(text, sizeof text, logical_scale_mode);
SDLTest_DrawString(renderer, 0.0f, textY, text);
textY += lineHeight;

View File

@ -366,7 +366,9 @@ WatchJoystick(SDL_Joystick *joystick)
SDL_RaiseWindow(window);
/* scale for platforms that don't give you the window size you asked for. */
SDL_SetRenderLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT);
SDL_SetRenderLogicalPresentation(screen, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_LOGICAL_PRESENTATION_LETTERBOX,
SDL_ScaleModeLinear);
/* Print info about the joystick we are watching */
name = SDL_GetJoystickName(joystick);

View File

@ -890,9 +890,11 @@ int render_testLogicalSize(void *arg)
clearScreen();
/* Set the logical size and do a fill operation */
ret = SDL_GetRendererOutputSize(renderer, &w, &h);
ret = SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_GetRendererOutputSize, expected: 0, got: %i", ret);
ret = SDL_SetRenderLogicalSize(renderer, w / factor, h / factor);
ret = SDL_SetRenderLogicalPresentation(renderer, w / factor, h / factor,
SDL_LOGICAL_PRESENTATION_LETTERBOX,
SDL_ScaleModeNearest);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderLogicalSize, expected: 0, got: %i", ret);
ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
@ -902,7 +904,10 @@ int render_testLogicalSize(void *arg)
rect.h = (float)viewport.h / factor;
ret = SDL_RenderFillRect(renderer, &rect);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
ret = SDL_SetRenderLogicalSize(renderer, 0, 0);
(void)SDL_RenderPresent(renderer);
ret = SDL_SetRenderLogicalPresentation(renderer, 0, 0,
SDL_LOGICAL_PRESENTATION_DISABLED,
SDL_ScaleModeNearest);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderLogicalSize, expected: 0, got: %i", ret);
/* Check to see if final image matches. */
@ -912,9 +917,11 @@ int render_testLogicalSize(void *arg)
clearScreen();
/* Set the logical size and viewport and do a fill operation */
ret = SDL_GetRendererOutputSize(renderer, &w, &h);
ret = SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_GetRendererOutputSize, expected: 0, got: %i", ret);
ret = SDL_SetRenderLogicalSize(renderer, w / factor, h / factor);
ret = SDL_SetRenderLogicalPresentation(renderer, w / factor, h / factor,
SDL_LOGICAL_PRESENTATION_LETTERBOX,
SDL_ScaleModeNearest);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderLogicalSize, expected: 0, got: %i", ret);
viewport.x = (TESTRENDER_SCREEN_W / 4) / factor;
viewport.y = (TESTRENDER_SCREEN_H / 4) / factor;
@ -928,7 +935,10 @@ int render_testLogicalSize(void *arg)
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
ret = SDL_SetRenderViewport(renderer, NULL);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderViewport, expected: 0, got: %i", ret);
ret = SDL_SetRenderLogicalSize(renderer, 0, 0);
(void)SDL_RenderPresent(renderer);
ret = SDL_SetRenderLogicalPresentation(renderer, 0, 0,
SDL_LOGICAL_PRESENTATION_DISABLED,
SDL_ScaleModeNearest);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderLogicalSize, expected: 0, got: %i", ret);
/* Check to see if final image matches. */
@ -953,15 +963,22 @@ int render_testLogicalSize(void *arg)
clearScreen();
/* Set the logical size and do a fill operation */
ret = SDL_GetRendererOutputSize(renderer, &w, &h);
ret = SDL_GetCurrentRenderOutputSize(renderer, &w, &h);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_GetRendererOutputSize, expected: 0, got: %i", ret);
ret = SDL_SetRenderLogicalSize(renderer, w - 2 * (TESTRENDER_SCREEN_W / 4), h);
ret = SDL_SetRenderLogicalPresentation(renderer,
w - 2 * (TESTRENDER_SCREEN_W / 4),
h,
SDL_LOGICAL_PRESENTATION_LETTERBOX,
SDL_ScaleModeLinear);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderLogicalSize, expected: 0, got: %i", ret);
ret = SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderDrawColor, expected: 0, got: %i", ret);
ret = SDL_RenderFillRect(renderer, NULL);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_RenderFillRect, expected: 0, got: %i", ret);
ret = SDL_SetRenderLogicalSize(renderer, 0, 0);
(void)SDL_RenderPresent(renderer);
ret = SDL_SetRenderLogicalPresentation(renderer, 0, 0,
SDL_LOGICAL_PRESENTATION_DISABLED,
SDL_ScaleModeNearest);
SDLTest_AssertCheck(ret == 0, "Validate result from SDL_SetRenderLogicalSize, expected: 0, got: %i", ret);
/* Check to see if final image matches. */

View File

@ -911,7 +911,9 @@ int main(int argc, char *argv[])
SDL_RenderPresent(screen);
/* scale for platforms that don't give you the window size you asked for. */
SDL_SetRenderLogicalSize(screen, SCREEN_WIDTH, SCREEN_HEIGHT);
SDL_SetRenderLogicalPresentation(screen, SCREEN_WIDTH, SCREEN_HEIGHT,
SDL_LOGICAL_PRESENTATION_LETTERBOX,
SDL_ScaleModeLinear);
background_front = LoadTexture(screen, "gamepadmap.bmp", SDL_FALSE, NULL, NULL);
background_back = LoadTexture(screen, "gamepadmap_back.bmp", SDL_FALSE, NULL, NULL);

View File

@ -71,7 +71,7 @@ draw_modes_menu(SDL_Window *window, SDL_Renderer *renderer, SDL_FRect viewport)
float logical_x, logical_y;
SDL_GetMouseState(&window_x, &window_y);
SDL_RenderWindowToLogical(renderer, window_x, window_y, &logical_x, &logical_y);
SDL_RenderCoordinatesFromWindow(renderer, window_x, window_y, &logical_x, &logical_y);
mouse_pos.x = logical_x;
mouse_pos.y = logical_y;