SDL_render.h 72 KB

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