SDL_render.h 73 KB

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