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