SDL_render.h 67 KB

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