Atlas - SDL_render.h

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