SDL_render.h 71 KB

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