Skip to content

Commit

Permalink
Removed SDL_RendererFlags
Browse files Browse the repository at this point in the history
The flags parameter has been removed from SDL_CreateRenderer() and SDL_RENDERER_PRESENTVSYNC has been replaced with SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER during window creation and SDL_PROP_RENDERER_VSYNC_NUMBER after renderer creation.

SDL_SetRenderVSync() now takes additional values besides 0 and 1.

The maximum texture size has been removed from SDL_RendererInfo, replaced with SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER.
  • Loading branch information
slouken committed May 13, 2024
1 parent 678cfd2 commit 17520c2
Show file tree
Hide file tree
Showing 41 changed files with 264 additions and 393 deletions.
9 changes: 6 additions & 3 deletions docs/README-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,12 +722,13 @@ The following hints have been removed:
* SDL_HINT_IDLE_TIMER_DISABLED - use SDL_DisableScreenSaver() instead
* SDL_HINT_IME_SUPPORT_EXTENDED_TEXT - the normal text editing event has extended text
* SDL_HINT_MOUSE_RELATIVE_SCALING - mouse coordinates are no longer automatically scaled by the SDL renderer
* SDL_HINT_PS2_DYNAMIC_VSYNC - use SDL_SetRendererVSync(renderer, -1) instead
* SDL_HINT_RENDER_BATCHING - Render batching is always enabled, apps should call SDL_FlushRenderer() before calling into a lower-level graphics API.
* SDL_HINT_RENDER_LOGICAL_SIZE_MODE - the logical size mode is explicitly set with SDL_SetRenderLogicalPresentation()
* SDL_HINT_RENDER_OPENGL_SHADERS - shaders are always used if they are available
* SDL_HINT_RENDER_SCALE_QUALITY - textures now default to linear filtering, use SDL_SetTextureScaleMode(texture, SDL_SCALEMODE_NEAREST) if you want nearest pixel mode instead
* SDL_HINT_VIDEO_EXTERNAL_CONTEXT - replaced with SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN in SDL_CreateWindowWithProperties()
* SDL_HINT_THREAD_STACK_SIZE - the stack size can be specified using SDL_CreateThreadWithStackSize()
* SDL_HINT_VIDEO_EXTERNAL_CONTEXT - replaced with SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN in SDL_CreateWindowWithProperties()
* SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL - replaced with SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN in SDL_CreateWindowWithProperties()
* SDL_HINT_VIDEO_FOREIGN_WINDOW_VULKAN - replaced with SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN in SDL_CreateWindowWithProperties()
* SDL_HINT_VIDEO_HIGHDPI_DISABLED - high DPI support is always enabled
Expand All @@ -752,7 +753,6 @@ The following hints have been renamed:
* SDL_HINT_LINUX_HAT_DEADZONES => SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES
* SDL_HINT_LINUX_JOYSTICK_CLASSIC => SDL_HINT_JOYSTICK_LINUX_CLASSIC
* SDL_HINT_LINUX_JOYSTICK_DEADZONES => SDL_HINT_JOYSTICK_LINUX_DEADZONES
* SDL_HINT_PS2_DYNAMIC_VSYNC => SDL_HINT_RENDER_PS2_DYNAMIC_VSYNC

The following functions have been removed:
* SDL_ClearHints() - replaced with SDL_ResetHints()
Expand Down Expand Up @@ -1092,12 +1092,14 @@ was used to figure out the index of a driver, so one would call it in a for-loop
for the driver named "opengl" or whatnot. SDL_GetRenderDriver() has been added for this
functionality, which returns only the name of the driver.
Additionally, SDL_CreateRenderer()'s second argument is no longer an integer index, but a
SDL_CreateRenderer()'s second argument is no longer an integer index, but a
`const char *` representing a renderer's name; if you were just using a for-loop to find
which index is the "opengl" or whatnot driver, you can just pass that string directly
here, now. Passing NULL is the same as passing -1 here in SDL2, to signify you want SDL
to decide for you.
SDL_CreateRenderer()'s flags parameter has been removed. See specific flags below for how to achieve the same functionality in SDL 3.0.

SDL_CreateWindowAndRenderer() now takes the window title as the first parameter.

Mouse and touch events are no longer filtered to change their coordinates, instead you
Expand Down Expand Up @@ -1169,6 +1171,7 @@ The following symbols have been renamed:

The following symbols have been removed:
* SDL_RENDERER_ACCELERATED - all renderers except `SDL_SOFTWARE_RENDERER` are accelerated
* SDL_RENDERER_PRESENTVSYNC - replaced with SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER during renderer creation and SDL_PROP_RENDERER_VSYNC_NUMBER after renderer creation
* SDL_RENDERER_SOFTWARE - you can check whether the name of the renderer is `SDL_SOFTWARE_RENDERER`
* SDL_RENDERER_TARGETTEXTURE - all renderers support target texture functionality

