SDL_render.h 72 KB

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