diff options
Diffstat (limited to 'contrib/SDL-3.2.8/include/SDL3/SDL_render.h')
| -rw-r--r-- | contrib/SDL-3.2.8/include/SDL3/SDL_render.h | 2646 |
1 files changed, 2646 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/include/SDL3/SDL_render.h b/contrib/SDL-3.2.8/include/SDL3/SDL_render.h new file mode 100644 index 0000000..3352545 --- /dev/null +++ b/contrib/SDL-3.2.8/include/SDL3/SDL_render.h | |||
| @@ -0,0 +1,2646 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> | ||
| 4 | |||
| 5 | This software is provided 'as-is', without any express or implied | ||
| 6 | warranty. In no event will the authors be held liable for any damages | ||
| 7 | arising from the use of this software. | ||
| 8 | |||
| 9 | Permission is granted to anyone to use this software for any purpose, | ||
| 10 | including commercial applications, and to alter it and redistribute it | ||
| 11 | freely, subject to the following restrictions: | ||
| 12 | |||
| 13 | 1. The origin of this software must not be misrepresented; you must not | ||
| 14 | claim that you wrote the original software. If you use this software | ||
| 15 | in a product, an acknowledgment in the product documentation would be | ||
| 16 | appreciated but is not required. | ||
| 17 | 2. Altered source versions must be plainly marked as such, and must not be | ||
| 18 | misrepresented as being the original software. | ||
| 19 | 3. This notice may not be removed or altered from any source distribution. | ||
| 20 | */ | ||
| 21 | |||
| 22 | /** | ||
| 23 | * # CategoryRender | ||
| 24 | * | ||
| 25 | * Header file for SDL 2D rendering functions. | ||
| 26 | * | ||
| 27 | * This API supports the following features: | ||
| 28 | * | ||
| 29 | * - single pixel points | ||
| 30 | * - single pixel lines | ||
| 31 | * - filled rectangles | ||
| 32 | * - texture images | ||
| 33 | * - 2D polygons | ||
| 34 | * | ||
| 35 | * The primitives may be drawn in opaque, blended, or additive modes. | ||
| 36 | * | ||
| 37 | * The texture images may be drawn in opaque, blended, or additive modes. They | ||
| 38 | * can have an additional color tint or alpha modulation applied to them, and | ||
| 39 | * may also be stretched with linear interpolation. | ||
| 40 | * | ||
| 41 | * This API is designed to accelerate simple 2D operations. You may want more | ||
| 42 | * functionality such as polygons and particle effects and in that case you | ||
| 43 | * should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the | ||
| 44 | * many good 3D engines. | ||
| 45 | * | ||
| 46 | * These functions must be called from the main thread. See this bug for | ||
| 47 | * details: https://github.com/libsdl-org/SDL/issues/986 | ||
| 48 | */ | ||
| 49 | |||
| 50 | #ifndef SDL_render_h_ | ||
| 51 | #define SDL_render_h_ | ||
| 52 | |||
| 53 | #include <SDL3/SDL_stdinc.h> | ||
| 54 | #include <SDL3/SDL_blendmode.h> | ||
| 55 | #include <SDL3/SDL_error.h> | ||
| 56 | #include <SDL3/SDL_events.h> | ||
| 57 | #include <SDL3/SDL_pixels.h> | ||
| 58 | #include <SDL3/SDL_properties.h> | ||
| 59 | #include <SDL3/SDL_rect.h> | ||
| 60 | #include <SDL3/SDL_surface.h> | ||
| 61 | #include <SDL3/SDL_video.h> | ||
| 62 | |||
| 63 | #include <SDL3/SDL_begin_code.h> | ||
| 64 | /* Set up for C function definitions, even when using C++ */ | ||
| 65 | #ifdef __cplusplus | ||
| 66 | extern "C" { | ||
| 67 | #endif | ||
| 68 | |||
| 69 | /** | ||
| 70 | * The name of the software renderer. | ||
| 71 | * | ||
| 72 | * \since This macro is available since SDL 3.2.0. | ||
| 73 | */ | ||
| 74 | #define SDL_SOFTWARE_RENDERER "software" | ||
| 75 | |||
| 76 | /** | ||
| 77 | * Vertex structure. | ||
| 78 | * | ||
| 79 | * \since This struct is available since SDL 3.2.0. | ||
| 80 | */ | ||
| 81 | typedef struct SDL_Vertex | ||
| 82 | { | ||
| 83 | SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */ | ||
| 84 | SDL_FColor color; /**< Vertex color */ | ||
| 85 | SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */ | ||
| 86 | } SDL_Vertex; | ||
| 87 | |||
| 88 | /** | ||
| 89 | * The access pattern allowed for a texture. | ||
| 90 | * | ||
| 91 | * \since This enum is available since SDL 3.2.0. | ||
| 92 | */ | ||
| 93 | typedef enum SDL_TextureAccess | ||
| 94 | { | ||
| 95 | SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ | ||
| 96 | SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ | ||
| 97 | SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ | ||
| 98 | } SDL_TextureAccess; | ||
| 99 | |||
| 100 | /** | ||
| 101 | * How the logical size is mapped to the output. | ||
| 102 | * | ||
| 103 | * \since This enum is available since SDL 3.2.0. | ||
| 104 | */ | ||
| 105 | typedef enum SDL_RendererLogicalPresentation | ||
| 106 | { | ||
| 107 | SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */ | ||
| 108 | SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */ | ||
| 109 | SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */ | ||
| 110 | SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */ | ||
| 111 | SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */ | ||
| 112 | } SDL_RendererLogicalPresentation; | ||
| 113 | |||
| 114 | /** | ||
| 115 | * A structure representing rendering state | ||
| 116 | * | ||
| 117 | * \since This struct is available since SDL 3.2.0. | ||
| 118 | */ | ||
| 119 | typedef struct SDL_Renderer SDL_Renderer; | ||
| 120 | |||
| 121 | #ifndef SDL_INTERNAL | ||
| 122 | |||
| 123 | /** | ||
| 124 | * An efficient driver-specific representation of pixel data | ||
| 125 | * | ||
| 126 | * \since This struct is available since SDL 3.2.0. | ||
| 127 | * | ||
| 128 | * \sa SDL_CreateTexture | ||
| 129 | * \sa SDL_CreateTextureFromSurface | ||
| 130 | * \sa SDL_CreateTextureWithProperties | ||
| 131 | * \sa SDL_DestroyTexture | ||
| 132 | */ | ||
| 133 | struct SDL_Texture | ||
| 134 | { | ||
| 135 | SDL_PixelFormat format; /**< The format of the texture, read-only */ | ||
| 136 | int w; /**< The width of the texture, read-only. */ | ||
| 137 | int h; /**< The height of the texture, read-only. */ | ||
| 138 | |||
| 139 | int refcount; /**< Application reference count, used when freeing texture */ | ||
| 140 | }; | ||
| 141 | #endif /* !SDL_INTERNAL */ | ||
| 142 | |||
| 143 | typedef struct SDL_Texture SDL_Texture; | ||
| 144 | |||
| 145 | /* Function prototypes */ | ||
| 146 | |||
| 147 | /** | ||
| 148 | * Get the number of 2D rendering drivers available for the current display. | ||
| 149 | * | ||
| 150 | * A render driver is a set of code that handles rendering and texture | ||
| 151 | * management on a particular display. Normally there is only one, but some | ||
| 152 | * drivers may have several available with different capabilities. | ||
| 153 | * | ||
| 154 | * There may be none if SDL was compiled without render support. | ||
| 155 | * | ||
| 156 | * \returns the number of built in render drivers. | ||
| 157 | * | ||
| 158 | * \threadsafety It is safe to call this function from any thread. | ||
| 159 | * | ||
| 160 | * \since This function is available since SDL 3.2.0. | ||
| 161 | * | ||
| 162 | * \sa SDL_CreateRenderer | ||
| 163 | * \sa SDL_GetRenderDriver | ||
| 164 | */ | ||
| 165 | extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); | ||
| 166 | |||
| 167 | /** | ||
| 168 | * Use this function to get the name of a built in 2D rendering driver. | ||
| 169 | * | ||
| 170 | * The list of rendering drivers is given in the order that they are normally | ||
| 171 | * initialized by default; the drivers that seem more reasonable to choose | ||
| 172 | * first (as far as the SDL developers believe) are earlier in the list. | ||
| 173 | * | ||
| 174 | * The names of drivers are all simple, low-ASCII identifiers, like "opengl", | ||
| 175 | * "direct3d12" or "metal". These never have Unicode characters, and are not | ||
| 176 | * meant to be proper names. | ||
| 177 | * | ||
| 178 | * \param index the index of the rendering driver; the value ranges from 0 to | ||
| 179 | * SDL_GetNumRenderDrivers() - 1. | ||
| 180 | * \returns the name of the rendering driver at the requested index, or NULL | ||
| 181 | * if an invalid index was specified. | ||
| 182 | * | ||
| 183 | * \threadsafety It is safe to call this function from any thread. | ||
| 184 | * | ||
| 185 | * \since This function is available since SDL 3.2.0. | ||
| 186 | * | ||
| 187 | * \sa SDL_GetNumRenderDrivers | ||
| 188 | */ | ||
| 189 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetRenderDriver(int index); | ||
| 190 | |||
| 191 | /** | ||
| 192 | * Create a window and default renderer. | ||
| 193 | * | ||
| 194 | * \param title the title of the window, in UTF-8 encoding. | ||
| 195 | * \param width the width of the window. | ||
| 196 | * \param height the height of the window. | ||
| 197 | * \param window_flags the flags used to create the window (see | ||
| 198 | * SDL_CreateWindow()). | ||
| 199 | * \param window a pointer filled with the window, or NULL on error. | ||
| 200 | * \param renderer a pointer filled with the renderer, or NULL on error. | ||
| 201 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 202 | * information. | ||
| 203 | * | ||
| 204 | * \threadsafety This function should only be called on the main thread. | ||
| 205 | * | ||
| 206 | * \since This function is available since SDL 3.2.0. | ||
| 207 | * | ||
| 208 | * \sa SDL_CreateRenderer | ||
| 209 | * \sa SDL_CreateWindow | ||
| 210 | */ | ||
| 211 | extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer); | ||
| 212 | |||
| 213 | /** | ||
| 214 | * Create a 2D rendering context for a window. | ||
| 215 | * | ||
| 216 | * If you want a specific renderer, you can specify its name here. A list of | ||
| 217 | * available renderers can be obtained by calling SDL_GetRenderDriver() | ||
| 218 | * multiple times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you | ||
| 219 | * don't need a specific renderer, specify NULL and SDL will attempt to choose | ||
| 220 | * the best option for you, based on what is available on the user's system. | ||
| 221 | * | ||
| 222 | * If `name` is a comma-separated list, SDL will try each name, in the order | ||
| 223 | * listed, until one succeeds or all of them fail. | ||
| 224 | * | ||
| 225 | * By default the rendering size matches the window size in pixels, but you | ||
| 226 | * can call SDL_SetRenderLogicalPresentation() to change the content size and | ||
| 227 | * scaling options. | ||
| 228 | * | ||
| 229 | * \param window the window where rendering is displayed. | ||
| 230 | * \param name the name of the rendering driver to initialize, or NULL to let | ||
| 231 | * SDL choose one. | ||
| 232 | * \returns a valid rendering context or NULL if there was an error; call | ||
| 233 | * SDL_GetError() for more information. | ||
| 234 | * | ||
| 235 | * \threadsafety This function should only be called on the main thread. | ||
| 236 | * | ||
| 237 | * \since This function is available since SDL 3.2.0. | ||
| 238 | * | ||
| 239 | * \sa SDL_CreateRendererWithProperties | ||
| 240 | * \sa SDL_CreateSoftwareRenderer | ||
| 241 | * \sa SDL_DestroyRenderer | ||
| 242 | * \sa SDL_GetNumRenderDrivers | ||
| 243 | * \sa SDL_GetRenderDriver | ||
| 244 | * \sa SDL_GetRendererName | ||
| 245 | */ | ||
| 246 | extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name); | ||
| 247 | |||
| 248 | /** | ||
| 249 | * Create a 2D rendering context for a window, with the specified properties. | ||
| 250 | * | ||
| 251 | * These are the supported properties: | ||
| 252 | * | ||
| 253 | * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver | ||
| 254 | * to use, if a specific one is desired | ||
| 255 | * - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is | ||
| 256 | * displayed, required if this isn't a software renderer using a surface | ||
| 257 | * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering | ||
| 258 | * is displayed, if you want a software renderer without a window | ||
| 259 | * - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace | ||
| 260 | * value describing the colorspace for output to the display, defaults to | ||
| 261 | * SDL_COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers | ||
| 262 | * support SDL_COLORSPACE_SRGB_LINEAR, which is a linear color space and | ||
| 263 | * supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing | ||
| 264 | * still uses the sRGB colorspace, but values can go beyond 1.0 and float | ||
| 265 | * (linear) format textures can be used for HDR content. | ||
| 266 | * - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want | ||
| 267 | * present synchronized with the refresh rate. This property can take any | ||
| 268 | * value that is supported by SDL_SetRenderVSync() for the renderer. | ||
| 269 | * | ||
| 270 | * With the vulkan renderer: | ||
| 271 | * | ||
| 272 | * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use | ||
| 273 | * with the renderer, optional. | ||
| 274 | * - `SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR to use | ||
| 275 | * with the renderer, optional. | ||
| 276 | * - `SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`: the | ||
| 277 | * VkPhysicalDevice to use with the renderer, optional. | ||
| 278 | * - `SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`: the VkDevice to use | ||
| 279 | * with the renderer, optional. | ||
| 280 | * - `SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the | ||
| 281 | * queue family index used for rendering. | ||
| 282 | * - `SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the | ||
| 283 | * queue family index used for presentation. | ||
| 284 | * | ||
| 285 | * \param props the properties to use. | ||
| 286 | * \returns a valid rendering context or NULL if there was an error; call | ||
| 287 | * SDL_GetError() for more information. | ||
| 288 | * | ||
| 289 | * \threadsafety This function should only be called on the main thread. | ||
| 290 | * | ||
| 291 | * \since This function is available since SDL 3.2.0. | ||
| 292 | * | ||
| 293 | * \sa SDL_CreateProperties | ||
| 294 | * \sa SDL_CreateRenderer | ||
| 295 | * \sa SDL_CreateSoftwareRenderer | ||
| 296 | * \sa SDL_DestroyRenderer | ||
| 297 | * \sa SDL_GetRendererName | ||
| 298 | */ | ||
| 299 | extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props); | ||
| 300 | |||
| 301 | #define SDL_PROP_RENDERER_CREATE_NAME_STRING "SDL.renderer.create.name" | ||
| 302 | #define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "SDL.renderer.create.window" | ||
| 303 | #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface" | ||
| 304 | #define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace" | ||
| 305 | #define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync" | ||
| 306 | #define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance" | ||
| 307 | #define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface" | ||
| 308 | #define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device" | ||
| 309 | #define SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER "SDL.renderer.create.vulkan.device" | ||
| 310 | #define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index" | ||
| 311 | #define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index" | ||
| 312 | |||
| 313 | /** | ||
| 314 | * Create a 2D software rendering context for a surface. | ||
| 315 | * | ||
| 316 | * Two other API which can be used to create SDL_Renderer: | ||
| 317 | * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_ | ||
| 318 | * create a software renderer, but they are intended to be used with an | ||
| 319 | * SDL_Window as the final destination and not an SDL_Surface. | ||
| 320 | * | ||
| 321 | * \param surface the SDL_Surface structure representing the surface where | ||
| 322 | * rendering is done. | ||
| 323 | * \returns a valid rendering context or NULL if there was an error; call | ||
| 324 | * SDL_GetError() for more information. | ||
| 325 | * | ||
| 326 | * \threadsafety This function should only be called on the main thread. | ||
| 327 | * | ||
| 328 | * \since This function is available since SDL 3.2.0. | ||
| 329 | * | ||
| 330 | * \sa SDL_DestroyRenderer | ||
| 331 | */ | ||
| 332 | extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface); | ||
| 333 | |||
| 334 | /** | ||
| 335 | * Get the renderer associated with a window. | ||
| 336 | * | ||
| 337 | * \param window the window to query. | ||
| 338 | * \returns the rendering context on success or NULL on failure; call | ||
| 339 | * SDL_GetError() for more information. | ||
| 340 | * | ||
| 341 | * \threadsafety It is safe to call this function from any thread. | ||
| 342 | * | ||
| 343 | * \since This function is available since SDL 3.2.0. | ||
| 344 | */ | ||
| 345 | extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window *window); | ||
| 346 | |||
| 347 | /** | ||
| 348 | * Get the window associated with a renderer. | ||
| 349 | * | ||
| 350 | * \param renderer the renderer to query. | ||
| 351 | * \returns the window on success or NULL on failure; call SDL_GetError() for | ||
| 352 | * more information. | ||
| 353 | * | ||
| 354 | * \threadsafety It is safe to call this function from any thread. | ||
| 355 | * | ||
| 356 | * \since This function is available since SDL 3.2.0. | ||
| 357 | */ | ||
| 358 | extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer); | ||
| 359 | |||
| 360 | /** | ||
| 361 | * Get the name of a renderer. | ||
| 362 | * | ||
| 363 | * \param renderer the rendering context. | ||
| 364 | * \returns the name of the selected renderer, or NULL on failure; call | ||
| 365 | * SDL_GetError() for more information. | ||
| 366 | * | ||
| 367 | * \threadsafety It is safe to call this function from any thread. | ||
| 368 | * | ||
| 369 | * \since This function is available since SDL 3.2.0. | ||
| 370 | * | ||
| 371 | * \sa SDL_CreateRenderer | ||
| 372 | * \sa SDL_CreateRendererWithProperties | ||
| 373 | */ | ||
| 374 | extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *renderer); | ||
| 375 | |||
| 376 | /** | ||
| 377 | * Get the properties associated with a renderer. | ||
| 378 | * | ||
| 379 | * The following read-only properties are provided by SDL: | ||
| 380 | * | ||
| 381 | * - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver | ||
| 382 | * - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is | ||
| 383 | * displayed, if any | ||
| 384 | * - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is | ||
| 385 | * displayed, if this is a software renderer without a window | ||
| 386 | * - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting | ||
| 387 | * - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width | ||
| 388 | * and height | ||
| 389 | * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *) | ||
| 390 | * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN, | ||
| 391 | * representing the available texture formats for this renderer. | ||
| 392 | * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_Colorspace value | ||
| 393 | * describing the colorspace for output to the display, defaults to | ||
| 394 | * SDL_COLORSPACE_SRGB. | ||
| 395 | * - `SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`: true if the output colorspace is | ||
| 396 | * SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with | ||
| 397 | * HDR enabled. This property can change dynamically when | ||
| 398 | * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. | ||
| 399 | * - `SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the | ||
| 400 | * SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is | ||
| 401 | * automatically multiplied into the color scale. This property can change | ||
| 402 | * dynamically when SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. | ||
| 403 | * - `SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`: the additional high dynamic range | ||
| 404 | * that can be displayed, in terms of the SDR white point. When HDR is not | ||
| 405 | * enabled, this will be 1.0. This property can change dynamically when | ||
| 406 | * SDL_EVENT_WINDOW_HDR_STATE_CHANGED is sent. | ||
| 407 | * | ||
| 408 | * With the direct3d renderer: | ||
| 409 | * | ||
| 410 | * - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated | ||
| 411 | * with the renderer | ||
| 412 | * | ||
| 413 | * With the direct3d11 renderer: | ||
| 414 | * | ||
| 415 | * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated | ||
| 416 | * with the renderer | ||
| 417 | * - `SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`: the IDXGISwapChain1 | ||
| 418 | * associated with the renderer. This may change when the window is resized. | ||
| 419 | * | ||
| 420 | * With the direct3d12 renderer: | ||
| 421 | * | ||
| 422 | * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated | ||
| 423 | * with the renderer | ||
| 424 | * - `SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`: the IDXGISwapChain4 | ||
| 425 | * associated with the renderer. | ||
| 426 | * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue | ||
| 427 | * associated with the renderer | ||
| 428 | * | ||
| 429 | * With the vulkan renderer: | ||
| 430 | * | ||
| 431 | * - `SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`: the VkInstance associated | ||
| 432 | * with the renderer | ||
| 433 | * - `SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR associated | ||
| 434 | * with the renderer | ||
| 435 | * - `SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`: the VkPhysicalDevice | ||
| 436 | * associated with the renderer | ||
| 437 | * - `SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`: the VkDevice associated with | ||
| 438 | * the renderer | ||
| 439 | * - `SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the queue | ||
| 440 | * family index used for rendering | ||
| 441 | * - `SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the queue | ||
| 442 | * family index used for presentation | ||
| 443 | * - `SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`: the number of | ||
| 444 | * swapchain images, or potential frames in flight, used by the Vulkan | ||
| 445 | * renderer | ||
| 446 | * | ||
| 447 | * With the gpu renderer: | ||
| 448 | * | ||
| 449 | * - `SDL_PROP_RENDERER_GPU_DEVICE_POINTER`: the SDL_GPUDevice associated with | ||
| 450 | * the renderer | ||
| 451 | * | ||
| 452 | * \param renderer the rendering context. | ||
| 453 | * \returns a valid property ID on success or 0 on failure; call | ||
| 454 | * SDL_GetError() for more information. | ||
| 455 | * | ||
| 456 | * \threadsafety It is safe to call this function from any thread. | ||
| 457 | * | ||
| 458 | * \since This function is available since SDL 3.2.0. | ||
| 459 | */ | ||
| 460 | extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer); | ||
| 461 | |||
| 462 | #define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name" | ||
| 463 | #define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window" | ||
| 464 | #define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface" | ||
| 465 | #define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync" | ||
| 466 | #define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size" | ||
| 467 | #define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats" | ||
| 468 | #define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace" | ||
| 469 | #define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled" | ||
| 470 | #define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point" | ||
| 471 | #define SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT "SDL.renderer.HDR_headroom" | ||
| 472 | #define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device" | ||
| 473 | #define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device" | ||
| 474 | #define SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER "SDL.renderer.d3d11.swap_chain" | ||
| 475 | #define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device" | ||
| 476 | #define SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER "SDL.renderer.d3d12.swap_chain" | ||
| 477 | #define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue" | ||
| 478 | #define SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER "SDL.renderer.vulkan.instance" | ||
| 479 | #define SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER "SDL.renderer.vulkan.surface" | ||
| 480 | #define SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.vulkan.physical_device" | ||
| 481 | #define SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER "SDL.renderer.vulkan.device" | ||
| 482 | #define SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.graphics_queue_family_index" | ||
| 483 | #define SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.present_queue_family_index" | ||
| 484 | #define SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER "SDL.renderer.vulkan.swapchain_image_count" | ||
| 485 | #define SDL_PROP_RENDERER_GPU_DEVICE_POINTER "SDL.renderer.gpu.device" | ||
| 486 | |||
| 487 | /** | ||
| 488 | * Get the output size in pixels of a rendering context. | ||
| 489 | * | ||
| 490 | * This returns the true output size in pixels, ignoring any render targets or | ||
| 491 | * logical size and presentation. | ||
| 492 | * | ||
| 493 | * For the output size of the current rendering target, with logical size | ||
| 494 | * adjustments, use SDL_GetCurrentRenderOutputSize() instead. | ||
| 495 | * | ||
| 496 | * \param renderer the rendering context. | ||
| 497 | * \param w a pointer filled in with the width in pixels. | ||
| 498 | * \param h a pointer filled in with the height in pixels. | ||
| 499 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 500 | * information. | ||
| 501 | * | ||
| 502 | * \threadsafety This function should only be called on the main thread. | ||
| 503 | * | ||
| 504 | * \since This function is available since SDL 3.2.0. | ||
| 505 | * | ||
| 506 | * \sa SDL_GetCurrentRenderOutputSize | ||
| 507 | */ | ||
| 508 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h); | ||
| 509 | |||
| 510 | /** | ||
| 511 | * Get the current output size in pixels of a rendering context. | ||
| 512 | * | ||
| 513 | * If a rendering target is active, this will return the size of the rendering | ||
| 514 | * target in pixels, otherwise return the value of SDL_GetRenderOutputSize(). | ||
| 515 | * | ||
| 516 | * Rendering target or not, the output will be adjusted by the current logical | ||
| 517 | * presentation state, dictated by SDL_SetRenderLogicalPresentation(). | ||
| 518 | * | ||
| 519 | * \param renderer the rendering context. | ||
| 520 | * \param w a pointer filled in with the current width. | ||
| 521 | * \param h a pointer filled in with the current height. | ||
| 522 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 523 | * information. | ||
| 524 | * | ||
| 525 | * \threadsafety This function should only be called on the main thread. | ||
| 526 | * | ||
| 527 | * \since This function is available since SDL 3.2.0. | ||
| 528 | * | ||
| 529 | * \sa SDL_GetRenderOutputSize | ||
| 530 | */ | ||
| 531 | extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h); | ||
| 532 | |||
| 533 | /** | ||
| 534 | * Create a texture for a rendering context. | ||
| 535 | * | ||
| 536 | * The contents of a texture when first created are not defined. | ||
| 537 | * | ||
| 538 | * \param renderer the rendering context. | ||
| 539 | * \param format one of the enumerated values in SDL_PixelFormat. | ||
| 540 | * \param access one of the enumerated values in SDL_TextureAccess. | ||
| 541 | * \param w the width of the texture in pixels. | ||
| 542 | * \param h the height of the texture in pixels. | ||
| 543 | * \returns the created texture or NULL on failure; call SDL_GetError() for | ||
| 544 | * more information. | ||
| 545 | * | ||
| 546 | * \threadsafety This function should only be called on the main thread. | ||
| 547 | * | ||
| 548 | * \since This function is available since SDL 3.2.0. | ||
| 549 | * | ||
| 550 | * \sa SDL_CreateTextureFromSurface | ||
| 551 | * \sa SDL_CreateTextureWithProperties | ||
| 552 | * \sa SDL_DestroyTexture | ||
| 553 | * \sa SDL_GetTextureSize | ||
| 554 | * \sa SDL_UpdateTexture | ||
| 555 | */ | ||
| 556 | extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h); | ||
| 557 | |||
| 558 | /** | ||
| 559 | * Create a texture from an existing surface. | ||
| 560 | * | ||
| 561 | * The surface is not modified or freed by this function. | ||
| 562 | * | ||
| 563 | * The SDL_TextureAccess hint for the created texture is | ||
| 564 | * `SDL_TEXTUREACCESS_STATIC`. | ||
| 565 | * | ||
| 566 | * The pixel format of the created texture may be different from the pixel | ||
| 567 | * format of the surface, and can be queried using the | ||
| 568 | * SDL_PROP_TEXTURE_FORMAT_NUMBER property. | ||
| 569 | * | ||
| 570 | * \param renderer the rendering context. | ||
| 571 | * \param surface the SDL_Surface structure containing pixel data used to fill | ||
| 572 | * the texture. | ||
| 573 | * \returns the created texture or NULL on failure; call SDL_GetError() for | ||
| 574 | * more information. | ||
| 575 | * | ||
| 576 | * \threadsafety This function should only be called on the main thread. | ||
| 577 | * | ||
| 578 | * \since This function is available since SDL 3.2.0. | ||
| 579 | * | ||
| 580 | * \sa SDL_CreateTexture | ||
| 581 | * \sa SDL_CreateTextureWithProperties | ||
| 582 | * \sa SDL_DestroyTexture | ||
| 583 | */ | ||
| 584 | extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface); | ||
| 585 | |||
| 586 | /** | ||
| 587 | * Create a texture for a rendering context with the specified properties. | ||
| 588 | * | ||
| 589 | * These are the supported properties: | ||
| 590 | * | ||
| 591 | * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_Colorspace value | ||
| 592 | * describing the texture colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR | ||
| 593 | * for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures, | ||
| 594 | * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for | ||
| 595 | * YUV textures. | ||
| 596 | * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in | ||
| 597 | * SDL_PixelFormat, defaults to the best RGBA format for the renderer | ||
| 598 | * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in | ||
| 599 | * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC | ||
| 600 | * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in | ||
| 601 | * pixels, required | ||
| 602 | * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in | ||
| 603 | * pixels, required | ||
| 604 | * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating | ||
| 605 | * point textures, this defines the value of 100% diffuse white, with higher | ||
| 606 | * values being displayed in the High Dynamic Range headroom. This defaults | ||
| 607 | * to 100 for HDR10 textures and 1.0 for floating point textures. | ||
| 608 | * - `SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`: for HDR10 and floating | ||
| 609 | * point textures, this defines the maximum dynamic range used by the | ||
| 610 | * content, in terms of the SDR white point. This would be equivalent to | ||
| 611 | * maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content. | ||
| 612 | * If this is defined, any values outside the range supported by the display | ||
| 613 | * will be scaled into the available HDR headroom, otherwise they are | ||
| 614 | * clipped. | ||
| 615 | * | ||
| 616 | * With the direct3d11 renderer: | ||
| 617 | * | ||
| 618 | * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D | ||
| 619 | * associated with the texture, if you want to wrap an existing texture. | ||
| 620 | * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D | ||
| 621 | * associated with the U plane of a YUV texture, if you want to wrap an | ||
| 622 | * existing texture. | ||
| 623 | * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D | ||
| 624 | * associated with the V plane of a YUV texture, if you want to wrap an | ||
| 625 | * existing texture. | ||
| 626 | * | ||
| 627 | * With the direct3d12 renderer: | ||
| 628 | * | ||
| 629 | * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource | ||
| 630 | * associated with the texture, if you want to wrap an existing texture. | ||
| 631 | * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource | ||
| 632 | * associated with the U plane of a YUV texture, if you want to wrap an | ||
| 633 | * existing texture. | ||
| 634 | * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource | ||
| 635 | * associated with the V plane of a YUV texture, if you want to wrap an | ||
| 636 | * existing texture. | ||
| 637 | * | ||
| 638 | * With the metal renderer: | ||
| 639 | * | ||
| 640 | * - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef | ||
| 641 | * associated with the texture, if you want to create a texture from an | ||
| 642 | * existing pixel buffer. | ||
| 643 | * | ||
| 644 | * With the opengl renderer: | ||
| 645 | * | ||
| 646 | * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture | ||
| 647 | * associated with the texture, if you want to wrap an existing texture. | ||
| 648 | * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture | ||
| 649 | * associated with the UV plane of an NV12 texture, if you want to wrap an | ||
| 650 | * existing texture. | ||
| 651 | * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture | ||
| 652 | * associated with the U plane of a YUV texture, if you want to wrap an | ||
| 653 | * existing texture. | ||
| 654 | * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture | ||
| 655 | * associated with the V plane of a YUV texture, if you want to wrap an | ||
| 656 | * existing texture. | ||
| 657 | * | ||
| 658 | * With the opengles2 renderer: | ||
| 659 | * | ||
| 660 | * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture | ||
| 661 | * associated with the texture, if you want to wrap an existing texture. | ||
| 662 | * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture | ||
| 663 | * associated with the texture, if you want to wrap an existing texture. | ||
| 664 | * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture | ||
| 665 | * associated with the UV plane of an NV12 texture, if you want to wrap an | ||
| 666 | * existing texture. | ||
| 667 | * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture | ||
| 668 | * associated with the U plane of a YUV texture, if you want to wrap an | ||
| 669 | * existing texture. | ||
| 670 | * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture | ||
| 671 | * associated with the V plane of a YUV texture, if you want to wrap an | ||
| 672 | * existing texture. | ||
| 673 | * | ||
| 674 | * With the vulkan renderer: | ||
| 675 | * | ||
| 676 | * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage with layout | ||
| 677 | * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if | ||
| 678 | * you want to wrap an existing texture. | ||
| 679 | * | ||
| 680 | * \param renderer the rendering context. | ||
| 681 | * \param props the properties to use. | ||
| 682 | * \returns the created texture or NULL on failure; call SDL_GetError() for | ||
| 683 | * more information. | ||
| 684 | * | ||
| 685 | * \threadsafety This function should only be called on the main thread. | ||
| 686 | * | ||
| 687 | * \since This function is available since SDL 3.2.0. | ||
| 688 | * | ||
| 689 | * \sa SDL_CreateProperties | ||
| 690 | * \sa SDL_CreateTexture | ||
| 691 | * \sa SDL_CreateTextureFromSurface | ||
| 692 | * \sa SDL_DestroyTexture | ||
| 693 | * \sa SDL_GetTextureSize | ||
| 694 | * \sa SDL_UpdateTexture | ||
| 695 | */ | ||
| 696 | extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props); | ||
| 697 | |||
| 698 | #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace" | ||
| 699 | #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format" | ||
| 700 | #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access" | ||
| 701 | #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width" | ||
| 702 | #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height" | ||
| 703 | #define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point" | ||
| 704 | #define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom" | ||
| 705 | #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture" | ||
| 706 | #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u" | ||
| 707 | #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v" | ||
| 708 | #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture" | ||
| 709 | #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u" | ||
| 710 | #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v" | ||
| 711 | #define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer" | ||
| 712 | #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture" | ||
| 713 | #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv" | ||
| 714 | #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u" | ||
| 715 | #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v" | ||
| 716 | #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture" | ||
| 717 | #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv" | ||
| 718 | #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u" | ||
| 719 | #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v" | ||
| 720 | #define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture" | ||
| 721 | |||
| 722 | /** | ||
| 723 | * Get the properties associated with a texture. | ||
| 724 | * | ||
| 725 | * The following read-only properties are provided by SDL: | ||
| 726 | * | ||
| 727 | * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_Colorspace value describing | ||
| 728 | * the texture colorspace. | ||
| 729 | * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in | ||
| 730 | * SDL_PixelFormat. | ||
| 731 | * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in | ||
| 732 | * SDL_TextureAccess. | ||
| 733 | * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels. | ||
| 734 | * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels. | ||
| 735 | * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point | ||
| 736 | * textures, this defines the value of 100% diffuse white, with higher | ||
| 737 | * values being displayed in the High Dynamic Range headroom. This defaults | ||
| 738 | * to 100 for HDR10 textures and 1.0 for other textures. | ||
| 739 | * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point | ||
| 740 | * textures, this defines the maximum dynamic range used by the content, in | ||
| 741 | * terms of the SDR white point. If this is defined, any values outside the | ||
| 742 | * range supported by the display will be scaled into the available HDR | ||
| 743 | * headroom, otherwise they are clipped. This defaults to 1.0 for SDR | ||
| 744 | * textures, 4.0 for HDR10 textures, and no default for floating point | ||
| 745 | * textures. | ||
| 746 | * | ||
| 747 | * With the direct3d11 renderer: | ||
| 748 | * | ||
| 749 | * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated | ||
| 750 | * with the texture | ||
| 751 | * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D | ||
| 752 | * associated with the U plane of a YUV texture | ||
| 753 | * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D | ||
| 754 | * associated with the V plane of a YUV texture | ||
| 755 | * | ||
| 756 | * With the direct3d12 renderer: | ||
| 757 | * | ||
| 758 | * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated | ||
| 759 | * with the texture | ||
| 760 | * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated | ||
| 761 | * with the U plane of a YUV texture | ||
| 762 | * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated | ||
| 763 | * with the V plane of a YUV texture | ||
| 764 | * | ||
| 765 | * With the vulkan renderer: | ||
| 766 | * | ||
| 767 | * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the | ||
| 768 | * texture | ||
| 769 | * | ||
| 770 | * With the opengl renderer: | ||
| 771 | * | ||
| 772 | * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated | ||
| 773 | * with the texture | ||
| 774 | * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture | ||
| 775 | * associated with the UV plane of an NV12 texture | ||
| 776 | * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated | ||
| 777 | * with the U plane of a YUV texture | ||
| 778 | * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated | ||
| 779 | * with the V plane of a YUV texture | ||
| 780 | * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the | ||
| 781 | * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc) | ||
| 782 | * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of | ||
| 783 | * the texture (0.0 - 1.0) | ||
| 784 | * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of | ||
| 785 | * the texture (0.0 - 1.0) | ||
| 786 | * | ||
| 787 | * With the opengles2 renderer: | ||
| 788 | * | ||
| 789 | * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture | ||
| 790 | * associated with the texture | ||
| 791 | * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture | ||
| 792 | * associated with the UV plane of an NV12 texture | ||
| 793 | * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture | ||
| 794 | * associated with the U plane of a YUV texture | ||
| 795 | * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture | ||
| 796 | * associated with the V plane of a YUV texture | ||
| 797 | * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the | ||
| 798 | * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc) | ||
| 799 | * | ||
| 800 | * \param texture the texture to query. | ||
| 801 | * \returns a valid property ID on success or 0 on failure; call | ||
| 802 | * SDL_GetError() for more information. | ||
| 803 | * | ||
| 804 | * \threadsafety It is safe to call this function from any thread. | ||
| 805 | * | ||
| 806 | * \since This function is available since SDL 3.2.0. | ||
| 807 | */ | ||
| 808 | extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture); | ||
| 809 | |||
| 810 | #define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace" | ||
| 811 | #define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format" | ||
| 812 | #define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access" | ||
| 813 | #define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width" | ||
| 814 | #define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height" | ||
| 815 | #define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point" | ||
| 816 | #define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom" | ||
| 817 | #define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture" | ||
| 818 | #define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u" | ||
| 819 | #define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v" | ||
| 820 | #define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture" | ||
| 821 | #define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u" | ||
| 822 | #define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v" | ||
| 823 | #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture" | ||
| 824 | #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv" | ||
| 825 | #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u" | ||
| 826 | #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v" | ||
| 827 | #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target" | ||
| 828 | #define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w" | ||
| 829 | #define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h" | ||
| 830 | #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture" | ||
| 831 | #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv" | ||
| 832 | #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u" | ||
| 833 | #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v" | ||
| 834 | #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target" | ||
| 835 | #define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture" | ||
| 836 | |||
| 837 | /** | ||
| 838 | * Get the renderer that created an SDL_Texture. | ||
| 839 | * | ||
| 840 | * \param texture the texture to query. | ||
| 841 | * \returns a pointer to the SDL_Renderer that created the texture, or NULL on | ||
| 842 | * failure; call SDL_GetError() for more information. | ||
| 843 | * | ||
| 844 | * \threadsafety It is safe to call this function from any thread. | ||
| 845 | * | ||
| 846 | * \since This function is available since SDL 3.2.0. | ||
| 847 | */ | ||
| 848 | extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture); | ||
| 849 | |||
| 850 | /** | ||
| 851 | * Get the size of a texture, as floating point values. | ||
| 852 | * | ||
| 853 | * \param texture the texture to query. | ||
| 854 | * \param w a pointer filled in with the width of the texture in pixels. This | ||
| 855 | * argument can be NULL if you don't need this information. | ||
| 856 | * \param h a pointer filled in with the height of the texture in pixels. This | ||
| 857 | * argument can be NULL if you don't need this information. | ||
| 858 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 859 | * information. | ||
| 860 | * | ||
| 861 | * \threadsafety This function should only be called on the main thread. | ||
| 862 | * | ||
| 863 | * \since This function is available since SDL 3.2.0. | ||
| 864 | */ | ||
| 865 | extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h); | ||
| 866 | |||
| 867 | /** | ||
| 868 | * Set an additional color value multiplied into render copy operations. | ||
| 869 | * | ||
| 870 | * When this texture is rendered, during the copy operation each source color | ||
| 871 | * channel is modulated by the appropriate color value according to the | ||
| 872 | * following formula: | ||
| 873 | * | ||
| 874 | * `srcC = srcC * (color / 255)` | ||
| 875 | * | ||
| 876 | * Color modulation is not always supported by the renderer; it will return | ||
| 877 | * false if color modulation is not supported. | ||
| 878 | * | ||
| 879 | * \param texture the texture to update. | ||
| 880 | * \param r the red color value multiplied into copy operations. | ||
| 881 | * \param g the green color value multiplied into copy operations. | ||
| 882 | * \param b the blue color value multiplied into copy operations. | ||
| 883 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 884 | * information. | ||
| 885 | * | ||
| 886 | * \threadsafety This function should only be called on the main thread. | ||
| 887 | * | ||
| 888 | * \since This function is available since SDL 3.2.0. | ||
| 889 | * | ||
| 890 | * \sa SDL_GetTextureColorMod | ||
| 891 | * \sa SDL_SetTextureAlphaMod | ||
| 892 | * \sa SDL_SetTextureColorModFloat | ||
| 893 | */ | ||
| 894 | extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b); | ||
| 895 | |||
| 896 | |||
| 897 | /** | ||
| 898 | * Set an additional color value multiplied into render copy operations. | ||
| 899 | * | ||
| 900 | * When this texture is rendered, during the copy operation each source color | ||
| 901 | * channel is modulated by the appropriate color value according to the | ||
| 902 | * following formula: | ||
| 903 | * | ||
| 904 | * `srcC = srcC * color` | ||
| 905 | * | ||
| 906 | * Color modulation is not always supported by the renderer; it will return | ||
| 907 | * false if color modulation is not supported. | ||
| 908 | * | ||
| 909 | * \param texture the texture to update. | ||
| 910 | * \param r the red color value multiplied into copy operations. | ||
| 911 | * \param g the green color value multiplied into copy operations. | ||
| 912 | * \param b the blue color value multiplied into copy operations. | ||
| 913 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 914 | * information. | ||
| 915 | * | ||
| 916 | * \threadsafety This function should only be called on the main thread. | ||
| 917 | * | ||
| 918 | * \since This function is available since SDL 3.2.0. | ||
| 919 | * | ||
| 920 | * \sa SDL_GetTextureColorModFloat | ||
| 921 | * \sa SDL_SetTextureAlphaModFloat | ||
| 922 | * \sa SDL_SetTextureColorMod | ||
| 923 | */ | ||
| 924 | extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b); | ||
| 925 | |||
| 926 | |||
| 927 | /** | ||
| 928 | * Get the additional color value multiplied into render copy operations. | ||
| 929 | * | ||
| 930 | * \param texture the texture to query. | ||
| 931 | * \param r a pointer filled in with the current red color value. | ||
| 932 | * \param g a pointer filled in with the current green color value. | ||
| 933 | * \param b a pointer filled in with the current blue color value. | ||
| 934 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 935 | * information. | ||
| 936 | * | ||
| 937 | * \threadsafety This function should only be called on the main thread. | ||
| 938 | * | ||
| 939 | * \since This function is available since SDL 3.2.0. | ||
| 940 | * | ||
| 941 | * \sa SDL_GetTextureAlphaMod | ||
| 942 | * \sa SDL_GetTextureColorModFloat | ||
| 943 | * \sa SDL_SetTextureColorMod | ||
| 944 | */ | ||
| 945 | extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b); | ||
| 946 | |||
| 947 | /** | ||
| 948 | * Get the additional color value multiplied into render copy operations. | ||
| 949 | * | ||
| 950 | * \param texture the texture to query. | ||
| 951 | * \param r a pointer filled in with the current red color value. | ||
| 952 | * \param g a pointer filled in with the current green color value. | ||
| 953 | * \param b a pointer filled in with the current blue color value. | ||
| 954 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 955 | * information. | ||
| 956 | * | ||
| 957 | * \threadsafety This function should only be called on the main thread. | ||
| 958 | * | ||
| 959 | * \since This function is available since SDL 3.2.0. | ||
| 960 | * | ||
| 961 | * \sa SDL_GetTextureAlphaModFloat | ||
| 962 | * \sa SDL_GetTextureColorMod | ||
| 963 | * \sa SDL_SetTextureColorModFloat | ||
| 964 | */ | ||
| 965 | extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b); | ||
| 966 | |||
| 967 | /** | ||
| 968 | * Set an additional alpha value multiplied into render copy operations. | ||
| 969 | * | ||
| 970 | * When this texture is rendered, during the copy operation the source alpha | ||
| 971 | * value is modulated by this alpha value according to the following formula: | ||
| 972 | * | ||
| 973 | * `srcA = srcA * (alpha / 255)` | ||
| 974 | * | ||
| 975 | * Alpha modulation is not always supported by the renderer; it will return | ||
| 976 | * false if alpha modulation is not supported. | ||
| 977 | * | ||
| 978 | * \param texture the texture to update. | ||
| 979 | * \param alpha the source alpha value multiplied into copy operations. | ||
| 980 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 981 | * information. | ||
| 982 | * | ||
| 983 | * \threadsafety This function should only be called on the main thread. | ||
| 984 | * | ||
| 985 | * \since This function is available since SDL 3.2.0. | ||
| 986 | * | ||
| 987 | * \sa SDL_GetTextureAlphaMod | ||
| 988 | * \sa SDL_SetTextureAlphaModFloat | ||
| 989 | * \sa SDL_SetTextureColorMod | ||
| 990 | */ | ||
| 991 | extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha); | ||
| 992 | |||
| 993 | /** | ||
| 994 | * Set an additional alpha value multiplied into render copy operations. | ||
| 995 | * | ||
| 996 | * When this texture is rendered, during the copy operation the source alpha | ||
| 997 | * value is modulated by this alpha value according to the following formula: | ||
| 998 | * | ||
| 999 | * `srcA = srcA * alpha` | ||
| 1000 | * | ||
| 1001 | * Alpha modulation is not always supported by the renderer; it will return | ||
| 1002 | * false if alpha modulation is not supported. | ||
| 1003 | * | ||
| 1004 | * \param texture the texture to update. | ||
| 1005 | * \param alpha the source alpha value multiplied into copy operations. | ||
| 1006 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1007 | * information. | ||
| 1008 | * | ||
| 1009 | * \threadsafety This function should only be called on the main thread. | ||
| 1010 | * | ||
| 1011 | * \since This function is available since SDL 3.2.0. | ||
| 1012 | * | ||
| 1013 | * \sa SDL_GetTextureAlphaModFloat | ||
| 1014 | * \sa SDL_SetTextureAlphaMod | ||
| 1015 | * \sa SDL_SetTextureColorModFloat | ||
| 1016 | */ | ||
| 1017 | extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha); | ||
| 1018 | |||
| 1019 | /** | ||
| 1020 | * Get the additional alpha value multiplied into render copy operations. | ||
| 1021 | * | ||
| 1022 | * \param texture the texture to query. | ||
| 1023 | * \param alpha a pointer filled in with the current alpha value. | ||
| 1024 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1025 | * information. | ||
| 1026 | * | ||
| 1027 | * \threadsafety This function should only be called on the main thread. | ||
| 1028 | * | ||
| 1029 | * \since This function is available since SDL 3.2.0. | ||
| 1030 | * | ||
| 1031 | * \sa SDL_GetTextureAlphaModFloat | ||
| 1032 | * \sa SDL_GetTextureColorMod | ||
| 1033 | * \sa SDL_SetTextureAlphaMod | ||
| 1034 | */ | ||
| 1035 | extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha); | ||
| 1036 | |||
| 1037 | /** | ||
| 1038 | * Get the additional alpha value multiplied into render copy operations. | ||
| 1039 | * | ||
| 1040 | * \param texture the texture to query. | ||
| 1041 | * \param alpha a pointer filled in with the current alpha value. | ||
| 1042 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1043 | * information. | ||
| 1044 | * | ||
| 1045 | * \threadsafety This function should only be called on the main thread. | ||
| 1046 | * | ||
| 1047 | * \since This function is available since SDL 3.2.0. | ||
| 1048 | * | ||
| 1049 | * \sa SDL_GetTextureAlphaMod | ||
| 1050 | * \sa SDL_GetTextureColorModFloat | ||
| 1051 | * \sa SDL_SetTextureAlphaModFloat | ||
| 1052 | */ | ||
| 1053 | extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha); | ||
| 1054 | |||
| 1055 | /** | ||
| 1056 | * Set the blend mode for a texture, used by SDL_RenderTexture(). | ||
| 1057 | * | ||
| 1058 | * If the blend mode is not supported, the closest supported mode is chosen | ||
| 1059 | * and this function returns false. | ||
| 1060 | * | ||
| 1061 | * \param texture the texture to update. | ||
| 1062 | * \param blendMode the SDL_BlendMode to use for texture blending. | ||
| 1063 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1064 | * information. | ||
| 1065 | * | ||
| 1066 | * \threadsafety This function should only be called on the main thread. | ||
| 1067 | * | ||
| 1068 | * \since This function is available since SDL 3.2.0. | ||
| 1069 | * | ||
| 1070 | * \sa SDL_GetTextureBlendMode | ||
| 1071 | */ | ||
| 1072 | extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode); | ||
| 1073 | |||
| 1074 | /** | ||
| 1075 | * Get the blend mode used for texture copy operations. | ||
| 1076 | * | ||
| 1077 | * \param texture the texture to query. | ||
| 1078 | * \param blendMode a pointer filled in with the current SDL_BlendMode. | ||
| 1079 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1080 | * information. | ||
| 1081 | * | ||
| 1082 | * \threadsafety This function should only be called on the main thread. | ||
| 1083 | * | ||
| 1084 | * \since This function is available since SDL 3.2.0. | ||
| 1085 | * | ||
| 1086 | * \sa SDL_SetTextureBlendMode | ||
| 1087 | */ | ||
| 1088 | extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode); | ||
| 1089 | |||
| 1090 | /** | ||
| 1091 | * Set the scale mode used for texture scale operations. | ||
| 1092 | * | ||
| 1093 | * The default texture scale mode is SDL_SCALEMODE_LINEAR. | ||
| 1094 | * | ||
| 1095 | * If the scale mode is not supported, the closest supported mode is chosen. | ||
| 1096 | * | ||
| 1097 | * \param texture the texture to update. | ||
| 1098 | * \param scaleMode the SDL_ScaleMode to use for texture scaling. | ||
| 1099 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1100 | * information. | ||
| 1101 | * | ||
| 1102 | * \threadsafety This function should only be called on the main thread. | ||
| 1103 | * | ||
| 1104 | * \since This function is available since SDL 3.2.0. | ||
| 1105 | * | ||
| 1106 | * \sa SDL_GetTextureScaleMode | ||
| 1107 | */ | ||
| 1108 | extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode); | ||
| 1109 | |||
| 1110 | /** | ||
| 1111 | * Get the scale mode used for texture scale operations. | ||
| 1112 | * | ||
| 1113 | * \param texture the texture to query. | ||
| 1114 | * \param scaleMode a pointer filled in with the current scale mode. | ||
| 1115 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1116 | * information. | ||
| 1117 | * | ||
| 1118 | * \threadsafety This function should only be called on the main thread. | ||
| 1119 | * | ||
| 1120 | * \since This function is available since SDL 3.2.0. | ||
| 1121 | * | ||
| 1122 | * \sa SDL_SetTextureScaleMode | ||
| 1123 | */ | ||
| 1124 | extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode); | ||
| 1125 | |||
| 1126 | /** | ||
| 1127 | * Update the given texture rectangle with new pixel data. | ||
| 1128 | * | ||
| 1129 | * The pixel data must be in the pixel format of the texture, which can be | ||
| 1130 | * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property. | ||
| 1131 | * | ||
| 1132 | * This is a fairly slow function, intended for use with static textures that | ||
| 1133 | * do not change often. | ||
| 1134 | * | ||
| 1135 | * If the texture is intended to be updated often, it is preferred to create | ||
| 1136 | * the texture as streaming and use the locking functions referenced below. | ||
| 1137 | * While this function will work with streaming textures, for optimization | ||
| 1138 | * reasons you may not get the pixels back if you lock the texture afterward. | ||
| 1139 | * | ||
| 1140 | * \param texture the texture to update. | ||
| 1141 | * \param rect an SDL_Rect structure representing the area to update, or NULL | ||
| 1142 | * to update the entire texture. | ||
| 1143 | * \param pixels the raw pixel data in the format of the texture. | ||
| 1144 | * \param pitch the number of bytes in a row of pixel data, including padding | ||
| 1145 | * between lines. | ||
| 1146 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1147 | * information. | ||
| 1148 | * | ||
| 1149 | * \threadsafety This function should only be called on the main thread. | ||
| 1150 | * | ||
| 1151 | * \since This function is available since SDL 3.2.0. | ||
| 1152 | * | ||
| 1153 | * \sa SDL_LockTexture | ||
| 1154 | * \sa SDL_UnlockTexture | ||
| 1155 | * \sa SDL_UpdateNVTexture | ||
| 1156 | * \sa SDL_UpdateYUVTexture | ||
| 1157 | */ | ||
| 1158 | extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch); | ||
| 1159 | |||
| 1160 | /** | ||
| 1161 | * Update a rectangle within a planar YV12 or IYUV texture with new pixel | ||
| 1162 | * data. | ||
| 1163 | * | ||
| 1164 | * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous | ||
| 1165 | * block of Y and U/V planes in the proper order, but this function is | ||
| 1166 | * available if your pixel data is not contiguous. | ||
| 1167 | * | ||
| 1168 | * \param texture the texture to update. | ||
| 1169 | * \param rect a pointer to the rectangle of pixels to update, or NULL to | ||
| 1170 | * update the entire texture. | ||
| 1171 | * \param Yplane the raw pixel data for the Y plane. | ||
| 1172 | * \param Ypitch the number of bytes between rows of pixel data for the Y | ||
| 1173 | * plane. | ||
| 1174 | * \param Uplane the raw pixel data for the U plane. | ||
| 1175 | * \param Upitch the number of bytes between rows of pixel data for the U | ||
| 1176 | * plane. | ||
| 1177 | * \param Vplane the raw pixel data for the V plane. | ||
| 1178 | * \param Vpitch the number of bytes between rows of pixel data for the V | ||
| 1179 | * plane. | ||
| 1180 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1181 | * information. | ||
| 1182 | * | ||
| 1183 | * \threadsafety This function should only be called on the main thread. | ||
| 1184 | * | ||
| 1185 | * \since This function is available since SDL 3.2.0. | ||
| 1186 | * | ||
| 1187 | * \sa SDL_UpdateNVTexture | ||
| 1188 | * \sa SDL_UpdateTexture | ||
| 1189 | */ | ||
| 1190 | extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture, | ||
| 1191 | const SDL_Rect *rect, | ||
| 1192 | const Uint8 *Yplane, int Ypitch, | ||
| 1193 | const Uint8 *Uplane, int Upitch, | ||
| 1194 | const Uint8 *Vplane, int Vpitch); | ||
| 1195 | |||
| 1196 | /** | ||
| 1197 | * Update a rectangle within a planar NV12 or NV21 texture with new pixels. | ||
| 1198 | * | ||
| 1199 | * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous | ||
| 1200 | * block of NV12/21 planes in the proper order, but this function is available | ||
| 1201 | * if your pixel data is not contiguous. | ||
| 1202 | * | ||
| 1203 | * \param texture the texture to update. | ||
| 1204 | * \param rect a pointer to the rectangle of pixels to update, or NULL to | ||
| 1205 | * update the entire texture. | ||
| 1206 | * \param Yplane the raw pixel data for the Y plane. | ||
| 1207 | * \param Ypitch the number of bytes between rows of pixel data for the Y | ||
| 1208 | * plane. | ||
| 1209 | * \param UVplane the raw pixel data for the UV plane. | ||
| 1210 | * \param UVpitch the number of bytes between rows of pixel data for the UV | ||
| 1211 | * plane. | ||
| 1212 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1213 | * information. | ||
| 1214 | * | ||
| 1215 | * \threadsafety This function should only be called on the main thread. | ||
| 1216 | * | ||
| 1217 | * \since This function is available since SDL 3.2.0. | ||
| 1218 | * | ||
| 1219 | * \sa SDL_UpdateTexture | ||
| 1220 | * \sa SDL_UpdateYUVTexture | ||
| 1221 | */ | ||
| 1222 | extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture, | ||
| 1223 | const SDL_Rect *rect, | ||
| 1224 | const Uint8 *Yplane, int Ypitch, | ||
| 1225 | const Uint8 *UVplane, int UVpitch); | ||
| 1226 | |||
| 1227 | /** | ||
| 1228 | * Lock a portion of the texture for **write-only** pixel access. | ||
| 1229 | * | ||
| 1230 | * As an optimization, the pixels made available for editing don't necessarily | ||
| 1231 | * contain the old texture data. This is a write-only operation, and if you | ||
| 1232 | * need to keep a copy of the texture data you should do that at the | ||
| 1233 | * application level. | ||
| 1234 | * | ||
| 1235 | * You must use SDL_UnlockTexture() to unlock the pixels and apply any | ||
| 1236 | * changes. | ||
| 1237 | * | ||
| 1238 | * \param texture the texture to lock for access, which was created with | ||
| 1239 | * `SDL_TEXTUREACCESS_STREAMING`. | ||
| 1240 | * \param rect an SDL_Rect structure representing the area to lock for access; | ||
| 1241 | * NULL to lock the entire texture. | ||
| 1242 | * \param pixels this is filled in with a pointer to the locked pixels, | ||
| 1243 | * appropriately offset by the locked area. | ||
| 1244 | * \param pitch this is filled in with the pitch of the locked pixels; the | ||
| 1245 | * pitch is the length of one row in bytes. | ||
| 1246 | * \returns true on success or false if the texture is not valid or was not | ||
| 1247 | * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError() | ||
| 1248 | * for more information. | ||
| 1249 | * | ||
| 1250 | * \threadsafety This function should only be called on the main thread. | ||
| 1251 | * | ||
| 1252 | * \since This function is available since SDL 3.2.0. | ||
| 1253 | * | ||
| 1254 | * \sa SDL_LockTextureToSurface | ||
| 1255 | * \sa SDL_UnlockTexture | ||
| 1256 | */ | ||
| 1257 | extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture, | ||
| 1258 | const SDL_Rect *rect, | ||
| 1259 | void **pixels, int *pitch); | ||
| 1260 | |||
| 1261 | /** | ||
| 1262 | * Lock a portion of the texture for **write-only** pixel access, and expose | ||
| 1263 | * it as a SDL surface. | ||
| 1264 | * | ||
| 1265 | * Besides providing an SDL_Surface instead of raw pixel data, this function | ||
| 1266 | * operates like SDL_LockTexture. | ||
| 1267 | * | ||
| 1268 | * As an optimization, the pixels made available for editing don't necessarily | ||
| 1269 | * contain the old texture data. This is a write-only operation, and if you | ||
| 1270 | * need to keep a copy of the texture data you should do that at the | ||
| 1271 | * application level. | ||
| 1272 | * | ||
| 1273 | * You must use SDL_UnlockTexture() to unlock the pixels and apply any | ||
| 1274 | * changes. | ||
| 1275 | * | ||
| 1276 | * The returned surface is freed internally after calling SDL_UnlockTexture() | ||
| 1277 | * or SDL_DestroyTexture(). The caller should not free it. | ||
| 1278 | * | ||
| 1279 | * \param texture the texture to lock for access, which must be created with | ||
| 1280 | * `SDL_TEXTUREACCESS_STREAMING`. | ||
| 1281 | * \param rect a pointer to the rectangle to lock for access. If the rect is | ||
| 1282 | * NULL, the entire texture will be locked. | ||
| 1283 | * \param surface a pointer to an SDL surface of size **rect**. Don't assume | ||
| 1284 | * any specific pixel content. | ||
| 1285 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1286 | * information. | ||
| 1287 | * | ||
| 1288 | * \threadsafety This function should only be called on the main thread. | ||
| 1289 | * | ||
| 1290 | * \since This function is available since SDL 3.2.0. | ||
| 1291 | * | ||
| 1292 | * \sa SDL_LockTexture | ||
| 1293 | * \sa SDL_UnlockTexture | ||
| 1294 | */ | ||
| 1295 | extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface); | ||
| 1296 | |||
| 1297 | /** | ||
| 1298 | * Unlock a texture, uploading the changes to video memory, if needed. | ||
| 1299 | * | ||
| 1300 | * **Warning**: Please note that SDL_LockTexture() is intended to be | ||
| 1301 | * write-only; it will not guarantee the previous contents of the texture will | ||
| 1302 | * be provided. You must fully initialize any area of a texture that you lock | ||
| 1303 | * before unlocking it, as the pixels might otherwise be uninitialized memory. | ||
| 1304 | * | ||
| 1305 | * Which is to say: locking and immediately unlocking a texture can result in | ||
| 1306 | * corrupted textures, depending on the renderer in use. | ||
| 1307 | * | ||
| 1308 | * \param texture a texture locked by SDL_LockTexture(). | ||
| 1309 | * | ||
| 1310 | * \threadsafety This function should only be called on the main thread. | ||
| 1311 | * | ||
| 1312 | * \since This function is available since SDL 3.2.0. | ||
| 1313 | * | ||
| 1314 | * \sa SDL_LockTexture | ||
| 1315 | */ | ||
| 1316 | extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture); | ||
| 1317 | |||
| 1318 | /** | ||
| 1319 | * Set a texture as the current rendering target. | ||
| 1320 | * | ||
| 1321 | * The default render target is the window for which the renderer was created. | ||
| 1322 | * To stop rendering to a texture and render to the window again, call this | ||
| 1323 | * function with a NULL `texture`. | ||
| 1324 | * | ||
| 1325 | * Viewport, cliprect, scale, and logical presentation are unique to each | ||
| 1326 | * render target. Get and set functions for these states apply to the current | ||
| 1327 | * render target set by this function, and those states persist on each target | ||
| 1328 | * when the current render target changes. | ||
| 1329 | * | ||
| 1330 | * \param renderer the rendering context. | ||
| 1331 | * \param texture the targeted texture, which must be created with the | ||
| 1332 | * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the | ||
| 1333 | * window instead of a texture. | ||
| 1334 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1335 | * information. | ||
| 1336 | * | ||
| 1337 | * \threadsafety This function should only be called on the main thread. | ||
| 1338 | * | ||
| 1339 | * \since This function is available since SDL 3.2.0. | ||
| 1340 | * | ||
| 1341 | * \sa SDL_GetRenderTarget | ||
| 1342 | */ | ||
| 1343 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture); | ||
| 1344 | |||
| 1345 | /** | ||
| 1346 | * Get the current render target. | ||
| 1347 | * | ||
| 1348 | * The default render target is the window for which the renderer was created, | ||
| 1349 | * and is reported a NULL here. | ||
| 1350 | * | ||
| 1351 | * \param renderer the rendering context. | ||
| 1352 | * \returns the current render target or NULL for the default render target. | ||
| 1353 | * | ||
| 1354 | * \threadsafety This function should only be called on the main thread. | ||
| 1355 | * | ||
| 1356 | * \since This function is available since SDL 3.2.0. | ||
| 1357 | * | ||
| 1358 | * \sa SDL_SetRenderTarget | ||
| 1359 | */ | ||
| 1360 | extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); | ||
| 1361 | |||
| 1362 | /** | ||
| 1363 | * Set a device-independent resolution and presentation mode for rendering. | ||
| 1364 | * | ||
| 1365 | * This function sets the width and height of the logical rendering output. | ||
| 1366 | * The renderer will act as if the current render target is always the | ||
| 1367 | * requested dimensions, scaling to the actual resolution as necessary. | ||
| 1368 | * | ||
| 1369 | * This can be useful for games that expect a fixed size, but would like to | ||
| 1370 | * scale the output to whatever is available, regardless of how a user resizes | ||
| 1371 | * a window, or if the display is high DPI. | ||
| 1372 | * | ||
| 1373 | * Logical presentation can be used with both render target textures and the | ||
| 1374 | * renderer's window; the state is unique to each render target, and this | ||
| 1375 | * function sets the state for the current render target. It might be useful | ||
| 1376 | * to draw to a texture that matches the window dimensions with logical | ||
| 1377 | * presentation enabled, and then draw that texture across the entire window | ||
| 1378 | * with logical presentation disabled. Be careful not to render both with | ||
| 1379 | * logical presentation enabled, however, as this could produce | ||
| 1380 | * double-letterboxing, etc. | ||
| 1381 | * | ||
| 1382 | * You can disable logical coordinates by setting the mode to | ||
| 1383 | * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel | ||
| 1384 | * resolution of the render target; it is safe to toggle logical presentation | ||
| 1385 | * during the rendering of a frame: perhaps most of the rendering is done to | ||
| 1386 | * specific dimensions but to make fonts look sharp, the app turns off logical | ||
| 1387 | * presentation while drawing text, for example. | ||
| 1388 | * | ||
| 1389 | * For the renderer's window, letterboxing is drawn into the framebuffer if | ||
| 1390 | * logical presentation is enabled during SDL_RenderPresent; be sure to | ||
| 1391 | * reenable it before presenting if you were toggling it, otherwise the | ||
| 1392 | * letterbox areas might have artifacts from previous frames (or artifacts | ||
| 1393 | * from external overlays, etc). Letterboxing is never drawn into texture | ||
| 1394 | * render targets; be sure to call SDL_RenderClear() before drawing into the | ||
| 1395 | * texture so the letterboxing areas are cleared, if appropriate. | ||
| 1396 | * | ||
| 1397 | * You can convert coordinates in an event into rendering coordinates using | ||
| 1398 | * SDL_ConvertEventToRenderCoordinates(). | ||
| 1399 | * | ||
| 1400 | * \param renderer the rendering context. | ||
| 1401 | * \param w the width of the logical resolution. | ||
| 1402 | * \param h the height of the logical resolution. | ||
| 1403 | * \param mode the presentation mode used. | ||
| 1404 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1405 | * information. | ||
| 1406 | * | ||
| 1407 | * \threadsafety This function should only be called on the main thread. | ||
| 1408 | * | ||
| 1409 | * \since This function is available since SDL 3.2.0. | ||
| 1410 | * | ||
| 1411 | * \sa SDL_ConvertEventToRenderCoordinates | ||
| 1412 | * \sa SDL_GetRenderLogicalPresentation | ||
| 1413 | * \sa SDL_GetRenderLogicalPresentationRect | ||
| 1414 | */ | ||
| 1415 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode); | ||
| 1416 | |||
| 1417 | /** | ||
| 1418 | * Get device independent resolution and presentation mode for rendering. | ||
| 1419 | * | ||
| 1420 | * This function gets the width and height of the logical rendering output, or | ||
| 1421 | * the output size in pixels if a logical resolution is not enabled. | ||
| 1422 | * | ||
| 1423 | * Each render target has its own logical presentation state. This function | ||
| 1424 | * gets the state for the current render target. | ||
| 1425 | * | ||
| 1426 | * \param renderer the rendering context. | ||
| 1427 | * \param w an int to be filled with the width. | ||
| 1428 | * \param h an int to be filled with the height. | ||
| 1429 | * \param mode the presentation mode used. | ||
| 1430 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1431 | * information. | ||
| 1432 | * | ||
| 1433 | * \threadsafety This function should only be called on the main thread. | ||
| 1434 | * | ||
| 1435 | * \since This function is available since SDL 3.2.0. | ||
| 1436 | * | ||
| 1437 | * \sa SDL_SetRenderLogicalPresentation | ||
| 1438 | */ | ||
| 1439 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode); | ||
| 1440 | |||
| 1441 | /** | ||
| 1442 | * Get the final presentation rectangle for rendering. | ||
| 1443 | * | ||
| 1444 | * This function returns the calculated rectangle used for logical | ||
| 1445 | * presentation, based on the presentation mode and output size. If logical | ||
| 1446 | * presentation is disabled, it will fill the rectangle with the output size, | ||
| 1447 | * in pixels. | ||
| 1448 | * | ||
| 1449 | * Each render target has its own logical presentation state. This function | ||
| 1450 | * gets the rectangle for the current render target. | ||
| 1451 | * | ||
| 1452 | * \param renderer the rendering context. | ||
| 1453 | * \param rect a pointer filled in with the final presentation rectangle, may | ||
| 1454 | * be NULL. | ||
| 1455 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1456 | * information. | ||
| 1457 | * | ||
| 1458 | * \threadsafety This function should only be called on the main thread. | ||
| 1459 | * | ||
| 1460 | * \since This function is available since SDL 3.2.0. | ||
| 1461 | * | ||
| 1462 | * \sa SDL_SetRenderLogicalPresentation | ||
| 1463 | */ | ||
| 1464 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect); | ||
| 1465 | |||
| 1466 | /** | ||
| 1467 | * Get a point in render coordinates when given a point in window coordinates. | ||
| 1468 | * | ||
| 1469 | * This takes into account several states: | ||
| 1470 | * | ||
| 1471 | * - The window dimensions. | ||
| 1472 | * - The logical presentation settings (SDL_SetRenderLogicalPresentation) | ||
| 1473 | * - The scale (SDL_SetRenderScale) | ||
| 1474 | * - The viewport (SDL_SetRenderViewport) | ||
| 1475 | * | ||
| 1476 | * \param renderer the rendering context. | ||
| 1477 | * \param window_x the x coordinate in window coordinates. | ||
| 1478 | * \param window_y the y coordinate in window coordinates. | ||
| 1479 | * \param x a pointer filled with the x coordinate in render coordinates. | ||
| 1480 | * \param y a pointer filled with the y coordinate in render coordinates. | ||
| 1481 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1482 | * information. | ||
| 1483 | * | ||
| 1484 | * \threadsafety This function should only be called on the main thread. | ||
| 1485 | * | ||
| 1486 | * \since This function is available since SDL 3.2.0. | ||
| 1487 | * | ||
| 1488 | * \sa SDL_SetRenderLogicalPresentation | ||
| 1489 | * \sa SDL_SetRenderScale | ||
| 1490 | */ | ||
| 1491 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y); | ||
| 1492 | |||
| 1493 | /** | ||
| 1494 | * Get a point in window coordinates when given a point in render coordinates. | ||
| 1495 | * | ||
| 1496 | * This takes into account several states: | ||
| 1497 | * | ||
| 1498 | * - The window dimensions. | ||
| 1499 | * - The logical presentation settings (SDL_SetRenderLogicalPresentation) | ||
| 1500 | * - The scale (SDL_SetRenderScale) | ||
| 1501 | * - The viewport (SDL_SetRenderViewport) | ||
| 1502 | * | ||
| 1503 | * \param renderer the rendering context. | ||
| 1504 | * \param x the x coordinate in render coordinates. | ||
| 1505 | * \param y the y coordinate in render coordinates. | ||
| 1506 | * \param window_x a pointer filled with the x coordinate in window | ||
| 1507 | * coordinates. | ||
| 1508 | * \param window_y a pointer filled with the y coordinate in window | ||
| 1509 | * coordinates. | ||
| 1510 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1511 | * information. | ||
| 1512 | * | ||
| 1513 | * \threadsafety This function should only be called on the main thread. | ||
| 1514 | * | ||
| 1515 | * \since This function is available since SDL 3.2.0. | ||
| 1516 | * | ||
| 1517 | * \sa SDL_SetRenderLogicalPresentation | ||
| 1518 | * \sa SDL_SetRenderScale | ||
| 1519 | * \sa SDL_SetRenderViewport | ||
| 1520 | */ | ||
| 1521 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y); | ||
| 1522 | |||
| 1523 | /** | ||
| 1524 | * Convert the coordinates in an event to render coordinates. | ||
| 1525 | * | ||
| 1526 | * This takes into account several states: | ||
| 1527 | * | ||
| 1528 | * - The window dimensions. | ||
| 1529 | * - The logical presentation settings (SDL_SetRenderLogicalPresentation) | ||
| 1530 | * - The scale (SDL_SetRenderScale) | ||
| 1531 | * - The viewport (SDL_SetRenderViewport) | ||
| 1532 | * | ||
| 1533 | * Various event types are converted with this function: mouse, touch, pen, | ||
| 1534 | * etc. | ||
| 1535 | * | ||
| 1536 | * Touch coordinates are converted from normalized coordinates in the window | ||
| 1537 | * to non-normalized rendering coordinates. | ||
| 1538 | * | ||
| 1539 | * Relative mouse coordinates (xrel and yrel event fields) are _also_ | ||
| 1540 | * converted. Applications that do not want these fields converted should use | ||
| 1541 | * SDL_RenderCoordinatesFromWindow() on the specific event fields instead of | ||
| 1542 | * converting the entire event structure. | ||
| 1543 | * | ||
| 1544 | * Once converted, coordinates may be outside the rendering area. | ||
| 1545 | * | ||
| 1546 | * \param renderer the rendering context. | ||
| 1547 | * \param event the event to modify. | ||
| 1548 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1549 | * information. | ||
| 1550 | * | ||
| 1551 | * \threadsafety This function should only be called on the main thread. | ||
| 1552 | * | ||
| 1553 | * \since This function is available since SDL 3.2.0. | ||
| 1554 | * | ||
| 1555 | * \sa SDL_RenderCoordinatesFromWindow | ||
| 1556 | */ | ||
| 1557 | extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event); | ||
| 1558 | |||
| 1559 | /** | ||
| 1560 | * Set the drawing area for rendering on the current target. | ||
| 1561 | * | ||
| 1562 | * Drawing will clip to this area (separately from any clipping done with | ||
| 1563 | * SDL_SetRenderClipRect), and the top left of the area will become coordinate | ||
| 1564 | * (0, 0) for future drawing commands. | ||
| 1565 | * | ||
| 1566 | * The area's width and height must be >= 0. | ||
| 1567 | * | ||
| 1568 | * Each render target has its own viewport. This function sets the viewport | ||
| 1569 | * for the current render target. | ||
| 1570 | * | ||
| 1571 | * \param renderer the rendering context. | ||
| 1572 | * \param rect the SDL_Rect structure representing the drawing area, or NULL | ||
| 1573 | * to set the viewport to the entire target. | ||
| 1574 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1575 | * information. | ||
| 1576 | * | ||
| 1577 | * \threadsafety This function should only be called on the main thread. | ||
| 1578 | * | ||
| 1579 | * \since This function is available since SDL 3.2.0. | ||
| 1580 | * | ||
| 1581 | * \sa SDL_GetRenderViewport | ||
| 1582 | * \sa SDL_RenderViewportSet | ||
| 1583 | */ | ||
| 1584 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect); | ||
| 1585 | |||
| 1586 | /** | ||
| 1587 | * Get the drawing area for the current target. | ||
| 1588 | * | ||
| 1589 | * Each render target has its own viewport. This function gets the viewport | ||
| 1590 | * for the current render target. | ||
| 1591 | * | ||
| 1592 | * \param renderer the rendering context. | ||
| 1593 | * \param rect an SDL_Rect structure filled in with the current drawing area. | ||
| 1594 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1595 | * information. | ||
| 1596 | * | ||
| 1597 | * \threadsafety This function should only be called on the main thread. | ||
| 1598 | * | ||
| 1599 | * \since This function is available since SDL 3.2.0. | ||
| 1600 | * | ||
| 1601 | * \sa SDL_RenderViewportSet | ||
| 1602 | * \sa SDL_SetRenderViewport | ||
| 1603 | */ | ||
| 1604 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect); | ||
| 1605 | |||
| 1606 | /** | ||
| 1607 | * Return whether an explicit rectangle was set as the viewport. | ||
| 1608 | * | ||
| 1609 | * This is useful if you're saving and restoring the viewport and want to know | ||
| 1610 | * whether you should restore a specific rectangle or NULL. Note that the | ||
| 1611 | * viewport is always reset when changing rendering targets. | ||
| 1612 | * | ||
| 1613 | * Each render target has its own viewport. This function checks the viewport | ||
| 1614 | * for the current render target. | ||
| 1615 | * | ||
| 1616 | * \param renderer the rendering context. | ||
| 1617 | * \returns true if the viewport was set to a specific rectangle, or false if | ||
| 1618 | * it was set to NULL (the entire target). | ||
| 1619 | * | ||
| 1620 | * \threadsafety This function should only be called on the main thread. | ||
| 1621 | * | ||
| 1622 | * \since This function is available since SDL 3.2.0. | ||
| 1623 | * | ||
| 1624 | * \sa SDL_GetRenderViewport | ||
| 1625 | * \sa SDL_SetRenderViewport | ||
| 1626 | */ | ||
| 1627 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer); | ||
| 1628 | |||
| 1629 | /** | ||
| 1630 | * Get the safe area for rendering within the current viewport. | ||
| 1631 | * | ||
| 1632 | * Some devices have portions of the screen which are partially obscured or | ||
| 1633 | * not interactive, possibly due to on-screen controls, curved edges, camera | ||
| 1634 | * notches, TV overscan, etc. This function provides the area of the current | ||
| 1635 | * viewport which is safe to have interactible content. You should continue | ||
| 1636 | * rendering into the rest of the render target, but it should not contain | ||
| 1637 | * visually important or interactible content. | ||
| 1638 | * | ||
| 1639 | * \param renderer the rendering context. | ||
| 1640 | * \param rect a pointer filled in with the area that is safe for interactive | ||
| 1641 | * content. | ||
| 1642 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1643 | * information. | ||
| 1644 | * | ||
| 1645 | * \threadsafety This function should only be called on the main thread. | ||
| 1646 | * | ||
| 1647 | * \since This function is available since SDL 3.2.0. | ||
| 1648 | */ | ||
| 1649 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect); | ||
| 1650 | |||
| 1651 | /** | ||
| 1652 | * Set the clip rectangle for rendering on the specified target. | ||
| 1653 | * | ||
| 1654 | * Each render target has its own clip rectangle. This function sets the | ||
| 1655 | * cliprect for the current render target. | ||
| 1656 | * | ||
| 1657 | * \param renderer the rendering context. | ||
| 1658 | * \param rect an SDL_Rect structure representing the clip area, relative to | ||
| 1659 | * the viewport, or NULL to disable clipping. | ||
| 1660 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1661 | * information. | ||
| 1662 | * | ||
| 1663 | * \threadsafety This function should only be called on the main thread. | ||
| 1664 | * | ||
| 1665 | * \since This function is available since SDL 3.2.0. | ||
| 1666 | * | ||
| 1667 | * \sa SDL_GetRenderClipRect | ||
| 1668 | * \sa SDL_RenderClipEnabled | ||
| 1669 | */ | ||
| 1670 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect); | ||
| 1671 | |||
| 1672 | /** | ||
| 1673 | * Get the clip rectangle for the current target. | ||
| 1674 | * | ||
| 1675 | * Each render target has its own clip rectangle. This function gets the | ||
| 1676 | * cliprect for the current render target. | ||
| 1677 | * | ||
| 1678 | * \param renderer the rendering context. | ||
| 1679 | * \param rect an SDL_Rect structure filled in with the current clipping area | ||
| 1680 | * or an empty rectangle if clipping is disabled. | ||
| 1681 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1682 | * information. | ||
| 1683 | * | ||
| 1684 | * \threadsafety This function should only be called on the main thread. | ||
| 1685 | * | ||
| 1686 | * \since This function is available since SDL 3.2.0. | ||
| 1687 | * | ||
| 1688 | * \sa SDL_RenderClipEnabled | ||
| 1689 | * \sa SDL_SetRenderClipRect | ||
| 1690 | */ | ||
| 1691 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect); | ||
| 1692 | |||
| 1693 | /** | ||
| 1694 | * Get whether clipping is enabled on the given render target. | ||
| 1695 | * | ||
| 1696 | * Each render target has its own clip rectangle. This function checks the | ||
| 1697 | * cliprect for the current render target. | ||
| 1698 | * | ||
| 1699 | * \param renderer the rendering context. | ||
| 1700 | * \returns true if clipping is enabled or false if not; call SDL_GetError() | ||
| 1701 | * for more information. | ||
| 1702 | * | ||
| 1703 | * \threadsafety This function should only be called on the main thread. | ||
| 1704 | * | ||
| 1705 | * \since This function is available since SDL 3.2.0. | ||
| 1706 | * | ||
| 1707 | * \sa SDL_GetRenderClipRect | ||
| 1708 | * \sa SDL_SetRenderClipRect | ||
| 1709 | */ | ||
| 1710 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer); | ||
| 1711 | |||
| 1712 | /** | ||
| 1713 | * Set the drawing scale for rendering on the current target. | ||
| 1714 | * | ||
| 1715 | * The drawing coordinates are scaled by the x/y scaling factors before they | ||
| 1716 | * are used by the renderer. This allows resolution independent drawing with a | ||
| 1717 | * single coordinate system. | ||
| 1718 | * | ||
| 1719 | * If this results in scaling or subpixel drawing by the rendering backend, it | ||
| 1720 | * will be handled using the appropriate quality hints. For best results use | ||
| 1721 | * integer scaling factors. | ||
| 1722 | * | ||
| 1723 | * Each render target has its own scale. This function sets the scale for the | ||
| 1724 | * current render target. | ||
| 1725 | * | ||
| 1726 | * \param renderer the rendering context. | ||
| 1727 | * \param scaleX the horizontal scaling factor. | ||
| 1728 | * \param scaleY the vertical scaling factor. | ||
| 1729 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1730 | * information. | ||
| 1731 | * | ||
| 1732 | * \threadsafety This function should only be called on the main thread. | ||
| 1733 | * | ||
| 1734 | * \since This function is available since SDL 3.2.0. | ||
| 1735 | * | ||
| 1736 | * \sa SDL_GetRenderScale | ||
| 1737 | */ | ||
| 1738 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY); | ||
| 1739 | |||
| 1740 | /** | ||
| 1741 | * Get the drawing scale for the current target. | ||
| 1742 | * | ||
| 1743 | * Each render target has its own scale. This function gets the scale for the | ||
| 1744 | * current render target. | ||
| 1745 | * | ||
| 1746 | * \param renderer the rendering context. | ||
| 1747 | * \param scaleX a pointer filled in with the horizontal scaling factor. | ||
| 1748 | * \param scaleY a pointer filled in with the vertical scaling factor. | ||
| 1749 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1750 | * information. | ||
| 1751 | * | ||
| 1752 | * \threadsafety This function should only be called on the main thread. | ||
| 1753 | * | ||
| 1754 | * \since This function is available since SDL 3.2.0. | ||
| 1755 | * | ||
| 1756 | * \sa SDL_SetRenderScale | ||
| 1757 | */ | ||
| 1758 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY); | ||
| 1759 | |||
| 1760 | /** | ||
| 1761 | * Set the color used for drawing operations. | ||
| 1762 | * | ||
| 1763 | * Set the color for drawing or filling rectangles, lines, and points, and for | ||
| 1764 | * SDL_RenderClear(). | ||
| 1765 | * | ||
| 1766 | * \param renderer the rendering context. | ||
| 1767 | * \param r the red value used to draw on the rendering target. | ||
| 1768 | * \param g the green value used to draw on the rendering target. | ||
| 1769 | * \param b the blue value used to draw on the rendering target. | ||
| 1770 | * \param a the alpha value used to draw on the rendering target; usually | ||
| 1771 | * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to | ||
| 1772 | * specify how the alpha channel is used. | ||
| 1773 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1774 | * information. | ||
| 1775 | * | ||
| 1776 | * \threadsafety This function should only be called on the main thread. | ||
| 1777 | * | ||
| 1778 | * \since This function is available since SDL 3.2.0. | ||
| 1779 | * | ||
| 1780 | * \sa SDL_GetRenderDrawColor | ||
| 1781 | * \sa SDL_SetRenderDrawColorFloat | ||
| 1782 | */ | ||
| 1783 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a); | ||
| 1784 | |||
| 1785 | /** | ||
| 1786 | * Set the color used for drawing operations (Rect, Line and Clear). | ||
| 1787 | * | ||
| 1788 | * Set the color for drawing or filling rectangles, lines, and points, and for | ||
| 1789 | * SDL_RenderClear(). | ||
| 1790 | * | ||
| 1791 | * \param renderer the rendering context. | ||
| 1792 | * \param r the red value used to draw on the rendering target. | ||
| 1793 | * \param g the green value used to draw on the rendering target. | ||
| 1794 | * \param b the blue value used to draw on the rendering target. | ||
| 1795 | * \param a the alpha value used to draw on the rendering target. Use | ||
| 1796 | * SDL_SetRenderDrawBlendMode to specify how the alpha channel is | ||
| 1797 | * used. | ||
| 1798 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1799 | * information. | ||
| 1800 | * | ||
| 1801 | * \threadsafety This function should only be called on the main thread. | ||
| 1802 | * | ||
| 1803 | * \since This function is available since SDL 3.2.0. | ||
| 1804 | * | ||
| 1805 | * \sa SDL_GetRenderDrawColorFloat | ||
| 1806 | * \sa SDL_SetRenderDrawColor | ||
| 1807 | */ | ||
| 1808 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a); | ||
| 1809 | |||
| 1810 | /** | ||
| 1811 | * Get the color used for drawing operations (Rect, Line and Clear). | ||
| 1812 | * | ||
| 1813 | * \param renderer the rendering context. | ||
| 1814 | * \param r a pointer filled in with the red value used to draw on the | ||
| 1815 | * rendering target. | ||
| 1816 | * \param g a pointer filled in with the green value used to draw on the | ||
| 1817 | * rendering target. | ||
| 1818 | * \param b a pointer filled in with the blue value used to draw on the | ||
| 1819 | * rendering target. | ||
| 1820 | * \param a a pointer filled in with the alpha value used to draw on the | ||
| 1821 | * rendering target; usually `SDL_ALPHA_OPAQUE` (255). | ||
| 1822 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1823 | * information. | ||
| 1824 | * | ||
| 1825 | * \threadsafety This function should only be called on the main thread. | ||
| 1826 | * | ||
| 1827 | * \since This function is available since SDL 3.2.0. | ||
| 1828 | * | ||
| 1829 | * \sa SDL_GetRenderDrawColorFloat | ||
| 1830 | * \sa SDL_SetRenderDrawColor | ||
| 1831 | */ | ||
| 1832 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a); | ||
| 1833 | |||
| 1834 | /** | ||
| 1835 | * Get the color used for drawing operations (Rect, Line and Clear). | ||
| 1836 | * | ||
| 1837 | * \param renderer the rendering context. | ||
| 1838 | * \param r a pointer filled in with the red value used to draw on the | ||
| 1839 | * rendering target. | ||
| 1840 | * \param g a pointer filled in with the green value used to draw on the | ||
| 1841 | * rendering target. | ||
| 1842 | * \param b a pointer filled in with the blue value used to draw on the | ||
| 1843 | * rendering target. | ||
| 1844 | * \param a a pointer filled in with the alpha value used to draw on the | ||
| 1845 | * rendering target. | ||
| 1846 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1847 | * information. | ||
| 1848 | * | ||
| 1849 | * \threadsafety This function should only be called on the main thread. | ||
| 1850 | * | ||
| 1851 | * \since This function is available since SDL 3.2.0. | ||
| 1852 | * | ||
| 1853 | * \sa SDL_SetRenderDrawColorFloat | ||
| 1854 | * \sa SDL_GetRenderDrawColor | ||
| 1855 | */ | ||
| 1856 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a); | ||
| 1857 | |||
| 1858 | /** | ||
| 1859 | * Set the color scale used for render operations. | ||
| 1860 | * | ||
| 1861 | * The color scale is an additional scale multiplied into the pixel color | ||
| 1862 | * value while rendering. This can be used to adjust the brightness of colors | ||
| 1863 | * during HDR rendering, or changing HDR video brightness when playing on an | ||
| 1864 | * SDR display. | ||
| 1865 | * | ||
| 1866 | * The color scale does not affect the alpha channel, only the color | ||
| 1867 | * brightness. | ||
| 1868 | * | ||
| 1869 | * \param renderer the rendering context. | ||
| 1870 | * \param scale the color scale value. | ||
| 1871 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1872 | * information. | ||
| 1873 | * | ||
| 1874 | * \threadsafety This function should only be called on the main thread. | ||
| 1875 | * | ||
| 1876 | * \since This function is available since SDL 3.2.0. | ||
| 1877 | * | ||
| 1878 | * \sa SDL_GetRenderColorScale | ||
| 1879 | */ | ||
| 1880 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale); | ||
| 1881 | |||
| 1882 | /** | ||
| 1883 | * Get the color scale used for render operations. | ||
| 1884 | * | ||
| 1885 | * \param renderer the rendering context. | ||
| 1886 | * \param scale a pointer filled in with the current color scale value. | ||
| 1887 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1888 | * information. | ||
| 1889 | * | ||
| 1890 | * \threadsafety This function should only be called on the main thread. | ||
| 1891 | * | ||
| 1892 | * \since This function is available since SDL 3.2.0. | ||
| 1893 | * | ||
| 1894 | * \sa SDL_SetRenderColorScale | ||
| 1895 | */ | ||
| 1896 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale); | ||
| 1897 | |||
| 1898 | /** | ||
| 1899 | * Set the blend mode used for drawing operations (Fill and Line). | ||
| 1900 | * | ||
| 1901 | * If the blend mode is not supported, the closest supported mode is chosen. | ||
| 1902 | * | ||
| 1903 | * \param renderer the rendering context. | ||
| 1904 | * \param blendMode the SDL_BlendMode to use for blending. | ||
| 1905 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1906 | * information. | ||
| 1907 | * | ||
| 1908 | * \threadsafety This function should only be called on the main thread. | ||
| 1909 | * | ||
| 1910 | * \since This function is available since SDL 3.2.0. | ||
| 1911 | * | ||
| 1912 | * \sa SDL_GetRenderDrawBlendMode | ||
| 1913 | */ | ||
| 1914 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode); | ||
| 1915 | |||
| 1916 | /** | ||
| 1917 | * Get the blend mode used for drawing operations. | ||
| 1918 | * | ||
| 1919 | * \param renderer the rendering context. | ||
| 1920 | * \param blendMode a pointer filled in with the current SDL_BlendMode. | ||
| 1921 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1922 | * information. | ||
| 1923 | * | ||
| 1924 | * \threadsafety This function should only be called on the main thread. | ||
| 1925 | * | ||
| 1926 | * \since This function is available since SDL 3.2.0. | ||
| 1927 | * | ||
| 1928 | * \sa SDL_SetRenderDrawBlendMode | ||
| 1929 | */ | ||
| 1930 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode); | ||
| 1931 | |||
| 1932 | /** | ||
| 1933 | * Clear the current rendering target with the drawing color. | ||
| 1934 | * | ||
| 1935 | * This function clears the entire rendering target, ignoring the viewport and | ||
| 1936 | * the clip rectangle. Note, that clearing will also set/fill all pixels of | ||
| 1937 | * the rendering target to current renderer draw color, so make sure to invoke | ||
| 1938 | * SDL_SetRenderDrawColor() when needed. | ||
| 1939 | * | ||
| 1940 | * \param renderer the rendering context. | ||
| 1941 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1942 | * information. | ||
| 1943 | * | ||
| 1944 | * \threadsafety This function should only be called on the main thread. | ||
| 1945 | * | ||
| 1946 | * \since This function is available since SDL 3.2.0. | ||
| 1947 | * | ||
| 1948 | * \sa SDL_SetRenderDrawColor | ||
| 1949 | */ | ||
| 1950 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer); | ||
| 1951 | |||
| 1952 | /** | ||
| 1953 | * Draw a point on the current rendering target at subpixel precision. | ||
| 1954 | * | ||
| 1955 | * \param renderer the renderer which should draw a point. | ||
| 1956 | * \param x the x coordinate of the point. | ||
| 1957 | * \param y the y coordinate of the point. | ||
| 1958 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1959 | * information. | ||
| 1960 | * | ||
| 1961 | * \threadsafety This function should only be called on the main thread. | ||
| 1962 | * | ||
| 1963 | * \since This function is available since SDL 3.2.0. | ||
| 1964 | * | ||
| 1965 | * \sa SDL_RenderPoints | ||
| 1966 | */ | ||
| 1967 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y); | ||
| 1968 | |||
| 1969 | /** | ||
| 1970 | * Draw multiple points on the current rendering target at subpixel precision. | ||
| 1971 | * | ||
| 1972 | * \param renderer the renderer which should draw multiple points. | ||
| 1973 | * \param points the points to draw. | ||
| 1974 | * \param count the number of points to draw. | ||
| 1975 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1976 | * information. | ||
| 1977 | * | ||
| 1978 | * \threadsafety This function should only be called on the main thread. | ||
| 1979 | * | ||
| 1980 | * \since This function is available since SDL 3.2.0. | ||
| 1981 | * | ||
| 1982 | * \sa SDL_RenderPoint | ||
| 1983 | */ | ||
| 1984 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count); | ||
| 1985 | |||
| 1986 | /** | ||
| 1987 | * Draw a line on the current rendering target at subpixel precision. | ||
| 1988 | * | ||
| 1989 | * \param renderer the renderer which should draw a line. | ||
| 1990 | * \param x1 the x coordinate of the start point. | ||
| 1991 | * \param y1 the y coordinate of the start point. | ||
| 1992 | * \param x2 the x coordinate of the end point. | ||
| 1993 | * \param y2 the y coordinate of the end point. | ||
| 1994 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 1995 | * information. | ||
| 1996 | * | ||
| 1997 | * \threadsafety This function should only be called on the main thread. | ||
| 1998 | * | ||
| 1999 | * \since This function is available since SDL 3.2.0. | ||
| 2000 | * | ||
| 2001 | * \sa SDL_RenderLines | ||
| 2002 | */ | ||
| 2003 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2); | ||
| 2004 | |||
| 2005 | /** | ||
| 2006 | * Draw a series of connected lines on the current rendering target at | ||
| 2007 | * subpixel precision. | ||
| 2008 | * | ||
| 2009 | * \param renderer the renderer which should draw multiple lines. | ||
| 2010 | * \param points the points along the lines. | ||
| 2011 | * \param count the number of points, drawing count-1 lines. | ||
| 2012 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2013 | * information. | ||
| 2014 | * | ||
| 2015 | * \threadsafety This function should only be called on the main thread. | ||
| 2016 | * | ||
| 2017 | * \since This function is available since SDL 3.2.0. | ||
| 2018 | * | ||
| 2019 | * \sa SDL_RenderLine | ||
| 2020 | */ | ||
| 2021 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count); | ||
| 2022 | |||
| 2023 | /** | ||
| 2024 | * Draw a rectangle on the current rendering target at subpixel precision. | ||
| 2025 | * | ||
| 2026 | * \param renderer the renderer which should draw a rectangle. | ||
| 2027 | * \param rect a pointer to the destination rectangle, or NULL to outline the | ||
| 2028 | * entire rendering target. | ||
| 2029 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2030 | * information. | ||
| 2031 | * | ||
| 2032 | * \threadsafety This function should only be called on the main thread. | ||
| 2033 | * | ||
| 2034 | * \since This function is available since SDL 3.2.0. | ||
| 2035 | * | ||
| 2036 | * \sa SDL_RenderRects | ||
| 2037 | */ | ||
| 2038 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect); | ||
| 2039 | |||
| 2040 | /** | ||
| 2041 | * Draw some number of rectangles on the current rendering target at subpixel | ||
| 2042 | * precision. | ||
| 2043 | * | ||
| 2044 | * \param renderer the renderer which should draw multiple rectangles. | ||
| 2045 | * \param rects a pointer to an array of destination rectangles. | ||
| 2046 | * \param count the number of rectangles. | ||
| 2047 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2048 | * information. | ||
| 2049 | * | ||
| 2050 | * \threadsafety This function should only be called on the main thread. | ||
| 2051 | * | ||
| 2052 | * \since This function is available since SDL 3.2.0. | ||
| 2053 | * | ||
| 2054 | * \sa SDL_RenderRect | ||
| 2055 | */ | ||
| 2056 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count); | ||
| 2057 | |||
| 2058 | /** | ||
| 2059 | * Fill a rectangle on the current rendering target with the drawing color at | ||
| 2060 | * subpixel precision. | ||
| 2061 | * | ||
| 2062 | * \param renderer the renderer which should fill a rectangle. | ||
| 2063 | * \param rect a pointer to the destination rectangle, or NULL for the entire | ||
| 2064 | * rendering target. | ||
| 2065 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2066 | * information. | ||
| 2067 | * | ||
| 2068 | * \threadsafety This function should only be called on the main thread. | ||
| 2069 | * | ||
| 2070 | * \since This function is available since SDL 3.2.0. | ||
| 2071 | * | ||
| 2072 | * \sa SDL_RenderFillRects | ||
| 2073 | */ | ||
| 2074 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect); | ||
| 2075 | |||
| 2076 | /** | ||
| 2077 | * Fill some number of rectangles on the current rendering target with the | ||
| 2078 | * drawing color at subpixel precision. | ||
| 2079 | * | ||
| 2080 | * \param renderer the renderer which should fill multiple rectangles. | ||
| 2081 | * \param rects a pointer to an array of destination rectangles. | ||
| 2082 | * \param count the number of rectangles. | ||
| 2083 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2084 | * information. | ||
| 2085 | * | ||
| 2086 | * \threadsafety This function should only be called on the main thread. | ||
| 2087 | * | ||
| 2088 | * \since This function is available since SDL 3.2.0. | ||
| 2089 | * | ||
| 2090 | * \sa SDL_RenderFillRect | ||
| 2091 | */ | ||
| 2092 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count); | ||
| 2093 | |||
| 2094 | /** | ||
| 2095 | * Copy a portion of the texture to the current rendering target at subpixel | ||
| 2096 | * precision. | ||
| 2097 | * | ||
| 2098 | * \param renderer the renderer which should copy parts of a texture. | ||
| 2099 | * \param texture the source texture. | ||
| 2100 | * \param srcrect a pointer to the source rectangle, or NULL for the entire | ||
| 2101 | * texture. | ||
| 2102 | * \param dstrect a pointer to the destination rectangle, or NULL for the | ||
| 2103 | * entire rendering target. | ||
| 2104 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2105 | * information. | ||
| 2106 | * | ||
| 2107 | * \threadsafety This function should only be called on the main thread. | ||
| 2108 | * | ||
| 2109 | * \since This function is available since SDL 3.2.0. | ||
| 2110 | * | ||
| 2111 | * \sa SDL_RenderTextureRotated | ||
| 2112 | * \sa SDL_RenderTextureTiled | ||
| 2113 | */ | ||
| 2114 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect); | ||
| 2115 | |||
| 2116 | /** | ||
| 2117 | * Copy a portion of the source texture to the current rendering target, with | ||
| 2118 | * rotation and flipping, at subpixel precision. | ||
| 2119 | * | ||
| 2120 | * \param renderer the renderer which should copy parts of a texture. | ||
| 2121 | * \param texture the source texture. | ||
| 2122 | * \param srcrect a pointer to the source rectangle, or NULL for the entire | ||
| 2123 | * texture. | ||
| 2124 | * \param dstrect a pointer to the destination rectangle, or NULL for the | ||
| 2125 | * entire rendering target. | ||
| 2126 | * \param angle an angle in degrees that indicates the rotation that will be | ||
| 2127 | * applied to dstrect, rotating it in a clockwise direction. | ||
| 2128 | * \param center a pointer to a point indicating the point around which | ||
| 2129 | * dstrect will be rotated (if NULL, rotation will be done | ||
| 2130 | * around dstrect.w/2, dstrect.h/2). | ||
| 2131 | * \param flip an SDL_FlipMode value stating which flipping actions should be | ||
| 2132 | * performed on the texture. | ||
| 2133 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2134 | * information. | ||
| 2135 | * | ||
| 2136 | * \threadsafety This function should only be called on the main thread. | ||
| 2137 | * | ||
| 2138 | * \since This function is available since SDL 3.2.0. | ||
| 2139 | * | ||
| 2140 | * \sa SDL_RenderTexture | ||
| 2141 | */ | ||
| 2142 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture, | ||
| 2143 | const SDL_FRect *srcrect, const SDL_FRect *dstrect, | ||
| 2144 | double angle, const SDL_FPoint *center, | ||
| 2145 | SDL_FlipMode flip); | ||
| 2146 | |||
| 2147 | /** | ||
| 2148 | * Copy a portion of the source texture to the current rendering target, with | ||
| 2149 | * affine transform, at subpixel precision. | ||
| 2150 | * | ||
| 2151 | * \param renderer the renderer which should copy parts of a texture. | ||
| 2152 | * \param texture the source texture. | ||
| 2153 | * \param srcrect a pointer to the source rectangle, or NULL for the entire | ||
| 2154 | * texture. | ||
| 2155 | * \param origin a pointer to a point indicating where the top-left corner of | ||
| 2156 | * srcrect should be mapped to, or NULL for the rendering | ||
| 2157 | * target's origin. | ||
| 2158 | * \param right a pointer to a point indicating where the top-right corner of | ||
| 2159 | * srcrect should be mapped to, or NULL for the rendering | ||
| 2160 | * target's top-right corner. | ||
| 2161 | * \param down a pointer to a point indicating where the bottom-left corner of | ||
| 2162 | * srcrect should be mapped to, or NULL for the rendering target's | ||
| 2163 | * bottom-left corner. | ||
| 2164 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2165 | * information. | ||
| 2166 | * | ||
| 2167 | * \threadsafety You may only call this function from the main thread. | ||
| 2168 | * | ||
| 2169 | * \since This function is available since SDL 3.2.0. | ||
| 2170 | * | ||
| 2171 | * \sa SDL_RenderTexture | ||
| 2172 | */ | ||
| 2173 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture, | ||
| 2174 | const SDL_FRect *srcrect, const SDL_FPoint *origin, | ||
| 2175 | const SDL_FPoint *right, const SDL_FPoint *down); | ||
| 2176 | |||
| 2177 | /** | ||
| 2178 | * Tile a portion of the texture to the current rendering target at subpixel | ||
| 2179 | * precision. | ||
| 2180 | * | ||
| 2181 | * The pixels in `srcrect` will be repeated as many times as needed to | ||
| 2182 | * completely fill `dstrect`. | ||
| 2183 | * | ||
| 2184 | * \param renderer the renderer which should copy parts of a texture. | ||
| 2185 | * \param texture the source texture. | ||
| 2186 | * \param srcrect a pointer to the source rectangle, or NULL for the entire | ||
| 2187 | * texture. | ||
| 2188 | * \param scale the scale used to transform srcrect into the destination | ||
| 2189 | * rectangle, e.g. a 32x32 texture with a scale of 2 would fill | ||
| 2190 | * 64x64 tiles. | ||
| 2191 | * \param dstrect a pointer to the destination rectangle, or NULL for the | ||
| 2192 | * entire rendering target. | ||
| 2193 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2194 | * information. | ||
| 2195 | * | ||
| 2196 | * \threadsafety This function should only be called on the main thread. | ||
| 2197 | * | ||
| 2198 | * \since This function is available since SDL 3.2.0. | ||
| 2199 | * | ||
| 2200 | * \sa SDL_RenderTexture | ||
| 2201 | */ | ||
| 2202 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect); | ||
| 2203 | |||
| 2204 | /** | ||
| 2205 | * Perform a scaled copy using the 9-grid algorithm to the current rendering | ||
| 2206 | * target at subpixel precision. | ||
| 2207 | * | ||
| 2208 | * The pixels in the texture are split into a 3x3 grid, using the different | ||
| 2209 | * corner sizes for each corner, and the sides and center making up the | ||
| 2210 | * remaining pixels. The corners are then scaled using `scale` and fit into | ||
| 2211 | * the corners of the destination rectangle. The sides and center are then | ||
| 2212 | * stretched into place to cover the remaining destination rectangle. | ||
| 2213 | * | ||
| 2214 | * \param renderer the renderer which should copy parts of a texture. | ||
| 2215 | * \param texture the source texture. | ||
| 2216 | * \param srcrect the SDL_Rect structure representing the rectangle to be used | ||
| 2217 | * for the 9-grid, or NULL to use the entire texture. | ||
| 2218 | * \param left_width the width, in pixels, of the left corners in `srcrect`. | ||
| 2219 | * \param right_width the width, in pixels, of the right corners in `srcrect`. | ||
| 2220 | * \param top_height the height, in pixels, of the top corners in `srcrect`. | ||
| 2221 | * \param bottom_height the height, in pixels, of the bottom corners in | ||
| 2222 | * `srcrect`. | ||
| 2223 | * \param scale the scale used to transform the corner of `srcrect` into the | ||
| 2224 | * corner of `dstrect`, or 0.0f for an unscaled copy. | ||
| 2225 | * \param dstrect a pointer to the destination rectangle, or NULL for the | ||
| 2226 | * entire rendering target. | ||
| 2227 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2228 | * information. | ||
| 2229 | * | ||
| 2230 | * \threadsafety This function should only be called on the main thread. | ||
| 2231 | * | ||
| 2232 | * \since This function is available since SDL 3.2.0. | ||
| 2233 | * | ||
| 2234 | * \sa SDL_RenderTexture | ||
| 2235 | */ | ||
| 2236 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect); | ||
| 2237 | |||
| 2238 | /** | ||
| 2239 | * Render a list of triangles, optionally using a texture and indices into the | ||
| 2240 | * vertex array Color and alpha modulation is done per vertex | ||
| 2241 | * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). | ||
| 2242 | * | ||
| 2243 | * \param renderer the rendering context. | ||
| 2244 | * \param texture (optional) The SDL texture to use. | ||
| 2245 | * \param vertices vertices. | ||
| 2246 | * \param num_vertices number of vertices. | ||
| 2247 | * \param indices (optional) An array of integer indices into the 'vertices' | ||
| 2248 | * array, if NULL all vertices will be rendered in sequential | ||
| 2249 | * order. | ||
| 2250 | * \param num_indices number of indices. | ||
| 2251 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2252 | * information. | ||
| 2253 | * | ||
| 2254 | * \threadsafety This function should only be called on the main thread. | ||
| 2255 | * | ||
| 2256 | * \since This function is available since SDL 3.2.0. | ||
| 2257 | * | ||
| 2258 | * \sa SDL_RenderGeometryRaw | ||
| 2259 | */ | ||
| 2260 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer, | ||
| 2261 | SDL_Texture *texture, | ||
| 2262 | const SDL_Vertex *vertices, int num_vertices, | ||
| 2263 | const int *indices, int num_indices); | ||
| 2264 | |||
| 2265 | /** | ||
| 2266 | * Render a list of triangles, optionally using a texture and indices into the | ||
| 2267 | * vertex arrays Color and alpha modulation is done per vertex | ||
| 2268 | * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). | ||
| 2269 | * | ||
| 2270 | * \param renderer the rendering context. | ||
| 2271 | * \param texture (optional) The SDL texture to use. | ||
| 2272 | * \param xy vertex positions. | ||
| 2273 | * \param xy_stride byte size to move from one element to the next element. | ||
| 2274 | * \param color vertex colors (as SDL_FColor). | ||
| 2275 | * \param color_stride byte size to move from one element to the next element. | ||
| 2276 | * \param uv vertex normalized texture coordinates. | ||
| 2277 | * \param uv_stride byte size to move from one element to the next element. | ||
| 2278 | * \param num_vertices number of vertices. | ||
| 2279 | * \param indices (optional) An array of indices into the 'vertices' arrays, | ||
| 2280 | * if NULL all vertices will be rendered in sequential order. | ||
| 2281 | * \param num_indices number of indices. | ||
| 2282 | * \param size_indices index size: 1 (byte), 2 (short), 4 (int). | ||
| 2283 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2284 | * information. | ||
| 2285 | * | ||
| 2286 | * \threadsafety This function should only be called on the main thread. | ||
| 2287 | * | ||
| 2288 | * \since This function is available since SDL 3.2.0. | ||
| 2289 | * | ||
| 2290 | * \sa SDL_RenderGeometry | ||
| 2291 | */ | ||
| 2292 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, | ||
| 2293 | SDL_Texture *texture, | ||
| 2294 | const float *xy, int xy_stride, | ||
| 2295 | const SDL_FColor *color, int color_stride, | ||
| 2296 | const float *uv, int uv_stride, | ||
| 2297 | int num_vertices, | ||
| 2298 | const void *indices, int num_indices, int size_indices); | ||
| 2299 | |||
| 2300 | /** | ||
| 2301 | * Read pixels from the current rendering target. | ||
| 2302 | * | ||
| 2303 | * The returned surface contains pixels inside the desired area clipped to the | ||
| 2304 | * current viewport, and should be freed with SDL_DestroySurface(). | ||
| 2305 | * | ||
| 2306 | * Note that this returns the actual pixels on the screen, so if you are using | ||
| 2307 | * logical presentation you should use SDL_GetRenderLogicalPresentationRect() | ||
| 2308 | * to get the area containing your content. | ||
| 2309 | * | ||
| 2310 | * **WARNING**: This is a very slow operation, and should not be used | ||
| 2311 | * frequently. If you're using this on the main rendering target, it should be | ||
| 2312 | * called after rendering and before SDL_RenderPresent(). | ||
| 2313 | * | ||
| 2314 | * \param renderer the rendering context. | ||
| 2315 | * \param rect an SDL_Rect structure representing the area to read, which will | ||
| 2316 | * be clipped to the current viewport, or NULL for the entire | ||
| 2317 | * viewport. | ||
| 2318 | * \returns a new SDL_Surface on success or NULL on failure; call | ||
| 2319 | * SDL_GetError() for more information. | ||
| 2320 | * | ||
| 2321 | * \threadsafety This function should only be called on the main thread. | ||
| 2322 | * | ||
| 2323 | * \since This function is available since SDL 3.2.0. | ||
| 2324 | */ | ||
| 2325 | extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect); | ||
| 2326 | |||
| 2327 | /** | ||
| 2328 | * Update the screen with any rendering performed since the previous call. | ||
| 2329 | * | ||
| 2330 | * SDL's rendering functions operate on a backbuffer; that is, calling a | ||
| 2331 | * rendering function such as SDL_RenderLine() does not directly put a line on | ||
| 2332 | * the screen, but rather updates the backbuffer. As such, you compose your | ||
| 2333 | * entire scene and *present* the composed backbuffer to the screen as a | ||
| 2334 | * complete picture. | ||
| 2335 | * | ||
| 2336 | * Therefore, when using SDL's rendering API, one does all drawing intended | ||
| 2337 | * for the frame, and then calls this function once per frame to present the | ||
| 2338 | * final drawing to the user. | ||
| 2339 | * | ||
| 2340 | * The backbuffer should be considered invalidated after each present; do not | ||
| 2341 | * assume that previous contents will exist between frames. You are strongly | ||
| 2342 | * encouraged to call SDL_RenderClear() to initialize the backbuffer before | ||
| 2343 | * starting each new frame's drawing, even if you plan to overwrite every | ||
| 2344 | * pixel. | ||
| 2345 | * | ||
| 2346 | * Please note, that in case of rendering to a texture - there is **no need** | ||
| 2347 | * to call `SDL_RenderPresent` after drawing needed objects to a texture, and | ||
| 2348 | * should not be done; you are only required to change back the rendering | ||
| 2349 | * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as | ||
| 2350 | * textures by themselves do not have a concept of backbuffers. Calling | ||
| 2351 | * SDL_RenderPresent while rendering to a texture will still update the screen | ||
| 2352 | * with any current drawing that has been done _to the window itself_. | ||
| 2353 | * | ||
| 2354 | * \param renderer the rendering context. | ||
| 2355 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2356 | * information. | ||
| 2357 | * | ||
| 2358 | * \threadsafety This function should only be called on the main thread. | ||
| 2359 | * | ||
| 2360 | * \since This function is available since SDL 3.2.0. | ||
| 2361 | * | ||
| 2362 | * \sa SDL_CreateRenderer | ||
| 2363 | * \sa SDL_RenderClear | ||
| 2364 | * \sa SDL_RenderFillRect | ||
| 2365 | * \sa SDL_RenderFillRects | ||
| 2366 | * \sa SDL_RenderLine | ||
| 2367 | * \sa SDL_RenderLines | ||
| 2368 | * \sa SDL_RenderPoint | ||
| 2369 | * \sa SDL_RenderPoints | ||
| 2370 | * \sa SDL_RenderRect | ||
| 2371 | * \sa SDL_RenderRects | ||
| 2372 | * \sa SDL_SetRenderDrawBlendMode | ||
| 2373 | * \sa SDL_SetRenderDrawColor | ||
| 2374 | */ | ||
| 2375 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer); | ||
| 2376 | |||
| 2377 | /** | ||
| 2378 | * Destroy the specified texture. | ||
| 2379 | * | ||
| 2380 | * Passing NULL or an otherwise invalid texture will set the SDL error message | ||
| 2381 | * to "Invalid texture". | ||
| 2382 | * | ||
| 2383 | * \param texture the texture to destroy. | ||
| 2384 | * | ||
| 2385 | * \threadsafety This function should only be called on the main thread. | ||
| 2386 | * | ||
| 2387 | * \since This function is available since SDL 3.2.0. | ||
| 2388 | * | ||
| 2389 | * \sa SDL_CreateTexture | ||
| 2390 | * \sa SDL_CreateTextureFromSurface | ||
| 2391 | */ | ||
| 2392 | extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture); | ||
| 2393 | |||
| 2394 | /** | ||
| 2395 | * Destroy the rendering context for a window and free all associated | ||
| 2396 | * textures. | ||
| 2397 | * | ||
| 2398 | * This should be called before destroying the associated window. | ||
| 2399 | * | ||
| 2400 | * \param renderer the rendering context. | ||
| 2401 | * | ||
| 2402 | * \threadsafety This function should only be called on the main thread. | ||
| 2403 | * | ||
| 2404 | * \since This function is available since SDL 3.2.0. | ||
| 2405 | * | ||
| 2406 | * \sa SDL_CreateRenderer | ||
| 2407 | */ | ||
| 2408 | extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer); | ||
| 2409 | |||
| 2410 | /** | ||
| 2411 | * Force the rendering context to flush any pending commands and state. | ||
| 2412 | * | ||
| 2413 | * You do not need to (and in fact, shouldn't) call this function unless you | ||
| 2414 | * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in | ||
| 2415 | * addition to using an SDL_Renderer. | ||
| 2416 | * | ||
| 2417 | * This is for a very-specific case: if you are using SDL's render API, and | ||
| 2418 | * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API | ||
| 2419 | * calls. If this applies, you should call this function between calls to | ||
| 2420 | * SDL's render API and the low-level API you're using in cooperation. | ||
| 2421 | * | ||
| 2422 | * In all other cases, you can ignore this function. | ||
| 2423 | * | ||
| 2424 | * This call makes SDL flush any pending rendering work it was queueing up to | ||
| 2425 | * do later in a single batch, and marks any internal cached state as invalid, | ||
| 2426 | * so it'll prepare all its state again later, from scratch. | ||
| 2427 | * | ||
| 2428 | * This means you do not need to save state in your rendering code to protect | ||
| 2429 | * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and | ||
| 2430 | * OpenGL state that can confuse things; you should use your best judgment and | ||
| 2431 | * be prepared to make changes if specific state needs to be protected. | ||
| 2432 | * | ||
| 2433 | * \param renderer the rendering context. | ||
| 2434 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2435 | * information. | ||
| 2436 | * | ||
| 2437 | * \threadsafety This function should only be called on the main thread. | ||
| 2438 | * | ||
| 2439 | * \since This function is available since SDL 3.2.0. | ||
| 2440 | */ | ||
| 2441 | extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer); | ||
| 2442 | |||
| 2443 | /** | ||
| 2444 | * Get the CAMetalLayer associated with the given Metal renderer. | ||
| 2445 | * | ||
| 2446 | * This function returns `void *`, so SDL doesn't have to include Metal's | ||
| 2447 | * headers, but it can be safely cast to a `CAMetalLayer *`. | ||
| 2448 | * | ||
| 2449 | * \param renderer the renderer to query. | ||
| 2450 | * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a | ||
| 2451 | * Metal renderer. | ||
| 2452 | * | ||
| 2453 | * \threadsafety This function should only be called on the main thread. | ||
| 2454 | * | ||
| 2455 | * \since This function is available since SDL 3.2.0. | ||
| 2456 | * | ||
| 2457 | * \sa SDL_GetRenderMetalCommandEncoder | ||
| 2458 | */ | ||
| 2459 | extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer); | ||
| 2460 | |||
| 2461 | /** | ||
| 2462 | * Get the Metal command encoder for the current frame. | ||
| 2463 | * | ||
| 2464 | * This function returns `void *`, so SDL doesn't have to include Metal's | ||
| 2465 | * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`. | ||
| 2466 | * | ||
| 2467 | * This will return NULL if Metal refuses to give SDL a drawable to render to, | ||
| 2468 | * which might happen if the window is hidden/minimized/offscreen. This | ||
| 2469 | * doesn't apply to command encoders for render targets, just the window's | ||
| 2470 | * backbuffer. Check your return values! | ||
| 2471 | * | ||
| 2472 | * \param renderer the renderer to query. | ||
| 2473 | * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the | ||
| 2474 | * renderer isn't a Metal renderer or there was an error. | ||
| 2475 | * | ||
| 2476 | * \threadsafety This function should only be called on the main thread. | ||
| 2477 | * | ||
| 2478 | * \since This function is available since SDL 3.2.0. | ||
| 2479 | * | ||
| 2480 | * \sa SDL_GetRenderMetalLayer | ||
| 2481 | */ | ||
| 2482 | extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer); | ||
| 2483 | |||
| 2484 | |||
| 2485 | /** | ||
| 2486 | * Add a set of synchronization semaphores for the current frame. | ||
| 2487 | * | ||
| 2488 | * The Vulkan renderer will wait for `wait_semaphore` before submitting | ||
| 2489 | * rendering commands and signal `signal_semaphore` after rendering commands | ||
| 2490 | * are complete for this frame. | ||
| 2491 | * | ||
| 2492 | * This should be called each frame that you want semaphore synchronization. | ||
| 2493 | * The Vulkan renderer may have multiple frames in flight on the GPU, so you | ||
| 2494 | * should have multiple semaphores that are used for synchronization. Querying | ||
| 2495 | * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the | ||
| 2496 | * maximum number of semaphores you'll need. | ||
| 2497 | * | ||
| 2498 | * \param renderer the rendering context. | ||
| 2499 | * \param wait_stage_mask the VkPipelineStageFlags for the wait. | ||
| 2500 | * \param wait_semaphore a VkSempahore to wait on before rendering the current | ||
| 2501 | * frame, or 0 if not needed. | ||
| 2502 | * \param signal_semaphore a VkSempahore that SDL will signal when rendering | ||
| 2503 | * for the current frame is complete, or 0 if not | ||
| 2504 | * needed. | ||
| 2505 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2506 | * information. | ||
| 2507 | * | ||
| 2508 | * \threadsafety It is **NOT** safe to call this function from two threads at | ||
| 2509 | * once. | ||
| 2510 | * | ||
| 2511 | * \since This function is available since SDL 3.2.0. | ||
| 2512 | */ | ||
| 2513 | extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore); | ||
| 2514 | |||
| 2515 | /** | ||
| 2516 | * Toggle VSync of the given renderer. | ||
| 2517 | * | ||
| 2518 | * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED. | ||
| 2519 | * | ||
| 2520 | * The `vsync` parameter can be 1 to synchronize present with every vertical | ||
| 2521 | * refresh, 2 to synchronize present with every second vertical refresh, etc., | ||
| 2522 | * SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or | ||
| 2523 | * SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by | ||
| 2524 | * every driver, so you should check the return value to see whether the | ||
| 2525 | * requested setting is supported. | ||
| 2526 | * | ||
| 2527 | * \param renderer the renderer to toggle. | ||
| 2528 | * \param vsync the vertical refresh sync interval. | ||
| 2529 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2530 | * information. | ||
| 2531 | * | ||
| 2532 | * \threadsafety This function should only be called on the main thread. | ||
| 2533 | * | ||
| 2534 | * \since This function is available since SDL 3.2.0. | ||
| 2535 | * | ||
| 2536 | * \sa SDL_GetRenderVSync | ||
| 2537 | */ | ||
| 2538 | extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync); | ||
| 2539 | |||
| 2540 | #define SDL_RENDERER_VSYNC_DISABLED 0 | ||
| 2541 | #define SDL_RENDERER_VSYNC_ADAPTIVE (-1) | ||
| 2542 | |||
| 2543 | /** | ||
| 2544 | * Get VSync of the given renderer. | ||
| 2545 | * | ||
| 2546 | * \param renderer the renderer to toggle. | ||
| 2547 | * \param vsync an int filled with the current vertical refresh sync interval. | ||
| 2548 | * See SDL_SetRenderVSync() for the meaning of the value. | ||
| 2549 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2550 | * information. | ||
| 2551 | * | ||
| 2552 | * \threadsafety This function should only be called on the main thread. | ||
| 2553 | * | ||
| 2554 | * \since This function is available since SDL 3.2.0. | ||
| 2555 | * | ||
| 2556 | * \sa SDL_SetRenderVSync | ||
| 2557 | */ | ||
| 2558 | extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync); | ||
| 2559 | |||
| 2560 | /** | ||
| 2561 | * The size, in pixels, of a single SDL_RenderDebugText() character. | ||
| 2562 | * | ||
| 2563 | * The font is monospaced and square, so this applies to all characters. | ||
| 2564 | * | ||
| 2565 | * \since This macro is available since SDL 3.2.0. | ||
| 2566 | * | ||
| 2567 | * \sa SDL_RenderDebugText | ||
| 2568 | */ | ||
| 2569 | #define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8 | ||
| 2570 | |||
| 2571 | /** | ||
| 2572 | * Draw debug text to an SDL_Renderer. | ||
| 2573 | * | ||
| 2574 | * This function will render a string of text to an SDL_Renderer. Note that | ||
| 2575 | * this is a convenience function for debugging, with severe limitations, and | ||
| 2576 | * not intended to be used for production apps and games. | ||
| 2577 | * | ||
| 2578 | * Among these limitations: | ||
| 2579 | * | ||
| 2580 | * - It accepts UTF-8 strings, but will only renders ASCII characters. | ||
| 2581 | * - It has a single, tiny size (8x8 pixels). One can use logical presentation | ||
| 2582 | * or scaling to adjust it, but it will be blurry. | ||
| 2583 | * - It uses a simple, hardcoded bitmap font. It does not allow different font | ||
| 2584 | * selections and it does not support truetype, for proper scaling. | ||
| 2585 | * - It does no word-wrapping and does not treat newline characters as a line | ||
| 2586 | * break. If the text goes out of the window, it's gone. | ||
| 2587 | * | ||
| 2588 | * For serious text rendering, there are several good options, such as | ||
| 2589 | * SDL_ttf, stb_truetype, or other external libraries. | ||
| 2590 | * | ||
| 2591 | * On first use, this will create an internal texture for rendering glyphs. | ||
| 2592 | * This texture will live until the renderer is destroyed. | ||
| 2593 | * | ||
| 2594 | * The text is drawn in the color specified by SDL_SetRenderDrawColor(). | ||
| 2595 | * | ||
| 2596 | * \param renderer the renderer which should draw a line of text. | ||
| 2597 | * \param x the x coordinate where the top-left corner of the text will draw. | ||
| 2598 | * \param y the y coordinate where the top-left corner of the text will draw. | ||
| 2599 | * \param str the string to render. | ||
| 2600 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2601 | * information. | ||
| 2602 | * | ||
| 2603 | * \threadsafety This function should only be called on the main thread. | ||
| 2604 | * | ||
| 2605 | * \since This function is available since SDL 3.2.0. | ||
| 2606 | * | ||
| 2607 | * \sa SDL_RenderDebugTextFormat | ||
| 2608 | * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE | ||
| 2609 | */ | ||
| 2610 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, float x, float y, const char *str); | ||
| 2611 | |||
| 2612 | /** | ||
| 2613 | * Draw debug text to an SDL_Renderer. | ||
| 2614 | * | ||
| 2615 | * This function will render a printf()-style format string to a renderer. | ||
| 2616 | * Note that this is a convinence function for debugging, with severe | ||
| 2617 | * limitations, and is not intended to be used for production apps and games. | ||
| 2618 | * | ||
| 2619 | * For the full list of limitations and other useful information, see | ||
| 2620 | * SDL_RenderDebugText. | ||
| 2621 | * | ||
| 2622 | * \param renderer the renderer which should draw the text. | ||
| 2623 | * \param x the x coordinate where the top-left corner of the text will draw. | ||
| 2624 | * \param y the y coordinate where the top-left corner of the text will draw. | ||
| 2625 | * \param fmt the format string to draw. | ||
| 2626 | * \param ... additional parameters matching % tokens in the `fmt` string, if | ||
| 2627 | * any. | ||
| 2628 | * \returns true on success or false on failure; call SDL_GetError() for more | ||
| 2629 | * information. | ||
| 2630 | * | ||
| 2631 | * \threadsafety This function should only be called on the main thread. | ||
| 2632 | * | ||
| 2633 | * \since This function is available since SDL 3.2.0. | ||
| 2634 | * | ||
| 2635 | * \sa SDL_RenderDebugText | ||
| 2636 | * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE | ||
| 2637 | */ | ||
| 2638 | extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugTextFormat(SDL_Renderer *renderer, float x, float y, SDL_PRINTF_FORMAT_STRING const char *fmt, ...) SDL_PRINTF_VARARG_FUNC(4); | ||
| 2639 | |||
| 2640 | /* Ends C function definitions when using C++ */ | ||
| 2641 | #ifdef __cplusplus | ||
| 2642 | } | ||
| 2643 | #endif | ||
| 2644 | #include <SDL3/SDL_close_code.h> | ||
| 2645 | |||
| 2646 | #endif /* SDL_render_h_ */ | ||
