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

1098 lines
42 KiB

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