Counter Strike : Global Offensive Source Code
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.

870 lines
32 KiB

  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2014 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 maximimum texture width */
  76. int max_texture_height; /**< The maximimum 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 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 0 if no rendering context was
  207. * active, the format was unsupported, or the width or height were out
  208. * of range.
  209. *
  210. * \sa SDL_QueryTexture()
  211. * \sa SDL_UpdateTexture()
  212. * \sa SDL_DestroyTexture()
  213. */
  214. extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
  215. Uint32 format,
  216. int access, int w,
  217. int h);
  218. /**
  219. * \brief Create a texture from an existing surface.
  220. *
  221. * \param renderer The renderer.
  222. * \param surface The surface containing pixel data used to fill the texture.
  223. *
  224. * \return The created texture is returned, or 0 on error.
  225. *
  226. * \note The surface is not modified or freed by this function.
  227. *
  228. * \sa SDL_QueryTexture()
  229. * \sa SDL_DestroyTexture()
  230. */
  231. extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
  232. /**
  233. * \brief Query the attributes of a texture
  234. *
  235. * \param texture A texture to be queried.
  236. * \param format A pointer filled in with the raw format of the texture. The
  237. * actual format may differ, but pixel transfers will use this
  238. * format.
  239. * \param access A pointer filled in with the actual access to the texture.
  240. * \param w A pointer filled in with the width of the texture in pixels.
  241. * \param h A pointer filled in with the height of the texture in pixels.
  242. *
  243. * \return 0 on success, or -1 if the texture is not valid.
  244. */
  245. extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
  246. Uint32 * format, int *access,
  247. int *w, int *h);
  248. /**
  249. * \brief Set an additional color value used in render copy operations.
  250. *
  251. * \param texture The texture to update.
  252. * \param r The red color value multiplied into copy operations.
  253. * \param g The green color value multiplied into copy operations.
  254. * \param b The blue color value multiplied into copy operations.
  255. *
  256. * \return 0 on success, or -1 if the texture is not valid or color modulation
  257. * is not supported.
  258. *
  259. * \sa SDL_GetTextureColorMod()
  260. */
  261. extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
  262. Uint8 r, Uint8 g, Uint8 b);
  263. /**
  264. * \brief Get the additional color value used in render copy operations.
  265. *
  266. * \param texture The texture to query.
  267. * \param r A pointer filled in with the current red color value.
  268. * \param g A pointer filled in with the current green color value.
  269. * \param b A pointer filled in with the current blue color value.
  270. *
  271. * \return 0 on success, or -1 if the texture is not valid.
  272. *
  273. * \sa SDL_SetTextureColorMod()
  274. */
  275. extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
  276. Uint8 * r, Uint8 * g,
  277. Uint8 * b);
  278. /**
  279. * \brief Set an additional alpha value used in render copy operations.
  280. *
  281. * \param texture The texture to update.
  282. * \param alpha The alpha value multiplied into copy operations.
  283. *
  284. * \return 0 on success, or -1 if the texture is not valid or alpha modulation
  285. * is not supported.
  286. *
  287. * \sa SDL_GetTextureAlphaMod()
  288. */
  289. extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
  290. Uint8 alpha);
  291. /**
  292. * \brief Get the additional alpha value used in render copy operations.
  293. *
  294. * \param texture The texture to query.
  295. * \param alpha A pointer filled in with the current alpha value.
  296. *
  297. * \return 0 on success, or -1 if the texture is not valid.
  298. *
  299. * \sa SDL_SetTextureAlphaMod()
  300. */
  301. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
  302. Uint8 * alpha);
  303. /**
  304. * \brief Set the blend mode used for texture copy operations.
  305. *
  306. * \param texture The texture to update.
  307. * \param blendMode ::SDL_BlendMode to use for texture blending.
  308. *
  309. * \return 0 on success, or -1 if the texture is not valid or the blend mode is
  310. * not supported.
  311. *
  312. * \note If the blend mode is not supported, the closest supported mode is
  313. * chosen.
  314. *
  315. * \sa SDL_GetTextureBlendMode()
  316. */
  317. extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
  318. SDL_BlendMode blendMode);
  319. /**
  320. * \brief Get the blend mode used for texture copy operations.
  321. *
  322. * \param texture The texture to query.
  323. * \param blendMode A pointer filled in with the current blend mode.
  324. *
  325. * \return 0 on success, or -1 if the texture is not valid.
  326. *
  327. * \sa SDL_SetTextureBlendMode()
  328. */
  329. extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
  330. SDL_BlendMode *blendMode);
  331. /**
  332. * \brief Update the given texture rectangle with new pixel data.
  333. *
  334. * \param texture The texture to update
  335. * \param rect A pointer to the rectangle of pixels to update, or NULL to
  336. * update the entire texture.
  337. * \param pixels The raw pixel data.
  338. * \param pitch The number of bytes between rows of pixel data.
  339. *
  340. * \return 0 on success, or -1 if the texture is not valid.
  341. *
  342. * \note This is a fairly slow function.
  343. */
  344. extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
  345. const SDL_Rect * rect,
  346. const void *pixels, int pitch);
  347. /**
  348. * \brief Update a rectangle within a planar YV12 or IYUV texture with new pixel data.
  349. *
  350. * \param texture The texture to update
  351. * \param rect A pointer to the rectangle of pixels to update, or NULL to
  352. * update the entire texture.
  353. * \param Yplane The raw pixel data for the Y plane.
  354. * \param Ypitch The number of bytes between rows of pixel data for the Y plane.
  355. * \param Uplane The raw pixel data for the U plane.
  356. * \param Upitch The number of bytes between rows of pixel data for the U plane.
  357. * \param Vplane The raw pixel data for the V plane.
  358. * \param Vpitch The number of bytes between rows of pixel data for the V plane.
  359. *
  360. * \return 0 on success, or -1 if the texture is not valid.
  361. *
  362. * \note You can use SDL_UpdateTexture() as long as your pixel data is
  363. * a contiguous block of Y and U/V planes in the proper order, but
  364. * this function is available if your pixel data is not contiguous.
  365. */
  366. extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
  367. const SDL_Rect * rect,
  368. const Uint8 *Yplane, int Ypitch,
  369. const Uint8 *Uplane, int Upitch,
  370. const Uint8 *Vplane, int Vpitch);
  371. /**
  372. * \brief Lock a portion of the texture for write-only pixel access.
  373. *
  374. * \param texture The texture to lock for access, which was created with
  375. * ::SDL_TEXTUREACCESS_STREAMING.
  376. * \param rect A pointer to the rectangle to lock for access. If the rect
  377. * is NULL, the entire texture will be locked.
  378. * \param pixels This is filled in with a pointer to the locked pixels,
  379. * appropriately offset by the locked area.
  380. * \param pitch This is filled in with the pitch of the locked pixels.
  381. *
  382. * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING.
  383. *
  384. * \sa SDL_UnlockTexture()
  385. */
  386. extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
  387. const SDL_Rect * rect,
  388. void **pixels, int *pitch);
  389. /**
  390. * \brief Unlock a texture, uploading the changes to video memory, if needed.
  391. *
  392. * \sa SDL_LockTexture()
  393. */
  394. extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
  395. /**
  396. * \brief Determines whether a window supports the use of render targets
  397. *
  398. * \param renderer The renderer that will be checked
  399. *
  400. * \return SDL_TRUE if supported, SDL_FALSE if not.
  401. */
  402. extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
  403. /**
  404. * \brief Set a texture as the current rendering target.
  405. *
  406. * \param renderer The renderer.
  407. * \param texture The targeted texture, which must be created with the SDL_TEXTUREACCESS_TARGET flag, or NULL for the default render target
  408. *
  409. * \return 0 on success, or -1 on error
  410. *
  411. * \sa SDL_GetRenderTarget()
  412. */
  413. extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
  414. SDL_Texture *texture);
  415. /**
  416. * \brief Get the current render target or NULL for the default render target.
  417. *
  418. * \return The current render target
  419. *
  420. * \sa SDL_SetRenderTarget()
  421. */
  422. extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  423. /**
  424. * \brief Set device independent resolution for rendering
  425. *
  426. * \param renderer The renderer for which resolution should be set.
  427. * \param w The width of the logical resolution
  428. * \param h The height of the logical resolution
  429. *
  430. * This function uses the viewport and scaling functionality to allow a fixed logical
  431. * resolution for rendering, regardless of the actual output resolution. If the actual
  432. * output resolution doesn't have the same aspect ratio the output rendering will be
  433. * centered within the output display.
  434. *
  435. * If the output display is a window, mouse events in the window will be filtered
  436. * and scaled so they seem to arrive within the logical resolution.
  437. *
  438. * \note If this function results in scaling or subpixel drawing by the
  439. * rendering backend, it will be handled using the appropriate
  440. * quality hints.
  441. *
  442. * \sa SDL_RenderGetLogicalSize()
  443. * \sa SDL_RenderSetScale()
  444. * \sa SDL_RenderSetViewport()
  445. */
  446. extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
  447. /**
  448. * \brief Get device independent resolution for rendering
  449. *
  450. * \param renderer The renderer from which resolution should be queried.
  451. * \param w A pointer filled with the width of the logical resolution
  452. * \param h A pointer filled with the height of the logical resolution
  453. *
  454. * \sa SDL_RenderSetLogicalSize()
  455. */
  456. extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
  457. /**
  458. * \brief Set the drawing area for rendering on the current target.
  459. *
  460. * \param renderer The renderer for which the drawing area should be set.
  461. * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target.
  462. *
  463. * The x,y of the viewport rect represents the origin for rendering.
  464. *
  465. * \return 0 on success, or -1 on error
  466. *
  467. * \note If the window associated with the renderer is resized, the viewport is automatically reset.
  468. *
  469. * \sa SDL_RenderGetViewport()
  470. * \sa SDL_RenderSetLogicalSize()
  471. */
  472. extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
  473. const SDL_Rect * rect);
  474. /**
  475. * \brief Get the drawing area for the current target.
  476. *
  477. * \sa SDL_RenderSetViewport()
  478. */
  479. extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
  480. SDL_Rect * rect);
  481. /**
  482. * \brief Set the clip rectangle for the current target.
  483. *
  484. * \param renderer The renderer for which clip rectangle should be set.
  485. * \param rect A pointer to the rectangle to set as the clip rectangle, or
  486. * NULL to disable clipping.
  487. *
  488. * \return 0 on success, or -1 on error
  489. *
  490. * \sa SDL_RenderGetClipRect()
  491. */
  492. extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
  493. const SDL_Rect * rect);
  494. /**
  495. * \brief Get the clip rectangle for the current target.
  496. *
  497. * \param renderer The renderer from which clip rectangle should be queried.
  498. * \param rect A pointer filled in with the current clip rectangle, or
  499. * an empty rectangle if clipping is disabled.
  500. *
  501. * \sa SDL_RenderSetClipRect()
  502. */
  503. extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
  504. SDL_Rect * rect);
  505. /**
  506. * \brief Set the drawing scale for rendering on the current target.
  507. *
  508. * \param renderer The renderer for which the drawing scale should be set.
  509. * \param scaleX The horizontal scaling factor
  510. * \param scaleY The vertical scaling factor
  511. *
  512. * The drawing coordinates are scaled by the x/y scaling factors
  513. * before they are used by the renderer. This allows resolution
  514. * independent drawing with a single coordinate system.
  515. *
  516. * \note If this results in scaling or subpixel drawing by the
  517. * rendering backend, it will be handled using the appropriate
  518. * quality hints. For best results use integer scaling factors.
  519. *
  520. * \sa SDL_RenderGetScale()
  521. * \sa SDL_RenderSetLogicalSize()
  522. */
  523. extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
  524. float scaleX, float scaleY);
  525. /**
  526. * \brief Get the drawing scale for the current target.
  527. *
  528. * \param renderer The renderer from which drawing scale should be queried.
  529. * \param scaleX A pointer filled in with the horizontal scaling factor
  530. * \param scaleY A pointer filled in with the vertical scaling factor
  531. *
  532. * \sa SDL_RenderSetScale()
  533. */
  534. extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
  535. float *scaleX, float *scaleY);
  536. /**
  537. * \brief Set the color used for drawing operations (Rect, Line and Clear).
  538. *
  539. * \param renderer The renderer for which drawing color should be set.
  540. * \param r The red value used to draw on the rendering target.
  541. * \param g The green value used to draw on the rendering target.
  542. * \param b The blue value used to draw on the rendering target.
  543. * \param a The alpha value used to draw on the rendering target, usually
  544. * ::SDL_ALPHA_OPAQUE (255).
  545. *
  546. * \return 0 on success, or -1 on error
  547. */
  548. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
  549. Uint8 r, Uint8 g, Uint8 b,
  550. Uint8 a);
  551. /**
  552. * \brief Get the color used for drawing operations (Rect, Line and Clear).
  553. *
  554. * \param renderer The renderer from which drawing color should be queried.
  555. * \param r A pointer to the red value used to draw on the rendering target.
  556. * \param g A pointer to the green value used to draw on the rendering target.
  557. * \param b A pointer to the blue value used to draw on the rendering target.
  558. * \param a A pointer to the alpha value used to draw on the rendering target,
  559. * usually ::SDL_ALPHA_OPAQUE (255).
  560. *
  561. * \return 0 on success, or -1 on error
  562. */
  563. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
  564. Uint8 * r, Uint8 * g, Uint8 * b,
  565. Uint8 * a);
  566. /**
  567. * \brief Set the blend mode used for drawing operations (Fill and Line).
  568. *
  569. * \param renderer The renderer for which blend mode should be set.
  570. * \param blendMode ::SDL_BlendMode to use for blending.
  571. *
  572. * \return 0 on success, or -1 on error
  573. *
  574. * \note If the blend mode is not supported, the closest supported mode is
  575. * chosen.
  576. *
  577. * \sa SDL_GetRenderDrawBlendMode()
  578. */
  579. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
  580. SDL_BlendMode blendMode);
  581. /**
  582. * \brief Get the blend mode used for drawing operations.
  583. *
  584. * \param renderer The renderer from which blend mode should be queried.
  585. * \param blendMode A pointer filled in with the current blend mode.
  586. *
  587. * \return 0 on success, or -1 on error
  588. *
  589. * \sa SDL_SetRenderDrawBlendMode()
  590. */
  591. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
  592. SDL_BlendMode *blendMode);
  593. /**
  594. * \brief Clear the current rendering target with the drawing color
  595. *
  596. * This function clears the entire rendering target, ignoring the viewport.
  597. *
  598. * \return 0 on success, or -1 on error
  599. */
  600. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
  601. /**
  602. * \brief Draw a point on the current rendering target.
  603. *
  604. * \param renderer The renderer which should draw a point.
  605. * \param x The x coordinate of the point.
  606. * \param y The y coordinate of the point.
  607. *
  608. * \return 0 on success, or -1 on error
  609. */
  610. extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
  611. int x, int y);
  612. /**
  613. * \brief Draw multiple points on the current rendering target.
  614. *
  615. * \param renderer The renderer which should draw multiple points.
  616. * \param points The points to draw
  617. * \param count The number of points to draw
  618. *
  619. * \return 0 on success, or -1 on error
  620. */
  621. extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
  622. const SDL_Point * points,
  623. int count);
  624. /**
  625. * \brief Draw a line on the current rendering target.
  626. *
  627. * \param renderer The renderer which should draw a line.
  628. * \param x1 The x coordinate of the start point.
  629. * \param y1 The y coordinate of the start point.
  630. * \param x2 The x coordinate of the end point.
  631. * \param y2 The y coordinate of the end point.
  632. *
  633. * \return 0 on success, or -1 on error
  634. */
  635. extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
  636. int x1, int y1, int x2, int y2);
  637. /**
  638. * \brief Draw a series of connected lines on the current rendering target.
  639. *
  640. * \param renderer The renderer which should draw multiple lines.
  641. * \param points The points along the lines
  642. * \param count The number of points, drawing count-1 lines
  643. *
  644. * \return 0 on success, or -1 on error
  645. */
  646. extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
  647. const SDL_Point * points,
  648. int count);
  649. /**
  650. * \brief Draw a rectangle on the current rendering target.
  651. *
  652. * \param renderer The renderer which should draw a rectangle.
  653. * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target.
  654. *
  655. * \return 0 on success, or -1 on error
  656. */
  657. extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
  658. const SDL_Rect * rect);
  659. /**
  660. * \brief Draw some number of rectangles on the current rendering target.
  661. *
  662. * \param renderer The renderer which should draw multiple rectangles.
  663. * \param rects A pointer to an array of destination rectangles.
  664. * \param count The number of rectangles.
  665. *
  666. * \return 0 on success, or -1 on error
  667. */
  668. extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
  669. const SDL_Rect * rects,
  670. int count);
  671. /**
  672. * \brief Fill a rectangle on the current rendering target with the drawing color.
  673. *
  674. * \param renderer The renderer which should fill a rectangle.
  675. * \param rect A pointer to the destination rectangle, or NULL for the entire
  676. * rendering target.
  677. *
  678. * \return 0 on success, or -1 on error
  679. */
  680. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
  681. const SDL_Rect * rect);
  682. /**
  683. * \brief Fill some number of rectangles on the current rendering target with the drawing color.
  684. *
  685. * \param renderer The renderer which should fill multiple rectangles.
  686. * \param rects A pointer to an array of destination rectangles.
  687. * \param count The number of rectangles.
  688. *
  689. * \return 0 on success, or -1 on error
  690. */
  691. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
  692. const SDL_Rect * rects,
  693. int count);
  694. /**
  695. * \brief Copy a portion of the texture to the current rendering target.
  696. *
  697. * \param renderer The renderer which should copy parts of a texture.
  698. * \param texture The source texture.
  699. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  700. * texture.
  701. * \param dstrect A pointer to the destination rectangle, or NULL for the
  702. * entire rendering target.
  703. *
  704. * \return 0 on success, or -1 on error
  705. */
  706. extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
  707. SDL_Texture * texture,
  708. const SDL_Rect * srcrect,
  709. const SDL_Rect * dstrect);
  710. /**
  711. * \brief Copy a portion of the source texture to the current rendering target, rotating it by angle around the given center
  712. *
  713. * \param renderer The renderer which should copy parts of a texture.
  714. * \param texture The source texture.
  715. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  716. * texture.
  717. * \param dstrect A pointer to the destination rectangle, or NULL for the
  718. * entire rendering target.
  719. * \param angle An angle in degrees that indicates the rotation that will be applied to dstrect
  720. * \param center A pointer to a point indicating the point around which dstrect will be rotated (if NULL, rotation will be done aroud dstrect.w/2, dstrect.h/2)
  721. * \param flip An SDL_RendererFlip value stating which flipping actions should be performed on the texture
  722. *
  723. * \return 0 on success, or -1 on error
  724. */
  725. extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
  726. SDL_Texture * texture,
  727. const SDL_Rect * srcrect,
  728. const SDL_Rect * dstrect,
  729. const double angle,
  730. const SDL_Point *center,
  731. const SDL_RendererFlip flip);
  732. /**
  733. * \brief Read pixels from the current rendering target.
  734. *
  735. * \param renderer The renderer from which pixels should be read.
  736. * \param rect A pointer to the rectangle to read, or NULL for the entire
  737. * render target.
  738. * \param format The desired format of the pixel data, or 0 to use the format
  739. * of the rendering target
  740. * \param pixels A pointer to be filled in with the pixel data
  741. * \param pitch The pitch of the pixels parameter.
  742. *
  743. * \return 0 on success, or -1 if pixel reading is not supported.
  744. *
  745. * \warning This is a very slow operation, and should not be used frequently.
  746. */
  747. extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
  748. const SDL_Rect * rect,
  749. Uint32 format,
  750. void *pixels, int pitch);
  751. /**
  752. * \brief Update the screen with rendering performed.
  753. */
  754. extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
  755. /**
  756. * \brief Destroy the specified texture.
  757. *
  758. * \sa SDL_CreateTexture()
  759. * \sa SDL_CreateTextureFromSurface()
  760. */
  761. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
  762. /**
  763. * \brief Destroy the rendering context for a window and free associated
  764. * textures.
  765. *
  766. * \sa SDL_CreateRenderer()
  767. */
  768. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
  769. /**
  770. * \brief Bind the texture to the current OpenGL/ES/ES2 context for use with
  771. * OpenGL instructions.
  772. *
  773. * \param texture The SDL texture to bind
  774. * \param texw A pointer to a float that will be filled with the texture width
  775. * \param texh A pointer to a float that will be filled with the texture height
  776. *
  777. * \return 0 on success, or -1 if the operation is not supported
  778. */
  779. extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
  780. /**
  781. * \brief Unbind a texture from the current OpenGL/ES/ES2 context.
  782. *
  783. * \param texture The SDL texture to unbind
  784. *
  785. * \return 0 on success, or -1 if the operation is not supported
  786. */
  787. extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
  788. /* Ends C function definitions when using C++ */
  789. #ifdef __cplusplus
  790. }
  791. #endif
  792. #include "close_code.h"
  793. #endif /* _SDL_render_h */
  794. /* vi: set ts=4 sw=4 expandtab: */