SDL_render.h 61 KB

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