SDL_render.h 71 KB

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