SDL_render.h 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625
  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 copy operations.
  381. *
  382. * \param texture the texture to query
  383. * \param alpha a pointer filled in with the current alpha value
  384. * \returns 0 on success or a negative error code on failure; call
  385. * SDL_GetError() for more information.
  386. *
  387. * \sa SDL_GetTextureColorMod
  388. * \sa SDL_SetTextureAlphaMod
  389. */
  390. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
  391. Uint8 * alpha);
  392. /**
  393. * Set the blend mode for a texture, used by SDL_RenderCopy().
  394. *
  395. * If the blend mode is not supported, the closest supported mode is chosen
  396. * and this function returns -1.
  397. *
  398. * \param texture the texture to update
  399. * \param blendMode the SDL_BlendMode to use for texture blending
  400. * \returns 0 on success or a negative error code on failure; call
  401. * SDL_GetError() for more information.
  402. *
  403. * \sa SDL_GetTextureBlendMode
  404. * \sa SDL_RenderCopy
  405. */
  406. extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
  407. SDL_BlendMode blendMode);
  408. /**
  409. * Get the blend mode used for texture copy operations.
  410. *
  411. * \param texture the texture to query
  412. * \param blendMode a pointer filled in with the current SDL_BlendMode
  413. * \returns 0 on success or a negative error code on failure; call
  414. * SDL_GetError() for more information.
  415. *
  416. * \sa SDL_SetTextureBlendMode
  417. */
  418. extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
  419. SDL_BlendMode *blendMode);
  420. /**
  421. * Set the scale mode used for texture scale operations.
  422. *
  423. * If the scale mode is not supported, the closest supported mode is chosen.
  424. *
  425. * \param texture The texture to update.
  426. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
  427. * \returns 0 on success, or -1 if the texture is not valid.
  428. *
  429. * \sa SDL_GetTextureScaleMode
  430. */
  431. extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
  432. SDL_ScaleMode scaleMode);
  433. /**
  434. * Get the scale mode used for texture scale operations.
  435. *
  436. * \param texture the texture to query.
  437. * \param scaleMode a pointer filled in with the current scale mode.
  438. * \return 0 on success, or -1 if the texture is not valid.
  439. *
  440. * \sa SDL_SetTextureScaleMode
  441. */
  442. extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
  443. SDL_ScaleMode *scaleMode);
  444. /**
  445. * Update the given texture rectangle with new pixel data.
  446. *
  447. * The pixel data must be in the pixel format of the texture. Use
  448. * SDL_QueryTexture() to query the pixel format of the texture.
  449. *
  450. * This is a fairly slow function, intended for use with static textures that
  451. * do not change often.
  452. *
  453. * If the texture is intended to be updated often, it is preferred to create
  454. * the texture as streaming and use the locking functions referenced below.
  455. * While this function will work with streaming textures, for optimization
  456. * reasons you may not get the pixels back if you lock the texture afterward.
  457. *
  458. * \param texture the texture to update
  459. * \param rect an SDL_Rect structure representing the area to update, or NULL
  460. * to update the entire texture
  461. * \param pixels the raw pixel data in the format of the texture
  462. * \param pitch the number of bytes in a row of pixel data, including padding
  463. * between lines
  464. * \returns 0 on success or a negative error code on failure; call
  465. * SDL_GetError() for more information.
  466. *
  467. * \sa SDL_CreateTexture
  468. * \sa SDL_LockTexture
  469. * \sa SDL_UnlockTexture
  470. */
  471. extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
  472. const SDL_Rect * rect,
  473. const void *pixels, int pitch);
  474. /**
  475. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  476. * data.
  477. *
  478. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  479. * block of Y and U/V planes in the proper order, but this function is
  480. * available if your pixel data is not contiguous.
  481. *
  482. * \param texture the texture to update
  483. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  484. * update the entire texture
  485. * \param Yplane the raw pixel data for the Y plane
  486. * \param Ypitch the number of bytes between rows of pixel data for the Y
  487. * plane
  488. * \param Uplane the raw pixel data for the U plane
  489. * \param Upitch the number of bytes between rows of pixel data for the U
  490. * plane
  491. * \param Vplane the raw pixel data for the V plane
  492. * \param Vpitch the number of bytes between rows of pixel data for the V
  493. * plane
  494. * \returns 0 on success or -1 if the texture is not valid; call
  495. * SDL_GetError() for more information.
  496. *
  497. * \since This function is available since SDL 2.0.1.
  498. *
  499. * \sa SDL_UpdateTexture
  500. */
  501. extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
  502. const SDL_Rect * rect,
  503. const Uint8 *Yplane, int Ypitch,
  504. const Uint8 *Uplane, int Upitch,
  505. const Uint8 *Vplane, int Vpitch);
  506. /**
  507. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  508. *
  509. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  510. * block of NV12/21 planes in the proper order, but this function is available
  511. * if your pixel data is not contiguous.
  512. *
  513. * \param texture the texture to update
  514. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  515. * update the entire texture.
  516. * \param Yplane the raw pixel data for the Y plane.
  517. * \param Ypitch the number of bytes between rows of pixel data for the Y
  518. * plane.
  519. * \param UVplane the raw pixel data for the UV plane.
  520. * \param UVpitch the number of bytes between rows of pixel data for the UV
  521. * 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 in
  598. * 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 if
  621. * 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 to render to the
  630. * 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. The SDL_HINT_MOUSE_RELATIVE_SCALING hint controls whether
  665. * relative motion events are also scaled.
  666. *
  667. * If this function results in scaling or subpixel drawing by the rendering
  668. * backend, it will be handled using the appropriate quality hints.
  669. *
  670. * \param renderer the renderer for which resolution should be set
  671. * \param w the width of the logical resolution
  672. * \param h the height of the logical resolution
  673. * \returns 0 on success or a negative error code on failure; call
  674. * SDL_GetError() for more information.
  675. *
  676. * \since This function is available since SDL 2.0.0.
  677. *
  678. * \sa SDL_RenderGetLogicalSize
  679. */
  680. extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
  681. /**
  682. * Get device independent resolution for rendering.
  683. *
  684. * This may return 0 for `w` and `h` if the SDL_Renderer has never had its
  685. * logical size set by SDL_RenderSetLogicalSize() and never had a render
  686. * target set.
  687. *
  688. * \param renderer a rendering context
  689. * \param w an int to be filled with the width
  690. * \param h an int to be filled with the height
  691. *
  692. * \since This function is available since SDL 2.0.0.
  693. *
  694. * \sa SDL_RenderSetLogicalSize
  695. */
  696. extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
  697. /**
  698. * Set whether to force integer scales for resolution-independent rendering.
  699. *
  700. * This function restricts the logical viewport to integer values - that is,
  701. * when a resolution is between two multiples of a logical size, the viewport
  702. * size is rounded down to the lower multiple.
  703. *
  704. * \param renderer the renderer for which integer scaling should be set
  705. * \param enable enable or disable the integer scaling for rendering
  706. * \returns 0 on success or a negative error code on failure; call
  707. * SDL_GetError() for more information.
  708. *
  709. * \since This function is available since SDL 2.0.5.
  710. *
  711. * \sa SDL_RenderGetIntegerScale
  712. * \sa SDL_RenderSetLogicalSize
  713. */
  714. extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
  715. SDL_bool enable);
  716. /**
  717. * Get whether integer scales are forced for resolution-independent rendering.
  718. *
  719. * \param renderer the renderer from which integer scaling should be queried
  720. * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on
  721. * failure; call SDL_GetError() for more information.
  722. *
  723. * \since This function is available since SDL 2.0.5.
  724. *
  725. * \sa SDL_RenderSetIntegerScale
  726. */
  727. extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
  728. /**
  729. * Set the drawing area for rendering on the current target.
  730. *
  731. * When the window is resized, the viewport is reset to fill the entire new
  732. * window size.
  733. *
  734. * \param renderer the rendering context
  735. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  736. * to set the viewport to the entire target
  737. * \returns 0 on success or a negative error code on failure; call
  738. * SDL_GetError() for more information.
  739. *
  740. * \sa SDL_RenderGetViewport
  741. */
  742. extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
  743. const SDL_Rect * rect);
  744. /**
  745. * Get the drawing area for the current target.
  746. *
  747. * \param renderer the rendering context
  748. * \param rect an SDL_Rect structure filled in with the current drawing area
  749. *
  750. * \sa SDL_RenderSetViewport
  751. */
  752. extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
  753. SDL_Rect * rect);
  754. /**
  755. * Set the clip rectangle for rendering on the specified target.
  756. *
  757. * \param renderer the rendering context for which clip rectangle should be
  758. * set
  759. * \param rect an SDL_Rect structure representing the clip area, relative to
  760. * the viewport, or NULL to disable clipping
  761. * \returns 0 on success or a negative error code on failure; call
  762. * SDL_GetError() for more information.
  763. *
  764. * \sa SDL_RenderGetClipRect
  765. * \sa SDL_RenderIsClipEnabled
  766. */
  767. extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
  768. const SDL_Rect * rect);
  769. /**
  770. * Get the clip rectangle for the current target.
  771. *
  772. * \param renderer the rendering context from which clip rectangle should be
  773. * queried
  774. * \param rect an SDL_Rect structure filled in with the current clipping area
  775. * or an empty rectangle if clipping is disabled
  776. *
  777. * \sa SDL_RenderIsClipEnabled
  778. * \sa SDL_RenderSetClipRect
  779. */
  780. extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
  781. SDL_Rect * rect);
  782. /**
  783. * Get whether clipping is enabled on the given renderer.
  784. *
  785. * \param renderer the renderer from which clip state should be queried
  786. * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
  787. * SDL_GetError() for more information.
  788. *
  789. * \since This function is available since SDL 2.0.4.
  790. *
  791. * \sa SDL_RenderGetClipRect
  792. * \sa SDL_RenderSetClipRect
  793. */
  794. extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
  795. /**
  796. * Set the drawing scale for rendering on the current target.
  797. *
  798. * The drawing coordinates are scaled by the x/y scaling factors before they
  799. * are used by the renderer. This allows resolution independent drawing with a
  800. * single coordinate system.
  801. *
  802. * If this results in scaling or subpixel drawing by the rendering backend, it
  803. * will be handled using the appropriate quality hints. For best results use
  804. * integer scaling factors.
  805. *
  806. * \param renderer a rendering context
  807. * \param scaleX the horizontal scaling factor
  808. * \param scaleY the vertical scaling factor
  809. * \returns 0 on success or a negative error code on failure; call
  810. * SDL_GetError() for more information.
  811. *
  812. * \since This function is available since SDL 2.0.0.
  813. *
  814. * \sa SDL_RenderGetScale
  815. * \sa SDL_RenderSetLogicalSize
  816. */
  817. extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
  818. float scaleX, float scaleY);
  819. /**
  820. * Get the drawing scale for the current target.
  821. *
  822. * \param renderer the renderer from which drawing scale should be queried
  823. * \param scaleX a pointer filled in with the horizontal scaling factor
  824. * \param scaleY a pointer filled in with the vertical scaling factor
  825. *
  826. * \since This function is available since SDL 2.0.0.
  827. *
  828. * \sa SDL_RenderSetScale
  829. */
  830. extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
  831. float *scaleX, float *scaleY);
  832. /**
  833. * Set the color used for drawing operations (Rect, Line and Clear).
  834. *
  835. * Set the color for drawing or filling rectangles, lines, and points, and for
  836. * SDL_RenderClear().
  837. *
  838. * \param renderer the rendering context
  839. * \param r the red value used to draw on the rendering target
  840. * \param g the green value used to draw on the rendering target
  841. * \param b the blue value used to draw on the rendering target
  842. * \param a the alpha value used to draw on the rendering target; usually
  843. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  844. * specify how the alpha channel is used
  845. * \returns 0 on success or a negative error code on failure; call
  846. * SDL_GetError() for more information.
  847. *
  848. * \sa SDL_GetRenderDrawColor
  849. * \sa SDL_RenderClear
  850. * \sa SDL_RenderDrawLine
  851. * \sa SDL_RenderDrawLines
  852. * \sa SDL_RenderDrawPoint
  853. * \sa SDL_RenderDrawPoints
  854. * \sa SDL_RenderDrawRect
  855. * \sa SDL_RenderDrawRects
  856. * \sa SDL_RenderFillRect
  857. * \sa SDL_RenderFillRects
  858. */
  859. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
  860. Uint8 r, Uint8 g, Uint8 b,
  861. Uint8 a);
  862. /**
  863. * Get the color used for drawing operations (Rect, Line and Clear).
  864. *
  865. * \param renderer the rendering context
  866. * \param r a pointer filled in with the red value used to draw on the
  867. * rendering target
  868. * \param g a pointer filled in with the green value used to draw on the
  869. * rendering target
  870. * \param b a pointer filled in with the blue value used to draw on the
  871. * rendering target
  872. * \param a a pointer filled in with the alpha value used to draw on the
  873. * rendering target; usually `SDL_ALPHA_OPAQUE` (255)
  874. * \returns 0 on success or a negative error code on failure; call
  875. * SDL_GetError() for more information.
  876. *
  877. * \sa SDL_SetRenderDrawColor
  878. */
  879. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
  880. Uint8 * r, Uint8 * g, Uint8 * b,
  881. Uint8 * a);
  882. /**
  883. * Set the blend mode used for drawing operations (Fill and Line).
  884. *
  885. * If the blend mode is not supported, the closest supported mode is chosen.
  886. *
  887. * \param renderer the rendering context
  888. * \param blendMode the SDL_BlendMode to use for blending
  889. * \returns 0 on success or a negative error code on failure; call
  890. * SDL_GetError() for more information.
  891. *
  892. * \sa SDL_GetRenderDrawBlendMode
  893. * \sa SDL_RenderDrawLine
  894. * \sa SDL_RenderDrawLines
  895. * \sa SDL_RenderDrawPoint
  896. * \sa SDL_RenderDrawPoints
  897. * \sa SDL_RenderDrawRect
  898. * \sa SDL_RenderDrawRects
  899. * \sa SDL_RenderFillRect
  900. * \sa SDL_RenderFillRects
  901. */
  902. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
  903. SDL_BlendMode blendMode);
  904. /**
  905. * Get the blend mode used for drawing operations.
  906. *
  907. * \param renderer the rendering context
  908. * \param blendMode a pointer filled in with the current SDL_BlendMode
  909. * \returns 0 on success or a negative error code on failure; call
  910. * SDL_GetError() for more information.
  911. *
  912. * \sa SDL_SetRenderDrawBlendMode
  913. */
  914. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
  915. SDL_BlendMode *blendMode);
  916. /**
  917. * Clear the current rendering target with the drawing color.
  918. *
  919. * This function clears the entire rendering target, ignoring the viewport and
  920. * the clip rectangle.
  921. *
  922. * \param renderer the rendering context
  923. * \returns 0 on success or a negative error code on failure; call
  924. * SDL_GetError() for more information.
  925. *
  926. * \since This function is available since SDL 2.0.0.
  927. *
  928. * \sa SDL_SetRenderDrawColor
  929. */
  930. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
  931. /**
  932. * Draw a point on the current rendering target.
  933. *
  934. * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple,
  935. * use SDL_RenderDrawPoints() instead.
  936. *
  937. * \param renderer the rendering context
  938. * \param x the x coordinate of the point
  939. * \param y the y coordinate of the point
  940. * \returns 0 on success or a negative error code on failure; call
  941. * SDL_GetError() for more information.
  942. *
  943. * \sa SDL_RenderDrawLine
  944. * \sa SDL_RenderDrawLines
  945. * \sa SDL_RenderDrawPoints
  946. * \sa SDL_RenderDrawRect
  947. * \sa SDL_RenderDrawRects
  948. * \sa SDL_RenderFillRect
  949. * \sa SDL_RenderFillRects
  950. * \sa SDL_RenderPresent
  951. * \sa SDL_SetRenderDrawBlendMode
  952. * \sa SDL_SetRenderDrawColor
  953. */
  954. extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
  955. int x, int y);
  956. /**
  957. * Draw multiple points on the current rendering target.
  958. *
  959. * \param renderer the rendering context
  960. * \param points an array of SDL_Point structures that represent the points to
  961. * draw
  962. * \param count the number of points to draw
  963. * \returns 0 on success or a negative error code on failure; call
  964. * SDL_GetError() for more information.
  965. *
  966. * \sa SDL_RenderDrawLine
  967. * \sa SDL_RenderDrawLines
  968. * \sa SDL_RenderDrawPoint
  969. * \sa SDL_RenderDrawRect
  970. * \sa SDL_RenderDrawRects
  971. * \sa SDL_RenderFillRect
  972. * \sa SDL_RenderFillRects
  973. * \sa SDL_RenderPresent
  974. * \sa SDL_SetRenderDrawBlendMode
  975. * \sa SDL_SetRenderDrawColor
  976. */
  977. extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
  978. const SDL_Point * points,
  979. int count);
  980. /**
  981. * Draw a line on the current rendering target.
  982. *
  983. * SDL_RenderDrawLine() draws the line to include both end points. If you want
  984. * to draw multiple, connecting lines use SDL_RenderDrawLines() instead.
  985. *
  986. * \param renderer the rendering context
  987. * \param x1 the x coordinate of the start point
  988. * \param y1 the y coordinate of the start point
  989. * \param x2 the x coordinate of the end point
  990. * \param y2 the y coordinate of the end point
  991. * \returns 0 on success or a negative error code on failure; call
  992. * SDL_GetError() for more information.
  993. *
  994. * \since This function is available since SDL 2.0.0.
  995. *
  996. * \sa SDL_RenderDrawLines
  997. * \sa SDL_RenderDrawPoint
  998. * \sa SDL_RenderDrawPoints
  999. * \sa SDL_RenderDrawRect
  1000. * \sa SDL_RenderDrawRects
  1001. * \sa SDL_RenderFillRect
  1002. * \sa SDL_RenderFillRects
  1003. * \sa SDL_RenderPresent
  1004. * \sa SDL_SetRenderDrawBlendMode
  1005. * \sa SDL_SetRenderDrawColor
  1006. */
  1007. extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
  1008. int x1, int y1, int x2, int y2);
  1009. /**
  1010. * Draw a series of connected lines on the current rendering target.
  1011. *
  1012. * \param renderer the rendering context
  1013. * \param points an array of SDL_Point structures representing points along
  1014. * the lines
  1015. * \param count the number of points, drawing count-1 lines
  1016. * \returns 0 on success or a negative error code on failure; call
  1017. * SDL_GetError() for more information.
  1018. *
  1019. * \since This function is available since SDL 2.0.0.
  1020. *
  1021. * \sa SDL_RenderDrawLine
  1022. * \sa SDL_RenderDrawPoint
  1023. * \sa SDL_RenderDrawPoints
  1024. * \sa SDL_RenderDrawRect
  1025. * \sa SDL_RenderDrawRects
  1026. * \sa SDL_RenderFillRect
  1027. * \sa SDL_RenderFillRects
  1028. * \sa SDL_RenderPresent
  1029. * \sa SDL_SetRenderDrawBlendMode
  1030. * \sa SDL_SetRenderDrawColor
  1031. */
  1032. extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
  1033. const SDL_Point * points,
  1034. int count);
  1035. /**
  1036. * Draw a rectangle on the current rendering target.
  1037. *
  1038. * \param renderer the rendering context
  1039. * \param rect an SDL_Rect structure representing the rectangle to draw, or
  1040. * NULL to outline the entire rendering target
  1041. * \returns 0 on success or a negative error code on failure; call
  1042. * SDL_GetError() for more information.
  1043. *
  1044. * \sa SDL_RenderDrawLine
  1045. * \sa SDL_RenderDrawLines
  1046. * \sa SDL_RenderDrawPoint
  1047. * \sa SDL_RenderDrawPoints
  1048. * \sa SDL_RenderDrawRects
  1049. * \sa SDL_RenderFillRect
  1050. * \sa SDL_RenderFillRects
  1051. * \sa SDL_RenderPresent
  1052. * \sa SDL_SetRenderDrawBlendMode
  1053. * \sa SDL_SetRenderDrawColor
  1054. */
  1055. extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
  1056. const SDL_Rect * rect);
  1057. /**
  1058. * Draw some number of rectangles on the current rendering target.
  1059. *
  1060. * \param renderer the rendering context
  1061. * \param rects an array of SDL_Rect structures representing the rectangles to
  1062. * be drawn
  1063. * \param count the number of rectangles
  1064. * \returns 0 on success or a negative error code on failure; call
  1065. * SDL_GetError() for more information.
  1066. *
  1067. * \sa SDL_RenderDrawLine
  1068. * \sa SDL_RenderDrawLines
  1069. * \sa SDL_RenderDrawPoint
  1070. * \sa SDL_RenderDrawPoints
  1071. * \sa SDL_RenderDrawRect
  1072. * \sa SDL_RenderFillRect
  1073. * \sa SDL_RenderFillRects
  1074. * \sa SDL_RenderPresent
  1075. * \sa SDL_SetRenderDrawBlendMode
  1076. * \sa SDL_SetRenderDrawColor
  1077. */
  1078. extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
  1079. const SDL_Rect * rects,
  1080. int count);
  1081. /**
  1082. * Fill a rectangle on the current rendering target with the drawing color.
  1083. *
  1084. * The current drawing color is set by SDL_SetRenderDrawColor(), and the
  1085. * color's alpha value is ignored unless blending is enabled with the
  1086. * appropriate call to SDL_SetRenderDrawBlendMode().
  1087. *
  1088. * \param renderer the rendering context
  1089. * \param rect the SDL_Rect structure representing the rectangle to fill, or
  1090. * NULL for the entire rendering target
  1091. * \returns 0 on success or a negative error code on failure; call
  1092. * SDL_GetError() for more information.
  1093. *
  1094. * \sa SDL_RenderDrawLine
  1095. * \sa SDL_RenderDrawLines
  1096. * \sa SDL_RenderDrawPoint
  1097. * \sa SDL_RenderDrawPoints
  1098. * \sa SDL_RenderDrawRect
  1099. * \sa SDL_RenderDrawRects
  1100. * \sa SDL_RenderFillRects
  1101. * \sa SDL_RenderPresent
  1102. * \sa SDL_SetRenderDrawBlendMode
  1103. * \sa SDL_SetRenderDrawColor
  1104. */
  1105. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
  1106. const SDL_Rect * rect);
  1107. /**
  1108. * Fill some number of rectangles on the current rendering target with the
  1109. * drawing color.
  1110. *
  1111. * \param renderer the rendering context
  1112. * \param rects an array of SDL_Rect structures representing the rectangles to
  1113. * be filled
  1114. * \param count the number of rectangles
  1115. * \returns 0 on success or a negative error code on failure; call
  1116. * SDL_GetError() for more information.
  1117. *
  1118. * \sa SDL_RenderDrawLine
  1119. * \sa SDL_RenderDrawLines
  1120. * \sa SDL_RenderDrawPoint
  1121. * \sa SDL_RenderDrawPoints
  1122. * \sa SDL_RenderDrawRect
  1123. * \sa SDL_RenderDrawRects
  1124. * \sa SDL_RenderFillRect
  1125. * \sa SDL_RenderPresent
  1126. */
  1127. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
  1128. const SDL_Rect * rects,
  1129. int count);
  1130. /**
  1131. * Copy a portion of the texture to the current rendering target.
  1132. *
  1133. * The texture is blended with the destination based on its blend mode set
  1134. * with SDL_SetTextureBlendMode().
  1135. *
  1136. * The texture color is affected based on its color modulation set by
  1137. * SDL_SetTextureColorMod().
  1138. *
  1139. * The texture alpha is affected based on its alpha modulation set by
  1140. * SDL_SetTextureAlphaMod().
  1141. *
  1142. * \param renderer the rendering context
  1143. * \param texture the source texture
  1144. * \param srcrect the source SDL_Rect structure or NULL for the entire texture
  1145. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1146. * rendering target; the texture will be stretched to fill the
  1147. * given rectangle
  1148. * \returns 0 on success or a negative error code on failure; call
  1149. * SDL_GetError() for more information.
  1150. *
  1151. * \sa SDL_RenderCopyEx
  1152. * \sa SDL_SetTextureAlphaMod
  1153. * \sa SDL_SetTextureBlendMode
  1154. * \sa SDL_SetTextureColorMod
  1155. */
  1156. extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
  1157. SDL_Texture * texture,
  1158. const SDL_Rect * srcrect,
  1159. const SDL_Rect * dstrect);
  1160. /**
  1161. * Copy a portion of the texture to the current rendering, with optional
  1162. * rotation and flipping.
  1163. *
  1164. * Copy a portion of the texture to the current rendering target, optionally
  1165. * rotating it by angle around the given center and also flipping it
  1166. * top-bottom and/or left-right.
  1167. *
  1168. * The texture is blended with the destination based on its blend mode set
  1169. * with SDL_SetTextureBlendMode().
  1170. *
  1171. * The texture color is affected based on its color modulation set by
  1172. * SDL_SetTextureColorMod().
  1173. *
  1174. * The texture alpha is affected based on its alpha modulation set by
  1175. * SDL_SetTextureAlphaMod().
  1176. *
  1177. * \param renderer the rendering context
  1178. * \param texture the source texture
  1179. * \param srcrect the source SDL_Rect structure or NULL for the entire texture
  1180. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1181. * rendering target
  1182. * \param angle an angle in degrees that indicates the rotation that will be
  1183. * applied to dstrect, rotating it in a clockwise direction
  1184. * \param center a pointer to a point indicating the point around which
  1185. * dstrect will be rotated (if NULL, rotation will be done
  1186. * around `dstrect.w / 2`, `dstrect.h / 2`)
  1187. * \param flip a SDL_RendererFlip value stating which flipping actions should
  1188. * be performed on the texture
  1189. * \returns 0 on success or a negative error code on failure; call
  1190. * SDL_GetError() for more information.
  1191. *
  1192. * \sa SDL_RenderCopy
  1193. * \sa SDL_SetTextureAlphaMod
  1194. * \sa SDL_SetTextureBlendMode
  1195. * \sa SDL_SetTextureColorMod
  1196. */
  1197. extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
  1198. SDL_Texture * texture,
  1199. const SDL_Rect * srcrect,
  1200. const SDL_Rect * dstrect,
  1201. const double angle,
  1202. const SDL_Point *center,
  1203. const SDL_RendererFlip flip);
  1204. /**
  1205. * Draw a point on the current rendering target at subpixel precision.
  1206. *
  1207. * \param renderer The renderer which should draw a point.
  1208. * \param x The x coordinate of the point.
  1209. * \param y The y coordinate of the point.
  1210. * \return 0 on success, or -1 on error
  1211. */
  1212. extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
  1213. float x, float y);
  1214. /**
  1215. * Draw multiple points on the current rendering target at subpixel precision.
  1216. *
  1217. * \param renderer The renderer which should draw multiple points.
  1218. * \param points The points to draw
  1219. * \param count The number of points to draw
  1220. * \return 0 on success, or -1 on error
  1221. */
  1222. extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
  1223. const SDL_FPoint * points,
  1224. int count);
  1225. /**
  1226. * Draw a line on the current rendering target at subpixel precision.
  1227. *
  1228. * \param renderer The renderer which should draw a line.
  1229. * \param x1 The x coordinate of the start point.
  1230. * \param y1 The y coordinate of the start point.
  1231. * \param x2 The x coordinate of the end point.
  1232. * \param y2 The y coordinate of the end point.
  1233. * \return 0 on success, or -1 on error
  1234. */
  1235. extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
  1236. float x1, float y1, float x2, float y2);
  1237. /**
  1238. * Draw a series of connected lines on the current rendering target at
  1239. * subpixel precision.
  1240. *
  1241. * \param renderer The renderer which should draw multiple lines.
  1242. * \param points The points along the lines
  1243. * \param count The number of points, drawing count-1 lines
  1244. * \return 0 on success, or -1 on error
  1245. */
  1246. extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
  1247. const SDL_FPoint * points,
  1248. int count);
  1249. /**
  1250. * Draw a rectangle on the current rendering target at subpixel precision.
  1251. *
  1252. * \param renderer The renderer which should draw a rectangle.
  1253. * \param rect A pointer to the destination rectangle, or NULL to outline the
  1254. * entire rendering target.
  1255. * \return 0 on success, or -1 on error
  1256. */
  1257. extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
  1258. const SDL_FRect * rect);
  1259. /**
  1260. * Draw some number of rectangles on the current rendering target at subpixel
  1261. * precision.
  1262. *
  1263. * \param renderer The renderer which should draw multiple rectangles.
  1264. * \param rects A pointer to an array of destination rectangles.
  1265. * \param count The number of rectangles.
  1266. * \return 0 on success, or -1 on error
  1267. */
  1268. extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
  1269. const SDL_FRect * rects,
  1270. int count);
  1271. /**
  1272. * Fill a rectangle on the current rendering target with the drawing color at
  1273. * subpixel precision.
  1274. *
  1275. * \param renderer The renderer which should fill a rectangle.
  1276. * \param rect A pointer to the destination rectangle, or NULL for the entire
  1277. * rendering target.
  1278. * \return 0 on success, or -1 on error
  1279. */
  1280. extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
  1281. const SDL_FRect * rect);
  1282. /**
  1283. * Fill some number of rectangles on the current rendering target with the
  1284. * drawing color at subpixel precision.
  1285. *
  1286. * \param renderer The renderer which should fill multiple rectangles.
  1287. * \param rects A pointer to an array of destination rectangles.
  1288. * \param count The number of rectangles.
  1289. * \return 0 on success, or -1 on error
  1290. */
  1291. extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
  1292. const SDL_FRect * rects,
  1293. int count);
  1294. /**
  1295. * Copy a portion of the texture to the current rendering target at subpixel
  1296. * precision.
  1297. *
  1298. * \param renderer The renderer which should copy parts of a texture.
  1299. * \param texture The source texture.
  1300. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1301. * texture.
  1302. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1303. * entire rendering target.
  1304. * \return 0 on success, or -1 on error
  1305. */
  1306. extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
  1307. SDL_Texture * texture,
  1308. const SDL_Rect * srcrect,
  1309. const SDL_FRect * dstrect);
  1310. /**
  1311. * Copy a portion of the source texture to the current rendering target, with
  1312. * rotation and flipping, at subpixel precision.
  1313. *
  1314. * \param renderer The renderer which should copy parts of a texture.
  1315. * \param texture The source texture.
  1316. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1317. * texture.
  1318. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1319. * entire rendering target.
  1320. * \param angle An angle in degrees that indicates the rotation that will be
  1321. * applied to dstrect, rotating it in a clockwise direction
  1322. * \param center A pointer to a point indicating the point around which
  1323. * dstrect will be rotated (if NULL, rotation will be done
  1324. * around dstrect.w/2, dstrect.h/2).
  1325. * \param flip An SDL_RendererFlip value stating which flipping actions should
  1326. * be performed on the texture
  1327. * \return 0 on success, or -1 on error
  1328. */
  1329. extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
  1330. SDL_Texture * texture,
  1331. const SDL_Rect * srcrect,
  1332. const SDL_FRect * dstrect,
  1333. const double angle,
  1334. const SDL_FPoint *center,
  1335. const SDL_RendererFlip flip);
  1336. /**
  1337. * Read pixels from the current rendering target to an array of pixels.
  1338. *
  1339. * **WARNING**: This is a very slow operation, and should not be used
  1340. * frequently.
  1341. *
  1342. * `pitch` specifies the number of bytes between rows in the destination
  1343. * `pixels` data. This allows you to write to a subrectangle or have padded
  1344. * rows in the destination. Generally, `pitch` should equal the number of
  1345. * pixels per row in the `pixels` data times the number of bytes per pixel,
  1346. * but it might contain additional padding (for example, 24bit RGB Windows
  1347. * Bitmap data pads all rows to multiples of 4 bytes).
  1348. *
  1349. * \param renderer the rendering context
  1350. * \param rect an SDL_Rect structure representing the area to read, or NULL
  1351. * for the entire render target
  1352. * \param format an SDL_PixelFormatEnum value of the desired format of the
  1353. * pixel data, or 0 to use the format of the rendering target
  1354. * \param pixels a pointer to the pixel data to copy into
  1355. * \param pitch the pitch of the `pixels` parameter
  1356. * \returns 0 on success or a negative error code on failure; call
  1357. * SDL_GetError() for more information.
  1358. */
  1359. extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
  1360. const SDL_Rect * rect,
  1361. Uint32 format,
  1362. void *pixels, int pitch);
  1363. /**
  1364. * Update the screen with any rendering performed since the previous call.
  1365. *
  1366. * SDL's rendering functions operate on a backbuffer; that is, calling a
  1367. * rendering function such as SDL_RenderDrawLine() does not directly put a
  1368. * line on the screen, but rather updates the backbuffer. As such, you compose
  1369. * your entire scene and *present* the composed backbuffer to the screen as a
  1370. * complete picture.
  1371. *
  1372. * Therefore, when using SDL's rendering API, one does all drawing intended
  1373. * for the frame, and then calls this function once per frame to present the
  1374. * final drawing to the user.
  1375. *
  1376. * The backbuffer should be considered invalidated after each present; do not
  1377. * assume that previous contents will exist between frames. You are strongly
  1378. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  1379. * starting each new frame's drawing, even if you plan to overwrite every
  1380. * pixel.
  1381. *
  1382. * \param renderer the rendering context
  1383. *
  1384. * \sa SDL_RenderClear
  1385. * \sa SDL_RenderDrawLine
  1386. * \sa SDL_RenderDrawLines
  1387. * \sa SDL_RenderDrawPoint
  1388. * \sa SDL_RenderDrawPoints
  1389. * \sa SDL_RenderDrawRect
  1390. * \sa SDL_RenderDrawRects
  1391. * \sa SDL_RenderFillRect
  1392. * \sa SDL_RenderFillRects
  1393. * \sa SDL_SetRenderDrawBlendMode
  1394. * \sa SDL_SetRenderDrawColor
  1395. */
  1396. extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
  1397. /**
  1398. * Destroy the specified texture.
  1399. *
  1400. * Passing NULL or an otherwise invalid texture will set the SDL error message
  1401. * to "Invalid texture".
  1402. *
  1403. * \param texture the texture to destroy
  1404. *
  1405. * \sa SDL_CreateTexture
  1406. * \sa SDL_CreateTextureFromSurface
  1407. */
  1408. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
  1409. /**
  1410. * Destroy the rendering context for a window and free associated textures.
  1411. *
  1412. * \param renderer the rendering context
  1413. *
  1414. * \sa SDL_CreateRenderer
  1415. */
  1416. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
  1417. /**
  1418. * Force the rendering context to flush any pending commands to the underlying
  1419. * rendering API.
  1420. *
  1421. * You do not need to (and in fact, shouldn't) call this function unless you
  1422. * are planning to call into OpenGL/Direct3D/Metal/whatever directly in
  1423. * addition to using an SDL_Renderer.
  1424. *
  1425. * This is for a very-specific case: if you are using SDL's render API, you
  1426. * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set
  1427. * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
  1428. * calls in addition to SDL render API calls. If all of this applies, you
  1429. * should call SDL_RenderFlush() between calls to SDL's render API and the
  1430. * low-level API you're using in cooperation.
  1431. *
  1432. * In all other cases, you can ignore this function. This is only here to get
  1433. * maximum performance out of a specific situation. In all other cases, SDL
  1434. * will do the right thing, perhaps at a performance loss.
  1435. *
  1436. * This function is first available in SDL 2.0.10, and is not needed in 2.0.9
  1437. * and earlier, as earlier versions did not queue rendering commands at all,
  1438. * instead flushing them to the OS immediately.
  1439. *
  1440. * \param renderer the rendering context
  1441. * \returns 0 on success or a negative error code on failure; call
  1442. * SDL_GetError() for more information.
  1443. *
  1444. * \since This function is available since SDL 2.0.10.
  1445. */
  1446. extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
  1447. /**
  1448. * Bind an OpenGL/ES/ES2 texture to the current context.
  1449. *
  1450. * This is for use with OpenGL instructions when rendering OpenGL primitives
  1451. * directly.
  1452. *
  1453. * If not NULL, `texw` and `texh` will be filled with the width and height
  1454. * values suitable for the provided texture. In most cases, both will be 1.0,
  1455. * however, on systems that support the GL_ARB_texture_rectangle extension,
  1456. * these values will actually be the pixel width and height used to create the
  1457. * texture, so this factor needs to be taken into account when providing
  1458. * texture coordinates to OpenGL.
  1459. *
  1460. * You need a renderer to create an SDL_Texture, therefore you can only use
  1461. * this function with an implicit OpenGL context from SDL_CreateRenderer(),
  1462. * not with your own OpenGL context. If you need control over your OpenGL
  1463. * context, you need to write your own texture-loading methods.
  1464. *
  1465. * Also note that SDL may upload RGB textures as BGR (or vice-versa), and
  1466. * re-order the color channels in the shaders phase, so the uploaded texture
  1467. * may have swapped color channels.
  1468. *
  1469. * \param texture the texture to bind to the current OpenGL/ES/ES2 context
  1470. * \param texw a pointer to a float value which will be filled with the
  1471. * texture width or NULL if you don't need that value
  1472. * \param texh a pointer to a float value which will be filled with the
  1473. * texture height or NULL if you don't need that value
  1474. * \returns 0 on success, or -1 if the operation is not supported; call
  1475. * SDL_GetError() for more information.
  1476. *
  1477. * \since This function is available since SDL 2.0.0.
  1478. *
  1479. * \sa SDL_GL_MakeCurrent
  1480. * \sa SDL_GL_UnbindTexture
  1481. */
  1482. extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
  1483. /**
  1484. * Unbind an OpenGL/ES/ES2 texture from the current context.
  1485. *
  1486. * See SDL_GL_BindTexture() for examples on how to use these functions
  1487. *
  1488. * \param texture the texture to unbind from the current OpenGL/ES/ES2 context
  1489. * \returns 0 on success, or -1 if the operation is not supported
  1490. *
  1491. * \sa SDL_GL_BindTexture
  1492. * \sa SDL_GL_MakeCurrent
  1493. */
  1494. extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
  1495. /**
  1496. * Get the CAMetalLayer associated with the given Metal renderer.
  1497. *
  1498. * This function returns `void *`, so SDL doesn't have to include Metal's
  1499. * headers, but it can be safely cast to a `CAMetalLayer *`.
  1500. *
  1501. * \param renderer The renderer to query
  1502. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  1503. * Metal renderer
  1504. *
  1505. * \sa SDL_RenderGetMetalCommandEncoder
  1506. */
  1507. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
  1508. /**
  1509. * Get the Metal command encoder for the current frame
  1510. *
  1511. * This function returns `void *`, so SDL doesn't have to include Metal's
  1512. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  1513. *
  1514. * \param renderer The renderer to query
  1515. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  1516. * renderer isn't a Metal renderer.
  1517. *
  1518. * \sa SDL_RenderGetMetalLayer
  1519. */
  1520. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
  1521. /* Ends C function definitions when using C++ */
  1522. #ifdef __cplusplus
  1523. }
  1524. #endif
  1525. #include "close_code.h"
  1526. #endif /* SDL_render_h_ */
  1527. /* vi: set ts=4 sw=4 expandtab: */