SDL_render.h 71 KB

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