Expand Down
4 changes: 0 additions & 4 deletions docs/README-ps2.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ cmake --build build
cmake --install build
```

## Hints
The PS2 port has a special Hint for having a dynamic VSYNC. The Hint is `SDL_HINT_RENDER_PS2_DYNAMIC_VSYNC`.
If you enabled the dynamic vsync having as well `SDL_RENDERER_PRESENTVSYNC` enabled, then if the app is not able to run at 60 FPS, automatically the `vsync` will be disabled having a better performance, instead of dropping FPS to 30.

## Notes
If you trying to debug a SDL app through [ps2client](https://github.com/ps2dev/ps2client) you need to avoid the IOP reset, otherwise you will lose the connection with your computer.
So to avoid the reset of the IOP CPU, you need to call to the macro `SDL_PS2_SKIP_IOP_RESET();`.
Expand Down
2 changes: 1 addition & 1 deletion docs/README-visualc.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Here's a sample SDL snippet to verify everything is setup in your IDE:
SDL_Init(SDL_INIT_VIDEO);
window = SDL_CreateWindow("Hello SDL", WIDTH, HEIGHT, 0);
renderer = SDL_CreateRenderer(window, NULL, SDL_RENDERER_PRESENTVSYNC);
renderer = SDL_CreateRenderer(window, NULL);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
Expand Down
2 changes: 1 addition & 1 deletion docs/README-wayland.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ int main(int argc, char *argv[])
}

/* Create a renderer */
sdlRenderer = SDL_CreateRenderer(sdlWindow, NULL, 0);
sdlRenderer = SDL_CreateRenderer(sdlWindow, NULL);
if (!sdlRenderer) {
goto exit;
}
Expand Down
6 changes: 3 additions & 3 deletions docs/README-winrt.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ Here is a rough list of what works, and what doesn't:
UWP itself).
* turning off VSync when rendering on Windows Phone. Attempts to turn VSync
off on Windows Phone result either in Direct3D not drawing anything, or it
forcing VSync back on. As such, SDL_RENDERER_PRESENTVSYNC will always get
turned-on on Windows Phone. This limitation is not present in non-Phone
WinRT (such as Windows 8.x), where turning off VSync appears to work.
forcing VSync back on. As such, vsync will always get turned-on on Windows
Phone. This limitation is not present in non-Phone WinRT (such as Windows 8.x),
where turning off VSync appears to work.
* probably anything else that's not listed as supported


Expand Down
16 changes: 0 additions & 16 deletions include/SDL3/SDL_hints.h
Original file line number Diff line number Diff line change
Expand Up @@ -2570,22 +2570,6 @@ extern "C" {
*/
#define SDL_HINT_RENDER_METAL_PREFER_LOW_POWER_DEVICE "SDL_RENDER_METAL_PREFER_LOW_POWER_DEVICE"

/**
* A variable controlling whether vsync is automatically disabled if doesn't
* reach enough FPS.
*
* The variable can be set to the following values:
*
* - "0": It will be using VSYNC as defined in the main flag. (default)
* - "1": If VSYNC was previously enabled, then it will disable VSYNC if
* doesn't reach enough speed
*
* This hint should be set before creating a renderer.
*
* \since This hint is available since SDL 3.0.0.
*/
#define SDL_HINT_RENDER_PS2_DYNAMIC_VSYNC "SDL_RENDER_PS2_DYNAMIC_VSYNC"

/**
* A variable controlling whether updates to the SDL screen surface should be
* synchronized with the vertical refresh, to avoid tearing.
Expand Down
2 changes: 0 additions & 2 deletions include/SDL3/SDL_oldnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@
#define SDL_HINT_LINUX_HAT_DEADZONES SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES
#define SDL_HINT_LINUX_JOYSTICK_CLASSIC SDL_HINT_JOYSTICK_LINUX_CLASSIC
#define SDL_HINT_LINUX_JOYSTICK_DEADZONES SDL_HINT_JOYSTICK_LINUX_DEADZONES
#define SDL_HINT_PS2_DYNAMIC_VSYNC SDL_HINT_RENDER_PS2_DYNAMIC_VSYNC

/* ##SDL_joystick.h */
#define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMEPAD
Expand Down Expand Up @@ -800,7 +799,6 @@
#define SDL_HINT_LINUX_HAT_DEADZONES SDL_HINT_LINUX_HAT_DEADZONES_renamed_SDL_HINT_JOYSTICK_LINUX_HAT_DEADZONES
#define SDL_HINT_LINUX_JOYSTICK_CLASSIC SDL_HINT_LINUX_JOYSTICK_CLASSIC_renamed_SDL_HINT_JOYSTICK_LINUX_CLASSIC
#define SDL_HINT_LINUX_JOYSTICK_DEADZONES SDL_HINT_LINUX_JOYSTICK_DEADZONES_renamed_SDL_HINT_JOYSTICK_LINUX_DEADZONES
#define SDL_HINT_PS2_DYNAMIC_VSYNC SDL_HINT_PS2_DYNAMIC_VSYNC_renamed_SDL_HINT_RENDER_PS2_DYNAMIC_VSYNC

/* ##SDL_joystick.h */
#define SDL_JOYSTICK_TYPE_GAMECONTROLLER SDL_JOYSTICK_TYPE_GAMECONTROLLER_renamed_SDL_JOYSTICK_TYPE_GAMEPAD
Expand Down
30 changes: 10 additions & 20 deletions include/SDL3/SDL_render.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ extern "C" {
*/
#define SDL_SOFTWARE_RENDERER "software"

/**
* Flags used when creating a rendering context.
*
* \since This datatype is available since SDL 3.0.0.
*/
typedef Uint32 SDL_RendererFlags;

#define SDL_RENDERER_PRESENTVSYNC 0x00000004u /**< Present is synchronized with the refresh rate */

/**
* Information on the capabilities of a render driver or context.
*
Expand All @@ -85,11 +76,8 @@ typedef Uint32 SDL_RendererFlags;
typedef struct SDL_RendererInfo
{
const char *name; /**< The name of the renderer */
SDL_RendererFlags flags; /**< Supported ::SDL_RendererFlags */
int num_texture_formats; /**< The number of available texture formats */
const SDL_PixelFormatEnum *texture_formats; /**< The available texture formats */
int max_texture_width; /**< The maximum texture width */
int max_texture_height; /**< The maximum texture height */
} SDL_RendererInfo;

/**
Expand Down Expand Up @@ -228,7 +216,6 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(const char *title, int w
* \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
* \param flags 0, or one or more SDL_RendererFlags OR'd together
* \returns a valid rendering context or NULL if there was an error; call
* SDL_GetError() for more information.
*
Expand All @@ -241,7 +228,7 @@ extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(const char *title, int w
* \sa SDL_GetRenderDriver
* \sa SDL_GetRendererInfo
*/
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name, SDL_RendererFlags flags);
extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name);

/**
* Create a 2D rendering context for a window, with the specified properties.
Expand All @@ -261,8 +248,8 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, co
* supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing
* still uses the sRGB colorspace, but values can go beyond 1.0 and float
* (linear) format textures can be used for HDR content.
* - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN`: true if you want
* present synchronized with the refresh rate
* - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want
* present synchronized with the refresh rate. This property can take any value that is supported by SDL_SetRenderVSync() for the renderer.
*
* With the vulkan renderer:
*
Expand Down Expand Up @@ -297,7 +284,7 @@ extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_Prop
#define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "window"
#define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "surface"
#define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "output_colorspace"
#define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN "present_vsync"
#define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "present_vsync"
#define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "vulkan.instance"
#define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "vulkan.surface"
#define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "vulkan.physical_device"
Expand Down Expand Up @@ -372,6 +359,8 @@ extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_Rend
* displayed, if any
* - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is
* displayed, if this is a software renderer without a window
* - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting
* - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width and height
* - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace value
* describing the colorspace for output to the display, defaults to
* SDL_COLORSPACE_SRGB.
Expand Down Expand Up @@ -441,6 +430,8 @@ extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer
#define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name"
#define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window"
#define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface"
#define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync"
#define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size"
#define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace"
#define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled"
#define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point"
Expand Down Expand Up @@ -2145,7 +2136,7 @@ extern DECLSPEC int SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer
* Toggle VSync of the given renderer.
*
* \param renderer The renderer to toggle
* \param vsync 1 for on, 0 for off. All other values are reserved
* \param vsync the vertical refresh sync interval, 1 to synchronize present with every vertical refresh, 2 to synchronize present with every second vertical refresh, etc., or -1 for late swap tearing (adaptive vsync). Not every value is supported by every renderer, so you should check the return value to see whether the requested setting is supported.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
Expand All @@ -2159,8 +2150,7 @@ extern DECLSPEC int SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync
* Get VSync of the given renderer.
*
* \param renderer The renderer to toggle
* \param vsync an int filled with 1 for on, 0 for off. All other values are
* reserved
* \param vsync an int filled with the current vertical refresh sync interval
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
Expand Down
2 changes: 1 addition & 1 deletion include/SDL3/SDL_test_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ typedef struct

