SDL_render.h 73 KB

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