SDL_render.h 65 KB

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