/* Renderer info */
const char *renderdriver;
Uint32 render_flags;
int render_vsync;
SDL_bool skip_renderer;
SDL_Renderer **renderers;
SDL_Texture **targets;
Expand Down
2 changes: 1 addition & 1 deletion src/dynapi/SDL_dynapi_procs.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ SDL_DYNAPI_PROC(SDL_PixelFormat*,SDL_CreatePixelFormat,(SDL_PixelFormatEnum a),(
SDL_DYNAPI_PROC(SDL_Window*,SDL_CreatePopupWindow,(SDL_Window *a, int b, int c, int d, int e, SDL_WindowFlags f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_CreateProperties,(void),(),return)
SDL_DYNAPI_PROC(SDL_RWLock*,SDL_CreateRWLock,(void),(),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, const char *b, SDL_RendererFlags c),(a,b,c),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRenderer,(SDL_Window *a, const char *b),(a,b),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateRendererWithProperties,(SDL_PropertiesID a),(a),return)
SDL_DYNAPI_PROC(SDL_Semaphore*,SDL_CreateSemaphore,(Uint32 a),(a),return)
SDL_DYNAPI_PROC(SDL_Renderer*,SDL_CreateSoftwareRenderer,(SDL_Surface *a),(a),return)
Expand Down

0 comments on commit 17520c2

Please sign in to comment.