🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1908 lines
72 KiB

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