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

1158 lines
44 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 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. * \brief 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. * \brief 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. * \brief The scaling mode for a texture.
  80. */
  81. typedef enum
  82. {
  83. SDL_ScaleModeNearest, /**< nearest pixel sampling */
  84. SDL_ScaleModeLinear, /**< linear filtering */
  85. SDL_ScaleModeBest /**< anisotropic filtering */
  86. } SDL_ScaleMode;
  87. /**
  88. * \brief The access pattern allowed for a texture.
  89. */
  90. typedef enum
  91. {
  92. SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
  93. SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
  94. SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
  95. } SDL_TextureAccess;
  96. /**
  97. * \brief The texture channel modulation used in SDL_RenderCopy().
  98. */
  99. typedef enum
  100. {
  101. SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */
  102. SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */
  103. SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */
  104. } SDL_TextureModulate;
  105. /**
  106. * \brief Flip constants for SDL_RenderCopyEx
  107. */
  108. typedef enum
  109. {
  110. SDL_FLIP_NONE = 0x00000000, /**< Do not flip */
  111. SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */
  112. SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */
  113. } SDL_RendererFlip;
  114. /**
  115. * \brief A structure representing rendering state
  116. */
  117. struct SDL_Renderer;
  118. typedef struct SDL_Renderer SDL_Renderer;
  119. /**
  120. * \brief An efficient driver-specific representation of pixel data
  121. */
  122. struct SDL_Texture;
  123. typedef struct SDL_Texture SDL_Texture;
  124. /* Function prototypes */
  125. /**
  126. * \brief Get the number of 2D rendering drivers available for the current
  127. * display.
  128. *
  129. * A render driver is a set of code that handles rendering and texture
  130. * management on a particular display. Normally there is only one, but
  131. * some drivers may have several available with different capabilities.
  132. *
  133. * \sa SDL_GetRenderDriverInfo()
  134. * \sa SDL_CreateRenderer()
  135. */
  136. extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
  137. /**
  138. * \brief Get information about a specific 2D rendering driver for the current
  139. * display.
  140. *
  141. * \param index The index of the driver to query information about.
  142. * \param info A pointer to an SDL_RendererInfo struct to be filled with
  143. * information on the rendering driver.
  144. *
  145. * \return 0 on success, -1 if the index was out of range.
  146. *
  147. * \sa SDL_CreateRenderer()
  148. */
  149. extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
  150. SDL_RendererInfo * info);
  151. /**
  152. * \brief Create a window and default renderer
  153. *
  154. * \param width The width of the window
  155. * \param height The height of the window
  156. * \param window_flags The flags used to create the window
  157. * \param window A pointer filled with the window, or NULL on error
  158. * \param renderer A pointer filled with the renderer, or NULL on error
  159. *
  160. * \return 0 on success, or -1 on error
  161. */
  162. extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(
  163. int width, int height, Uint32 window_flags,
  164. SDL_Window **window, SDL_Renderer **renderer);
  165. /**
  166. * \brief Create a 2D rendering context for a window.
  167. *
  168. * \param window The window where rendering is displayed.
  169. * \param index The index of the rendering driver to initialize, or -1 to
  170. * initialize the first one supporting the requested flags.
  171. * \param flags ::SDL_RendererFlags.
  172. *
  173. * \return A valid rendering context or NULL if there was an error.
  174. *
  175. * \sa SDL_CreateSoftwareRenderer()
  176. * \sa SDL_GetRendererInfo()
  177. * \sa SDL_DestroyRenderer()
  178. */
  179. extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
  180. int index, Uint32 flags);
  181. /**
  182. * \brief Create a 2D software rendering context for a surface.
  183. *
  184. * \param surface The surface where rendering is done.
  185. *
  186. * \return A valid rendering context or NULL if there was an error.
  187. *
  188. * \sa SDL_CreateRenderer()
  189. * \sa SDL_DestroyRenderer()
  190. */
  191. extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
  192. /**
  193. * \brief Get the renderer associated with a window.
  194. */
  195. extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
  196. /**
  197. * \brief Get information about a rendering context.
  198. */
  199. extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
  200. SDL_RendererInfo * info);
  201. /**
  202. * \brief Get the output size in pixels of a rendering context.
  203. */
  204. extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer,
  205. int *w, int *h);
  206. /**
  207. * \brief Create a texture for a rendering context.
  208. *
  209. * \param renderer The renderer.
  210. * \param format The format of the texture.
  211. * \param access One of the enumerated values in ::SDL_TextureAccess.
  212. * \param w The width of the texture in pixels.
  213. * \param h The height of the texture in pixels.
  214. *
  215. * \return The created texture is returned, or NULL if no rendering context was
  216. * active, the format was unsupported, or the width or height were out
  217. * of range.
  218. *
  219. * \note The contents of the texture are not defined at creation.
  220. *
  221. * \sa SDL_QueryTexture()
  222. * \sa SDL_UpdateTexture()
  223. * \sa SDL_DestroyTexture()
  224. */
  225. extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
  226. Uint32 format,
  227. int access, int w,
  228. int h);
  229. /**
  230. * \brief Create a texture from an existing surface.
  231. *
  232. * \param renderer The renderer.
  233. * \param surface The surface containing pixel data used to fill the texture.
  234. *
  235. * \return The created texture is returned, or NULL on error.
  236. *
  237. * \note The surface is not modified or freed by this function.
  238. *
  239. * \sa SDL_QueryTexture()
  240. * \sa SDL_DestroyTexture()
  241. */
  242. extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
  243. /**
  244. * \brief Query the attributes of a texture
  245. *
  246. * \param texture A texture to be queried.
  247. * \param format A pointer filled in with the raw format of the texture. The
  248. * actual format may differ, but pixel transfers will use this
  249. * format.
  250. * \param access A pointer filled in with the actual access to the texture.
  251. * \param w A pointer filled in with the width of the texture in pixels.
  252. * \param h A pointer filled in with the height of the texture in pixels.
  253. *
  254. * \return 0 on success, or -1 if the texture is not valid.
  255. */
  256. extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
  257. Uint32 * format, int *access,
  258. int *w, int *h);
  259. /**
  260. * \brief Set an additional color value used in render copy operations.
  261. *
  262. * \param texture The texture to update.
  263. * \param r The red color value multiplied into copy operations.
  264. * \param g The green color value multiplied into copy operations.
  265. * \param b The blue color value multiplied into copy operations.
  266. *
  267. * \return 0 on success, or -1 if the texture is not valid or color modulation
  268. * is not supported.
  269. *
  270. * \sa SDL_GetTextureColorMod()
  271. */
  272. extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
  273. Uint8 r, Uint8 g, Uint8 b);
  274. /**
  275. * \brief Get the additional color value used in render copy operations.
  276. *
  277. * \param texture The texture to query.
  278. * \param r A pointer filled in with the current red color value.
  279. * \param g A pointer filled in with the current green color value.
  280. * \param b A pointer filled in with the current blue color value.
  281. *
  282. * \return 0 on success, or -1 if the texture is not valid.
  283. *
  284. * \sa SDL_SetTextureColorMod()
  285. */
  286. extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
  287. Uint8 * r, Uint8 * g,
  288. Uint8 * b);
  289. /**
  290. * \brief Set an additional alpha value used in render copy operations.
  291. *
  292. * \param texture The texture to update.
  293. * \param alpha The alpha value multiplied into copy operations.
  294. *
  295. * \return 0 on success, or -1 if the texture is not valid or alpha modulation
  296. * is not supported.
  297. *
  298. * \sa SDL_GetTextureAlphaMod()
  299. */
  300. extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
  301. Uint8 alpha);
  302. /**
  303. * \brief Get the additional alpha value used in render copy operations.
  304. *
  305. * \param texture The texture to query.
  306. * \param alpha A pointer filled in with the current alpha value.
  307. *
  308. * \return 0 on success, or -1 if the texture is not valid.
  309. *
  310. * \sa SDL_SetTextureAlphaMod()
  311. */
  312. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
  313. Uint8 * alpha);
  314. /**
  315. * \brief Set the blend mode used for texture copy operations.
  316. *
  317. * \param texture The texture to update.
  318. * \param blendMode ::SDL_BlendMode to use for texture blending.
  319. *
  320. * \return 0 on success, or -1 if the texture is not valid or the blend mode is
  321. * not supported.
  322. *
  323. * \note If the blend mode is not supported, the closest supported mode is
  324. * chosen.
  325. *
  326. * \sa SDL_GetTextureBlendMode()
  327. */
  328. extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
  329. SDL_BlendMode blendMode);
  330. /**
  331. * \brief Get the blend mode used for texture copy operations.
  332. *
  333. * \param texture The texture to query.
  334. * \param blendMode A pointer filled in with the current blend mode.
  335. *
  336. * \return 0 on success, or -1 if the texture is not valid.
  337. *
  338. * \sa SDL_SetTextureBlendMode()
  339. */
  340. extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
  341. SDL_BlendMode *blendMode);
  342. /**
  343. * \brief Set the scale mode used for texture scale operations.
  344. *
  345. * \param texture The texture to update.
  346. * \param scaleMode ::SDL_ScaleMode to use for texture scaling.
  347. *
  348. * \return 0 on success, or -1 if the texture is not valid.
  349. *
  350. * \note If the scale mode is not supported, the closest supported mode is
  351. * chosen.
  352. *
  353. * \sa SDL_GetTextureScaleMode()
  354. */
  355. extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
  356. SDL_ScaleMode scaleMode);
  357. /**
  358. * \brief Get the scale mode used for texture scale operations.
  359. *
  360. * \param texture The texture to query.
  361. * \param scaleMode A pointer filled in with the current scale mode.
  362. *
  363. * \return 0 on success, or -1 if the texture is not valid.
  364. *
  365. * \sa SDL_SetTextureScaleMode()
  366. */
  367. extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
  368. SDL_ScaleMode *scaleMode);
  369. /**
  370. * \brief Update the given texture rectangle with new pixel data.
  371. *
  372. * \param texture The texture to update
  373. * \param rect A pointer to the rectangle of pixels to update, or NULL to
  374. * update the entire texture.
  375. * \param pixels The raw pixel data in the format of the texture.
  376. * \param pitch The number of bytes in a row of pixel data, including padding between lines.
  377. *
  378. * The pixel data must be in the format of the texture. The pixel format can be
  379. * queried with SDL_QueryTexture.
  380. *
  381. * \return 0 on success, or -1 if the texture is not valid.
  382. *
  383. * \note This is a fairly slow function.
  384. */
  385. extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
  386. const SDL_Rect * rect,
  387. const void *pixels, int pitch);
  388. /**
  389. * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
  390. *
  391. * \param texture The texture to update
  392. * \param rect A pointer to the rectangle of pixels to update, or NULL to
  393. * update the entire texture.
  394. * \param Yplane The raw pixel data for the Y plane.
  395. * \param Ypitch The number of bytes between rows of pixel data for the Y plane.
  396. * \param Uplane The raw pixel data for the U plane.
  397. * \param Upitch The number of bytes between rows of pixel data for the U plane.
  398. * \param Vplane The raw pixel data for the V plane.
  399. * \param Vpitch The number of bytes between rows of pixel data for the V plane.
  400. *
  401. * \return 0 on success, or -1 if the texture is not valid.
  402. *
  403. * \note You can use SDL_UpdateTexture() as long as your pixel data is
  404. * a contiguous block of Y and U/V planes in the proper order, but
  405. * this function is available if your pixel data is not contiguous.
  406. */
  407. extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
  408. const SDL_Rect * rect,
  409. const Uint8 *Yplane, int Ypitch,
  410. const Uint8 *Uplane, int Upitch,
  411. const Uint8 *Vplane, int Vpitch);
  412. /**
  413. * \brief Lock a portion of the texture for write-only pixel access.
  414. *
  415. * \param texture The texture to lock for access, which was created with
  416. * ::SDL_TEXTUREACCESS_STREAMING.
  417. * \param rect A pointer to the rectangle to lock for access. If the rect
  418. * is NULL, the entire texture will be locked.
  419. * \param pixels This is filled in with a pointer to the locked pixels,
  420. * appropriately offset by the locked area.
  421. * \param pitch This is filled in with the pitch of the locked pixels.
  422. *
  423. * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
  424. *
  425. * \sa SDL_UnlockTexture()
  426. */
  427. extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
  428. const SDL_Rect * rect,
  429. void **pixels, int *pitch);
  430. /**
  431. * \brief Lock a portion of the texture for write-only pixel access.
  432. * Expose it as a SDL surface.
  433. *
  434. * \param texture The texture to lock for access, which was created with
  435. * ::SDL_TEXTUREACCESS_STREAMING.
  436. * \param rect A pointer to the rectangle to lock for access. If the rect
  437. * is NULL, the entire texture will be locked.
  438. * \param surface This is filled in with a SDL surface representing the locked area
  439. * Surface is freed internally after calling SDL_UnlockTexture or SDL_DestroyTexture.
  440. *
  441. * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
  442. *
  443. * \sa SDL_UnlockTexture()
  444. */
  445. extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
  446. const SDL_Rect *rect,
  447. SDL_Surface **surface);
  448. /**
  449. * \brief Unlock a texture, uploading the changes to video memory, if needed.
  450. * If SDL_LockTextureToSurface() was called for locking, the SDL surface is freed.
  451. *
  452. * \sa SDL_LockTexture()
  453. * \sa SDL_LockTextureToSurface()
  454. */
  455. extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
  456. /**
  457. * \brief Determines whether a window supports the use of render targets
  458. *
  459. * \param renderer The renderer that will be checked
  460. *
  461. * \return SDL_TRUE if supported, SDL_FALSE if not.
  462. */
  463. extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
  464. /**
  465. * \brief Set a texture as the current rendering target.
  466. *
  467. * \param renderer The renderer.
  468. * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
  469. *
  470. * \return 0 on success, or -1 on error
  471. *
  472. * \sa SDL_GetRenderTarget()
  473. */
  474. extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
  475. SDL_Texture *texture);
  476. /**
  477. * \brief Get the current render target or NULL for the default render target.
  478. *
  479. * \return The current render target
  480. *
  481. * \sa SDL_SetRenderTarget()
  482. */
  483. extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  484. /**
  485. * \brief Set device independent resolution for rendering
  486. *
  487. * \param renderer The renderer for which resolution should be set.
  488. * \param w The width of the logical resolution
  489. * \param h The height of the logical resolution
  490. *
  491. * This function uses the viewport and scaling functionality to allow a fixed logical
  492. * resolution for rendering, regardless of the actual output resolution. If the actual
  493. * output resolution doesn't have the same aspect ratio the output rendering will be
  494. * centered within the output display.
  495. *
  496. * If the output display is a window, mouse events in the window will be filtered
  497. * and scaled so they seem to arrive within the logical resolution.
  498. *
  499. * \note If this function results in scaling or subpixel drawing by the
  500. * rendering backend, it will be handled using the appropriate
  501. * quality hints.
  502. *
  503. * \sa SDL_RenderGetLogicalSize()
  504. * \sa SDL_RenderSetScale()
  505. * \sa SDL_RenderSetViewport()
  506. */
  507. extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
  508. /**
  509. * \brief Get device independent resolution for rendering
  510. *
  511. * \param renderer The renderer from which resolution should be queried.
  512. * \param w A pointer filled with the width of the logical resolution
  513. * \param h A pointer filled with the height of the logical resolution
  514. *
  515. * \sa SDL_RenderSetLogicalSize()
  516. */
  517. extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
  518. /**
  519. * \brief Set whether to force integer scales for resolution-independent rendering
  520. *
  521. * \param renderer The renderer for which integer scaling should be set.
  522. * \param enable Enable or disable integer scaling
  523. *
  524. * This function restricts the logical viewport to integer values - that is, when
  525. * a resolution is between two multiples of a logical size, the viewport size is
  526. * rounded down to the lower multiple.
  527. *
  528. * \sa SDL_RenderSetLogicalSize()
  529. */
  530. extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
  531. SDL_bool enable);
  532. /**
  533. * \brief Get whether integer scales are forced for resolution-independent rendering
  534. *
  535. * \param renderer The renderer from which integer scaling should be queried.
  536. *
  537. * \sa SDL_RenderSetIntegerScale()
  538. */
  539. extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
  540. /**
  541. * \brief Set the drawing area for rendering on the current target.
  542. *
  543. * \param renderer The renderer for which the drawing area should be set.
  544. * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
  545. *
  546. * The x,y of the viewport rect represents the origin for rendering.
  547. *
  548. * \return 0 on success, or -1 on error
  549. *
  550. * \note If the window associated with the renderer is resized, the viewport is automatically reset.
  551. *
  552. * \sa SDL_RenderGetViewport()
  553. * \sa SDL_RenderSetLogicalSize()
  554. */
  555. extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
  556. const SDL_Rect * rect);
  557. /**
  558. * \brief Get the drawing area for the current target.
  559. *
  560. * \sa SDL_RenderSetViewport()
  561. */
  562. extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
  563. SDL_Rect * rect);
  564. /**
  565. * \brief Set the clip rectangle for the current target.
  566. *
  567. * \param renderer The renderer for which clip rectangle should be set.
  568. * \param rect A pointer to the rectangle to set as the clip rectangle,
  569. * relative to the viewport, or NULL to disable clipping.
  570. *
  571. * \return 0 on success, or -1 on error
  572. *
  573. * \sa SDL_RenderGetClipRect()
  574. */
  575. extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
  576. const SDL_Rect * rect);
  577. /**
  578. * \brief Get the clip rectangle for the current target.
  579. *
  580. * \param renderer The renderer from which clip rectangle should be queried.
  581. * \param rect A pointer filled in with the current clip rectangle, or
  582. * an empty rectangle if clipping is disabled.
  583. *
  584. * \sa SDL_RenderSetClipRect()
  585. */
  586. extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
  587. SDL_Rect * rect);
  588. /**
  589. * \brief Get whether clipping is enabled on the given renderer.
  590. *
  591. * \param renderer The renderer from which clip state should be queried.
  592. *
  593. * \sa SDL_RenderGetClipRect()
  594. */
  595. extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
  596. /**
  597. * \brief Set the drawing scale for rendering on the current target.
  598. *
  599. * \param renderer The renderer for which the drawing scale should be set.
  600. * \param scaleX The horizontal scaling factor
  601. * \param scaleY The vertical scaling factor
  602. *
  603. * The drawing coordinates are scaled by the x/y scaling factors
  604. * before they are used by the renderer. This allows resolution
  605. * independent drawing with a single coordinate system.
  606. *
  607. * \note If this results in scaling or subpixel drawing by the
  608. * rendering backend, it will be handled using the appropriate
  609. * quality hints. For best results use integer scaling factors.
  610. *
  611. * \sa SDL_RenderGetScale()
  612. * \sa SDL_RenderSetLogicalSize()
  613. */
  614. extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
  615. float scaleX, float scaleY);
  616. /**
  617. * \brief Get the drawing scale for the current target.
  618. *
  619. * \param renderer The renderer from which drawing scale should be queried.
  620. * \param scaleX A pointer filled in with the horizontal scaling factor
  621. * \param scaleY A pointer filled in with the vertical scaling factor
  622. *
  623. * \sa SDL_RenderSetScale()
  624. */
  625. extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
  626. float *scaleX, float *scaleY);
  627. /**
  628. * \brief Set the color used for drawing operations (Rect, Line and Clear).
  629. *
  630. * \param renderer The renderer for which drawing color should be set.
  631. * \param r The red value used to draw on the rendering target.
  632. * \param g The green value used to draw on the rendering target.
  633. * \param b The blue value used to draw on the rendering target.
  634. * \param a The alpha value used to draw on the rendering target, usually
  635. * ::SDL_ALPHA_OPAQUE (255).
  636. *
  637. * \return 0 on success, or -1 on error
  638. */
  639. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
  640. Uint8 r, Uint8 g, Uint8 b,
  641. Uint8 a);
  642. /**
  643. * \brief Get the color used for drawing operations (Rect, Line and Clear).
  644. *
  645. * \param renderer The renderer from which drawing color should be queried.
  646. * \param r A pointer to the red value used to draw on the rendering target.
  647. * \param g A pointer to the green value used to draw on the rendering target.
  648. * \param b A pointer to the blue value used to draw on the rendering target.
  649. * \param a A pointer to the alpha value used to draw on the rendering target,
  650. * usually ::SDL_ALPHA_OPAQUE (255).
  651. *
  652. * \return 0 on success, or -1 on error
  653. */
  654. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
  655. Uint8 * r, Uint8 * g, Uint8 * b,
  656. Uint8 * a);
  657. /**
  658. * \brief Set the blend mode used for drawing operations (Fill and Line).
  659. *
  660. * \param renderer The renderer for which blend mode should be set.
  661. * \param blendMode ::SDL_BlendMode to use for blending.
  662. *
  663. * \return 0 on success, or -1 on error
  664. *
  665. * \note If the blend mode is not supported, the closest supported mode is
  666. * chosen.
  667. *
  668. * \sa SDL_GetRenderDrawBlendMode()
  669. */
  670. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
  671. SDL_BlendMode blendMode);
  672. /**
  673. * \brief Get the blend mode used for drawing operations.
  674. *
  675. * \param renderer The renderer from which blend mode should be queried.
  676. * \param blendMode A pointer filled in with the current blend mode.
  677. *
  678. * \return 0 on success, or -1 on error
  679. *
  680. * \sa SDL_SetRenderDrawBlendMode()
  681. */
  682. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
  683. SDL_BlendMode *blendMode);
  684. /**
  685. * \brief Clear the current rendering target with the drawing color
  686. *
  687. * This function clears the entire rendering target, ignoring the viewport and
  688. * the clip rectangle.
  689. *
  690. * \return 0 on success, or -1 on error
  691. */
  692. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
  693. /**
  694. * \brief Draw a point on the current rendering target.
  695. *
  696. * \param renderer The renderer which should draw a point.
  697. * \param x The x coordinate of the point.
  698. * \param y The y coordinate of the point.
  699. *
  700. * \return 0 on success, or -1 on error
  701. */
  702. extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
  703. int x, int y);
  704. /**
  705. * \brief Draw multiple points on the current rendering target.
  706. *
  707. * \param renderer The renderer which should draw multiple points.
  708. * \param points The points to draw
  709. * \param count The number of points to draw
  710. *
  711. * \return 0 on success, or -1 on error
  712. */
  713. extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
  714. const SDL_Point * points,
  715. int count);
  716. /**
  717. * \brief Draw a line on the current rendering target.
  718. *
  719. * \param renderer The renderer which should draw a line.
  720. * \param x1 The x coordinate of the start point.
  721. * \param y1 The y coordinate of the start point.
  722. * \param x2 The x coordinate of the end point.
  723. * \param y2 The y coordinate of the end point.
  724. *
  725. * \return 0 on success, or -1 on error
  726. */
  727. extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
  728. int x1, int y1, int x2, int y2);
  729. /**
  730. * \brief Draw a series of connected lines on the current rendering target.
  731. *
  732. * \param renderer The renderer which should draw multiple lines.
  733. * \param points The points along the lines
  734. * \param count The number of points, drawing count-1 lines
  735. *
  736. * \return 0 on success, or -1 on error
  737. */
  738. extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
  739. const SDL_Point * points,
  740. int count);
  741. /**
  742. * \brief Draw a rectangle on the current rendering target.
  743. *
  744. * \param renderer The renderer which should draw a rectangle.
  745. * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
  746. *
  747. * \return 0 on success, or -1 on error
  748. */
  749. extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
  750. const SDL_Rect * rect);
  751. /**
  752. * \brief Draw some number of rectangles on the current rendering target.
  753. *
  754. * \param renderer The renderer which should draw multiple rectangles.
  755. * \param rects A pointer to an array of destination rectangles.
  756. * \param count The number of rectangles.
  757. *
  758. * \return 0 on success, or -1 on error
  759. */
  760. extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
  761. const SDL_Rect * rects,
  762. int count);
  763. /**
  764. * \brief Fill a rectangle on the current rendering target with the drawing color.
  765. *
  766. * \param renderer The renderer which should fill a rectangle.
  767. * \param rect A pointer to the destination rectangle, or NULL for the entire
  768. * rendering target.
  769. *
  770. * \return 0 on success, or -1 on error
  771. */
  772. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
  773. const SDL_Rect * rect);
  774. /**
  775. * \brief Fill some number of rectangles on the current rendering target with the drawing color.
  776. *
  777. * \param renderer The renderer which should fill multiple rectangles.
  778. * \param rects A pointer to an array of destination rectangles.
  779. * \param count The number of rectangles.
  780. *
  781. * \return 0 on success, or -1 on error
  782. */
  783. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
  784. const SDL_Rect * rects,
  785. int count);
  786. /**
  787. * \brief Copy a portion of the texture to the current rendering target.
  788. *
  789. * \param renderer The renderer which should copy parts of a texture.
  790. * \param texture The source texture.
  791. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  792. * texture.
  793. * \param dstrect A pointer to the destination rectangle, or NULL for the
  794. * entire rendering target.
  795. *
  796. * \return 0 on success, or -1 on error
  797. */
  798. extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
  799. SDL_Texture * texture,
  800. const SDL_Rect * srcrect,
  801. const SDL_Rect * dstrect);
  802. /**
  803. * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
  804. *
  805. * \param renderer The renderer which should copy parts of a texture.
  806. * \param texture The source texture.
  807. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  808. * texture.
  809. * \param dstrect A pointer to the destination rectangle, or NULL for the
  810. * entire rendering target.
  811. * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
  812. * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
  813. * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture
  814. *
  815. * \return 0 on success, or -1 on error
  816. */
  817. extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
  818. SDL_Texture * texture,
  819. const SDL_Rect * srcrect,
  820. const SDL_Rect * dstrect,
  821. const double angle,
  822. const SDL_Point *center,
  823. const SDL_RendererFlip flip);
  824. /**
  825. * \brief Draw a point on the current rendering target.
  826. *
  827. * \param renderer The renderer which should draw a point.
  828. * \param x The x coordinate of the point.
  829. * \param y The y coordinate of the point.
  830. *
  831. * \return 0 on success, or -1 on error
  832. */
  833. extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
  834. float x, float y);
  835. /**
  836. * \brief Draw multiple points on the current rendering target.
  837. *
  838. * \param renderer The renderer which should draw multiple points.
  839. * \param points The points to draw
  840. * \param count The number of points to draw
  841. *
  842. * \return 0 on success, or -1 on error
  843. */
  844. extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
  845. const SDL_FPoint * points,
  846. int count);
  847. /**
  848. * \brief Draw a line on the current rendering target.
  849. *
  850. * \param renderer The renderer which should draw a line.
  851. * \param x1 The x coordinate of the start point.
  852. * \param y1 The y coordinate of the start point.
  853. * \param x2 The x coordinate of the end point.
  854. * \param y2 The y coordinate of the end point.
  855. *
  856. * \return 0 on success, or -1 on error
  857. */
  858. extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
  859. float x1, float y1, float x2, float y2);
  860. /**
  861. * \brief Draw a series of connected lines on the current rendering target.
  862. *
  863. * \param renderer The renderer which should draw multiple lines.
  864. * \param points The points along the lines
  865. * \param count The number of points, drawing count-1 lines
  866. *
  867. * \return 0 on success, or -1 on error
  868. */
  869. extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
  870. const SDL_FPoint * points,
  871. int count);
  872. /**
  873. * \brief Draw a rectangle on the current rendering target.
  874. *
  875. * \param renderer The renderer which should draw a rectangle.
  876. * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
  877. *
  878. * \return 0 on success, or -1 on error
  879. */
  880. extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
  881. const SDL_FRect * rect);
  882. /**
  883. * \brief Draw some number of rectangles on the current rendering target.
  884. *
  885. * \param renderer The renderer which should draw multiple rectangles.
  886. * \param rects A pointer to an array of destination rectangles.
  887. * \param count The number of rectangles.
  888. *
  889. * \return 0 on success, or -1 on error
  890. */
  891. extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
  892. const SDL_FRect * rects,
  893. int count);
  894. /**
  895. * \brief Fill a rectangle on the current rendering target with the drawing color.
  896. *
  897. * \param renderer The renderer which should fill a rectangle.
  898. * \param rect A pointer to the destination rectangle, or NULL for the entire
  899. * rendering target.
  900. *
  901. * \return 0 on success, or -1 on error
  902. */
  903. extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
  904. const SDL_FRect * rect);
  905. /**
  906. * \brief Fill some number of rectangles on the current rendering target with the drawing color.
  907. *
  908. * \param renderer The renderer which should fill multiple rectangles.
  909. * \param rects A pointer to an array of destination rectangles.
  910. * \param count The number of rectangles.
  911. *
  912. * \return 0 on success, or -1 on error
  913. */
  914. extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
  915. const SDL_FRect * rects,
  916. int count);
  917. /**
  918. * \brief Copy a portion of the texture to the current rendering target.
  919. *
  920. * \param renderer The renderer which should copy parts of a texture.
  921. * \param texture The source texture.
  922. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  923. * texture.
  924. * \param dstrect A pointer to the destination rectangle, or NULL for the
  925. * entire rendering target.
  926. *
  927. * \return 0 on success, or -1 on error
  928. */
  929. extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
  930. SDL_Texture * texture,
  931. const SDL_Rect * srcrect,
  932. const SDL_FRect * dstrect);
  933. /**
  934. * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
  935. *
  936. * \param renderer The renderer which should copy parts of a texture.
  937. * \param texture The source texture.
  938. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  939. * texture.
  940. * \param dstrect A pointer to the destination rectangle, or NULL for the
  941. * entire rendering target.
  942. * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect, rotating it in a clockwise direction
  943. * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done around dstrect.w/2, dstrect.h/2).
  944. * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture
  945. *
  946. * \return 0 on success, or -1 on error
  947. */
  948. extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
  949. SDL_Texture * texture,
  950. const SDL_Rect * srcrect,
  951. const SDL_FRect * dstrect,
  952. const double angle,
  953. const SDL_FPoint *center,
  954. const SDL_RendererFlip flip);
  955. /**
  956. * \brief Read pixels from the current rendering target.
  957. *
  958. * \param renderer The renderer from which pixels should be read.
  959. * \param rect A pointer to the rectangle to read, or NULL for the entire
  960. * render target.
  961. * \param format The desired format of the pixel data, or 0 to use the format
  962. * of the rendering target
  963. * \param pixels A pointer to be filled in with the pixel data
  964. * \param pitch The pitch of the pixels parameter.
  965. *
  966. * \return 0 on success, or -1 if pixel reading is not supported.
  967. *
  968. * \warning This is a very slow operation, and should not be used frequently.
  969. */
  970. extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
  971. const SDL_Rect * rect,
  972. Uint32 format,
  973. void *pixels, int pitch);
  974. /**
  975. * \brief Update the screen with rendering performed.
  976. */
  977. extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
  978. /**
  979. * \brief Destroy the specified texture.
  980. *
  981. * \sa SDL_CreateTexture()
  982. * \sa SDL_CreateTextureFromSurface()
  983. */
  984. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
  985. /**
  986. * \brief Destroy the rendering context for a window and free associated
  987. * textures.
  988. *
  989. * \sa SDL_CreateRenderer()
  990. */
  991. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
  992. /**
  993. * \brief Force the rendering context to flush any pending commands to the
  994. * underlying rendering API.
  995. *
  996. * You do not need to (and in fact, shouldn't) call this function unless
  997. * you are planning to call into OpenGL/Direct3D/Metal/whatever directly
  998. * in addition to using an SDL_Renderer.
  999. *
  1000. * This is for a very-specific case: if you are using SDL's render API,
  1001. * you asked for a specific renderer backend (OpenGL, Direct3D, etc),
  1002. * you set SDL_HINT_RENDER_BATCHING to "1", and you plan to make
  1003. * OpenGL/D3D/whatever calls in addition to SDL render API calls. If all of
  1004. * this applies, you should call SDL_RenderFlush() between calls to SDL's
  1005. * render API and the low-level API you're using in cooperation.
  1006. *
  1007. * In all other cases, you can ignore this function. This is only here to
  1008. * get maximum performance out of a specific situation. In all other cases,
  1009. * SDL will do the right thing, perhaps at a performance loss.
  1010. *
  1011. * This function is first available in SDL 2.0.10, and is not needed in
  1012. * 2.0.9 and earlier, as earlier versions did not queue rendering commands
  1013. * at all, instead flushing them to the OS immediately.
  1014. */
  1015. extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
  1016. /**
  1017. * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with
  1018. * OpenGL instructions.
  1019. *
  1020. * \param texture The SDL texture to bind
  1021. * \param texw A pointer to a float that will be filled with the texture width
  1022. * \param texh A pointer to a float that will be filled with the texture height
  1023. *
  1024. * \return 0 on success, or -1 if the operation is not supported
  1025. */
  1026. extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
  1027. /**
  1028. * \brief Unbind a texture from the current OpenGL/ES/ES2 context.
  1029. *
  1030. * \param texture The SDL texture to unbind
  1031. *
  1032. * \return 0 on success, or -1 if the operation is not supported
  1033. */
  1034. extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
  1035. /**
  1036. * \brief Get the CAMetalLayer associated with the given Metal renderer
  1037. *
  1038. * \param renderer The renderer to query
  1039. *
  1040. * \return CAMetalLayer* on success, or NULL if the renderer isn't a Metal renderer
  1041. *
  1042. * \sa SDL_RenderGetMetalCommandEncoder()
  1043. */
  1044. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
  1045. /**
  1046. * \brief Get the Metal command encoder for the current frame
  1047. *
  1048. * \param renderer The renderer to query
  1049. *
  1050. * \return id<MTLRenderCommandEncoder> on success, or NULL if the renderer isn't a Metal renderer
  1051. *
  1052. * \sa SDL_RenderGetMetalLayer()
  1053. */
  1054. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
  1055. /* Ends C function definitions when using C++ */
  1056. #ifdef __cplusplus
  1057. }
  1058. #endif
  1059. #include "close_code.h"
  1060. #endif /* SDL_render_h_ */
  1061. /* vi: set ts=4 sw=4 expandtab: */