1 /* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20 */ 21 22 /** 23 * # CategoryRender 24 * 25 * Header file for SDL 2D rendering functions. 26 * 27 * This API supports the following features: 28 * 29 * - single pixel points 30 * - single pixel lines 31 * - filled rectangles 32 * - texture images 33 * 34 * The primitives may be drawn in opaque, blended, or additive modes. 35 * 36 * The texture images may be drawn in opaque, blended, or additive modes. They 37 * can have an additional color tint or alpha modulation applied to them, and 38 * may also be stretched with linear interpolation. 39 * 40 * This API is designed to accelerate simple 2D operations. You may want more 41 * functionality such as polygons and particle effects and in that case you 42 * should use SDL's OpenGL/Direct3D support or one of the many good 3D 43 * engines. 44 * 45 * These functions must be called from the main thread. See this bug for 46 * details: https://github.com/libsdl-org/SDL/issues/986 47 */ 48 49 #ifndef SDL_render_h_ 50 #define SDL_render_h_ 51 52 #include "SDL_stdinc.h" 53 #include "SDL_rect.h" 54 #include "SDL_video.h" 55 56 #include "begin_code.h" 57 /* Set up for C function definitions, even when using C++ */ 58 #ifdef __cplusplus 59 extern "C" { 60 #endif 61 62 /** 63 * Flags used when creating a rendering context 64 */ 65 typedef enum SDL_RendererFlags 66 { 67 SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ 68 SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware 69 acceleration */ 70 SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized 71 with the refresh rate */ 72 SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports 73 rendering to texture */ 74 } SDL_RendererFlags; 75 76 /** 77 * Information on the capabilities of a render driver or context. 78 */ 79 typedef struct SDL_RendererInfo 80 { 81 const char *name; /**< The name of the renderer */ 82 Uint32 flags; /**< Supported SDL_RendererFlags */ 83 Uint32 num_texture_formats; /**< The number of available texture formats */ 84 Uint32 texture_formats[16]; /**< The available texture formats */ 85 int max_texture_width; /**< The maximum texture width */ 86 int max_texture_height; /**< The maximum texture height */ 87 } SDL_RendererInfo; 88 89 /** 90 * Vertex structure 91 */ 92 typedef struct SDL_Vertex 93 { 94 SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */ 95 SDL_Color color; /**< Vertex color */ 96 SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */ 97 } SDL_Vertex; 98 99 /** 100 * The scaling mode for a texture. 101 */ 102 typedef enum SDL_ScaleMode 103 { 104 SDL_ScaleModeNearest, /**< nearest pixel sampling */ 105 SDL_ScaleModeLinear, /**< linear filtering */ 106 SDL_ScaleModeBest /**< anisotropic filtering */ 107 } SDL_ScaleMode; 108 109 /** 110 * The access pattern allowed for a texture. 111 */ 112 typedef enum SDL_TextureAccess 113 { 114 SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ 115 SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */ 116 SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */ 117 } SDL_TextureAccess; 118 119 /** 120 * The texture channel modulation used in SDL_RenderCopy(). 121 */ 122 typedef enum SDL_TextureModulate 123 { 124 SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ 125 SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ 126 SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ 127 } SDL_TextureModulate; 128 129 /** 130 * Flip constants for SDL_RenderCopyEx 131 */ 132 typedef enum SDL_RendererFlip 133 { 134 SDL_FLIP_NONE = 0x00000000, /**< Do not flip */ 135 SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */ 136 SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */ 137 } SDL_RendererFlip; 138 139 /** 140 * A structure representing rendering state 141 */ 142 struct SDL_Renderer; 143 typedef struct SDL_Renderer SDL_Renderer; 144 145 /** 146 * An efficient driver-specific representation of pixel data 147 */ 148 struct SDL_Texture; 149 typedef struct SDL_Texture SDL_Texture; 150 151 /* Function prototypes */ 152 153 /** 154 * Get the number of 2D rendering drivers available for the current display. 155 * 156 * A render driver is a set of code that handles rendering and texture 157 * management on a particular display. Normally there is only one, but some 158 * drivers may have several available with different capabilities. 159 * 160 * There may be none if SDL was compiled without render support. 161 * 162 * \returns a number >= 0 on success or a negative error code on failure; call 163 * SDL_GetError() for more information. 164 * 165 * \since This function is available since SDL 2.0.0. 166 * 167 * \sa SDL_CreateRenderer 168 * \sa SDL_GetRenderDriverInfo 169 */ 170 extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); 171 172 /** 173 * Get info about a specific 2D rendering driver for the current display. 174 * 175 * \param index the index of the driver to query information about. 176 * \param info an SDL_RendererInfo structure to be filled with information on 177 * the rendering driver. 178 * \returns 0 on success or a negative error code on failure; call 179 * SDL_GetError() for more information. 180 * 181 * \since This function is available since SDL 2.0.0. 182 * 183 * \sa SDL_CreateRenderer 184 * \sa SDL_GetNumRenderDrivers 185 */ 186 extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, 187 SDL_RendererInfo * info); 188 189 /** 190 * Create a window and default renderer. 191 * 192 * \param width the width of the window. 193 * \param height the height of the window. 194 * \param window_flags the flags used to create the window (see 195 * SDL_CreateWindow()). 196 * \param window a pointer filled with the window, or NULL on error. 197 * \param renderer a pointer filled with the renderer, or NULL on error. 198 * \returns 0 on success, or -1 on error; call SDL_GetError() for more 199 * information. 200 * 201 * \since This function is available since SDL 2.0.0. 202 * 203 * \sa SDL_CreateRenderer 204 * \sa SDL_CreateWindow 205 */ 206 extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer( 207 int width, int height, Uint32 window_flags, 208 SDL_Window **window, SDL_Renderer **renderer); 209 210 211 /** 212 * Create a 2D rendering context for a window. 213 * 214 * \param window the window where rendering is displayed. 215 * \param index the index of the rendering driver to initialize, or -1 to 216 * initialize the first one supporting the requested flags. 217 * \param flags 0, or one or more SDL_RendererFlags OR'd together. 218 * \returns a valid rendering context or NULL if there was an error; call 219 * SDL_GetError() for more information. 220 * 221 * \since This function is available since SDL 2.0.0. 222 * 223 * \sa SDL_CreateSoftwareRenderer 224 * \sa SDL_DestroyRenderer 225 * \sa SDL_GetNumRenderDrivers 226 * \sa SDL_GetRendererInfo 227 */ 228 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, 229 int index, Uint32 flags); 230 231 /** 232 * Create a 2D software rendering context for a surface. 233 * 234 * Two other API which can be used to create SDL_Renderer: 235 * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_ 236 * create a software renderer, but they are intended to be used with an 237 * SDL_Window as the final destination and not an SDL_Surface. 238 * 239 * \param surface the SDL_Surface structure representing the surface where 240 * rendering is done. 241 * \returns a valid rendering context or NULL if there was an error; call 242 * SDL_GetError() for more information. 243 * 244 * \since This function is available since SDL 2.0.0. 245 * 246 * \sa SDL_CreateRenderer 247 * \sa SDL_CreateWindowAndRenderer 248 * \sa SDL_DestroyRenderer 249 */ 250 extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); 251 252 /** 253 * Get the renderer associated with a window. 254 * 255 * \param window the window to query. 256 * \returns the rendering context on success or NULL on failure; call 257 * SDL_GetError() for more information. 258 * 259 * \since This function is available since SDL 2.0.0. 260 * 261 * \sa SDL_CreateRenderer 262 */ 263 extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); 264 265 /** 266 * Get the window associated with a renderer. 267 * 268 * \param renderer the renderer to query. 269 * \returns the window on success or NULL on failure; call SDL_GetError() for 270 * more information. 271 * 272 * \since This function is available since SDL 2.0.22. 273 */ 274 extern DECLSPEC SDL_Window * SDLCALL SDL_RenderGetWindow(SDL_Renderer *renderer); 275 276 /** 277 * Get information about a rendering context. 278 * 279 * \param renderer the rendering context. 280 * \param info an SDL_RendererInfo structure filled with information about the 281 * current renderer. 282 * \returns 0 on success or a negative error code on failure; call 283 * SDL_GetError() for more information. 284 * 285 * \since This function is available since SDL 2.0.0. 286 * 287 * \sa SDL_CreateRenderer 288 */ 289 extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, 290 SDL_RendererInfo * info); 291 292 /** 293 * Get the output size in pixels of a rendering context. 294 * 295 * Due to high-dpi displays, you might end up with a rendering context that 296 * has more pixels than the window that contains it, so use this instead of 297 * SDL_GetWindowSize() to decide how much drawing area you have. 298 * 299 * \param renderer the rendering context. 300 * \param w an int filled with the width. 301 * \param h an int filled with the height. 302 * \returns 0 on success or a negative error code on failure; call 303 * SDL_GetError() for more information. 304 * 305 * \since This function is available since SDL 2.0.0. 306 * 307 * \sa SDL_GetRenderer 308 */ 309 extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer, 310 int *w, int *h); 311 312 /** 313 * Create a texture for a rendering context. 314 * 315 * You can set the texture scaling method by setting 316 * `SDL_HINT_RENDER_SCALE_QUALITY` before creating the texture. 317 * 318 * \param renderer the rendering context. 319 * \param format one of the enumerated values in SDL_PixelFormatEnum. 320 * \param access one of the enumerated values in SDL_TextureAccess. 321 * \param w the width of the texture in pixels. 322 * \param h the height of the texture in pixels. 323 * \returns a pointer to the created texture or NULL if no rendering context 324 * was active, the format was unsupported, or the width or height 325 * were out of range; call SDL_GetError() for more information. 326 * 327 * \since This function is available since SDL 2.0.0. 328 * 329 * \sa SDL_CreateTextureFromSurface 330 * \sa SDL_DestroyTexture 331 * \sa SDL_QueryTexture 332 * \sa SDL_UpdateTexture 333 */ 334 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, 335 Uint32 format, 336 int access, int w, 337 int h); 338 339 /** 340 * Create a texture from an existing surface. 341 * 342 * The surface is not modified or freed by this function. 343 * 344 * The SDL_TextureAccess hint for the created texture is 345 * `SDL_TEXTUREACCESS_STATIC`. 346 * 347 * The pixel format of the created texture may be different from the pixel 348 * format of the surface. Use SDL_QueryTexture() to query the pixel format of 349 * the texture. 350 * 351 * \param renderer the rendering context. 352 * \param surface the SDL_Surface structure containing pixel data used to fill 353 * the texture. 354 * \returns the created texture or NULL on failure; call SDL_GetError() for 355 * more information. 356 * 357 * \since This function is available since SDL 2.0.0. 358 * 359 * \sa SDL_CreateTexture 360 * \sa SDL_DestroyTexture 361 * \sa SDL_QueryTexture 362 */ 363 extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); 364 365 /** 366 * Query the attributes of a texture. 367 * 368 * \param texture the texture to query. 369 * \param format a pointer filled in with the raw format of the texture; the 370 * actual format may differ, but pixel transfers will use this 371 * format (one of the SDL_PixelFormatEnum values). This argument 372 * can be NULL if you don't need this information. 373 * \param access a pointer filled in with the actual access to the texture 374 * (one of the SDL_TextureAccess values). This argument can be 375 * NULL if you don't need this information. 376 * \param w a pointer filled in with the width of the texture in pixels. This 377 * argument can be NULL if you don't need this information. 378 * \param h a pointer filled in with the height of the texture in pixels. This 379 * argument can be NULL if you don't need this information. 380 * \returns 0 on success or a negative error code on failure; call 381 * SDL_GetError() for more information. 382 * 383 * \since This function is available since SDL 2.0.0. 384 * 385 * \sa SDL_CreateTexture 386 */ 387 extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, 388 Uint32 * format, int *access, 389 int *w, int *h); 390 391 /** 392 * Set an additional color value multiplied into render copy operations. 393 * 394 * When this texture is rendered, during the copy operation each source color 395 * channel is modulated by the appropriate color value according to the 396 * following formula: 397 * 398 * `srcC = srcC * (color / 255)` 399 * 400 * Color modulation is not always supported by the renderer; it will return -1 401 * if color modulation is not supported. 402 * 403 * \param texture the texture to update. 404 * \param r the red color value multiplied into copy operations. 405 * \param g the green color value multiplied into copy operations. 406 * \param b the blue color value multiplied into copy operations. 407 * \returns 0 on success or a negative error code on failure; call 408 * SDL_GetError() for more information. 409 * 410 * \since This function is available since SDL 2.0.0. 411 * 412 * \sa SDL_GetTextureColorMod 413 * \sa SDL_SetTextureAlphaMod 414 */ 415 extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, 416 Uint8 r, Uint8 g, Uint8 b); 417 418 419 /** 420 * Get the additional color value multiplied into render copy operations. 421 * 422 * \param texture the texture to query. 423 * \param r a pointer filled in with the current red color value. 424 * \param g a pointer filled in with the current green color value. 425 * \param b a pointer filled in with the current blue color value. 426 * \returns 0 on success or a negative error code on failure; call 427 * SDL_GetError() for more information. 428 * 429 * \since This function is available since SDL 2.0.0. 430 * 431 * \sa SDL_GetTextureAlphaMod 432 * \sa SDL_SetTextureColorMod 433 */ 434 extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, 435 Uint8 * r, Uint8 * g, 436 Uint8 * b); 437 438 /** 439 * Set an additional alpha value multiplied into render copy operations. 440 * 441 * When this texture is rendered, during the copy operation the source alpha 442 * value is modulated by this alpha value according to the following formula: 443 * 444 * `srcA = srcA * (alpha / 255)` 445 * 446 * Alpha modulation is not always supported by the renderer; it will return -1 447 * if alpha modulation is not supported. 448 * 449 * \param texture the texture to update. 450 * \param alpha the source alpha value multiplied into copy operations. 451 * \returns 0 on success or a negative error code on failure; call 452 * SDL_GetError() for more information. 453 * 454 * \since This function is available since SDL 2.0.0. 455 * 456 * \sa SDL_GetTextureAlphaMod 457 * \sa SDL_SetTextureColorMod 458 */ 459 extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, 460 Uint8 alpha); 461 462 /** 463 * Get the additional alpha value multiplied into render copy operations. 464 * 465 * \param texture the texture to query. 466 * \param alpha a pointer filled in with the current alpha value. 467 * \returns 0 on success or a negative error code on failure; call 468 * SDL_GetError() for more information. 469 * 470 * \since This function is available since SDL 2.0.0. 471 * 472 * \sa SDL_GetTextureColorMod 473 * \sa SDL_SetTextureAlphaMod 474 */ 475 extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, 476 Uint8 * alpha); 477 478 /** 479 * Set the blend mode for a texture, used by SDL_RenderCopy(). 480 * 481 * If the blend mode is not supported, the closest supported mode is chosen 482 * and this function returns -1. 483 * 484 * \param texture the texture to update. 485 * \param blendMode the SDL_BlendMode to use for texture blending. 486 * \returns 0 on success or a negative error code on failure; call 487 * SDL_GetError() for more information. 488 * 489 * \since This function is available since SDL 2.0.0. 490 * 491 * \sa SDL_GetTextureBlendMode 492 * \sa SDL_RenderCopy 493 */ 494 extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, 495 SDL_BlendMode blendMode); 496 497 /** 498 * Get the blend mode used for texture copy operations. 499 * 500 * \param texture the texture to query. 501 * \param blendMode a pointer filled in with the current SDL_BlendMode. 502 * \returns 0 on success or a negative error code on failure; call 503 * SDL_GetError() for more information. 504 * 505 * \since This function is available since SDL 2.0.0. 506 * 507 * \sa SDL_SetTextureBlendMode 508 */ 509 extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, 510 SDL_BlendMode *blendMode); 511 512 /** 513 * Set the scale mode used for texture scale operations. 514 * 515 * If the scale mode is not supported, the closest supported mode is chosen. 516 * 517 * \param texture The texture to update. 518 * \param scaleMode the SDL_ScaleMode to use for texture scaling. 519 * \returns 0 on success, or -1 if the texture is not valid. 520 * 521 * \since This function is available since SDL 2.0.12. 522 * 523 * \sa SDL_GetTextureScaleMode 524 */ 525 extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture, 526 SDL_ScaleMode scaleMode); 527 528 /** 529 * Get the scale mode used for texture scale operations. 530 * 531 * \param texture the texture to query. 532 * \param scaleMode a pointer filled in with the current scale mode. 533 * \return 0 on success, or -1 if the texture is not valid. 534 * 535 * \since This function is available since SDL 2.0.12. 536 * 537 * \sa SDL_SetTextureScaleMode 538 */ 539 extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture, 540 SDL_ScaleMode *scaleMode); 541 542 /** 543 * Associate a user-specified pointer with a texture. 544 * 545 * \param texture the texture to update. 546 * \param userdata the pointer to associate with the texture. 547 * \returns 0 on success, or -1 if the texture is not valid. 548 * 549 * \since This function is available since SDL 2.0.18. 550 * 551 * \sa SDL_GetTextureUserData 552 */ 553 extern DECLSPEC int SDLCALL SDL_SetTextureUserData(SDL_Texture * texture, 554 void *userdata); 555 556 /** 557 * Get the user-specified pointer associated with a texture 558 * 559 * \param texture the texture to query. 560 * \return the pointer associated with the texture, or NULL if the texture is 561 * not valid. 562 * 563 * \since This function is available since SDL 2.0.18. 564 * 565 * \sa SDL_SetTextureUserData 566 */ 567 extern DECLSPEC void * SDLCALL SDL_GetTextureUserData(SDL_Texture * texture); 568 569 /** 570 * Update the given texture rectangle with new pixel data. 571 * 572 * The pixel data must be in the pixel format of the texture. Use 573 * SDL_QueryTexture() to query the pixel format of the texture. 574 * 575 * This is a fairly slow function, intended for use with static textures that 576 * do not change often. 577 * 578 * If the texture is intended to be updated often, it is preferred to create 579 * the texture as streaming and use the locking functions referenced below. 580 * While this function will work with streaming textures, for optimization 581 * reasons you may not get the pixels back if you lock the texture afterward. 582 * 583 * \param texture the texture to update. 584 * \param rect an SDL_Rect structure representing the area to update, or NULL 585 * to update the entire texture. 586 * \param pixels the raw pixel data in the format of the texture. 587 * \param pitch the number of bytes in a row of pixel data, including padding 588 * between lines. 589 * \returns 0 on success or a negative error code on failure; call 590 * SDL_GetError() for more information. 591 * 592 * \since This function is available since SDL 2.0.0. 593 * 594 * \sa SDL_CreateTexture 595 * \sa SDL_LockTexture 596 * \sa SDL_UnlockTexture 597 */ 598 extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, 599 const SDL_Rect * rect, 600 const void *pixels, int pitch); 601 602 /** 603 * Update a rectangle within a planar YV12 or IYUV texture with new pixel 604 * data. 605 * 606 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous 607 * block of Y and U/V planes in the proper order, but this function is 608 * available if your pixel data is not contiguous. 609 * 610 * \param texture the texture to update. 611 * \param rect a pointer to the rectangle of pixels to update, or NULL to 612 * update the entire texture. 613 * \param Yplane the raw pixel data for the Y plane. 614 * \param Ypitch the number of bytes between rows of pixel data for the Y 615 * plane. 616 * \param Uplane the raw pixel data for the U plane. 617 * \param Upitch the number of bytes between rows of pixel data for the U 618 * plane. 619 * \param Vplane the raw pixel data for the V plane. 620 * \param Vpitch the number of bytes between rows of pixel data for the V 621 * plane. 622 * \returns 0 on success or -1 if the texture is not valid; call 623 * SDL_GetError() for more information. 624 * 625 * \since This function is available since SDL 2.0.1. 626 * 627 * \sa SDL_UpdateTexture 628 */ 629 extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture, 630 const SDL_Rect * rect, 631 const Uint8 *Yplane, int Ypitch, 632 const Uint8 *Uplane, int Upitch, 633 const Uint8 *Vplane, int Vpitch); 634 635 /** 636 * Update a rectangle within a planar NV12 or NV21 texture with new pixels. 637 * 638 * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous 639 * block of NV12/21 planes in the proper order, but this function is available 640 * if your pixel data is not contiguous. 641 * 642 * \param texture the texture to update. 643 * \param rect a pointer to the rectangle of pixels to update, or NULL to 644 * update the entire texture. 645 * \param Yplane the raw pixel data for the Y plane. 646 * \param Ypitch the number of bytes between rows of pixel data for the Y 647 * plane. 648 * \param UVplane the raw pixel data for the UV plane. 649 * \param UVpitch the number of bytes between rows of pixel data for the UV 650 * plane. 651 * \return 0 on success, or -1 if the texture is not valid. 652 * 653 * \since This function is available since SDL 2.0.16. 654 */ 655 extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture, 656 const SDL_Rect * rect, 657 const Uint8 *Yplane, int Ypitch, 658 const Uint8 *UVplane, int UVpitch); 659 660 /** 661 * Lock a portion of the texture for **write-only** pixel access. 662 * 663 * As an optimization, the pixels made available for editing don't necessarily 664 * contain the old texture data. This is a write-only operation, and if you 665 * need to keep a copy of the texture data you should do that at the 666 * application level. 667 * 668 * You must use SDL_UnlockTexture() to unlock the pixels and apply any 669 * changes. 670 * 671 * \param texture the texture to lock for access, which was created with 672 * `SDL_TEXTUREACCESS_STREAMING`. 673 * \param rect an SDL_Rect structure representing the area to lock for access; 674 * NULL to lock the entire texture. 675 * \param pixels this is filled in with a pointer to the locked pixels, 676 * appropriately offset by the locked area. 677 * \param pitch this is filled in with the pitch of the locked pixels; the 678 * pitch is the length of one row in bytes. 679 * \returns 0 on success or a negative error code if the texture is not valid 680 * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call 681 * SDL_GetError() for more information. 682 * 683 * \since This function is available since SDL 2.0.0. 684 * 685 * \sa SDL_UnlockTexture 686 */ 687 extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, 688 const SDL_Rect * rect, 689 void **pixels, int *pitch); 690 691 /** 692 * Lock a portion of the texture for **write-only** pixel access, and expose 693 * it as a SDL surface. 694 * 695 * Besides providing an SDL_Surface instead of raw pixel data, this function 696 * operates like SDL_LockTexture. 697 * 698 * As an optimization, the pixels made available for editing don't necessarily 699 * contain the old texture data. This is a write-only operation, and if you 700 * need to keep a copy of the texture data you should do that at the 701 * application level. 702 * 703 * You must use SDL_UnlockTexture() to unlock the pixels and apply any 704 * changes. 705 * 706 * The returned surface is freed internally after calling SDL_UnlockTexture() 707 * or SDL_DestroyTexture(). The caller should not free it. 708 * 709 * \param texture the texture to lock for access, which was created with 710 * `SDL_TEXTUREACCESS_STREAMING`. 711 * \param rect a pointer to the rectangle to lock for access. If the rect is 712 * NULL, the entire texture will be locked. 713 * \param surface this is filled in with an SDL surface representing the 714 * locked area. 715 * \returns 0 on success, or -1 if the texture is not valid or was not created 716 * with `SDL_TEXTUREACCESS_STREAMING`. 717 * 718 * \since This function is available since SDL 2.0.12. 719 * 720 * \sa SDL_LockTexture 721 * \sa SDL_UnlockTexture 722 */ 723 extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, 724 const SDL_Rect *rect, 725 SDL_Surface **surface); 726 727 /** 728 * Unlock a texture, uploading the changes to video memory, if needed. 729 * 730 * **Warning**: Please note that SDL_LockTexture() is intended to be 731 * write-only; it will not guarantee the previous contents of the texture will 732 * be provided. You must fully initialize any area of a texture that you lock 733 * before unlocking it, as the pixels might otherwise be uninitialized memory. 734 * 735 * Which is to say: locking and immediately unlocking a texture can result in 736 * corrupted textures, depending on the renderer in use. 737 * 738 * \param texture a texture locked by SDL_LockTexture(). 739 * 740 * \since This function is available since SDL 2.0.0. 741 * 742 * \sa SDL_LockTexture 743 */ 744 extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); 745 746 /** 747 * Determine whether a renderer supports the use of render targets. 748 * 749 * \param renderer the renderer that will be checked. 750 * \returns SDL_TRUE if supported or SDL_FALSE if not. 751 * 752 * \since This function is available since SDL 2.0.0. 753 * 754 * \sa SDL_SetRenderTarget 755 */ 756 extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer); 757 758 /** 759 * Set a texture as the current rendering target. 760 * 761 * Before using this function, you should check the 762 * `SDL_RENDERER_TARGETTEXTURE` bit in the flags of SDL_RendererInfo to see if 763 * render targets are supported. 764 * 765 * The default render target is the window for which the renderer was created. 766 * To stop rendering to a texture and render to the window again, call this 767 * function with a NULL `texture`. This will reset the renderer's viewport, 768 * clipping rectangle, and scaling settings to the state they were in before 769 * setting a non-NULL `texture` target, losing any changes made in the 770 * meantime. 771 * 772 * \param renderer the rendering context. 773 * \param texture the targeted texture, which must be created with the 774 * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the 775 * window instead of a texture. 776 * \returns 0 on success or a negative error code on failure; call 777 * SDL_GetError() for more information. 778 * 779 * \since This function is available since SDL 2.0.0. 780 * 781 * \sa SDL_GetRenderTarget 782 */ 783 extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, 784 SDL_Texture *texture); 785 786 /** 787 * Get the current render target. 788 * 789 * The default render target is the window for which the renderer was created, 790 * and is reported as NULL here. 791 * 792 * \param renderer the rendering context. 793 * \returns the current render target or NULL for the default render target. 794 * 795 * \since This function is available since SDL 2.0.0. 796 * 797 * \sa SDL_SetRenderTarget 798 */ 799 extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer); 800 801 /** 802 * Set a device independent resolution for rendering. 803 * 804 * This function uses the viewport and scaling functionality to allow a fixed 805 * logical resolution for rendering, regardless of the actual output 806 * resolution. If the actual output resolution doesn't have the same aspect 807 * ratio the output rendering will be centered within the output display. 808 * 809 * If the output display is a window, mouse and touch events in the window 810 * will be filtered and scaled so they seem to arrive within the logical 811 * resolution. The SDL_HINT_MOUSE_RELATIVE_SCALING hint controls whether 812 * relative motion events are also scaled. 813 * 814 * If this function results in scaling or subpixel drawing by the rendering 815 * backend, it will be handled using the appropriate quality hints. 816 * 817 * \param renderer the renderer for which resolution should be set. 818 * \param w the width of the logical resolution. 819 * \param h the height of the logical resolution. 820 * \returns 0 on success or a negative error code on failure; call 821 * SDL_GetError() for more information. 822 * 823 * \since This function is available since SDL 2.0.0. 824 * 825 * \sa SDL_RenderGetLogicalSize 826 */ 827 extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h); 828 829 /** 830 * Get device independent resolution for rendering. 831 * 832 * When using the main rendering target (eg no target texture is set): this 833 * may return 0 for `w` and `h` if the SDL_Renderer has never had its logical 834 * size set by SDL_RenderSetLogicalSize(). Otherwise it returns the logical 835 * width and height. 836 * 837 * When using a target texture: Never return 0 for `w` and `h` at first. Then 838 * it returns the logical width and height that are set. 839 * 840 * \param renderer a rendering context. 841 * \param w an int to be filled with the width. 842 * \param h an int to be filled with the height. 843 * 844 * \since This function is available since SDL 2.0.0. 845 * 846 * \sa SDL_RenderSetLogicalSize 847 */ 848 extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h); 849 850 /** 851 * Set whether to force integer scales for resolution-independent rendering. 852 * 853 * This function restricts the logical viewport to integer values - that is, 854 * when a resolution is between two multiples of a logical size, the viewport 855 * size is rounded down to the lower multiple. 856 * 857 * \param renderer the renderer for which integer scaling should be set. 858 * \param enable enable or disable the integer scaling for rendering. 859 * \returns 0 on success or a negative error code on failure; call 860 * SDL_GetError() for more information. 861 * 862 * \since This function is available since SDL 2.0.5. 863 * 864 * \sa SDL_RenderGetIntegerScale 865 * \sa SDL_RenderSetLogicalSize 866 */ 867 extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer, 868 SDL_bool enable); 869 870 /** 871 * Get whether integer scales are forced for resolution-independent rendering. 872 * 873 * \param renderer the renderer from which integer scaling should be queried. 874 * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on 875 * failure; call SDL_GetError() for more information. 876 * 877 * \since This function is available since SDL 2.0.5. 878 * 879 * \sa SDL_RenderSetIntegerScale 880 */ 881 extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer); 882 883 /** 884 * Set the drawing area for rendering on the current target. 885 * 886 * When the window is resized, the viewport is reset to fill the entire new 887 * window size. 888 * 889 * \param renderer the rendering context. 890 * \param rect the SDL_Rect structure representing the drawing area, or NULL 891 * to set the viewport to the entire target. 892 * \returns 0 on success or a negative error code on failure; call 893 * SDL_GetError() for more information. 894 * 895 * \since This function is available since SDL 2.0.0. 896 * 897 * \sa SDL_RenderGetViewport 898 */ 899 extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, 900 const SDL_Rect * rect); 901 902 /** 903 * Get the drawing area for the current target. 904 * 905 * \param renderer the rendering context. 906 * \param rect an SDL_Rect structure filled in with the current drawing area. 907 * 908 * \since This function is available since SDL 2.0.0. 909 * 910 * \sa SDL_RenderSetViewport 911 */ 912 extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, 913 SDL_Rect * rect); 914 915 /** 916 * Set the clip rectangle for rendering on the specified target. 917 * 918 * \param renderer the rendering context for which clip rectangle should be 919 * set. 920 * \param rect an SDL_Rect structure representing the clip area, relative to 921 * the viewport, or NULL to disable clipping. 922 * \returns 0 on success or a negative error code on failure; call 923 * SDL_GetError() for more information. 924 * 925 * \since This function is available since SDL 2.0.0. 926 * 927 * \sa SDL_RenderGetClipRect 928 * \sa SDL_RenderIsClipEnabled 929 */ 930 extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer, 931 const SDL_Rect * rect); 932 933 /** 934 * Get the clip rectangle for the current target. 935 * 936 * \param renderer the rendering context from which clip rectangle should be 937 * queried. 938 * \param rect an SDL_Rect structure filled in with the current clipping area 939 * or an empty rectangle if clipping is disabled. 940 * 941 * \since This function is available since SDL 2.0.0. 942 * 943 * \sa SDL_RenderIsClipEnabled 944 * \sa SDL_RenderSetClipRect 945 */ 946 extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer, 947 SDL_Rect * rect); 948 949 /** 950 * Get whether clipping is enabled on the given renderer. 951 * 952 * \param renderer the renderer from which clip state should be queried. 953 * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call 954 * SDL_GetError() for more information. 955 * 956 * \since This function is available since SDL 2.0.4. 957 * 958 * \sa SDL_RenderGetClipRect 959 * \sa SDL_RenderSetClipRect 960 */ 961 extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer); 962 963 964 /** 965 * Set the drawing scale for rendering on the current target. 966 * 967 * The drawing coordinates are scaled by the x/y scaling factors before they 968 * are used by the renderer. This allows resolution independent drawing with a 969 * single coordinate system. 970 * 971 * If this results in scaling or subpixel drawing by the rendering backend, it 972 * will be handled using the appropriate quality hints. For best results use 973 * integer scaling factors. 974 * 975 * \param renderer a rendering context. 976 * \param scaleX the horizontal scaling factor. 977 * \param scaleY the vertical scaling factor. 978 * \returns 0 on success or a negative error code on failure; call 979 * SDL_GetError() for more information. 980 * 981 * \since This function is available since SDL 2.0.0. 982 * 983 * \sa SDL_RenderGetScale 984 * \sa SDL_RenderSetLogicalSize 985 */ 986 extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer, 987 float scaleX, float scaleY); 988 989 /** 990 * Get the drawing scale for the current target. 991 * 992 * \param renderer the renderer from which drawing scale should be queried. 993 * \param scaleX a pointer filled in with the horizontal scaling factor. 994 * \param scaleY a pointer filled in with the vertical scaling factor. 995 * 996 * \since This function is available since SDL 2.0.0. 997 * 998 * \sa SDL_RenderSetScale 999 */ 1000 extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer, 1001 float *scaleX, float *scaleY); 1002 1003 /** 1004 * Get logical coordinates of point in renderer when given real coordinates of 1005 * point in window. 1006 * 1007 * Logical coordinates will differ from real coordinates when render is scaled 1008 * and logical renderer size set 1009 * 1010 * \param renderer the renderer from which the logical coordinates should be 1011 * calculated. 1012 * \param windowX the real X coordinate in the window. 1013 * \param windowY the real Y coordinate in the window. 1014 * \param logicalX the pointer filled with the logical x coordinate. 1015 * \param logicalY the pointer filled with the logical y coordinate. 1016 * 1017 * \since This function is available since SDL 2.0.18. 1018 * 1019 * \sa SDL_RenderGetScale 1020 * \sa SDL_RenderSetScale 1021 * \sa SDL_RenderGetLogicalSize 1022 * \sa SDL_RenderSetLogicalSize 1023 */ 1024 extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer, 1025 int windowX, int windowY, 1026 float *logicalX, float *logicalY); 1027 1028 1029 /** 1030 * Get real coordinates of point in window when given logical coordinates of 1031 * point in renderer. 1032 * 1033 * Logical coordinates will differ from real coordinates when render is scaled 1034 * and logical renderer size set 1035 * 1036 * \param renderer the renderer from which the window coordinates should be 1037 * calculated. 1038 * \param logicalX the logical x coordinate. 1039 * \param logicalY the logical y coordinate. 1040 * \param windowX the pointer filled with the real X coordinate in the window. 1041 * \param windowY the pointer filled with the real Y coordinate in the window. 1042 * 1043 * \since This function is available since SDL 2.0.18. 1044 * 1045 * \sa SDL_RenderGetScale 1046 * \sa SDL_RenderSetScale 1047 * \sa SDL_RenderGetLogicalSize 1048 * \sa SDL_RenderSetLogicalSize 1049 */ 1050 extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer, 1051 float logicalX, float logicalY, 1052 int *windowX, int *windowY); 1053 1054 /** 1055 * Set the color used for drawing operations (Rect, Line and Clear). 1056 * 1057 * Set the color for drawing or filling rectangles, lines, and points, and for 1058 * SDL_RenderClear(). 1059 * 1060 * \param renderer the rendering context. 1061 * \param r the red value used to draw on the rendering target. 1062 * \param g the green value used to draw on the rendering target. 1063 * \param b the blue value used to draw on the rendering target. 1064 * \param a the alpha value used to draw on the rendering target; usually 1065 * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to 1066 * specify how the alpha channel is used. 1067 * \returns 0 on success or a negative error code on failure; call 1068 * SDL_GetError() for more information. 1069 * 1070 * \since This function is available since SDL 2.0.0. 1071 * 1072 * \sa SDL_GetRenderDrawColor 1073 * \sa SDL_RenderClear 1074 * \sa SDL_RenderDrawLine 1075 * \sa SDL_RenderDrawLines 1076 * \sa SDL_RenderDrawPoint 1077 * \sa SDL_RenderDrawPoints 1078 * \sa SDL_RenderDrawRect 1079 * \sa SDL_RenderDrawRects 1080 * \sa SDL_RenderFillRect 1081 * \sa SDL_RenderFillRects 1082 */ 1083 extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer, 1084 Uint8 r, Uint8 g, Uint8 b, 1085 Uint8 a); 1086 1087 /** 1088 * Get the color used for drawing operations (Rect, Line and Clear). 1089 * 1090 * \param renderer the rendering context. 1091 * \param r a pointer filled in with the red value used to draw on the 1092 * rendering target. 1093 * \param g a pointer filled in with the green value used to draw on the 1094 * rendering target. 1095 * \param b a pointer filled in with the blue value used to draw on the 1096 * rendering target. 1097 * \param a a pointer filled in with the alpha value used to draw on the 1098 * rendering target; usually `SDL_ALPHA_OPAQUE` (255). 1099 * \returns 0 on success or a negative error code on failure; call 1100 * SDL_GetError() for more information. 1101 * 1102 * \since This function is available since SDL 2.0.0. 1103 * 1104 * \sa SDL_SetRenderDrawColor 1105 */ 1106 extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer, 1107 Uint8 * r, Uint8 * g, Uint8 * b, 1108 Uint8 * a); 1109 1110 /** 1111 * Set the blend mode used for drawing operations (Fill and Line). 1112 * 1113 * If the blend mode is not supported, the closest supported mode is chosen. 1114 * 1115 * \param renderer the rendering context. 1116 * \param blendMode the SDL_BlendMode to use for blending. 1117 * \returns 0 on success or a negative error code on failure; call 1118 * SDL_GetError() for more information. 1119 * 1120 * \since This function is available since SDL 2.0.0. 1121 * 1122 * \sa SDL_GetRenderDrawBlendMode 1123 * \sa SDL_RenderDrawLine 1124 * \sa SDL_RenderDrawLines 1125 * \sa SDL_RenderDrawPoint 1126 * \sa SDL_RenderDrawPoints 1127 * \sa SDL_RenderDrawRect 1128 * \sa SDL_RenderDrawRects 1129 * \sa SDL_RenderFillRect 1130 * \sa SDL_RenderFillRects 1131 */ 1132 extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, 1133 SDL_BlendMode blendMode); 1134 1135 /** 1136 * Get the blend mode used for drawing operations. 1137 * 1138 * \param renderer the rendering context. 1139 * \param blendMode a pointer filled in with the current SDL_BlendMode. 1140 * \returns 0 on success or a negative error code on failure; call 1141 * SDL_GetError() for more information. 1142 * 1143 * \since This function is available since SDL 2.0.0. 1144 * 1145 * \sa SDL_SetRenderDrawBlendMode 1146 */ 1147 extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, 1148 SDL_BlendMode *blendMode); 1149 1150 /** 1151 * Clear the current rendering target with the drawing color. 1152 * 1153 * This function clears the entire rendering target, ignoring the viewport and 1154 * the clip rectangle. 1155 * 1156 * \param renderer the rendering context. 1157 * \returns 0 on success or a negative error code on failure; call 1158 * SDL_GetError() for more information. 1159 * 1160 * \since This function is available since SDL 2.0.0. 1161 * 1162 * \sa SDL_SetRenderDrawColor 1163 */ 1164 extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); 1165 1166 /** 1167 * Draw a point on the current rendering target. 1168 * 1169 * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple, 1170 * use SDL_RenderDrawPoints() instead. 1171 * 1172 * \param renderer the rendering context. 1173 * \param x the x coordinate of the point. 1174 * \param y the y coordinate of the point. 1175 * \returns 0 on success or a negative error code on failure; call 1176 * SDL_GetError() for more information. 1177 * 1178 * \since This function is available since SDL 2.0.0. 1179 * 1180 * \sa SDL_RenderDrawLine 1181 * \sa SDL_RenderDrawLines 1182 * \sa SDL_RenderDrawPoints 1183 * \sa SDL_RenderDrawRect 1184 * \sa SDL_RenderDrawRects 1185 * \sa SDL_RenderFillRect 1186 * \sa SDL_RenderFillRects 1187 * \sa SDL_RenderPresent 1188 * \sa SDL_SetRenderDrawBlendMode 1189 * \sa SDL_SetRenderDrawColor 1190 */ 1191 extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, 1192 int x, int y); 1193 1194 /** 1195 * Draw multiple points on the current rendering target. 1196 * 1197 * \param renderer the rendering context. 1198 * \param points an array of SDL_Point structures that represent the points to 1199 * draw. 1200 * \param count the number of points to draw. 1201 * \returns 0 on success or a negative error code on failure; call 1202 * SDL_GetError() for more information. 1203 * 1204 * \since This function is available since SDL 2.0.0. 1205 * 1206 * \sa SDL_RenderDrawLine 1207 * \sa SDL_RenderDrawLines 1208 * \sa SDL_RenderDrawPoint 1209 * \sa SDL_RenderDrawRect 1210 * \sa SDL_RenderDrawRects 1211 * \sa SDL_RenderFillRect 1212 * \sa SDL_RenderFillRects 1213 * \sa SDL_RenderPresent 1214 * \sa SDL_SetRenderDrawBlendMode 1215 * \sa SDL_SetRenderDrawColor 1216 */ 1217 extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, 1218 const SDL_Point * points, 1219 int count); 1220 1221 /** 1222 * Draw a line on the current rendering target. 1223 * 1224 * SDL_RenderDrawLine() draws the line to include both end points. If you want 1225 * to draw multiple, connecting lines use SDL_RenderDrawLines() instead. 1226 * 1227 * \param renderer the rendering context. 1228 * \param x1 the x coordinate of the start point. 1229 * \param y1 the y coordinate of the start point. 1230 * \param x2 the x coordinate of the end point. 1231 * \param y2 the y coordinate of the end point. 1232 * \returns 0 on success or a negative error code on failure; call 1233 * SDL_GetError() for more information. 1234 * 1235 * \since This function is available since SDL 2.0.0. 1236 * 1237 * \sa SDL_RenderDrawLines 1238 * \sa SDL_RenderDrawPoint 1239 * \sa SDL_RenderDrawPoints 1240 * \sa SDL_RenderDrawRect 1241 * \sa SDL_RenderDrawRects 1242 * \sa SDL_RenderFillRect 1243 * \sa SDL_RenderFillRects 1244 * \sa SDL_RenderPresent 1245 * \sa SDL_SetRenderDrawBlendMode 1246 * \sa SDL_SetRenderDrawColor 1247 */ 1248 extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, 1249 int x1, int y1, int x2, int y2); 1250 1251 /** 1252 * Draw a series of connected lines on the current rendering target. 1253 * 1254 * \param renderer the rendering context. 1255 * \param points an array of SDL_Point structures representing points along 1256 * the lines. 1257 * \param count the number of points, drawing count-1 lines. 1258 * \returns 0 on success or a negative error code on failure; call 1259 * SDL_GetError() for more information. 1260 * 1261 * \since This function is available since SDL 2.0.0. 1262 * 1263 * \sa SDL_RenderDrawLine 1264 * \sa SDL_RenderDrawPoint 1265 * \sa SDL_RenderDrawPoints 1266 * \sa SDL_RenderDrawRect 1267 * \sa SDL_RenderDrawRects 1268 * \sa SDL_RenderFillRect 1269 * \sa SDL_RenderFillRects 1270 * \sa SDL_RenderPresent 1271 * \sa SDL_SetRenderDrawBlendMode 1272 * \sa SDL_SetRenderDrawColor 1273 */ 1274 extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, 1275 const SDL_Point * points, 1276 int count); 1277 1278 /** 1279 * Draw a rectangle on the current rendering target. 1280 * 1281 * \param renderer the rendering context. 1282 * \param rect an SDL_Rect structure representing the rectangle to draw, or 1283 * NULL to outline the entire rendering target. 1284 * \returns 0 on success or a negative error code on failure; call 1285 * SDL_GetError() for more information. 1286 * 1287 * \since This function is available since SDL 2.0.0. 1288 * 1289 * \sa SDL_RenderDrawLine 1290 * \sa SDL_RenderDrawLines 1291 * \sa SDL_RenderDrawPoint 1292 * \sa SDL_RenderDrawPoints 1293 * \sa SDL_RenderDrawRects 1294 * \sa SDL_RenderFillRect 1295 * \sa SDL_RenderFillRects 1296 * \sa SDL_RenderPresent 1297 * \sa SDL_SetRenderDrawBlendMode 1298 * \sa SDL_SetRenderDrawColor 1299 */ 1300 extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, 1301 const SDL_Rect * rect); 1302 1303 /** 1304 * Draw some number of rectangles on the current rendering target. 1305 * 1306 * \param renderer the rendering context. 1307 * \param rects an array of SDL_Rect structures representing the rectangles to 1308 * be drawn. 1309 * \param count the number of rectangles. 1310 * \returns 0 on success or a negative error code on failure; call 1311 * SDL_GetError() for more information. 1312 * 1313 * \since This function is available since SDL 2.0.0. 1314 * 1315 * \sa SDL_RenderDrawLine 1316 * \sa SDL_RenderDrawLines 1317 * \sa SDL_RenderDrawPoint 1318 * \sa SDL_RenderDrawPoints 1319 * \sa SDL_RenderDrawRect 1320 * \sa SDL_RenderFillRect 1321 * \sa SDL_RenderFillRects 1322 * \sa SDL_RenderPresent 1323 * \sa SDL_SetRenderDrawBlendMode 1324 * \sa SDL_SetRenderDrawColor 1325 */ 1326 extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, 1327 const SDL_Rect * rects, 1328 int count); 1329 1330 /** 1331 * Fill a rectangle on the current rendering target with the drawing color. 1332 * 1333 * The current drawing color is set by SDL_SetRenderDrawColor(), and the 1334 * color's alpha value is ignored unless blending is enabled with the 1335 * appropriate call to SDL_SetRenderDrawBlendMode(). 1336 * 1337 * \param renderer the rendering context. 1338 * \param rect the SDL_Rect structure representing the rectangle to fill, or 1339 * NULL for the entire rendering target. 1340 * \returns 0 on success or a negative error code on failure; call 1341 * SDL_GetError() for more information. 1342 * 1343 * \since This function is available since SDL 2.0.0. 1344 * 1345 * \sa SDL_RenderDrawLine 1346 * \sa SDL_RenderDrawLines 1347 * \sa SDL_RenderDrawPoint 1348 * \sa SDL_RenderDrawPoints 1349 * \sa SDL_RenderDrawRect 1350 * \sa SDL_RenderDrawRects 1351 * \sa SDL_RenderFillRects 1352 * \sa SDL_RenderPresent 1353 * \sa SDL_SetRenderDrawBlendMode 1354 * \sa SDL_SetRenderDrawColor 1355 */ 1356 extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, 1357 const SDL_Rect * rect); 1358 1359 /** 1360 * Fill some number of rectangles on the current rendering target with the 1361 * drawing color. 1362 * 1363 * \param renderer the rendering context. 1364 * \param rects an array of SDL_Rect structures representing the rectangles to 1365 * be filled. 1366 * \param count the number of rectangles. 1367 * \returns 0 on success or a negative error code on failure; call 1368 * SDL_GetError() for more information. 1369 * 1370 * \since This function is available since SDL 2.0.0. 1371 * 1372 * \sa SDL_RenderDrawLine 1373 * \sa SDL_RenderDrawLines 1374 * \sa SDL_RenderDrawPoint 1375 * \sa SDL_RenderDrawPoints 1376 * \sa SDL_RenderDrawRect 1377 * \sa SDL_RenderDrawRects 1378 * \sa SDL_RenderFillRect 1379 * \sa SDL_RenderPresent 1380 */ 1381 extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, 1382 const SDL_Rect * rects, 1383 int count); 1384 1385 /** 1386 * Copy a portion of the texture to the current rendering target. 1387 * 1388 * The texture is blended with the destination based on its blend mode set 1389 * with SDL_SetTextureBlendMode(). 1390 * 1391 * The texture color is affected based on its color modulation set by 1392 * SDL_SetTextureColorMod(). 1393 * 1394 * The texture alpha is affected based on its alpha modulation set by 1395 * SDL_SetTextureAlphaMod(). 1396 * 1397 * \param renderer the rendering context. 1398 * \param texture the source texture. 1399 * \param srcrect the source SDL_Rect structure or NULL for the entire 1400 * texture. 1401 * \param dstrect the destination SDL_Rect structure or NULL for the entire 1402 * rendering target; the texture will be stretched to fill the 1403 * given rectangle. 1404 * \returns 0 on success or a negative error code on failure; call 1405 * SDL_GetError() for more information. 1406 * 1407 * \since This function is available since SDL 2.0.0. 1408 * 1409 * \sa SDL_RenderCopyEx 1410 * \sa SDL_SetTextureAlphaMod 1411 * \sa SDL_SetTextureBlendMode 1412 * \sa SDL_SetTextureColorMod 1413 */ 1414 extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, 1415 SDL_Texture * texture, 1416 const SDL_Rect * srcrect, 1417 const SDL_Rect * dstrect); 1418 1419 /** 1420 * Copy a portion of the texture to the current rendering, with optional 1421 * rotation and flipping. 1422 * 1423 * Copy a portion of the texture to the current rendering target, optionally 1424 * rotating it by angle around the given center and also flipping it 1425 * top-bottom and/or left-right. 1426 * 1427 * The texture is blended with the destination based on its blend mode set 1428 * with SDL_SetTextureBlendMode(). 1429 * 1430 * The texture color is affected based on its color modulation set by 1431 * SDL_SetTextureColorMod(). 1432 * 1433 * The texture alpha is affected based on its alpha modulation set by 1434 * SDL_SetTextureAlphaMod(). 1435 * 1436 * \param renderer the rendering context. 1437 * \param texture the source texture. 1438 * \param srcrect the source SDL_Rect structure or NULL for the entire 1439 * texture. 1440 * \param dstrect the destination SDL_Rect structure or NULL for the entire 1441 * rendering target. 1442 * \param angle an angle in degrees that indicates the rotation that will be 1443 * applied to dstrect, rotating it in a clockwise direction. 1444 * \param center a pointer to a point indicating the point around which 1445 * dstrect will be rotated (if NULL, rotation will be done 1446 * around `dstrect.w / 2`, `dstrect.h / 2`). 1447 * \param flip a SDL_RendererFlip value stating which flipping actions should 1448 * be performed on the texture. 1449 * \returns 0 on success or a negative error code on failure; call 1450 * SDL_GetError() for more information. 1451 * 1452 * \since This function is available since SDL 2.0.0. 1453 * 1454 * \sa SDL_RenderCopy 1455 * \sa SDL_SetTextureAlphaMod 1456 * \sa SDL_SetTextureBlendMode 1457 * \sa SDL_SetTextureColorMod 1458 */ 1459 extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer, 1460 SDL_Texture * texture, 1461 const SDL_Rect * srcrect, 1462 const SDL_Rect * dstrect, 1463 const double angle, 1464 const SDL_Point *center, 1465 const SDL_RendererFlip flip); 1466 1467 1468 /** 1469 * Draw a point on the current rendering target at subpixel precision. 1470 * 1471 * \param renderer The renderer which should draw a point. 1472 * \param x The x coordinate of the point. 1473 * \param y The y coordinate of the point. 1474 * \return 0 on success, or -1 on error. 1475 * 1476 * \since This function is available since SDL 2.0.10. 1477 */ 1478 extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer, 1479 float x, float y); 1480 1481 /** 1482 * Draw multiple points on the current rendering target at subpixel precision. 1483 * 1484 * \param renderer The renderer which should draw multiple points. 1485 * \param points The points to draw. 1486 * \param count The number of points to draw. 1487 * \return 0 on success, or -1 on error. 1488 * 1489 * \since This function is available since SDL 2.0.10. 1490 */ 1491 extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer, 1492 const SDL_FPoint * points, 1493 int count); 1494 1495 /** 1496 * Draw a line on the current rendering target at subpixel precision. 1497 * 1498 * \param renderer The renderer which should draw a line. 1499 * \param x1 The x coordinate of the start point. 1500 * \param y1 The y coordinate of the start point. 1501 * \param x2 The x coordinate of the end point. 1502 * \param y2 The y coordinate of the end point. 1503 * \return 0 on success, or -1 on error. 1504 * 1505 * \since This function is available since SDL 2.0.10. 1506 */ 1507 extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer, 1508 float x1, float y1, float x2, float y2); 1509 1510 /** 1511 * Draw a series of connected lines on the current rendering target at 1512 * subpixel precision. 1513 * 1514 * \param renderer The renderer which should draw multiple lines. 1515 * \param points The points along the lines. 1516 * \param count The number of points, drawing count-1 lines. 1517 * \return 0 on success, or -1 on error. 1518 * 1519 * \since This function is available since SDL 2.0.10. 1520 */ 1521 extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer, 1522 const SDL_FPoint * points, 1523 int count); 1524 1525 /** 1526 * Draw a rectangle on the current rendering target at subpixel precision. 1527 * 1528 * \param renderer The renderer which should draw a rectangle. 1529 * \param rect A pointer to the destination rectangle, or NULL to outline the 1530 * entire rendering target. 1531 * \return 0 on success, or -1 on error. 1532 * 1533 * \since This function is available since SDL 2.0.10. 1534 */ 1535 extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer, 1536 const SDL_FRect * rect); 1537 1538 /** 1539 * Draw some number of rectangles on the current rendering target at subpixel 1540 * precision. 1541 * 1542 * \param renderer The renderer which should draw multiple rectangles. 1543 * \param rects A pointer to an array of destination rectangles. 1544 * \param count The number of rectangles. 1545 * \return 0 on success, or -1 on error. 1546 * 1547 * \since This function is available since SDL 2.0.10. 1548 */ 1549 extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer, 1550 const SDL_FRect * rects, 1551 int count); 1552 1553 /** 1554 * Fill a rectangle on the current rendering target with the drawing color at 1555 * subpixel precision. 1556 * 1557 * \param renderer The renderer which should fill a rectangle. 1558 * \param rect A pointer to the destination rectangle, or NULL for the entire 1559 * rendering target. 1560 * \return 0 on success, or -1 on error. 1561 * 1562 * \since This function is available since SDL 2.0.10. 1563 */ 1564 extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer, 1565 const SDL_FRect * rect); 1566 1567 /** 1568 * Fill some number of rectangles on the current rendering target with the 1569 * drawing color at subpixel precision. 1570 * 1571 * \param renderer The renderer which should fill multiple rectangles. 1572 * \param rects A pointer to an array of destination rectangles. 1573 * \param count The number of rectangles. 1574 * \return 0 on success, or -1 on error. 1575 * 1576 * \since This function is available since SDL 2.0.10. 1577 */ 1578 extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer, 1579 const SDL_FRect * rects, 1580 int count); 1581 1582 /** 1583 * Copy a portion of the texture to the current rendering target at subpixel 1584 * precision. 1585 * 1586 * \param renderer The renderer which should copy parts of a texture. 1587 * \param texture The source texture. 1588 * \param srcrect A pointer to the source rectangle, or NULL for the entire 1589 * texture. 1590 * \param dstrect A pointer to the destination rectangle, or NULL for the 1591 * entire rendering target. 1592 * \return 0 on success, or -1 on error. 1593 * 1594 * \since This function is available since SDL 2.0.10. 1595 */ 1596 extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer, 1597 SDL_Texture * texture, 1598 const SDL_Rect * srcrect, 1599 const SDL_FRect * dstrect); 1600 1601 /** 1602 * Copy a portion of the source texture to the current rendering target, with 1603 * rotation and flipping, at subpixel precision. 1604 * 1605 * \param renderer The renderer which should copy parts of a texture. 1606 * \param texture The source texture. 1607 * \param srcrect A pointer to the source rectangle, or NULL for the entire 1608 * texture. 1609 * \param dstrect A pointer to the destination rectangle, or NULL for the 1610 * entire rendering target. 1611 * \param angle An angle in degrees that indicates the rotation that will be 1612 * applied to dstrect, rotating it in a clockwise direction. 1613 * \param center A pointer to a point indicating the point around which 1614 * dstrect will be rotated (if NULL, rotation will be done 1615 * around dstrect.w/2, dstrect.h/2). 1616 * \param flip An SDL_RendererFlip value stating which flipping actions should 1617 * be performed on the texture. 1618 * \return 0 on success, or -1 on error. 1619 * 1620 * \since This function is available since SDL 2.0.10. 1621 */ 1622 extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer, 1623 SDL_Texture * texture, 1624 const SDL_Rect * srcrect, 1625 const SDL_FRect * dstrect, 1626 const double angle, 1627 const SDL_FPoint *center, 1628 const SDL_RendererFlip flip); 1629 1630 /** 1631 * Render a list of triangles, optionally using a texture and indices into the 1632 * vertex array Color and alpha modulation is done per vertex 1633 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). 1634 * 1635 * \param renderer The rendering context. 1636 * \param texture (optional) The SDL texture to use. 1637 * \param vertices Vertices. 1638 * \param num_vertices Number of vertices. 1639 * \param indices (optional) An array of integer indices into the 'vertices' 1640 * array, if NULL all vertices will be rendered in sequential 1641 * order. 1642 * \param num_indices Number of indices. 1643 * \return 0 on success, or -1 if the operation is not supported. 1644 * 1645 * \since This function is available since SDL 2.0.18. 1646 * 1647 * \sa SDL_RenderGeometryRaw 1648 * \sa SDL_Vertex 1649 */ 1650 extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer, 1651 SDL_Texture *texture, 1652 const SDL_Vertex *vertices, int num_vertices, 1653 const int *indices, int num_indices); 1654 1655 /** 1656 * Render a list of triangles, optionally using a texture and indices into the 1657 * vertex arrays Color and alpha modulation is done per vertex 1658 * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored). 1659 * 1660 * \param renderer The rendering context. 1661 * \param texture (optional) The SDL texture to use. 1662 * \param xy Vertex positions. 1663 * \param xy_stride Byte size to move from one element to the next element. 1664 * \param color Vertex colors (as SDL_Color). 1665 * \param color_stride Byte size to move from one element to the next element. 1666 * \param uv Vertex normalized texture coordinates. 1667 * \param uv_stride Byte size to move from one element to the next element. 1668 * \param num_vertices Number of vertices. 1669 * \param indices (optional) An array of indices into the 'vertices' arrays, 1670 * if NULL all vertices will be rendered in sequential order. 1671 * \param num_indices Number of indices. 1672 * \param size_indices Index size: 1 (byte), 2 (short), 4 (int). 1673 * \return 0 on success, or -1 if the operation is not supported. 1674 * 1675 * \since This function is available since SDL 2.0.18. 1676 * 1677 * \sa SDL_RenderGeometry 1678 * \sa SDL_Vertex 1679 */ 1680 extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer, 1681 SDL_Texture *texture, 1682 const float *xy, int xy_stride, 1683 const SDL_Color *color, int color_stride, 1684 const float *uv, int uv_stride, 1685 int num_vertices, 1686 const void *indices, int num_indices, int size_indices); 1687 1688 /** 1689 * Read pixels from the current rendering target to an array of pixels. 1690 * 1691 * **WARNING**: This is a very slow operation, and should not be used 1692 * frequently. If you're using this on the main rendering target, it should be 1693 * called after rendering and before SDL_RenderPresent(). 1694 * 1695 * `pitch` specifies the number of bytes between rows in the destination 1696 * `pixels` data. This allows you to write to a subrectangle or have padded 1697 * rows in the destination. Generally, `pitch` should equal the number of 1698 * pixels per row in the `pixels` data times the number of bytes per pixel, 1699 * but it might contain additional padding (for example, 24bit RGB Windows 1700 * Bitmap data pads all rows to multiples of 4 bytes). 1701 * 1702 * \param renderer the rendering context. 1703 * \param rect an SDL_Rect structure representing the area to read, or NULL 1704 * for the entire render target. 1705 * \param format an SDL_PixelFormatEnum value of the desired format of the 1706 * pixel data, or 0 to use the format of the rendering target. 1707 * \param pixels a pointer to the pixel data to copy into. 1708 * \param pitch the pitch of the `pixels` parameter. 1709 * \returns 0 on success or a negative error code on failure; call 1710 * SDL_GetError() for more information. 1711 * 1712 * \since This function is available since SDL 2.0.0. 1713 */ 1714 extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, 1715 const SDL_Rect * rect, 1716 Uint32 format, 1717 void *pixels, int pitch); 1718 1719 /** 1720 * Update the screen with any rendering performed since the previous call. 1721 * 1722 * SDL's rendering functions operate on a backbuffer; that is, calling a 1723 * rendering function such as SDL_RenderDrawLine() does not directly put a 1724 * line on the screen, but rather updates the backbuffer. As such, you compose 1725 * your entire scene and *present* the composed backbuffer to the screen as a 1726 * complete picture. 1727 * 1728 * Therefore, when using SDL's rendering API, one does all drawing intended 1729 * for the frame, and then calls this function once per frame to present the 1730 * final drawing to the user. 1731 * 1732 * The backbuffer should be considered invalidated after each present; do not 1733 * assume that previous contents will exist between frames. You are strongly 1734 * encouraged to call SDL_RenderClear() to initialize the backbuffer before 1735 * starting each new frame's drawing, even if you plan to overwrite every 1736 * pixel. 1737 * 1738 * \param renderer the rendering context. 1739 * 1740 * \threadsafety You may only call this function on the main thread. If this 1741 * happens to work on a background thread on any given platform 1742 * or backend, it's purely by luck and you should not rely on it 1743 * to work next time. 1744 * 1745 * \since This function is available since SDL 2.0.0. 1746 * 1747 * \sa SDL_CreateRenderer 1748 * \sa SDL_RenderClear 1749 * \sa SDL_RenderDrawLine 1750 * \sa SDL_RenderDrawLines 1751 * \sa SDL_RenderDrawPoint 1752 * \sa SDL_RenderDrawPoints 1753 * \sa SDL_RenderDrawRect 1754 * \sa SDL_RenderDrawRects 1755 * \sa SDL_RenderFillRect 1756 * \sa SDL_RenderFillRects 1757 * \sa SDL_SetRenderDrawBlendMode 1758 * \sa SDL_SetRenderDrawColor 1759 */ 1760 extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); 1761 1762 /** 1763 * Destroy the specified texture. 1764 * 1765 * Passing NULL or an otherwise invalid texture will set the SDL error message 1766 * to "Invalid texture". 1767 * 1768 * \param texture the texture to destroy. 1769 * 1770 * \since This function is available since SDL 2.0.0. 1771 * 1772 * \sa SDL_CreateTexture 1773 * \sa SDL_CreateTextureFromSurface 1774 */ 1775 extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); 1776 1777 /** 1778 * Destroy the rendering context for a window and free associated textures. 1779 * 1780 * If `renderer` is NULL, this function will return immediately after setting 1781 * the SDL error message to "Invalid renderer". See SDL_GetError(). 1782 * 1783 * \param renderer the rendering context. 1784 * 1785 * \since This function is available since SDL 2.0.0. 1786 * 1787 * \sa SDL_CreateRenderer 1788 */ 1789 extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); 1790 1791 /** 1792 * Force the rendering context to flush any pending commands to the underlying 1793 * rendering API. 1794 * 1795 * You do not need to (and in fact, shouldn't) call this function unless you 1796 * are planning to call into OpenGL/Direct3D/Metal/whatever directly in 1797 * addition to using an SDL_Renderer. 1798 * 1799 * This is for a very-specific case: if you are using SDL's render API, you 1800 * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set 1801 * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever 1802 * calls in addition to SDL render API calls. If all of this applies, you 1803 * should call SDL_RenderFlush() between calls to SDL's render API and the 1804 * low-level API you're using in cooperation. 1805 * 1806 * In all other cases, you can ignore this function. This is only here to get 1807 * maximum performance out of a specific situation. In all other cases, SDL 1808 * will do the right thing, perhaps at a performance loss. 1809 * 1810 * This function is first available in SDL 2.0.10, and is not needed in 2.0.9 1811 * and earlier, as earlier versions did not queue rendering commands at all, 1812 * instead flushing them to the OS immediately. 1813 * 1814 * \param renderer the rendering context. 1815 * \returns 0 on success or a negative error code on failure; call 1816 * SDL_GetError() for more information. 1817 * 1818 * \since This function is available since SDL 2.0.10. 1819 */ 1820 extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer); 1821 1822 1823 /** 1824 * Bind an OpenGL/ES/ES2 texture to the current context. 1825 * 1826 * This is for use with OpenGL instructions when rendering OpenGL primitives 1827 * directly. 1828 * 1829 * If not NULL, `texw` and `texh` will be filled with the width and height 1830 * values suitable for the provided texture. In most cases, both will be 1.0, 1831 * however, on systems that support the GL_ARB_texture_rectangle extension, 1832 * these values will actually be the pixel width and height used to create the 1833 * texture, so this factor needs to be taken into account when providing 1834 * texture coordinates to OpenGL. 1835 * 1836 * You need a renderer to create an SDL_Texture, therefore you can only use 1837 * this function with an implicit OpenGL context from SDL_CreateRenderer(), 1838 * not with your own OpenGL context. If you need control over your OpenGL 1839 * context, you need to write your own texture-loading methods. 1840 * 1841 * Also note that SDL may upload RGB textures as BGR (or vice-versa), and 1842 * re-order the color channels in the shaders phase, so the uploaded texture 1843 * may have swapped color channels. 1844 * 1845 * \param texture the texture to bind to the current OpenGL/ES/ES2 context. 1846 * \param texw a pointer to a float value which will be filled with the 1847 * texture width or NULL if you don't need that value. 1848 * \param texh a pointer to a float value which will be filled with the 1849 * texture height or NULL if you don't need that value. 1850 * \returns 0 on success, or -1 if the operation is not supported; call 1851 * SDL_GetError() for more information. 1852 * 1853 * \since This function is available since SDL 2.0.0. 1854 * 1855 * \sa SDL_GL_MakeCurrent 1856 * \sa SDL_GL_UnbindTexture 1857 */ 1858 extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh); 1859 1860 /** 1861 * Unbind an OpenGL/ES/ES2 texture from the current context. 1862 * 1863 * See SDL_GL_BindTexture() for examples on how to use these functions 1864 * 1865 * \param texture the texture to unbind from the current OpenGL/ES/ES2 1866 * context. 1867 * \returns 0 on success, or -1 if the operation is not supported. 1868 * 1869 * \since This function is available since SDL 2.0.0. 1870 * 1871 * \sa SDL_GL_BindTexture 1872 * \sa SDL_GL_MakeCurrent 1873 */ 1874 extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture); 1875 1876 /** 1877 * Get the CAMetalLayer associated with the given Metal renderer. 1878 * 1879 * This function returns `void *`, so SDL doesn't have to include Metal's 1880 * headers, but it can be safely cast to a `CAMetalLayer *`. 1881 * 1882 * \param renderer The renderer to query. 1883 * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a 1884 * Metal renderer. 1885 * 1886 * \since This function is available since SDL 2.0.8. 1887 * 1888 * \sa SDL_RenderGetMetalCommandEncoder 1889 */ 1890 extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer); 1891 1892 /** 1893 * Get the Metal command encoder for the current frame 1894 * 1895 * This function returns `void *`, so SDL doesn't have to include Metal's 1896 * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`. 1897 * 1898 * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give 1899 * SDL a drawable to render to, which might happen if the window is 1900 * hidden/minimized/offscreen. This doesn't apply to command encoders for 1901 * render targets, just the window's backbuffer. Check your return values! 1902 * 1903 * \param renderer The renderer to query. 1904 * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the 1905 * renderer isn't a Metal renderer or there was an error. 1906 * 1907 * \since This function is available since SDL 2.0.8. 1908 * 1909 * \sa SDL_RenderGetMetalLayer 1910 */ 1911 extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer); 1912 1913 /** 1914 * Toggle VSync of the given renderer. 1915 * 1916 * \param renderer The renderer to toggle. 1917 * \param vsync 1 for on, 0 for off. All other values are reserved. 1918 * \returns a 0 int on success, or non-zero on failure. 1919 * 1920 * \since This function is available since SDL 2.0.18. 1921 */ 1922 extern DECLSPEC int SDLCALL SDL_RenderSetVSync(SDL_Renderer* renderer, int vsync); 1923 1924 /* Ends C function definitions when using C++ */ 1925 #ifdef __cplusplus 1926 } 1927 #endif 1928 #include "close_code.h" 1929 1930 #endif /* SDL_render_h_ */ 1931 1932 /* vi: set ts=4 sw=4 expandtab: */