🛠️🐜 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.

1919 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. * When using the main rendering target (eg no target texture is set): this
  777. * may return 0 for `w` and `h` if the SDL_Renderer has never had its logical
  778. * size set by SDL_RenderSetLogicalSize(). Otherwise it returns the logical
  779. * width and height.
  780. *
  781. * When using a target texture: Never return 0 for `w` and `h` at first. Then
  782. * it returns the logical width and height that are set.
  783. *
  784. * \param renderer a rendering context
  785. * \param w an int to be filled with the width
  786. * \param h an int to be filled with the height
  787. *
  788. * \since This function is available since SDL 2.0.0.
  789. *
  790. * \sa SDL_RenderSetLogicalSize
  791. */
  792. extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
  793. /**
  794. * Set whether to force integer scales for resolution-independent rendering.
  795. *
  796. * This function restricts the logical viewport to integer values - that is,
  797. * when a resolution is between two multiples of a logical size, the viewport
  798. * size is rounded down to the lower multiple.
  799. *
  800. * \param renderer the renderer for which integer scaling should be set
  801. * \param enable enable or disable the integer scaling for rendering
  802. * \returns 0 on success or a negative error code on failure; call
  803. * SDL_GetError() for more information.
  804. *
  805. * \since This function is available since SDL 2.0.5.
  806. *
  807. * \sa SDL_RenderGetIntegerScale
  808. * \sa SDL_RenderSetLogicalSize
  809. */
  810. extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
  811. SDL_bool enable);
  812. /**
  813. * Get whether integer scales are forced for resolution-independent rendering.
  814. *
  815. * \param renderer the renderer from which integer scaling should be queried
  816. * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on
  817. * failure; call SDL_GetError() for more information.
  818. *
  819. * \since This function is available since SDL 2.0.5.
  820. *
  821. * \sa SDL_RenderSetIntegerScale
  822. */
  823. extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
  824. /**
  825. * Set the drawing area for rendering on the current target.
  826. *
  827. * When the window is resized, the viewport is reset to fill the entire new
  828. * window size.
  829. *
  830. * \param renderer the rendering context
  831. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  832. * to set the viewport to the entire target
  833. * \returns 0 on success or a negative error code on failure; call
  834. * SDL_GetError() for more information.
  835. *
  836. * \since This function is available since SDL 2.0.0.
  837. *
  838. * \sa SDL_RenderGetViewport
  839. */
  840. extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
  841. const SDL_Rect * rect);
  842. /**
  843. * Get the drawing area for the current target.
  844. *
  845. * \param renderer the rendering context
  846. * \param rect an SDL_Rect structure filled in with the current drawing area
  847. *
  848. * \since This function is available since SDL 2.0.0.
  849. *
  850. * \sa SDL_RenderSetViewport
  851. */
  852. extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
  853. SDL_Rect * rect);
  854. /**
  855. * Set the clip rectangle for rendering on the specified target.
  856. *
  857. * \param renderer the rendering context for which clip rectangle should be
  858. * set
  859. * \param rect an SDL_Rect structure representing the clip area, relative to
  860. * the viewport, or NULL to disable clipping
  861. * \returns 0 on success or a negative error code on failure; call
  862. * SDL_GetError() for more information.
  863. *
  864. * \since This function is available since SDL 2.0.0.
  865. *
  866. * \sa SDL_RenderGetClipRect
  867. * \sa SDL_RenderIsClipEnabled
  868. */
  869. extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
  870. const SDL_Rect * rect);
  871. /**
  872. * Get the clip rectangle for the current target.
  873. *
  874. * \param renderer the rendering context from which clip rectangle should be
  875. * queried
  876. * \param rect an SDL_Rect structure filled in with the current clipping area
  877. * or an empty rectangle if clipping is disabled
  878. *
  879. * \since This function is available since SDL 2.0.0.
  880. *
  881. * \sa SDL_RenderIsClipEnabled
  882. * \sa SDL_RenderSetClipRect
  883. */
  884. extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
  885. SDL_Rect * rect);
  886. /**
  887. * Get whether clipping is enabled on the given renderer.
  888. *
  889. * \param renderer the renderer from which clip state should be queried
  890. * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
  891. * SDL_GetError() for more information.
  892. *
  893. * \since This function is available since SDL 2.0.4.
  894. *
  895. * \sa SDL_RenderGetClipRect
  896. * \sa SDL_RenderSetClipRect
  897. */
  898. extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
  899. /**
  900. * Set the drawing scale for rendering on the current target.
  901. *
  902. * The drawing coordinates are scaled by the x/y scaling factors before they
  903. * are used by the renderer. This allows resolution independent drawing with a
  904. * single coordinate system.
  905. *
  906. * If this results in scaling or subpixel drawing by the rendering backend, it
  907. * will be handled using the appropriate quality hints. For best results use
  908. * integer scaling factors.
  909. *
  910. * \param renderer a rendering context
  911. * \param scaleX the horizontal scaling factor
  912. * \param scaleY the vertical scaling factor
  913. * \returns 0 on success or a negative error code on failure; call
  914. * SDL_GetError() for more information.
  915. *
  916. * \since This function is available since SDL 2.0.0.
  917. *
  918. * \sa SDL_RenderGetScale
  919. * \sa SDL_RenderSetLogicalSize
  920. */
  921. extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
  922. float scaleX, float scaleY);
  923. /**
  924. * Get the drawing scale for the current target.
  925. *
  926. * \param renderer the renderer from which drawing scale should be queried
  927. * \param scaleX a pointer filled in with the horizontal scaling factor
  928. * \param scaleY a pointer filled in with the vertical scaling factor
  929. *
  930. * \since This function is available since SDL 2.0.0.
  931. *
  932. * \sa SDL_RenderSetScale
  933. */
  934. extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
  935. float *scaleX, float *scaleY);
  936. /**
  937. * Get logical coordinates of point in renderer when given real coordinates of
  938. * point in window.
  939. *
  940. * Logical coordinates will differ from real coordinates when render is scaled
  941. * and logical renderer size set
  942. *
  943. * \param renderer the renderer from which the logical coordinates should be
  944. * calculated
  945. * \param windowX the real X coordinate in the window
  946. * \param windowY the real Y coordinate in the window
  947. * \param logicalX the pointer filled with the logical x coordinate
  948. * \param logicalY the pointer filled with the logical y coordinate
  949. *
  950. * \since This function is available since SDL 2.0.18.
  951. *
  952. * \sa SDL_RenderGetScale
  953. * \sa SDL_RenderSetScale
  954. * \sa SDL_RenderGetLogicalSize
  955. * \sa SDL_RenderSetLogicalSize
  956. */
  957. extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
  958. int windowX, int windowY,
  959. float *logicalX, float *logicalY);
  960. /**
  961. * Get real coordinates of point in window when given logical coordinates of
  962. * point in renderer.
  963. *
  964. * Logical coordinates will differ from real coordinates when render is scaled
  965. * and logical renderer size set
  966. *
  967. * \param renderer the renderer from which the window coordinates should be
  968. * calculated
  969. * \param logicalX the logical x coordinate
  970. * \param logicalY the logical y coordinate
  971. * \param windowX the pointer filled with the real X coordinate in the window
  972. * \param windowY the pointer filled with the real Y coordinate in the window
  973. *
  974. * \since This function is available since SDL 2.0.18.
  975. *
  976. * \sa SDL_RenderGetScale
  977. * \sa SDL_RenderSetScale
  978. * \sa SDL_RenderGetLogicalSize
  979. * \sa SDL_RenderSetLogicalSize
  980. */
  981. extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer,
  982. float logicalX, float logicalY,
  983. int *windowX, int *windowY);
  984. /**
  985. * Set the color used for drawing operations (Rect, Line and Clear).
  986. *
  987. * Set the color for drawing or filling rectangles, lines, and points, and for
  988. * SDL_RenderClear().
  989. *
  990. * \param renderer the rendering context
  991. * \param r the red value used to draw on the rendering target
  992. * \param g the green value used to draw on the rendering target
  993. * \param b the blue value used to draw on the rendering target
  994. * \param a the alpha value used to draw on the rendering target; usually
  995. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  996. * specify how the alpha channel is used
  997. * \returns 0 on success or a negative error code on failure; call
  998. * SDL_GetError() for more information.
  999. *
  1000. * \since This function is available since SDL 2.0.0.
  1001. *
  1002. * \sa SDL_GetRenderDrawColor
  1003. * \sa SDL_RenderClear
  1004. * \sa SDL_RenderDrawLine
  1005. * \sa SDL_RenderDrawLines
  1006. * \sa SDL_RenderDrawPoint
  1007. * \sa SDL_RenderDrawPoints
  1008. * \sa SDL_RenderDrawRect
  1009. * \sa SDL_RenderDrawRects
  1010. * \sa SDL_RenderFillRect
  1011. * \sa SDL_RenderFillRects
  1012. */
  1013. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
  1014. Uint8 r, Uint8 g, Uint8 b,
  1015. Uint8 a);
  1016. /**
  1017. * Get the color used for drawing operations (Rect, Line and Clear).
  1018. *
  1019. * \param renderer the rendering context
  1020. * \param r a pointer filled in with the red value used to draw on the
  1021. * rendering target
  1022. * \param g a pointer filled in with the green value used to draw on the
  1023. * rendering target
  1024. * \param b a pointer filled in with the blue value used to draw on the
  1025. * rendering target
  1026. * \param a a pointer filled in with the alpha value used to draw on the
  1027. * rendering target; usually `SDL_ALPHA_OPAQUE` (255)
  1028. * \returns 0 on success or a negative error code on failure; call
  1029. * SDL_GetError() for more information.
  1030. *
  1031. * \since This function is available since SDL 2.0.0.
  1032. *
  1033. * \sa SDL_SetRenderDrawColor
  1034. */
  1035. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
  1036. Uint8 * r, Uint8 * g, Uint8 * b,
  1037. Uint8 * a);
  1038. /**
  1039. * Set the blend mode used for drawing operations (Fill and Line).
  1040. *
  1041. * If the blend mode is not supported, the closest supported mode is chosen.
  1042. *
  1043. * \param renderer the rendering context
  1044. * \param blendMode the SDL_BlendMode to use for blending
  1045. * \returns 0 on success or a negative error code on failure; call
  1046. * SDL_GetError() for more information.
  1047. *
  1048. * \since This function is available since SDL 2.0.0.
  1049. *
  1050. * \sa SDL_GetRenderDrawBlendMode
  1051. * \sa SDL_RenderDrawLine
  1052. * \sa SDL_RenderDrawLines
  1053. * \sa SDL_RenderDrawPoint
  1054. * \sa SDL_RenderDrawPoints
  1055. * \sa SDL_RenderDrawRect
  1056. * \sa SDL_RenderDrawRects
  1057. * \sa SDL_RenderFillRect
  1058. * \sa SDL_RenderFillRects
  1059. */
  1060. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
  1061. SDL_BlendMode blendMode);
  1062. /**
  1063. * Get the blend mode used for drawing operations.
  1064. *
  1065. * \param renderer the rendering context
  1066. * \param blendMode a pointer filled in with the current SDL_BlendMode
  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_SetRenderDrawBlendMode
  1073. */
  1074. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
  1075. SDL_BlendMode *blendMode);
  1076. /**
  1077. * Clear the current rendering target with the drawing color.
  1078. *
  1079. * This function clears the entire rendering target, ignoring the viewport and
  1080. * the clip rectangle.
  1081. *
  1082. * \param renderer the rendering context
  1083. * \returns 0 on success or a negative error code on failure; call
  1084. * SDL_GetError() for more information.
  1085. *
  1086. * \since This function is available since SDL 2.0.0.
  1087. *
  1088. * \sa SDL_SetRenderDrawColor
  1089. */
  1090. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
  1091. /**
  1092. * Draw a point on the current rendering target.
  1093. *
  1094. * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple,
  1095. * use SDL_RenderDrawPoints() instead.
  1096. *
  1097. * \param renderer the rendering context
  1098. * \param x the x coordinate of the point
  1099. * \param y the y coordinate of the point
  1100. * \returns 0 on success or a negative error code on failure; call
  1101. * SDL_GetError() for more information.
  1102. *
  1103. * \since This function is available since SDL 2.0.0.
  1104. *
  1105. * \sa SDL_RenderDrawLine
  1106. * \sa SDL_RenderDrawLines
  1107. * \sa SDL_RenderDrawPoints
  1108. * \sa SDL_RenderDrawRect
  1109. * \sa SDL_RenderDrawRects
  1110. * \sa SDL_RenderFillRect
  1111. * \sa SDL_RenderFillRects
  1112. * \sa SDL_RenderPresent
  1113. * \sa SDL_SetRenderDrawBlendMode
  1114. * \sa SDL_SetRenderDrawColor
  1115. */
  1116. extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
  1117. int x, int y);
  1118. /**
  1119. * Draw multiple points on the current rendering target.
  1120. *
  1121. * \param renderer the rendering context
  1122. * \param points an array of SDL_Point structures that represent the points to
  1123. * draw
  1124. * \param count the number of points to draw
  1125. * \returns 0 on success or a negative error code on failure; call
  1126. * SDL_GetError() for more information.
  1127. *
  1128. * \since This function is available since SDL 2.0.0.
  1129. *
  1130. * \sa SDL_RenderDrawLine
  1131. * \sa SDL_RenderDrawLines
  1132. * \sa SDL_RenderDrawPoint
  1133. * \sa SDL_RenderDrawRect
  1134. * \sa SDL_RenderDrawRects
  1135. * \sa SDL_RenderFillRect
  1136. * \sa SDL_RenderFillRects
  1137. * \sa SDL_RenderPresent
  1138. * \sa SDL_SetRenderDrawBlendMode
  1139. * \sa SDL_SetRenderDrawColor
  1140. */
  1141. extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
  1142. const SDL_Point * points,
  1143. int count);
  1144. /**
  1145. * Draw a line on the current rendering target.
  1146. *
  1147. * SDL_RenderDrawLine() draws the line to include both end points. If you want
  1148. * to draw multiple, connecting lines use SDL_RenderDrawLines() instead.
  1149. *
  1150. * \param renderer the rendering context
  1151. * \param x1 the x coordinate of the start point
  1152. * \param y1 the y coordinate of the start point
  1153. * \param x2 the x coordinate of the end point
  1154. * \param y2 the y coordinate of the end point
  1155. * \returns 0 on success or a negative error code on failure; call
  1156. * SDL_GetError() for more information.
  1157. *
  1158. * \since This function is available since SDL 2.0.0.
  1159. *
  1160. * \sa SDL_RenderDrawLines
  1161. * \sa SDL_RenderDrawPoint
  1162. * \sa SDL_RenderDrawPoints
  1163. * \sa SDL_RenderDrawRect
  1164. * \sa SDL_RenderDrawRects
  1165. * \sa SDL_RenderFillRect
  1166. * \sa SDL_RenderFillRects
  1167. * \sa SDL_RenderPresent
  1168. * \sa SDL_SetRenderDrawBlendMode
  1169. * \sa SDL_SetRenderDrawColor
  1170. */
  1171. extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
  1172. int x1, int y1, int x2, int y2);
  1173. /**
  1174. * Draw a series of connected lines on the current rendering target.
  1175. *
  1176. * \param renderer the rendering context
  1177. * \param points an array of SDL_Point structures representing points along
  1178. * the lines
  1179. * \param count the number of points, drawing count-1 lines
  1180. * \returns 0 on success or a negative error code on failure; call
  1181. * SDL_GetError() for more information.
  1182. *
  1183. * \since This function is available since SDL 2.0.0.
  1184. *
  1185. * \sa SDL_RenderDrawLine
  1186. * \sa SDL_RenderDrawPoint
  1187. * \sa SDL_RenderDrawPoints
  1188. * \sa SDL_RenderDrawRect
  1189. * \sa SDL_RenderDrawRects
  1190. * \sa SDL_RenderFillRect
  1191. * \sa SDL_RenderFillRects
  1192. * \sa SDL_RenderPresent
  1193. * \sa SDL_SetRenderDrawBlendMode
  1194. * \sa SDL_SetRenderDrawColor
  1195. */
  1196. extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
  1197. const SDL_Point * points,
  1198. int count);
  1199. /**
  1200. * Draw a rectangle on the current rendering target.
  1201. *
  1202. * \param renderer the rendering context
  1203. * \param rect an SDL_Rect structure representing the rectangle to draw, or
  1204. * NULL to outline the entire rendering target
  1205. * \returns 0 on success or a negative error code on failure; call
  1206. * SDL_GetError() for more information.
  1207. *
  1208. * \since This function is available since SDL 2.0.0.
  1209. *
  1210. * \sa SDL_RenderDrawLine
  1211. * \sa SDL_RenderDrawLines
  1212. * \sa SDL_RenderDrawPoint
  1213. * \sa SDL_RenderDrawPoints
  1214. * \sa SDL_RenderDrawRects
  1215. * \sa SDL_RenderFillRect
  1216. * \sa SDL_RenderFillRects
  1217. * \sa SDL_RenderPresent
  1218. * \sa SDL_SetRenderDrawBlendMode
  1219. * \sa SDL_SetRenderDrawColor
  1220. */
  1221. extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
  1222. const SDL_Rect * rect);
  1223. /**
  1224. * Draw some number of rectangles on the current rendering target.
  1225. *
  1226. * \param renderer the rendering context
  1227. * \param rects an array of SDL_Rect structures representing the rectangles to
  1228. * be drawn
  1229. * \param count the number of rectangles
  1230. * \returns 0 on success or a negative error code on failure; call
  1231. * SDL_GetError() for more information.
  1232. *
  1233. * \since This function is available since SDL 2.0.0.
  1234. *
  1235. * \sa SDL_RenderDrawLine
  1236. * \sa SDL_RenderDrawLines
  1237. * \sa SDL_RenderDrawPoint
  1238. * \sa SDL_RenderDrawPoints
  1239. * \sa SDL_RenderDrawRect
  1240. * \sa SDL_RenderFillRect
  1241. * \sa SDL_RenderFillRects
  1242. * \sa SDL_RenderPresent
  1243. * \sa SDL_SetRenderDrawBlendMode
  1244. * \sa SDL_SetRenderDrawColor
  1245. */
  1246. extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
  1247. const SDL_Rect * rects,
  1248. int count);
  1249. /**
  1250. * Fill a rectangle on the current rendering target with the drawing color.
  1251. *
  1252. * The current drawing color is set by SDL_SetRenderDrawColor(), and the
  1253. * color's alpha value is ignored unless blending is enabled with the
  1254. * appropriate call to SDL_SetRenderDrawBlendMode().
  1255. *
  1256. * \param renderer the rendering context
  1257. * \param rect the SDL_Rect structure representing the rectangle to fill, or
  1258. * NULL for the entire rendering target
  1259. * \returns 0 on success or a negative error code on failure; call
  1260. * SDL_GetError() for more information.
  1261. *
  1262. * \since This function is available since SDL 2.0.0.
  1263. *
  1264. * \sa SDL_RenderDrawLine
  1265. * \sa SDL_RenderDrawLines
  1266. * \sa SDL_RenderDrawPoint
  1267. * \sa SDL_RenderDrawPoints
  1268. * \sa SDL_RenderDrawRect
  1269. * \sa SDL_RenderDrawRects
  1270. * \sa SDL_RenderFillRects
  1271. * \sa SDL_RenderPresent
  1272. * \sa SDL_SetRenderDrawBlendMode
  1273. * \sa SDL_SetRenderDrawColor
  1274. */
  1275. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
  1276. const SDL_Rect * rect);
  1277. /**
  1278. * Fill some number of rectangles on the current rendering target with the
  1279. * drawing color.
  1280. *
  1281. * \param renderer the rendering context
  1282. * \param rects an array of SDL_Rect structures representing the rectangles to
  1283. * be filled
  1284. * \param count the number of rectangles
  1285. * \returns 0 on success or a negative error code on failure; call
  1286. * SDL_GetError() for more information.
  1287. *
  1288. * \since This function is available since SDL 2.0.0.
  1289. *
  1290. * \sa SDL_RenderDrawLine
  1291. * \sa SDL_RenderDrawLines
  1292. * \sa SDL_RenderDrawPoint
  1293. * \sa SDL_RenderDrawPoints
  1294. * \sa SDL_RenderDrawRect
  1295. * \sa SDL_RenderDrawRects
  1296. * \sa SDL_RenderFillRect
  1297. * \sa SDL_RenderPresent
  1298. */
  1299. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
  1300. const SDL_Rect * rects,
  1301. int count);
  1302. /**
  1303. * Copy a portion of the texture to the current rendering target.
  1304. *
  1305. * The texture is blended with the destination based on its blend mode set
  1306. * with SDL_SetTextureBlendMode().
  1307. *
  1308. * The texture color is affected based on its color modulation set by
  1309. * SDL_SetTextureColorMod().
  1310. *
  1311. * The texture alpha is affected based on its alpha modulation set by
  1312. * SDL_SetTextureAlphaMod().
  1313. *
  1314. * \param renderer the rendering context
  1315. * \param texture the source texture
  1316. * \param srcrect the source SDL_Rect structure or NULL for the entire texture
  1317. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1318. * rendering target; the texture will be stretched to fill the
  1319. * given rectangle
  1320. * \returns 0 on success or a negative error code on failure; call
  1321. * SDL_GetError() for more information.
  1322. *
  1323. * \since This function is available since SDL 2.0.0.
  1324. *
  1325. * \sa SDL_RenderCopyEx
  1326. * \sa SDL_SetTextureAlphaMod
  1327. * \sa SDL_SetTextureBlendMode
  1328. * \sa SDL_SetTextureColorMod
  1329. */
  1330. extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
  1331. SDL_Texture * texture,
  1332. const SDL_Rect * srcrect,
  1333. const SDL_Rect * dstrect);
  1334. /**
  1335. * Copy a portion of the texture to the current rendering, with optional
  1336. * rotation and flipping.
  1337. *
  1338. * Copy a portion of the texture to the current rendering target, optionally
  1339. * rotating it by angle around the given center and also flipping it
  1340. * top-bottom and/or left-right.
  1341. *
  1342. * The texture is blended with the destination based on its blend mode set
  1343. * with SDL_SetTextureBlendMode().
  1344. *
  1345. * The texture color is affected based on its color modulation set by
  1346. * SDL_SetTextureColorMod().
  1347. *
  1348. * The texture alpha is affected based on its alpha modulation set by
  1349. * SDL_SetTextureAlphaMod().
  1350. *
  1351. * \param renderer the rendering context
  1352. * \param texture the source texture
  1353. * \param srcrect the source SDL_Rect structure or NULL for the entire texture
  1354. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1355. * rendering target
  1356. * \param angle an angle in degrees that indicates the rotation that will be
  1357. * applied to dstrect, rotating it in a clockwise direction
  1358. * \param center a pointer to a point indicating the point around which
  1359. * dstrect will be rotated (if NULL, rotation will be done
  1360. * around `dstrect.w / 2`, `dstrect.h / 2`)
  1361. * \param flip a SDL_RendererFlip value stating which flipping actions should
  1362. * be performed on the texture
  1363. * \returns 0 on success or a negative error code on failure; call
  1364. * SDL_GetError() for more information.
  1365. *
  1366. * \since This function is available since SDL 2.0.0.
  1367. *
  1368. * \sa SDL_RenderCopy
  1369. * \sa SDL_SetTextureAlphaMod
  1370. * \sa SDL_SetTextureBlendMode
  1371. * \sa SDL_SetTextureColorMod
  1372. */
  1373. extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
  1374. SDL_Texture * texture,
  1375. const SDL_Rect * srcrect,
  1376. const SDL_Rect * dstrect,
  1377. const double angle,
  1378. const SDL_Point *center,
  1379. const SDL_RendererFlip flip);
  1380. /**
  1381. * Draw a point on the current rendering target at subpixel precision.
  1382. *
  1383. * \param renderer The renderer which should draw a point.
  1384. * \param x The x coordinate of the point.
  1385. * \param y The y coordinate of the point.
  1386. * \return 0 on success, or -1 on error
  1387. *
  1388. * \since This function is available since SDL 2.0.10.
  1389. */
  1390. extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
  1391. float x, float y);
  1392. /**
  1393. * Draw multiple points on the current rendering target at subpixel precision.
  1394. *
  1395. * \param renderer The renderer which should draw multiple points.
  1396. * \param points The points to draw
  1397. * \param count The number of points to draw
  1398. * \return 0 on success, or -1 on error
  1399. *
  1400. * \since This function is available since SDL 2.0.10.
  1401. */
  1402. extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
  1403. const SDL_FPoint * points,
  1404. int count);
  1405. /**
  1406. * Draw a line on the current rendering target at subpixel precision.
  1407. *
  1408. * \param renderer The renderer which should draw a line.
  1409. * \param x1 The x coordinate of the start point.
  1410. * \param y1 The y coordinate of the start point.
  1411. * \param x2 The x coordinate of the end point.
  1412. * \param y2 The y coordinate of the end point.
  1413. * \return 0 on success, or -1 on error
  1414. *
  1415. * \since This function is available since SDL 2.0.10.
  1416. */
  1417. extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
  1418. float x1, float y1, float x2, float y2);
  1419. /**
  1420. * Draw a series of connected lines on the current rendering target at
  1421. * subpixel precision.
  1422. *
  1423. * \param renderer The renderer which should draw multiple lines.
  1424. * \param points The points along the lines
  1425. * \param count The number of points, drawing count-1 lines
  1426. * \return 0 on success, or -1 on error
  1427. *
  1428. * \since This function is available since SDL 2.0.10.
  1429. */
  1430. extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
  1431. const SDL_FPoint * points,
  1432. int count);
  1433. /**
  1434. * Draw a rectangle on the current rendering target at subpixel precision.
  1435. *
  1436. * \param renderer The renderer which should draw a rectangle.
  1437. * \param rect A pointer to the destination rectangle, or NULL to outline the
  1438. * entire rendering target.
  1439. * \return 0 on success, or -1 on error
  1440. *
  1441. * \since This function is available since SDL 2.0.10.
  1442. */
  1443. extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
  1444. const SDL_FRect * rect);
  1445. /**
  1446. * Draw some number of rectangles on the current rendering target at subpixel
  1447. * precision.
  1448. *
  1449. * \param renderer The renderer which should draw multiple rectangles.
  1450. * \param rects A pointer to an array of destination rectangles.
  1451. * \param count The number of rectangles.
  1452. * \return 0 on success, or -1 on error
  1453. *
  1454. * \since This function is available since SDL 2.0.10.
  1455. */
  1456. extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
  1457. const SDL_FRect * rects,
  1458. int count);
  1459. /**
  1460. * Fill a rectangle on the current rendering target with the drawing color at
  1461. * subpixel precision.
  1462. *
  1463. * \param renderer The renderer which should fill a rectangle.
  1464. * \param rect A pointer to the destination rectangle, or NULL for the entire
  1465. * rendering target.
  1466. * \return 0 on success, or -1 on error
  1467. *
  1468. * \since This function is available since SDL 2.0.10.
  1469. */
  1470. extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
  1471. const SDL_FRect * rect);
  1472. /**
  1473. * Fill some number of rectangles on the current rendering target with the
  1474. * drawing color at subpixel precision.
  1475. *
  1476. * \param renderer The renderer which should fill multiple rectangles.
  1477. * \param rects A pointer to an array of destination rectangles.
  1478. * \param count The number of rectangles.
  1479. * \return 0 on success, or -1 on error
  1480. *
  1481. * \since This function is available since SDL 2.0.10.
  1482. */
  1483. extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
  1484. const SDL_FRect * rects,
  1485. int count);
  1486. /**
  1487. * Copy a portion of the texture to the current rendering target at subpixel
  1488. * precision.
  1489. *
  1490. * \param renderer The renderer which should copy parts of a texture.
  1491. * \param texture The source texture.
  1492. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1493. * texture.
  1494. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1495. * entire rendering target.
  1496. * \return 0 on success, or -1 on error
  1497. *
  1498. * \since This function is available since SDL 2.0.10.
  1499. */
  1500. extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
  1501. SDL_Texture * texture,
  1502. const SDL_Rect * srcrect,
  1503. const SDL_FRect * dstrect);
  1504. /**
  1505. * Copy a portion of the source texture to the current rendering target, with
  1506. * rotation and flipping, at subpixel precision.
  1507. *
  1508. * \param renderer The renderer which should copy parts of a texture.
  1509. * \param texture The source texture.
  1510. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1511. * texture.
  1512. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1513. * entire rendering target.
  1514. * \param angle An angle in degrees that indicates the rotation that will be
  1515. * applied to dstrect, rotating it in a clockwise direction
  1516. * \param center A pointer to a point indicating the point around which
  1517. * dstrect will be rotated (if NULL, rotation will be done
  1518. * around dstrect.w/2, dstrect.h/2).
  1519. * \param flip An SDL_RendererFlip value stating which flipping actions should
  1520. * be performed on the texture
  1521. * \return 0 on success, or -1 on error
  1522. *
  1523. * \since This function is available since SDL 2.0.10.
  1524. */
  1525. extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
  1526. SDL_Texture * texture,
  1527. const SDL_Rect * srcrect,
  1528. const SDL_FRect * dstrect,
  1529. const double angle,
  1530. const SDL_FPoint *center,
  1531. const SDL_RendererFlip flip);
  1532. /**
  1533. * Render a list of triangles, optionally using a texture and indices into the
  1534. * vertex array Color and alpha modulation is done per vertex
  1535. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1536. *
  1537. * \param renderer The rendering context.
  1538. * \param texture (optional) The SDL texture to use.
  1539. * \param vertices Vertices.
  1540. * \param num_vertices Number of vertices.
  1541. * \param indices (optional) An array of integer indices into the 'vertices'
  1542. * array, if NULL all vertices will be rendered in sequential
  1543. * order.
  1544. * \param num_indices Number of indices.
  1545. * \return 0 on success, or -1 if the operation is not supported
  1546. *
  1547. * \since This function is available since SDL 2.0.18.
  1548. *
  1549. * \sa SDL_RenderGeometryRaw
  1550. * \sa SDL_Vertex
  1551. */
  1552. extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  1553. SDL_Texture *texture,
  1554. const SDL_Vertex *vertices, int num_vertices,
  1555. const int *indices, int num_indices);
  1556. /**
  1557. * Render a list of triangles, optionally using a texture and indices into the
  1558. * vertex arrays Color and alpha modulation is done per vertex
  1559. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1560. *
  1561. * \param renderer The rendering context.
  1562. * \param texture (optional) The SDL texture to use.
  1563. * \param xy Vertex positions
  1564. * \param xy_stride Byte size to move from one element to the next element
  1565. * \param color Vertex colors (as SDL_Color)
  1566. * \param color_stride Byte size to move from one element to the next element
  1567. * \param uv Vertex normalized texture coordinates
  1568. * \param uv_stride Byte size to move from one element to the next element
  1569. * \param num_vertices Number of vertices.
  1570. * \param indices (optional) An array of indices into the 'vertices' arrays,
  1571. * if NULL all vertices will be rendered in sequential order.
  1572. * \param num_indices Number of indices.
  1573. * \param size_indices Index size: 1 (byte), 2 (short), 4 (int)
  1574. * \return 0 on success, or -1 if the operation is not supported
  1575. *
  1576. * \since This function is available since SDL 2.0.18.
  1577. *
  1578. * \sa SDL_RenderGeometry
  1579. * \sa SDL_Vertex
  1580. */
  1581. extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  1582. SDL_Texture *texture,
  1583. const float *xy, int xy_stride,
  1584. const SDL_Color *color, int color_stride,
  1585. const float *uv, int uv_stride,
  1586. int num_vertices,
  1587. const void *indices, int num_indices, int size_indices);
  1588. /**
  1589. * Read pixels from the current rendering target to an array of pixels.
  1590. *
  1591. * **WARNING**: This is a very slow operation, and should not be used
  1592. * frequently. If you're using this on the main rendering target, it should be
  1593. * called after rendering and before SDL_RenderPresent().
  1594. *
  1595. * `pitch` specifies the number of bytes between rows in the destination
  1596. * `pixels` data. This allows you to write to a subrectangle or have padded
  1597. * rows in the destination. Generally, `pitch` should equal the number of
  1598. * pixels per row in the `pixels` data times the number of bytes per pixel,
  1599. * but it might contain additional padding (for example, 24bit RGB Windows
  1600. * Bitmap data pads all rows to multiples of 4 bytes).
  1601. *
  1602. * \param renderer the rendering context
  1603. * \param rect an SDL_Rect structure representing the area to read, or NULL
  1604. * for the entire render target
  1605. * \param format an SDL_PixelFormatEnum value of the desired format of the
  1606. * pixel data, or 0 to use the format of the rendering target
  1607. * \param pixels a pointer to the pixel data to copy into
  1608. * \param pitch the pitch of the `pixels` parameter
  1609. * \returns 0 on success or a negative error code on failure; call
  1610. * SDL_GetError() for more information.
  1611. *
  1612. * \since This function is available since SDL 2.0.0.
  1613. */
  1614. extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
  1615. const SDL_Rect * rect,
  1616. Uint32 format,
  1617. void *pixels, int pitch);
  1618. /**
  1619. * Update the screen with any rendering performed since the previous call.
  1620. *
  1621. * SDL's rendering functions operate on a backbuffer; that is, calling a
  1622. * rendering function such as SDL_RenderDrawLine() does not directly put a
  1623. * line on the screen, but rather updates the backbuffer. As such, you compose
  1624. * your entire scene and *present* the composed backbuffer to the screen as a
  1625. * complete picture.
  1626. *
  1627. * Therefore, when using SDL's rendering API, one does all drawing intended
  1628. * for the frame, and then calls this function once per frame to present the
  1629. * final drawing to the user.
  1630. *
  1631. * The backbuffer should be considered invalidated after each present; do not
  1632. * assume that previous contents will exist between frames. You are strongly
  1633. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  1634. * starting each new frame's drawing, even if you plan to overwrite every
  1635. * pixel.
  1636. *
  1637. * \param renderer the rendering context
  1638. *
  1639. * \since This function is available since SDL 2.0.0.
  1640. *
  1641. * \sa SDL_RenderClear
  1642. * \sa SDL_RenderDrawLine
  1643. * \sa SDL_RenderDrawLines
  1644. * \sa SDL_RenderDrawPoint
  1645. * \sa SDL_RenderDrawPoints
  1646. * \sa SDL_RenderDrawRect
  1647. * \sa SDL_RenderDrawRects
  1648. * \sa SDL_RenderFillRect
  1649. * \sa SDL_RenderFillRects
  1650. * \sa SDL_SetRenderDrawBlendMode
  1651. * \sa SDL_SetRenderDrawColor
  1652. */
  1653. extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
  1654. /**
  1655. * Destroy the specified texture.
  1656. *
  1657. * Passing NULL or an otherwise invalid texture will set the SDL error message
  1658. * to "Invalid texture".
  1659. *
  1660. * \param texture the texture to destroy
  1661. *
  1662. * \since This function is available since SDL 2.0.0.
  1663. *
  1664. * \sa SDL_CreateTexture
  1665. * \sa SDL_CreateTextureFromSurface
  1666. */
  1667. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
  1668. /**
  1669. * Destroy the rendering context for a window and free associated textures.
  1670. *
  1671. * If `renderer` is NULL, this function will return immediately after setting
  1672. * the SDL error message to "Invalid renderer". See SDL_GetError().
  1673. *
  1674. * \param renderer the rendering context
  1675. *
  1676. * \since This function is available since SDL 2.0.0.
  1677. *
  1678. * \sa SDL_CreateRenderer
  1679. */
  1680. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
  1681. /**
  1682. * Force the rendering context to flush any pending commands to the underlying
  1683. * rendering API.
  1684. *
  1685. * You do not need to (and in fact, shouldn't) call this function unless you
  1686. * are planning to call into OpenGL/Direct3D/Metal/whatever directly in
  1687. * addition to using an SDL_Renderer.
  1688. *
  1689. * This is for a very-specific case: if you are using SDL's render API, you
  1690. * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set
  1691. * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
  1692. * calls in addition to SDL render API calls. If all of this applies, you
  1693. * should call SDL_RenderFlush() between calls to SDL's render API and the
  1694. * low-level API you're using in cooperation.
  1695. *
  1696. * In all other cases, you can ignore this function. This is only here to get
  1697. * maximum performance out of a specific situation. In all other cases, SDL
  1698. * will do the right thing, perhaps at a performance loss.
  1699. *
  1700. * This function is first available in SDL 2.0.10, and is not needed in 2.0.9
  1701. * and earlier, as earlier versions did not queue rendering commands at all,
  1702. * instead flushing them to the OS immediately.
  1703. *
  1704. * \param renderer the rendering context
  1705. * \returns 0 on success or a negative error code on failure; call
  1706. * SDL_GetError() for more information.
  1707. *
  1708. * \since This function is available since SDL 2.0.10.
  1709. */
  1710. extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
  1711. /**
  1712. * Bind an OpenGL/ES/ES2 texture to the current context.
  1713. *
  1714. * This is for use with OpenGL instructions when rendering OpenGL primitives
  1715. * directly.
  1716. *
  1717. * If not NULL, `texw` and `texh` will be filled with the width and height
  1718. * values suitable for the provided texture. In most cases, both will be 1.0,
  1719. * however, on systems that support the GL_ARB_texture_rectangle extension,
  1720. * these values will actually be the pixel width and height used to create the
  1721. * texture, so this factor needs to be taken into account when providing
  1722. * texture coordinates to OpenGL.
  1723. *
  1724. * You need a renderer to create an SDL_Texture, therefore you can only use
  1725. * this function with an implicit OpenGL context from SDL_CreateRenderer(),
  1726. * not with your own OpenGL context. If you need control over your OpenGL
  1727. * context, you need to write your own texture-loading methods.
  1728. *
  1729. * Also note that SDL may upload RGB textures as BGR (or vice-versa), and
  1730. * re-order the color channels in the shaders phase, so the uploaded texture
  1731. * may have swapped color channels.
  1732. *
  1733. * \param texture the texture to bind to the current OpenGL/ES/ES2 context
  1734. * \param texw a pointer to a float value which will be filled with the
  1735. * texture width or NULL if you don't need that value
  1736. * \param texh a pointer to a float value which will be filled with the
  1737. * texture height or NULL if you don't need that value
  1738. * \returns 0 on success, or -1 if the operation is not supported; call
  1739. * SDL_GetError() for more information.
  1740. *
  1741. * \since This function is available since SDL 2.0.0.
  1742. *
  1743. * \sa SDL_GL_MakeCurrent
  1744. * \sa SDL_GL_UnbindTexture
  1745. */
  1746. extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
  1747. /**
  1748. * Unbind an OpenGL/ES/ES2 texture from the current context.
  1749. *
  1750. * See SDL_GL_BindTexture() for examples on how to use these functions
  1751. *
  1752. * \param texture the texture to unbind from the current OpenGL/ES/ES2 context
  1753. * \returns 0 on success, or -1 if the operation is not supported
  1754. *
  1755. * \since This function is available since SDL 2.0.0.
  1756. *
  1757. * \sa SDL_GL_BindTexture
  1758. * \sa SDL_GL_MakeCurrent
  1759. */
  1760. extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
  1761. /**
  1762. * Get the CAMetalLayer associated with the given Metal renderer.
  1763. *
  1764. * This function returns `void *`, so SDL doesn't have to include Metal's
  1765. * headers, but it can be safely cast to a `CAMetalLayer *`.
  1766. *
  1767. * \param renderer The renderer to query
  1768. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  1769. * Metal renderer
  1770. *
  1771. * \since This function is available since SDL 2.0.8.
  1772. *
  1773. * \sa SDL_RenderGetMetalCommandEncoder
  1774. */
  1775. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
  1776. /**
  1777. * Get the Metal command encoder for the current frame
  1778. *
  1779. * This function returns `void *`, so SDL doesn't have to include Metal's
  1780. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  1781. *
  1782. * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
  1783. * SDL a drawable to render to, which might happen if the window is
  1784. * hidden/minimized/offscreen. This doesn't apply to command encoders for
  1785. * render targets, just the window's backbacker. Check your return values!
  1786. *
  1787. * \param renderer The renderer to query
  1788. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  1789. * renderer isn't a Metal renderer or there was an error.
  1790. *
  1791. * \since This function is available since SDL 2.0.8.
  1792. *
  1793. * \sa SDL_RenderGetMetalLayer
  1794. */
  1795. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
  1796. /**
  1797. * Toggle VSync of the given renderer.
  1798. *
  1799. * \param renderer The renderer to toggle
  1800. * \param vsync 1 for on, 0 for off. All other values are reserved
  1801. * \returns a 0 int on success, or non-zero on failure
  1802. *
  1803. * \since This function is available since SDL 2.0.18.
  1804. */
  1805. extern DECLSPEC int SDLCALL SDL_RenderSetVSync(SDL_Renderer* renderer, int vsync);
  1806. /* Ends C function definitions when using C++ */
  1807. #ifdef __cplusplus
  1808. }
  1809. #endif
  1810. #include "close_code.h"
  1811. #endif /* SDL_render_h_ */
  1812. /* vi: set ts=4 sw=4 expandtab: */