SDL_render.h 101 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * # CategoryRender
  20. *
  21. * Header file for SDL 2D rendering functions.
  22. *
  23. * This API supports the following features:
  24. *
  25. * - single pixel points
  26. * - single pixel lines
  27. * - filled rectangles
  28. * - texture images
  29. * - 2D polygons
  30. *
  31. * The primitives may be drawn in opaque, blended, or additive modes.
  32. *
  33. * The texture images may be drawn in opaque, blended, or additive modes. They
  34. * can have an additional color tint or alpha modulation applied to them, and
  35. * may also be stretched with linear interpolation.
  36. *
  37. * This API is designed to accelerate simple 2D operations. You may want more
  38. * functionality such as polygons and particle effects and in that case you
  39. * should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the
  40. * many good 3D engines.
  41. *
  42. * These functions must be called from the main thread. See this bug for
  43. * details: https://github.com/libsdl-org/SDL/issues/986
  44. */
  45. #ifndef SDL_render_h_
  46. #define SDL_render_h_
  47. #include <SDL3/SDL_stdinc.h>
  48. #include <SDL3/SDL_blendmode.h>
  49. #include <SDL3/SDL_error.h>
  50. #include <SDL3/SDL_events.h>
  51. #include <SDL3/SDL_pixels.h>
  52. #include <SDL3/SDL_properties.h>
  53. #include <SDL3/SDL_rect.h>
  54. #include <SDL3/SDL_surface.h>
  55. #include <SDL3/SDL_video.h>
  56. #include <SDL3/SDL_begin_code.h>
  57. /* Set up for C function definitions, even when using C++ */
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. /**
  62. * The name of the software renderer.
  63. *
  64. * \since This macro is available since SDL 3.0.0.
  65. */
  66. #define SDL_SOFTWARE_RENDERER "software"
  67. /**
  68. * Vertex structure.
  69. *
  70. * \since This struct is available since SDL 3.0.0.
  71. */
  72. typedef struct SDL_Vertex
  73. {
  74. SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */
  75. SDL_FColor color; /**< Vertex color */
  76. SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
  77. } SDL_Vertex;
  78. /**
  79. * The access pattern allowed for a texture.
  80. *
  81. * \since This enum is available since SDL 3.0.0.
  82. */
  83. typedef enum SDL_TextureAccess
  84. {
  85. SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
  86. SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
  87. SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
  88. } SDL_TextureAccess;
  89. /**
  90. * How the logical size is mapped to the output.
  91. *
  92. * \since This enum is available since SDL 3.0.0.
  93. */
  94. typedef enum SDL_RendererLogicalPresentation
  95. {
  96. SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */
  97. SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */
  98. SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */
  99. SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */
  100. SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */
  101. } SDL_RendererLogicalPresentation;
  102. /**
  103. * A structure representing rendering state
  104. *
  105. * \since This struct is available since SDL 3.0.0.
  106. */
  107. typedef struct SDL_Renderer SDL_Renderer;
  108. #ifndef SDL_INTERNAL
  109. /**
  110. * An efficient driver-specific representation of pixel data
  111. *
  112. * \since This struct is available since SDL 3.0.0.
  113. *
  114. * \sa SDL_CreateTexture
  115. * \sa SDL_CreateTextureFromSurface
  116. * \sa SDL_CreateTextureWithProperties
  117. * \sa SDL_DestroyTexture
  118. */
  119. struct SDL_Texture
  120. {
  121. SDL_PixelFormat format; /**< The format of the texture, read-only */
  122. int w; /**< The width of the texture, read-only. */
  123. int h; /**< The height of the texture, read-only. */
  124. int refcount; /**< Application reference count, used when freeing texture */
  125. };
  126. #endif /* !SDL_INTERNAL */
  127. typedef struct SDL_Texture SDL_Texture;
  128. /* Function prototypes */
  129. /**
  130. * Get the number of 2D rendering drivers available for the current display.
  131. *
  132. * A render driver is a set of code that handles rendering and texture
  133. * management on a particular display. Normally there is only one, but some
  134. * drivers may have several available with different capabilities.
  135. *
  136. * There may be none if SDL was compiled without render support.
  137. *
  138. * \returns the number of built in render drivers.
  139. *
  140. * \threadsafety It is safe to call this function from any thread.
  141. *
  142. * \since This function is available since SDL 3.0.0.
  143. *
  144. * \sa SDL_CreateRenderer
  145. * \sa SDL_GetRenderDriver
  146. */
  147. extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
  148. /**
  149. * Use this function to get the name of a built in 2D rendering driver.
  150. *
  151. * The list of rendering drivers is given in the order that they are normally
  152. * initialized by default; the drivers that seem more reasonable to choose
  153. * first (as far as the SDL developers believe) are earlier in the list.
  154. *
  155. * The names of drivers are all simple, low-ASCII identifiers, like "opengl",
  156. * "direct3d12" or "metal". These never have Unicode characters, and are not
  157. * meant to be proper names.
  158. *
  159. * \param index the index of the rendering driver; the value ranges from 0 to
  160. * SDL_GetNumRenderDrivers() - 1.
  161. * \returns the name of the rendering driver at the requested index, or NULL
  162. * if an invalid index was specified.
  163. *
  164. * \threadsafety It is safe to call this function from any thread.
  165. *
  166. * \since This function is available since SDL 3.0.0.
  167. *
  168. * \sa SDL_GetNumRenderDrivers
  169. */
  170. extern SDL_DECLSPEC const char * SDLCALL SDL_GetRenderDriver(int index);
  171. /**
  172. * Create a window and default renderer.
  173. *
  174. * \param title the title of the window, in UTF-8 encoding.
  175. * \param width the width of the window.
  176. * \param height the height of the window.
  177. * \param window_flags the flags used to create the window (see
  178. * SDL_CreateWindow()).
  179. * \param window a pointer filled with the window, or NULL on error.
  180. * \param renderer a pointer filled with the renderer, or NULL on error.
  181. * \returns true on success or false on failure; call SDL_GetError() for more
  182. * information.
  183. *
  184. * \threadsafety You may only call this function from the main thread.
  185. *
  186. * \since This function is available since SDL 3.0.0.
  187. *
  188. * \sa SDL_CreateRenderer
  189. * \sa SDL_CreateWindow
  190. */
  191. extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer);
  192. /**
  193. * Create a 2D rendering context for a window.
  194. *
  195. * If you want a specific renderer, you can specify its name here. A list of
  196. * available renderers can be obtained by calling SDL_GetRenderDriver multiple
  197. * times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you don't
  198. * need a specific renderer, specify NULL and SDL will attempt to choose the
  199. * best option for you, based on what is available on the user's system.
  200. *
  201. * By default the rendering size matches the window size in pixels, but you
  202. * can call SDL_SetRenderLogicalPresentation() to change the content size and
  203. * scaling options.
  204. *
  205. * \param window the window where rendering is displayed.
  206. * \param name the name of the rendering driver to initialize, or NULL to
  207. * initialize the first one supporting the requested flags.
  208. * \returns a valid rendering context or NULL if there was an error; call
  209. * SDL_GetError() for more information.
  210. *
  211. * \threadsafety You may only call this function from the main thread.
  212. *
  213. * \since This function is available since SDL 3.0.0.
  214. *
  215. * \sa SDL_CreateRendererWithProperties
  216. * \sa SDL_CreateSoftwareRenderer
  217. * \sa SDL_DestroyRenderer
  218. * \sa SDL_GetNumRenderDrivers
  219. * \sa SDL_GetRenderDriver
  220. * \sa SDL_GetRendererName
  221. */
  222. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name);
  223. /**
  224. * Create a 2D rendering context for a window, with the specified properties.
  225. *
  226. * These are the supported properties:
  227. *
  228. * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver
  229. * to use, if a specific one is desired
  230. * - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is
  231. * displayed, required if this isn't a software renderer using a surface
  232. * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering
  233. * is displayed, if you want a software renderer without a window
  234. * - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace
  235. * value describing the colorspace for output to the display, defaults to
  236. * SDL_COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers
  237. * support SDL_COLORSPACE_SRGB_LINEAR, which is a linear color space and
  238. * supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing
  239. * still uses the sRGB colorspace, but values can go beyond 1.0 and float
  240. * (linear) format textures can be used for HDR content.
  241. * - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want
  242. * present synchronized with the refresh rate. This property can take any
  243. * value that is supported by SDL_SetRenderVSync() for the renderer.
  244. *
  245. * With the vulkan renderer:
  246. *
  247. * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use
  248. * with the renderer, optional.
  249. * - `SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR to use
  250. * with the renderer, optional.
  251. * - `SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`: the
  252. * VkPhysicalDevice to use with the renderer, optional.
  253. * - `SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`: the VkDevice to use
  254. * with the renderer, optional.
  255. * - `SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the
  256. * queue family index used for rendering.
  257. * - `SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the
  258. * queue family index used for presentation.
  259. *
  260. * \param props the properties to use.
  261. * \returns a valid rendering context or NULL if there was an error; call
  262. * SDL_GetError() for more information.
  263. *
  264. * \threadsafety You may only call this function from the main thread.
  265. *
  266. * \since This function is available since SDL 3.0.0.
  267. *
  268. * \sa SDL_CreateProperties
  269. * \sa SDL_CreateRenderer
  270. * \sa SDL_CreateSoftwareRenderer
  271. * \sa SDL_DestroyRenderer
  272. * \sa SDL_GetRendererName
  273. */
  274. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props);
  275. #define SDL_PROP_RENDERER_CREATE_NAME_STRING "SDL.renderer.create.name"
  276. #define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "SDL.renderer.create.window"
  277. #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface"
  278. #define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace"
  279. #define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync"
  280. #define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance"
  281. #define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface"
  282. #define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device"
  283. #define SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER "SDL.renderer.create.vulkan.device"
  284. #define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index"
  285. #define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index"
  286. /**
  287. * Create a 2D software rendering context for a surface.
  288. *
  289. * Two other API which can be used to create SDL_Renderer:
  290. * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_
  291. * create a software renderer, but they are intended to be used with an
  292. * SDL_Window as the final destination and not an SDL_Surface.
  293. *
  294. * \param surface the SDL_Surface structure representing the surface where
  295. * rendering is done.
  296. * \returns a valid rendering context or NULL if there was an error; call
  297. * SDL_GetError() for more information.
  298. *
  299. * \threadsafety You may only call this function from the main thread.
  300. *
  301. * \since This function is available since SDL 3.0.0.
  302. *
  303. * \sa SDL_DestroyRenderer
  304. */
  305. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface);
  306. /**
  307. * Get the renderer associated with a window.
  308. *
  309. * \param window the window to query.
  310. * \returns the rendering context on success or NULL on failure; call
  311. * SDL_GetError() for more information.
  312. *
  313. * \threadsafety It is safe to call this function from any thread.
  314. *
  315. * \since This function is available since SDL 3.0.0.
  316. */
  317. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window *window);
  318. /**
  319. * Get the window associated with a renderer.
  320. *
  321. * \param renderer the renderer to query.
  322. * \returns the window on success or NULL on failure; call SDL_GetError() for
  323. * more information.
  324. *
  325. * \threadsafety It is safe to call this function from any thread.
  326. *
  327. * \since This function is available since SDL 3.0.0.
  328. */
  329. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);
  330. /**
  331. * Get the name of a renderer.
  332. *
  333. * \param renderer the rendering context.
  334. * \returns the name of the selected renderer, or NULL on failure; call
  335. * SDL_GetError() for more information.
  336. *
  337. * \threadsafety It is safe to call this function from any thread.
  338. *
  339. * \since This function is available since SDL 3.0.0.
  340. *
  341. * \sa SDL_CreateRenderer
  342. * \sa SDL_CreateRendererWithProperties
  343. */
  344. extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *renderer);
  345. /**
  346. * Get the properties associated with a renderer.
  347. *
  348. * The following read-only properties are provided by SDL:
  349. *
  350. * - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver
  351. * - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is
  352. * displayed, if any
  353. * - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is
  354. * displayed, if this is a software renderer without a window
  355. * - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting
  356. * - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width
  357. * and height
  358. * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *)
  359. * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
  360. * representing the available texture formats for this renderer.
  361. * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace value
  362. * describing the colorspace for output to the display, defaults to
  363. * SDL_COLORSPACE_SRGB.
  364. * - `SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`: true if the output colorspace is
  365. * SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with
  366. * HDR enabled. This property can change dynamically when
  367. * SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
  368. * - `SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the
  369. * SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is
  370. * automatically multiplied into the color scale. This property can change
  371. * dynamically when SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
  372. * - `SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`: the additional high dynamic range
  373. * that can be displayed, in terms of the SDR white point. When HDR is not
  374. * enabled, this will be 1.0. This property can change dynamically when
  375. * SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
  376. *
  377. * With the direct3d renderer:
  378. *
  379. * - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated
  380. * with the renderer
  381. *
  382. * With the direct3d11 renderer:
  383. *
  384. * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated
  385. * with the renderer
  386. * - `SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`: the IDXGISwapChain1
  387. * associated with the renderer. This may change when the window is resized.
  388. *
  389. * With the direct3d12 renderer:
  390. *
  391. * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated
  392. * with the renderer
  393. * - `SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`: the IDXGISwapChain4
  394. * associated with the renderer.
  395. * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue
  396. * associated with the renderer
  397. *
  398. * With the vulkan renderer:
  399. *
  400. * - `SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`: the VkInstance associated
  401. * with the renderer
  402. * - `SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR associated
  403. * with the renderer
  404. * - `SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`: the VkPhysicalDevice
  405. * associated with the renderer
  406. * - `SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`: the VkDevice associated with
  407. * the renderer
  408. * - `SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the queue
  409. * family index used for rendering
  410. * - `SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the queue
  411. * family index used for presentation
  412. * - `SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`: the number of
  413. * swapchain images, or potential frames in flight, used by the Vulkan
  414. * renderer
  415. *
  416. * \param renderer the rendering context.
  417. * \returns a valid property ID on success or 0 on failure; call
  418. * SDL_GetError() for more information.
  419. *
  420. * \threadsafety It is safe to call this function from any thread.
  421. *
  422. * \since This function is available since SDL 3.0.0.
  423. */
  424. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer);
  425. #define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name"
  426. #define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window"
  427. #define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface"
  428. #define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync"
  429. #define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size"
  430. #define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats"
  431. #define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace"
  432. #define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled"
  433. #define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point"
  434. #define SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT "SDL.renderer.HDR_headroom"
  435. #define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device"
  436. #define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device"
  437. #define SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER "SDL.renderer.d3d11.swap_chain"
  438. #define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device"
  439. #define SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER "SDL.renderer.d3d12.swap_chain"
  440. #define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue"
  441. #define SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER "SDL.renderer.vulkan.instance"
  442. #define SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER "SDL.renderer.vulkan.surface"
  443. #define SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.vulkan.physical_device"
  444. #define SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER "SDL.renderer.vulkan.device"
  445. #define SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.graphics_queue_family_index"
  446. #define SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.present_queue_family_index"
  447. #define SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER "SDL.renderer.vulkan.swapchain_image_count"
  448. /**
  449. * Get the output size in pixels of a rendering context.
  450. *
  451. * This returns the true output size in pixels, ignoring any render targets or
  452. * logical size and presentation.
  453. *
  454. * \param renderer the rendering context.
  455. * \param w a pointer filled in with the width in pixels.
  456. * \param h a pointer filled in with the height in pixels.
  457. * \returns true on success or false on failure; call SDL_GetError() for more
  458. * information.
  459. *
  460. * \threadsafety You may only call this function from the main thread.
  461. *
  462. * \since This function is available since SDL 3.0.0.
  463. *
  464. * \sa SDL_GetCurrentRenderOutputSize
  465. */
  466. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  467. /**
  468. * Get the current output size in pixels of a rendering context.
  469. *
  470. * If a rendering target is active, this will return the size of the rendering
  471. * target in pixels, otherwise if a logical size is set, it will return the
  472. * logical size, otherwise it will return the value of
  473. * SDL_GetRenderOutputSize().
  474. *
  475. * \param renderer the rendering context.
  476. * \param w a pointer filled in with the current width.
  477. * \param h a pointer filled in with the current height.
  478. * \returns true on success or false on failure; call SDL_GetError() for more
  479. * information.
  480. *
  481. * \threadsafety You may only call this function from the main thread.
  482. *
  483. * \since This function is available since SDL 3.0.0.
  484. *
  485. * \sa SDL_GetRenderOutputSize
  486. */
  487. extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  488. /**
  489. * Create a texture for a rendering context.
  490. *
  491. * The contents of a texture when first created are not defined.
  492. *
  493. * \param renderer the rendering context.
  494. * \param format one of the enumerated values in SDL_PixelFormat.
  495. * \param access one of the enumerated values in SDL_TextureAccess.
  496. * \param w the width of the texture in pixels.
  497. * \param h the height of the texture in pixels.
  498. * \returns a pointer to the created texture or NULL if no rendering context
  499. * was active, the format was unsupported, or the width or height
  500. * were out of range; call SDL_GetError() for more information.
  501. *
  502. * \threadsafety You may only call this function from the main thread.
  503. *
  504. * \since This function is available since SDL 3.0.0.
  505. *
  506. * \sa SDL_CreateTextureFromSurface
  507. * \sa SDL_CreateTextureWithProperties
  508. * \sa SDL_DestroyTexture
  509. * \sa SDL_GetTextureSize
  510. * \sa SDL_UpdateTexture
  511. */
  512. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h);
  513. /**
  514. * Create a texture from an existing surface.
  515. *
  516. * The surface is not modified or freed by this function.
  517. *
  518. * The SDL_TextureAccess hint for the created texture is
  519. * `SDL_TEXTUREACCESS_STATIC`.
  520. *
  521. * The pixel format of the created texture may be different from the pixel
  522. * format of the surface, and can be queried using the
  523. * SDL_PROP_TEXTURE_FORMAT_NUMBER property.
  524. *
  525. * \param renderer the rendering context.
  526. * \param surface the SDL_Surface structure containing pixel data used to fill
  527. * the texture.
  528. * \returns the created texture or NULL on failure; call SDL_GetError() for
  529. * more information.
  530. *
  531. * \threadsafety You may only call this function from the main thread.
  532. *
  533. * \since This function is available since SDL 3.0.0.
  534. *
  535. * \sa SDL_CreateTexture
  536. * \sa SDL_CreateTextureWithProperties
  537. * \sa SDL_DestroyTexture
  538. */
  539. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
  540. /**
  541. * Create a texture for a rendering context with the specified properties.
  542. *
  543. * These are the supported properties:
  544. *
  545. * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_ColorSpace value
  546. * describing the texture colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR
  547. * for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures,
  548. * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for
  549. * YUV textures.
  550. * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in
  551. * SDL_PixelFormat, defaults to the best RGBA format for the renderer
  552. * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in
  553. * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC
  554. * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in
  555. * pixels, required
  556. * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in
  557. * pixels, required
  558. * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating
  559. * point textures, this defines the value of 100% diffuse white, with higher
  560. * values being displayed in the High Dynamic Range headroom. This defaults
  561. * to 100 for HDR10 textures and 1.0 for floating point textures.
  562. * - `SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`: for HDR10 and floating
  563. * point textures, this defines the maximum dynamic range used by the
  564. * content, in terms of the SDR white point. This would be equivalent to
  565. * maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content.
  566. * If this is defined, any values outside the range supported by the display
  567. * will be scaled into the available HDR headroom, otherwise they are
  568. * clipped.
  569. *
  570. * With the direct3d11 renderer:
  571. *
  572. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D
  573. * associated with the texture, if you want to wrap an existing texture.
  574. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  575. * associated with the U plane of a YUV texture, if you want to wrap an
  576. * existing texture.
  577. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  578. * associated with the V plane of a YUV texture, if you want to wrap an
  579. * existing texture.
  580. *
  581. * With the direct3d12 renderer:
  582. *
  583. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource
  584. * associated with the texture, if you want to wrap an existing texture.
  585. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource
  586. * associated with the U plane of a YUV texture, if you want to wrap an
  587. * existing texture.
  588. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource
  589. * associated with the V plane of a YUV texture, if you want to wrap an
  590. * existing texture.
  591. *
  592. * With the metal renderer:
  593. *
  594. * - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef
  595. * associated with the texture, if you want to create a texture from an
  596. * existing pixel buffer.
  597. *
  598. * With the opengl renderer:
  599. *
  600. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture
  601. * associated with the texture, if you want to wrap an existing texture.
  602. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  603. * associated with the UV plane of an NV12 texture, if you want to wrap an
  604. * existing texture.
  605. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture
  606. * associated with the U plane of a YUV texture, if you want to wrap an
  607. * existing texture.
  608. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture
  609. * associated with the V plane of a YUV texture, if you want to wrap an
  610. * existing texture.
  611. *
  612. * With the opengles2 renderer:
  613. *
  614. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  615. * associated with the texture, if you want to wrap an existing texture.
  616. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  617. * associated with the texture, if you want to wrap an existing texture.
  618. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  619. * associated with the UV plane of an NV12 texture, if you want to wrap an
  620. * existing texture.
  621. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  622. * associated with the U plane of a YUV texture, if you want to wrap an
  623. * existing texture.
  624. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  625. * associated with the V plane of a YUV texture, if you want to wrap an
  626. * existing texture.
  627. *
  628. * With the vulkan renderer:
  629. *
  630. * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage with layout
  631. * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if
  632. * you want to wrap an existing texture.
  633. *
  634. * \param renderer the rendering context.
  635. * \param props the properties to use.
  636. * \returns a pointer to the created texture or NULL if no rendering context
  637. * was active, the format was unsupported, or the width or height
  638. * were out of range; call SDL_GetError() for more information.
  639. *
  640. * \threadsafety You may only call this function from the main thread.
  641. *
  642. * \since This function is available since SDL 3.0.0.
  643. *
  644. * \sa SDL_CreateProperties
  645. * \sa SDL_CreateTexture
  646. * \sa SDL_CreateTextureFromSurface
  647. * \sa SDL_DestroyTexture
  648. * \sa SDL_GetTextureSize
  649. * \sa SDL_UpdateTexture
  650. */
  651. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
  652. #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace"
  653. #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format"
  654. #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access"
  655. #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width"
  656. #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height"
  657. #define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point"
  658. #define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom"
  659. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture"
  660. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u"
  661. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v"
  662. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture"
  663. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u"
  664. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v"
  665. #define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer"
  666. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture"
  667. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv"
  668. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u"
  669. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v"
  670. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture"
  671. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv"
  672. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u"
  673. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v"
  674. #define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture"
  675. /**
  676. * Get the properties associated with a texture.
  677. *
  678. * The following read-only properties are provided by SDL:
  679. *
  680. * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing
  681. * the texture colorspace.
  682. * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in
  683. * SDL_PixelFormat.
  684. * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in
  685. * SDL_TextureAccess.
  686. * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels.
  687. * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels.
  688. * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point
  689. * textures, this defines the value of 100% diffuse white, with higher
  690. * values being displayed in the High Dynamic Range headroom. This defaults
  691. * to 100 for HDR10 textures and 1.0 for other textures.
  692. * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point
  693. * textures, this defines the maximum dynamic range used by the content, in
  694. * terms of the SDR white point. If this is defined, any values outside the
  695. * range supported by the display will be scaled into the available HDR
  696. * headroom, otherwise they are clipped. This defaults to 1.0 for SDR
  697. * textures, 4.0 for HDR10 textures, and no default for floating point
  698. * textures.
  699. *
  700. * With the direct3d11 renderer:
  701. *
  702. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated
  703. * with the texture
  704. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  705. * associated with the U plane of a YUV texture
  706. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  707. * associated with the V plane of a YUV texture
  708. *
  709. * With the direct3d12 renderer:
  710. *
  711. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated
  712. * with the texture
  713. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated
  714. * with the U plane of a YUV texture
  715. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated
  716. * with the V plane of a YUV texture
  717. *
  718. * With the vulkan renderer:
  719. *
  720. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_POINTER`: the VkImage associated with
  721. * the texture
  722. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_U_POINTER`: the VkImage associated with
  723. * the U plane of a YUV texture
  724. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_V_POINTER`: the VkImage associated with
  725. * the V plane of a YUV texture
  726. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_UV_POINTER`: the VkImage associated with
  727. * the UV plane of a NV12/NV21 texture
  728. *
  729. * With the opengl renderer:
  730. *
  731. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated
  732. * with the texture
  733. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  734. * associated with the UV plane of an NV12 texture
  735. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated
  736. * with the U plane of a YUV texture
  737. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated
  738. * with the V plane of a YUV texture
  739. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the
  740. * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
  741. * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of
  742. * the texture (0.0 - 1.0)
  743. * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of
  744. * the texture (0.0 - 1.0)
  745. *
  746. * With the opengles2 renderer:
  747. *
  748. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  749. * associated with the texture
  750. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  751. * associated with the UV plane of an NV12 texture
  752. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  753. * associated with the U plane of a YUV texture
  754. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  755. * associated with the V plane of a YUV texture
  756. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the
  757. * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
  758. *
  759. * With the vulkan renderer:
  760. *
  761. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the
  762. * texture
  763. *
  764. * \param texture the texture to query.
  765. * \returns a valid property ID on success or 0 on failure; call
  766. * SDL_GetError() for more information.
  767. *
  768. * \threadsafety It is safe to call this function from any thread.
  769. *
  770. * \since This function is available since SDL 3.0.0.
  771. */
  772. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
  773. #define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"
  774. #define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format"
  775. #define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access"
  776. #define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width"
  777. #define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height"
  778. #define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point"
  779. #define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom"
  780. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"
  781. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"
  782. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"
  783. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"
  784. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"
  785. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"
  786. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"
  787. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"
  788. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"
  789. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"
  790. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target"
  791. #define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"
  792. #define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"
  793. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"
  794. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"
  795. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"
  796. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
  797. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target"
  798. #define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture"
  799. /**
  800. * Get the renderer that created an SDL_Texture.
  801. *
  802. * \param texture the texture to query.
  803. * \returns a pointer to the SDL_Renderer that created the texture, or NULL on
  804. * failure; call SDL_GetError() for more information.
  805. *
  806. * \threadsafety It is safe to call this function from any thread.
  807. *
  808. * \since This function is available since SDL 3.0.0.
  809. */
  810. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);
  811. /**
  812. * Get the size of a texture, as floating point values.
  813. *
  814. * \param texture the texture to query.
  815. * \param w a pointer filled in with the width of the texture in pixels. This
  816. * argument can be NULL if you don't need this information.
  817. * \param h a pointer filled in with the height of the texture in pixels. This
  818. * argument can be NULL if you don't need this information.
  819. * \returns true on success or false on failure; call SDL_GetError() for more
  820. * information.
  821. *
  822. * \threadsafety You may only call this function from the main thread.
  823. *
  824. * \since This function is available since SDL 3.0.0.
  825. */
  826. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);
  827. /**
  828. * Set an additional color value multiplied into render copy operations.
  829. *
  830. * When this texture is rendered, during the copy operation each source color
  831. * channel is modulated by the appropriate color value according to the
  832. * following formula:
  833. *
  834. * `srcC = srcC * (color / 255)`
  835. *
  836. * Color modulation is not always supported by the renderer; it will return
  837. * false if color modulation is not supported.
  838. *
  839. * \param texture the texture to update.
  840. * \param r the red color value multiplied into copy operations.
  841. * \param g the green color value multiplied into copy operations.
  842. * \param b the blue color value multiplied into copy operations.
  843. * \returns true on success or false on failure; call SDL_GetError() for more
  844. * information.
  845. *
  846. * \threadsafety You may only call this function from the main thread.
  847. *
  848. * \since This function is available since SDL 3.0.0.
  849. *
  850. * \sa SDL_GetTextureColorMod
  851. * \sa SDL_SetTextureAlphaMod
  852. * \sa SDL_SetTextureColorModFloat
  853. */
  854. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);
  855. /**
  856. * Set an additional color value multiplied into render copy operations.
  857. *
  858. * When this texture is rendered, during the copy operation each source color
  859. * channel is modulated by the appropriate color value according to the
  860. * following formula:
  861. *
  862. * `srcC = srcC * color`
  863. *
  864. * Color modulation is not always supported by the renderer; it will return
  865. * false if color modulation is not supported.
  866. *
  867. * \param texture the texture to update.
  868. * \param r the red color value multiplied into copy operations.
  869. * \param g the green color value multiplied into copy operations.
  870. * \param b the blue color value multiplied into copy operations.
  871. * \returns true on success or false on failure; call SDL_GetError() for more
  872. * information.
  873. *
  874. * \threadsafety You may only call this function from the main thread.
  875. *
  876. * \since This function is available since SDL 3.0.0.
  877. *
  878. * \sa SDL_GetTextureColorModFloat
  879. * \sa SDL_SetTextureAlphaModFloat
  880. * \sa SDL_SetTextureColorMod
  881. */
  882. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);
  883. /**
  884. * Get the additional color value multiplied into render copy operations.
  885. *
  886. * \param texture the texture to query.
  887. * \param r a pointer filled in with the current red color value.
  888. * \param g a pointer filled in with the current green color value.
  889. * \param b a pointer filled in with the current blue color value.
  890. * \returns true on success or false on failure; call SDL_GetError() for more
  891. * information.
  892. *
  893. * \threadsafety You may only call this function from the main thread.
  894. *
  895. * \since This function is available since SDL 3.0.0.
  896. *
  897. * \sa SDL_GetTextureAlphaMod
  898. * \sa SDL_GetTextureColorModFloat
  899. * \sa SDL_SetTextureColorMod
  900. */
  901. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);
  902. /**
  903. * Get the additional color value multiplied into render copy operations.
  904. *
  905. * \param texture the texture to query.
  906. * \param r a pointer filled in with the current red color value.
  907. * \param g a pointer filled in with the current green color value.
  908. * \param b a pointer filled in with the current blue color value.
  909. * \returns true on success or false on failure; call SDL_GetError() for more
  910. * information.
  911. *
  912. * \threadsafety You may only call this function from the main thread.
  913. *
  914. * \since This function is available since SDL 3.0.0.
  915. *
  916. * \sa SDL_GetTextureAlphaModFloat
  917. * \sa SDL_GetTextureColorMod
  918. * \sa SDL_SetTextureColorModFloat
  919. */
  920. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);
  921. /**
  922. * Set an additional alpha value multiplied into render copy operations.
  923. *
  924. * When this texture is rendered, during the copy operation the source alpha
  925. * value is modulated by this alpha value according to the following formula:
  926. *
  927. * `srcA = srcA * (alpha / 255)`
  928. *
  929. * Alpha modulation is not always supported by the renderer; it will return
  930. * false if alpha modulation is not supported.
  931. *
  932. * \param texture the texture to update.
  933. * \param alpha the source alpha value multiplied into copy operations.
  934. * \returns true on success or false on failure; call SDL_GetError() for more
  935. * information.
  936. *
  937. * \threadsafety You may only call this function from the main thread.
  938. *
  939. * \since This function is available since SDL 3.0.0.
  940. *
  941. * \sa SDL_GetTextureAlphaMod
  942. * \sa SDL_SetTextureAlphaModFloat
  943. * \sa SDL_SetTextureColorMod
  944. */
  945. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
  946. /**
  947. * Set an additional alpha value multiplied into render copy operations.
  948. *
  949. * When this texture is rendered, during the copy operation the source alpha
  950. * value is modulated by this alpha value according to the following formula:
  951. *
  952. * `srcA = srcA * alpha`
  953. *
  954. * Alpha modulation is not always supported by the renderer; it will return
  955. * false if alpha modulation is not supported.
  956. *
  957. * \param texture the texture to update.
  958. * \param alpha the source alpha value multiplied into copy operations.
  959. * \returns true on success or false on failure; call SDL_GetError() for more
  960. * information.
  961. *
  962. * \threadsafety You may only call this function from the main thread.
  963. *
  964. * \since This function is available since SDL 3.0.0.
  965. *
  966. * \sa SDL_GetTextureAlphaModFloat
  967. * \sa SDL_SetTextureAlphaMod
  968. * \sa SDL_SetTextureColorModFloat
  969. */
  970. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);
  971. /**
  972. * Get the additional alpha value multiplied into render copy operations.
  973. *
  974. * \param texture the texture to query.
  975. * \param alpha a pointer filled in with the current alpha value.
  976. * \returns true on success or false on failure; call SDL_GetError() for more
  977. * information.
  978. *
  979. * \threadsafety You may only call this function from the main thread.
  980. *
  981. * \since This function is available since SDL 3.0.0.
  982. *
  983. * \sa SDL_GetTextureAlphaModFloat
  984. * \sa SDL_GetTextureColorMod
  985. * \sa SDL_SetTextureAlphaMod
  986. */
  987. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);
  988. /**
  989. * Get the additional alpha value multiplied into render copy operations.
  990. *
  991. * \param texture the texture to query.
  992. * \param alpha a pointer filled in with the current alpha value.
  993. * \returns true on success or false on failure; call SDL_GetError() for more
  994. * information.
  995. *
  996. * \threadsafety You may only call this function from the main thread.
  997. *
  998. * \since This function is available since SDL 3.0.0.
  999. *
  1000. * \sa SDL_GetTextureAlphaMod
  1001. * \sa SDL_GetTextureColorModFloat
  1002. * \sa SDL_SetTextureAlphaModFloat
  1003. */
  1004. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);
  1005. /**
  1006. * Set the blend mode for a texture, used by SDL_RenderTexture().
  1007. *
  1008. * If the blend mode is not supported, the closest supported mode is chosen
  1009. * and this function returns false.
  1010. *
  1011. * \param texture the texture to update.
  1012. * \param blendMode the SDL_BlendMode to use for texture blending.
  1013. * \returns true on success or false on failure; call SDL_GetError() for more
  1014. * information.
  1015. *
  1016. * \threadsafety You may only call this function from the main thread.
  1017. *
  1018. * \since This function is available since SDL 3.0.0.
  1019. *
  1020. * \sa SDL_GetTextureBlendMode
  1021. */
  1022. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);
  1023. /**
  1024. * Get the blend mode used for texture copy operations.
  1025. *
  1026. * \param texture the texture to query.
  1027. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  1028. * \returns true on success or false on failure; call SDL_GetError() for more
  1029. * information.
  1030. *
  1031. * \threadsafety You may only call this function from the main thread.
  1032. *
  1033. * \since This function is available since SDL 3.0.0.
  1034. *
  1035. * \sa SDL_SetTextureBlendMode
  1036. */
  1037. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);
  1038. /**
  1039. * Set the scale mode used for texture scale operations.
  1040. *
  1041. * The default texture scale mode is SDL_SCALEMODE_LINEAR.
  1042. *
  1043. * If the scale mode is not supported, the closest supported mode is chosen.
  1044. *
  1045. * \param texture the texture to update.
  1046. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
  1047. * \returns true on success or false on failure; call SDL_GetError() for more
  1048. * information.
  1049. *
  1050. * \threadsafety You may only call this function from the main thread.
  1051. *
  1052. * \since This function is available since SDL 3.0.0.
  1053. *
  1054. * \sa SDL_GetTextureScaleMode
  1055. */
  1056. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);
  1057. /**
  1058. * Get the scale mode used for texture scale operations.
  1059. *
  1060. * \param texture the texture to query.
  1061. * \param scaleMode a pointer filled in with the current scale mode.
  1062. * \returns true on success or false on failure; call SDL_GetError() for more
  1063. * information.
  1064. *
  1065. * \threadsafety You may only call this function from the main thread.
  1066. *
  1067. * \since This function is available since SDL 3.0.0.
  1068. *
  1069. * \sa SDL_SetTextureScaleMode
  1070. */
  1071. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
  1072. /**
  1073. * Update the given texture rectangle with new pixel data.
  1074. *
  1075. * The pixel data must be in the pixel format of the texture, which can be
  1076. * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.
  1077. *
  1078. * This is a fairly slow function, intended for use with static textures that
  1079. * do not change often.
  1080. *
  1081. * If the texture is intended to be updated often, it is preferred to create
  1082. * the texture as streaming and use the locking functions referenced below.
  1083. * While this function will work with streaming textures, for optimization
  1084. * reasons you may not get the pixels back if you lock the texture afterward.
  1085. *
  1086. * \param texture the texture to update.
  1087. * \param rect an SDL_Rect structure representing the area to update, or NULL
  1088. * to update the entire texture.
  1089. * \param pixels the raw pixel data in the format of the texture.
  1090. * \param pitch the number of bytes in a row of pixel data, including padding
  1091. * between lines.
  1092. * \returns true on success or false on failure; call SDL_GetError() for more
  1093. * information.
  1094. *
  1095. * \threadsafety You may only call this function from the main thread.
  1096. *
  1097. * \since This function is available since SDL 3.0.0.
  1098. *
  1099. * \sa SDL_LockTexture
  1100. * \sa SDL_UnlockTexture
  1101. * \sa SDL_UpdateNVTexture
  1102. * \sa SDL_UpdateYUVTexture
  1103. */
  1104. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);
  1105. /**
  1106. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  1107. * data.
  1108. *
  1109. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  1110. * block of Y and U/V planes in the proper order, but this function is
  1111. * available if your pixel data is not contiguous.
  1112. *
  1113. * \param texture the texture to update.
  1114. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  1115. * update the entire texture.
  1116. * \param Yplane the raw pixel data for the Y plane.
  1117. * \param Ypitch the number of bytes between rows of pixel data for the Y
  1118. * plane.
  1119. * \param Uplane the raw pixel data for the U plane.
  1120. * \param Upitch the number of bytes between rows of pixel data for the U
  1121. * plane.
  1122. * \param Vplane the raw pixel data for the V plane.
  1123. * \param Vpitch the number of bytes between rows of pixel data for the V
  1124. * plane.
  1125. * \returns true on success or false on failure; call SDL_GetError() for more
  1126. * information.
  1127. *
  1128. * \threadsafety You may only call this function from the main thread.
  1129. *
  1130. * \since This function is available since SDL 3.0.0.
  1131. *
  1132. * \sa SDL_UpdateNVTexture
  1133. * \sa SDL_UpdateTexture
  1134. */
  1135. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
  1136. const SDL_Rect *rect,
  1137. const Uint8 *Yplane, int Ypitch,
  1138. const Uint8 *Uplane, int Upitch,
  1139. const Uint8 *Vplane, int Vpitch);
  1140. /**
  1141. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  1142. *
  1143. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  1144. * block of NV12/21 planes in the proper order, but this function is available
  1145. * if your pixel data is not contiguous.
  1146. *
  1147. * \param texture the texture to update.
  1148. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  1149. * update the entire texture.
  1150. * \param Yplane the raw pixel data for the Y plane.
  1151. * \param Ypitch the number of bytes between rows of pixel data for the Y
  1152. * plane.
  1153. * \param UVplane the raw pixel data for the UV plane.
  1154. * \param UVpitch the number of bytes between rows of pixel data for the UV
  1155. * plane.
  1156. * \returns true on success or false on failure; call SDL_GetError() for more
  1157. * information.
  1158. *
  1159. * \threadsafety You may only call this function from the main thread.
  1160. *
  1161. * \since This function is available since SDL 3.0.0.
  1162. *
  1163. * \sa SDL_UpdateTexture
  1164. * \sa SDL_UpdateYUVTexture
  1165. */
  1166. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,
  1167. const SDL_Rect *rect,
  1168. const Uint8 *Yplane, int Ypitch,
  1169. const Uint8 *UVplane, int UVpitch);
  1170. /**
  1171. * Lock a portion of the texture for **write-only** pixel access.
  1172. *
  1173. * As an optimization, the pixels made available for editing don't necessarily
  1174. * contain the old texture data. This is a write-only operation, and if you
  1175. * need to keep a copy of the texture data you should do that at the
  1176. * application level.
  1177. *
  1178. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1179. * changes.
  1180. *
  1181. * \param texture the texture to lock for access, which was created with
  1182. * `SDL_TEXTUREACCESS_STREAMING`.
  1183. * \param rect an SDL_Rect structure representing the area to lock for access;
  1184. * NULL to lock the entire texture.
  1185. * \param pixels this is filled in with a pointer to the locked pixels,
  1186. * appropriately offset by the locked area.
  1187. * \param pitch this is filled in with the pitch of the locked pixels; the
  1188. * pitch is the length of one row in bytes.
  1189. * \returns true on success or false if the texture is not valid or was not
  1190. * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError()
  1191. * for more information.
  1192. *
  1193. * \threadsafety You may only call this function from the main thread.
  1194. *
  1195. * \since This function is available since SDL 3.0.0.
  1196. *
  1197. * \sa SDL_LockTextureToSurface
  1198. * \sa SDL_UnlockTexture
  1199. */
  1200. extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture,
  1201. const SDL_Rect *rect,
  1202. void **pixels, int *pitch);
  1203. /**
  1204. * Lock a portion of the texture for **write-only** pixel access, and expose
  1205. * it as a SDL surface.
  1206. *
  1207. * Besides providing an SDL_Surface instead of raw pixel data, this function
  1208. * operates like SDL_LockTexture.
  1209. *
  1210. * As an optimization, the pixels made available for editing don't necessarily
  1211. * contain the old texture data. This is a write-only operation, and if you
  1212. * need to keep a copy of the texture data you should do that at the
  1213. * application level.
  1214. *
  1215. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1216. * changes.
  1217. *
  1218. * The returned surface is freed internally after calling SDL_UnlockTexture()
  1219. * or SDL_DestroyTexture(). The caller should not free it.
  1220. *
  1221. * \param texture the texture to lock for access, which must be created with
  1222. * `SDL_TEXTUREACCESS_STREAMING`.
  1223. * \param rect a pointer to the rectangle to lock for access. If the rect is
  1224. * NULL, the entire texture will be locked.
  1225. * \param surface this is filled in with an SDL surface representing the
  1226. * locked area.
  1227. * \returns true on success or false on failure; call SDL_GetError() for more
  1228. * information.
  1229. *
  1230. * \threadsafety You may only call this function from the main thread.
  1231. *
  1232. * \since This function is available since SDL 3.0.0.
  1233. *
  1234. * \sa SDL_LockTexture
  1235. * \sa SDL_UnlockTexture
  1236. */
  1237. extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface);
  1238. /**
  1239. * Unlock a texture, uploading the changes to video memory, if needed.
  1240. *
  1241. * **Warning**: Please note that SDL_LockTexture() is intended to be
  1242. * write-only; it will not guarantee the previous contents of the texture will
  1243. * be provided. You must fully initialize any area of a texture that you lock
  1244. * before unlocking it, as the pixels might otherwise be uninitialized memory.
  1245. *
  1246. * Which is to say: locking and immediately unlocking a texture can result in
  1247. * corrupted textures, depending on the renderer in use.
  1248. *
  1249. * \param texture a texture locked by SDL_LockTexture().
  1250. *
  1251. * \threadsafety You may only call this function from the main thread.
  1252. *
  1253. * \since This function is available since SDL 3.0.0.
  1254. *
  1255. * \sa SDL_LockTexture
  1256. */
  1257. extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
  1258. /**
  1259. * Set a texture as the current rendering target.
  1260. *
  1261. * The default render target is the window for which the renderer was created.
  1262. * To stop rendering to a texture and render to the window again, call this
  1263. * function with a NULL `texture`.
  1264. *
  1265. * \param renderer the rendering context.
  1266. * \param texture the targeted texture, which must be created with the
  1267. * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
  1268. * window instead of a texture.
  1269. * \returns true on success or false on failure; call SDL_GetError() for more
  1270. * information.
  1271. *
  1272. * \threadsafety You may only call this function from the main thread.
  1273. *
  1274. * \since This function is available since SDL 3.0.0.
  1275. *
  1276. * \sa SDL_GetRenderTarget
  1277. */
  1278. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);
  1279. /**
  1280. * Get the current render target.
  1281. *
  1282. * The default render target is the window for which the renderer was created,
  1283. * and is reported a NULL here.
  1284. *
  1285. * \param renderer the rendering context.
  1286. * \returns the current render target or NULL for the default render target.
  1287. *
  1288. * \threadsafety You may only call this function from the main thread.
  1289. *
  1290. * \since This function is available since SDL 3.0.0.
  1291. *
  1292. * \sa SDL_SetRenderTarget
  1293. */
  1294. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  1295. /**
  1296. * Set a device independent resolution and presentation mode for rendering.
  1297. *
  1298. * This function sets the width and height of the logical rendering output.
  1299. * The renderer will act as if the window is always the requested dimensions,
  1300. * scaling to the actual window resolution as necessary.
  1301. *
  1302. * This can be useful for games that expect a fixed size, but would like to
  1303. * scale the output to whatever is available, regardless of how a user resizes
  1304. * a window, or if the display is high DPI.
  1305. *
  1306. * You can disable logical coordinates by setting the mode to
  1307. * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
  1308. * resolution of the output window; it is safe to toggle logical presentation
  1309. * during the rendering of a frame: perhaps most of the rendering is done to
  1310. * specific dimensions but to make fonts look sharp, the app turns off logical
  1311. * presentation while drawing text.
  1312. *
  1313. * Letterboxing will only happen if logical presentation is enabled during
  1314. * SDL_RenderPresent; be sure to reenable it first if you were using it.
  1315. *
  1316. * You can convert coordinates in an event into rendering coordinates using
  1317. * SDL_ConvertEventToRenderCoordinates().
  1318. *
  1319. * \param renderer the rendering context.
  1320. * \param w the width of the logical resolution.
  1321. * \param h the height of the logical resolution.
  1322. * \param mode the presentation mode used.
  1323. * \returns true on success or false on failure; call SDL_GetError() for more
  1324. * information.
  1325. *
  1326. * \threadsafety You may only call this function from the main thread.
  1327. *
  1328. * \since This function is available since SDL 3.0.0.
  1329. *
  1330. * \sa SDL_ConvertEventToRenderCoordinates
  1331. * \sa SDL_GetRenderLogicalPresentation
  1332. * \sa SDL_GetRenderLogicalPresentationRect
  1333. */
  1334. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode);
  1335. /**
  1336. * Get device independent resolution and presentation mode for rendering.
  1337. *
  1338. * This function gets the width and height of the logical rendering output, or
  1339. * the output size in pixels if a logical resolution is not enabled.
  1340. *
  1341. * \param renderer the rendering context.
  1342. * \param w an int to be filled with the width.
  1343. * \param h an int to be filled with the height.
  1344. * \param mode the presentation mode used.
  1345. * \returns true on success or false on failure; call SDL_GetError() for more
  1346. * information.
  1347. *
  1348. * \threadsafety You may only call this function from the main thread.
  1349. *
  1350. * \since This function is available since SDL 3.0.0.
  1351. *
  1352. * \sa SDL_SetRenderLogicalPresentation
  1353. */
  1354. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode);
  1355. /**
  1356. * Get the final presentation rectangle for rendering.
  1357. *
  1358. * This function returns the calculated rectangle used for logical
  1359. * presentation, based on the presentation mode and output size. If logical
  1360. * presentation is disabled, it will fill the rectangle with the output size,
  1361. * in pixels.
  1362. *
  1363. * \param renderer the rendering context.
  1364. * \param rect a pointer filled in with the final presentation rectangle, may
  1365. * be NULL.
  1366. * \returns true on success or false on failure; call SDL_GetError() for more
  1367. * information.
  1368. *
  1369. * \threadsafety You may only call this function from the main thread.
  1370. *
  1371. * \since This function is available since SDL 3.0.0.
  1372. *
  1373. * \sa SDL_SetRenderLogicalPresentation
  1374. */
  1375. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect);
  1376. /**
  1377. * Get a point in render coordinates when given a point in window coordinates.
  1378. *
  1379. * This takes into account several states:
  1380. *
  1381. * - The window dimensions.
  1382. * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
  1383. * - The scale (SDL_SetRenderScale)
  1384. * - The viewport (SDL_SetRenderViewport)
  1385. *
  1386. * \param renderer the rendering context.
  1387. * \param window_x the x coordinate in window coordinates.
  1388. * \param window_y the y coordinate in window coordinates.
  1389. * \param x a pointer filled with the x coordinate in render coordinates.
  1390. * \param y a pointer filled with the y coordinate in render coordinates.
  1391. * \returns true on success or false on failure; call SDL_GetError() for more
  1392. * information.
  1393. *
  1394. * \threadsafety You may only call this function from the main thread.
  1395. *
  1396. * \since This function is available since SDL 3.0.0.
  1397. *
  1398. * \sa SDL_SetRenderLogicalPresentation
  1399. * \sa SDL_SetRenderScale
  1400. */
  1401. extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
  1402. /**
  1403. * Get a point in window coordinates when given a point in render coordinates.
  1404. *
  1405. * This takes into account several states:
  1406. *
  1407. * - The window dimensions.
  1408. * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
  1409. * - The scale (SDL_SetRenderScale)
  1410. * - The viewport (SDL_SetRenderViewport)
  1411. *
  1412. * \param renderer the rendering context.
  1413. * \param x the x coordinate in render coordinates.
  1414. * \param y the y coordinate in render coordinates.
  1415. * \param window_x a pointer filled with the x coordinate in window
  1416. * coordinates.
  1417. * \param window_y a pointer filled with the y coordinate in window
  1418. * coordinates.
  1419. * \returns true on success or false on failure; call SDL_GetError() for more
  1420. * information.
  1421. *
  1422. * \threadsafety You may only call this function from the main thread.
  1423. *
  1424. * \since This function is available since SDL 3.0.0.
  1425. *
  1426. * \sa SDL_SetRenderLogicalPresentation
  1427. * \sa SDL_SetRenderScale
  1428. * \sa SDL_SetRenderViewport
  1429. */
  1430. extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
  1431. /**
  1432. * Convert the coordinates in an event to render coordinates.
  1433. *
  1434. * This takes into account several states:
  1435. *
  1436. * - The window dimensions.
  1437. * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
  1438. * - The scale (SDL_SetRenderScale)
  1439. * - The viewport (SDL_SetRenderViewport)
  1440. *
  1441. * Touch coordinates are converted from normalized coordinates in the window
  1442. * to non-normalized rendering coordinates.
  1443. *
  1444. * Once converted, the coordinates may be outside the rendering area.
  1445. *
  1446. * \param renderer the rendering context.
  1447. * \param event the event to modify.
  1448. * \returns true on success or false on failure; call SDL_GetError() for more
  1449. * information.
  1450. *
  1451. * \threadsafety You may only call this function from the main thread.
  1452. *
  1453. * \since This function is available since SDL 3.0.0.
  1454. *
  1455. * \sa SDL_RenderCoordinatesFromWindow
  1456. */
  1457. extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
  1458. /**
  1459. * Set the drawing area for rendering on the current target.
  1460. *
  1461. * Drawing will clip to this area (separately from any clipping done with
  1462. * SDL_SetRenderClipRect), and the top left of the area will become coordinate
  1463. * (0, 0) for future drawing commands.
  1464. *
  1465. * The area's width and height must be >= 0.
  1466. *
  1467. * \param renderer the rendering context.
  1468. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  1469. * to set the viewport to the entire target.
  1470. * \returns true on success or false on failure; call SDL_GetError() for more
  1471. * information.
  1472. *
  1473. * \threadsafety You may only call this function from the main thread.
  1474. *
  1475. * \since This function is available since SDL 3.0.0.
  1476. *
  1477. * \sa SDL_GetRenderViewport
  1478. * \sa SDL_RenderViewportSet
  1479. */
  1480. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);
  1481. /**
  1482. * Get the drawing area for the current target.
  1483. *
  1484. * \param renderer the rendering context.
  1485. * \param rect an SDL_Rect structure filled in with the current drawing area.
  1486. * \returns true on success or false on failure; call SDL_GetError() for more
  1487. * information.
  1488. *
  1489. * \threadsafety You may only call this function from the main thread.
  1490. *
  1491. * \since This function is available since SDL 3.0.0.
  1492. *
  1493. * \sa SDL_RenderViewportSet
  1494. * \sa SDL_SetRenderViewport
  1495. */
  1496. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
  1497. /**
  1498. * Return whether an explicit rectangle was set as the viewport.
  1499. *
  1500. * This is useful if you're saving and restoring the viewport and want to know
  1501. * whether you should restore a specific rectangle or NULL. Note that the
  1502. * viewport is always reset when changing rendering targets.
  1503. *
  1504. * \param renderer the rendering context.
  1505. * \returns true if the viewport was set to a specific rectangle, or false if
  1506. * it was set to NULL (the entire target).
  1507. *
  1508. * \threadsafety You may only call this function from the main thread.
  1509. *
  1510. * \since This function is available since SDL 3.0.0.
  1511. *
  1512. * \sa SDL_GetRenderViewport
  1513. * \sa SDL_SetRenderViewport
  1514. */
  1515. extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer);
  1516. /**
  1517. * Get the safe area for rendering within the current viewport.
  1518. *
  1519. * Some devices have portions of the screen which are partially obscured or
  1520. * not interactive, possibly due to on-screen controls, curved edges, camera
  1521. * notches, TV overscan, etc. This function provides the area of the current
  1522. * viewport which is safe to have interactible content. You should continue
  1523. * rendering into the rest of the render target, but it should not contain
  1524. * visually important or interactible content.
  1525. *
  1526. * \param renderer the rendering context.
  1527. * \param rect a pointer filled in with the area that is safe for interactive
  1528. * content.
  1529. * \returns true on success or false on failure; call SDL_GetError() for more
  1530. * information.
  1531. *
  1532. * \threadsafety You may only call this function from the main thread.
  1533. *
  1534. * \since This function is available since SDL 3.0.0.
  1535. */
  1536. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect);
  1537. /**
  1538. * Set the clip rectangle for rendering on the specified target.
  1539. *
  1540. * \param renderer the rendering context.
  1541. * \param rect an SDL_Rect structure representing the clip area, relative to
  1542. * the viewport, or NULL to disable clipping.
  1543. * \returns true on success or false on failure; call SDL_GetError() for more
  1544. * information.
  1545. *
  1546. * \threadsafety You may only call this function from the main thread.
  1547. *
  1548. * \since This function is available since SDL 3.0.0.
  1549. *
  1550. * \sa SDL_GetRenderClipRect
  1551. * \sa SDL_RenderClipEnabled
  1552. */
  1553. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);
  1554. /**
  1555. * Get the clip rectangle for the current target.
  1556. *
  1557. * \param renderer the rendering context.
  1558. * \param rect an SDL_Rect structure filled in with the current clipping area
  1559. * or an empty rectangle if clipping is disabled.
  1560. * \returns true on success or false on failure; call SDL_GetError() for more
  1561. * information.
  1562. *
  1563. * \threadsafety You may only call this function from the main thread.
  1564. *
  1565. * \since This function is available since SDL 3.0.0.
  1566. *
  1567. * \sa SDL_RenderClipEnabled
  1568. * \sa SDL_SetRenderClipRect
  1569. */
  1570. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
  1571. /**
  1572. * Get whether clipping is enabled on the given renderer.
  1573. *
  1574. * \param renderer the rendering context.
  1575. * \returns true if clipping is enabled or false if not; call SDL_GetError()
  1576. * for more information.
  1577. *
  1578. * \threadsafety You may only call this function from the main thread.
  1579. *
  1580. * \since This function is available since SDL 3.0.0.
  1581. *
  1582. * \sa SDL_GetRenderClipRect
  1583. * \sa SDL_SetRenderClipRect
  1584. */
  1585. extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
  1586. /**
  1587. * Set the drawing scale for rendering on the current target.
  1588. *
  1589. * The drawing coordinates are scaled by the x/y scaling factors before they
  1590. * are used by the renderer. This allows resolution independent drawing with a
  1591. * single coordinate system.
  1592. *
  1593. * If this results in scaling or subpixel drawing by the rendering backend, it
  1594. * will be handled using the appropriate quality hints. For best results use
  1595. * integer scaling factors.
  1596. *
  1597. * \param renderer the rendering context.
  1598. * \param scaleX the horizontal scaling factor.
  1599. * \param scaleY the vertical scaling factor.
  1600. * \returns true on success or false on failure; call SDL_GetError() for more
  1601. * information.
  1602. *
  1603. * \threadsafety You may only call this function from the main thread.
  1604. *
  1605. * \since This function is available since SDL 3.0.0.
  1606. *
  1607. * \sa SDL_GetRenderScale
  1608. */
  1609. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
  1610. /**
  1611. * Get the drawing scale for the current target.
  1612. *
  1613. * \param renderer the rendering context.
  1614. * \param scaleX a pointer filled in with the horizontal scaling factor.
  1615. * \param scaleY a pointer filled in with the vertical scaling factor.
  1616. * \returns true on success or false on failure; call SDL_GetError() for more
  1617. * information.
  1618. *
  1619. * \threadsafety You may only call this function from the main thread.
  1620. *
  1621. * \since This function is available since SDL 3.0.0.
  1622. *
  1623. * \sa SDL_SetRenderScale
  1624. */
  1625. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
  1626. /**
  1627. * Set the color used for drawing operations.
  1628. *
  1629. * Set the color for drawing or filling rectangles, lines, and points, and for
  1630. * SDL_RenderClear().
  1631. *
  1632. * \param renderer the rendering context.
  1633. * \param r the red value used to draw on the rendering target.
  1634. * \param g the green value used to draw on the rendering target.
  1635. * \param b the blue value used to draw on the rendering target.
  1636. * \param a the alpha value used to draw on the rendering target; usually
  1637. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  1638. * specify how the alpha channel is used.
  1639. * \returns true on success or false on failure; call SDL_GetError() for more
  1640. * information.
  1641. *
  1642. * \threadsafety You may only call this function from the main thread.
  1643. *
  1644. * \since This function is available since SDL 3.0.0.
  1645. *
  1646. * \sa SDL_GetRenderDrawColor
  1647. * \sa SDL_SetRenderDrawColorFloat
  1648. */
  1649. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  1650. /**
  1651. * Set the color used for drawing operations (Rect, Line and Clear).
  1652. *
  1653. * Set the color for drawing or filling rectangles, lines, and points, and for
  1654. * SDL_RenderClear().
  1655. *
  1656. * \param renderer the rendering context.
  1657. * \param r the red value used to draw on the rendering target.
  1658. * \param g the green value used to draw on the rendering target.
  1659. * \param b the blue value used to draw on the rendering target.
  1660. * \param a the alpha value used to draw on the rendering target. Use
  1661. * SDL_SetRenderDrawBlendMode to specify how the alpha channel is
  1662. * used.
  1663. * \returns true on success or false on failure; call SDL_GetError() for more
  1664. * information.
  1665. *
  1666. * \threadsafety You may only call this function from the main thread.
  1667. *
  1668. * \since This function is available since SDL 3.0.0.
  1669. *
  1670. * \sa SDL_GetRenderDrawColorFloat
  1671. * \sa SDL_SetRenderDrawColor
  1672. */
  1673. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);
  1674. /**
  1675. * Get the color used for drawing operations (Rect, Line and Clear).
  1676. *
  1677. * \param renderer the rendering context.
  1678. * \param r a pointer filled in with the red value used to draw on the
  1679. * rendering target.
  1680. * \param g a pointer filled in with the green value used to draw on the
  1681. * rendering target.
  1682. * \param b a pointer filled in with the blue value used to draw on the
  1683. * rendering target.
  1684. * \param a a pointer filled in with the alpha value used to draw on the
  1685. * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
  1686. * \returns true on success or false on failure; call SDL_GetError() for more
  1687. * information.
  1688. *
  1689. * \threadsafety You may only call this function from the main thread.
  1690. *
  1691. * \since This function is available since SDL 3.0.0.
  1692. *
  1693. * \sa SDL_GetRenderDrawColorFloat
  1694. * \sa SDL_SetRenderDrawColor
  1695. */
  1696. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
  1697. /**
  1698. * Get the color used for drawing operations (Rect, Line and Clear).
  1699. *
  1700. * \param renderer the rendering context.
  1701. * \param r a pointer filled in with the red value used to draw on the
  1702. * rendering target.
  1703. * \param g a pointer filled in with the green value used to draw on the
  1704. * rendering target.
  1705. * \param b a pointer filled in with the blue value used to draw on the
  1706. * rendering target.
  1707. * \param a a pointer filled in with the alpha value used to draw on the
  1708. * rendering target.
  1709. * \returns true on success or false on failure; call SDL_GetError() for more
  1710. * information.
  1711. *
  1712. * \threadsafety You may only call this function from the main thread.
  1713. *
  1714. * \since This function is available since SDL 3.0.0.
  1715. *
  1716. * \sa SDL_SetRenderDrawColorFloat
  1717. * \sa SDL_GetRenderDrawColor
  1718. */
  1719. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);
  1720. /**
  1721. * Set the color scale used for render operations.
  1722. *
  1723. * The color scale is an additional scale multiplied into the pixel color
  1724. * value while rendering. This can be used to adjust the brightness of colors
  1725. * during HDR rendering, or changing HDR video brightness when playing on an
  1726. * SDR display.
  1727. *
  1728. * The color scale does not affect the alpha channel, only the color
  1729. * brightness.
  1730. *
  1731. * \param renderer the rendering context.
  1732. * \param scale the color scale value.
  1733. * \returns true on success or false on failure; call SDL_GetError() for more
  1734. * information.
  1735. *
  1736. * \threadsafety You may only call this function from the main thread.
  1737. *
  1738. * \since This function is available since SDL 3.0.0.
  1739. *
  1740. * \sa SDL_GetRenderColorScale
  1741. */
  1742. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);
  1743. /**
  1744. * Get the color scale used for render operations.
  1745. *
  1746. * \param renderer the rendering context.
  1747. * \param scale a pointer filled in with the current color scale value.
  1748. * \returns true on success or false on failure; call SDL_GetError() for more
  1749. * information.
  1750. *
  1751. * \threadsafety You may only call this function from the main thread.
  1752. *
  1753. * \since This function is available since SDL 3.0.0.
  1754. *
  1755. * \sa SDL_SetRenderColorScale
  1756. */
  1757. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale);
  1758. /**
  1759. * Set the blend mode used for drawing operations (Fill and Line).
  1760. *
  1761. * If the blend mode is not supported, the closest supported mode is chosen.
  1762. *
  1763. * \param renderer the rendering context.
  1764. * \param blendMode the SDL_BlendMode to use for blending.
  1765. * \returns true on success or false on failure; call SDL_GetError() for more
  1766. * information.
  1767. *
  1768. * \threadsafety You may only call this function from the main thread.
  1769. *
  1770. * \since This function is available since SDL 3.0.0.
  1771. *
  1772. * \sa SDL_GetRenderDrawBlendMode
  1773. */
  1774. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
  1775. /**
  1776. * Get the blend mode used for drawing operations.
  1777. *
  1778. * \param renderer the rendering context.
  1779. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  1780. * \returns true on success or false on failure; call SDL_GetError() for more
  1781. * information.
  1782. *
  1783. * \threadsafety You may only call this function from the main thread.
  1784. *
  1785. * \since This function is available since SDL 3.0.0.
  1786. *
  1787. * \sa SDL_SetRenderDrawBlendMode
  1788. */
  1789. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);
  1790. /**
  1791. * Clear the current rendering target with the drawing color.
  1792. *
  1793. * This function clears the entire rendering target, ignoring the viewport and
  1794. * the clip rectangle. Note, that clearing will also set/fill all pixels of
  1795. * the rendering target to current renderer draw color, so make sure to invoke
  1796. * SDL_SetRenderDrawColor() when needed.
  1797. *
  1798. * \param renderer the rendering context.
  1799. * \returns true on success or false on failure; call SDL_GetError() for more
  1800. * information.
  1801. *
  1802. * \threadsafety You may only call this function from the main thread.
  1803. *
  1804. * \since This function is available since SDL 3.0.0.
  1805. *
  1806. * \sa SDL_SetRenderDrawColor
  1807. */
  1808. extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
  1809. /**
  1810. * Draw a point on the current rendering target at subpixel precision.
  1811. *
  1812. * \param renderer the renderer which should draw a point.
  1813. * \param x the x coordinate of the point.
  1814. * \param y the y coordinate of the point.
  1815. * \returns true on success or false on failure; call SDL_GetError() for more
  1816. * information.
  1817. *
  1818. * \threadsafety You may only call this function from the main thread.
  1819. *
  1820. * \since This function is available since SDL 3.0.0.
  1821. *
  1822. * \sa SDL_RenderPoints
  1823. */
  1824. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);
  1825. /**
  1826. * Draw multiple points on the current rendering target at subpixel precision.
  1827. *
  1828. * \param renderer the renderer which should draw multiple points.
  1829. * \param points the points to draw.
  1830. * \param count the number of points to draw.
  1831. * \returns true on success or false on failure; call SDL_GetError() for more
  1832. * information.
  1833. *
  1834. * \threadsafety You may only call this function from the main thread.
  1835. *
  1836. * \since This function is available since SDL 3.0.0.
  1837. *
  1838. * \sa SDL_RenderPoint
  1839. */
  1840. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1841. /**
  1842. * Draw a line on the current rendering target at subpixel precision.
  1843. *
  1844. * \param renderer the renderer which should draw a line.
  1845. * \param x1 the x coordinate of the start point.
  1846. * \param y1 the y coordinate of the start point.
  1847. * \param x2 the x coordinate of the end point.
  1848. * \param y2 the y coordinate of the end point.
  1849. * \returns true on success or false on failure; call SDL_GetError() for more
  1850. * information.
  1851. *
  1852. * \threadsafety You may only call this function from the main thread.
  1853. *
  1854. * \since This function is available since SDL 3.0.0.
  1855. *
  1856. * \sa SDL_RenderLines
  1857. */
  1858. extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
  1859. /**
  1860. * Draw a series of connected lines on the current rendering target at
  1861. * subpixel precision.
  1862. *
  1863. * \param renderer the renderer which should draw multiple lines.
  1864. * \param points the points along the lines.
  1865. * \param count the number of points, drawing count-1 lines.
  1866. * \returns true on success or false on failure; call SDL_GetError() for more
  1867. * information.
  1868. *
  1869. * \threadsafety You may only call this function from the main thread.
  1870. *
  1871. * \since This function is available since SDL 3.0.0.
  1872. *
  1873. * \sa SDL_RenderLine
  1874. */
  1875. extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1876. /**
  1877. * Draw a rectangle on the current rendering target at subpixel precision.
  1878. *
  1879. * \param renderer the renderer which should draw a rectangle.
  1880. * \param rect a pointer to the destination rectangle, or NULL to outline the
  1881. * entire rendering target.
  1882. * \returns true on success or false on failure; call SDL_GetError() for more
  1883. * information.
  1884. *
  1885. * \threadsafety You may only call this function from the main thread.
  1886. *
  1887. * \since This function is available since SDL 3.0.0.
  1888. *
  1889. * \sa SDL_RenderRects
  1890. */
  1891. extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1892. /**
  1893. * Draw some number of rectangles on the current rendering target at subpixel
  1894. * precision.
  1895. *
  1896. * \param renderer the renderer which should draw multiple rectangles.
  1897. * \param rects a pointer to an array of destination rectangles.
  1898. * \param count the number of rectangles.
  1899. * \returns true on success or false on failure; call SDL_GetError() for more
  1900. * information.
  1901. *
  1902. * \threadsafety You may only call this function from the main thread.
  1903. *
  1904. * \since This function is available since SDL 3.0.0.
  1905. *
  1906. * \sa SDL_RenderRect
  1907. */
  1908. extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1909. /**
  1910. * Fill a rectangle on the current rendering target with the drawing color at
  1911. * subpixel precision.
  1912. *
  1913. * \param renderer the renderer which should fill a rectangle.
  1914. * \param rect a pointer to the destination rectangle, or NULL for the entire
  1915. * rendering target.
  1916. * \returns true on success or false on failure; call SDL_GetError() for more
  1917. * information.
  1918. *
  1919. * \threadsafety You may only call this function from the main thread.
  1920. *
  1921. * \since This function is available since SDL 3.0.0.
  1922. *
  1923. * \sa SDL_RenderFillRects
  1924. */
  1925. extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1926. /**
  1927. * Fill some number of rectangles on the current rendering target with the
  1928. * drawing color at subpixel precision.
  1929. *
  1930. * \param renderer the renderer which should fill multiple rectangles.
  1931. * \param rects a pointer to an array of destination rectangles.
  1932. * \param count the number of rectangles.
  1933. * \returns true on success or false on failure; call SDL_GetError() for more
  1934. * information.
  1935. *
  1936. * \threadsafety You may only call this function from the main thread.
  1937. *
  1938. * \since This function is available since SDL 3.0.0.
  1939. *
  1940. * \sa SDL_RenderFillRect
  1941. */
  1942. extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1943. /**
  1944. * Copy a portion of the texture to the current rendering target at subpixel
  1945. * precision.
  1946. *
  1947. * \param renderer the renderer which should copy parts of a texture.
  1948. * \param texture the source texture.
  1949. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  1950. * texture.
  1951. * \param dstrect a pointer to the destination rectangle, or NULL for the
  1952. * entire rendering target.
  1953. * \returns true on success or false on failure; call SDL_GetError() for more
  1954. * information.
  1955. *
  1956. * \threadsafety You may only call this function from the main thread.
  1957. *
  1958. * \since This function is available since SDL 3.0.0.
  1959. *
  1960. * \sa SDL_RenderTextureRotated
  1961. * \sa SDL_RenderTextureTiled
  1962. */
  1963. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);
  1964. /**
  1965. * Copy a portion of the source texture to the current rendering target, with
  1966. * rotation and flipping, at subpixel precision.
  1967. *
  1968. * \param renderer the renderer which should copy parts of a texture.
  1969. * \param texture the source texture.
  1970. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  1971. * texture.
  1972. * \param dstrect a pointer to the destination rectangle, or NULL for the
  1973. * entire rendering target.
  1974. * \param angle an angle in degrees that indicates the rotation that will be
  1975. * applied to dstrect, rotating it in a clockwise direction.
  1976. * \param center a pointer to a point indicating the point around which
  1977. * dstrect will be rotated (if NULL, rotation will be done
  1978. * around dstrect.w/2, dstrect.h/2).
  1979. * \param flip an SDL_FlipMode value stating which flipping actions should be
  1980. * performed on the texture.
  1981. * \returns true on success or false on failure; call SDL_GetError() for more
  1982. * information.
  1983. *
  1984. * \threadsafety You may only call this function from the main thread.
  1985. *
  1986. * \since This function is available since SDL 3.0.0.
  1987. *
  1988. * \sa SDL_RenderTexture
  1989. */
  1990. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
  1991. const SDL_FRect *srcrect, const SDL_FRect *dstrect,
  1992. double angle, const SDL_FPoint *center,
  1993. SDL_FlipMode flip);
  1994. /**
  1995. * Tile a portion of the texture to the current rendering target at subpixel
  1996. * precision.
  1997. *
  1998. * The pixels in `srcrect` will be repeated as many times as needed to
  1999. * completely fill `dstrect`.
  2000. *
  2001. * \param renderer the renderer which should copy parts of a texture.
  2002. * \param texture the source texture.
  2003. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  2004. * texture.
  2005. * \param scale the scale used to transform srcrect into the destination
  2006. * rectangle, e.g. a 32x32 texture with a scale of 2 would fill
  2007. * 64x64 tiles.
  2008. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2009. * entire rendering target.
  2010. * \returns true on success or false on failure; call SDL_GetError() for more
  2011. * information.
  2012. *
  2013. * \threadsafety You may only call this function from the main thread.
  2014. *
  2015. * \since This function is available since SDL 3.0.0.
  2016. *
  2017. * \sa SDL_RenderTexture
  2018. */
  2019. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect);
  2020. /**
  2021. * Perform a scaled copy using the 9-grid algorithm to the current rendering
  2022. * target at subpixel precision.
  2023. *
  2024. * The pixels in the texture are split into a 3x3 grid, using the different
  2025. * corner sizes for each corner, and the sides and center making up the
  2026. * remaining pixels. The corners are then scaled using `scale` and fit into
  2027. * the corners of the destination rectangle. The sides and center are then
  2028. * stretched into place to cover the remaining destination rectangle.
  2029. *
  2030. * \param renderer the renderer which should copy parts of a texture.
  2031. * \param texture the source texture.
  2032. * \param srcrect the SDL_Rect structure representing the rectangle to be used
  2033. * for the 9-grid, or NULL to use the entire texture.
  2034. * \param left_width the width, in pixels, of the left corners in `srcrect`.
  2035. * \param right_width the width, in pixels, of the right corners in `srcrect`.
  2036. * \param top_height the height, in pixels, of the top corners in `srcrect`.
  2037. * \param bottom_height the height, in pixels, of the bottom corners in
  2038. * `srcrect`.
  2039. * \param scale the scale used to transform the corner of `srcrect` into the
  2040. * corner of `dstrect`, or 0.0f for an unscaled copy.
  2041. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2042. * entire rendering target.
  2043. * \returns true on success or false on failure; call SDL_GetError() for more
  2044. * information.
  2045. *
  2046. * \threadsafety You may only call this function from the main thread.
  2047. *
  2048. * \since This function is available since SDL 3.0.0.
  2049. *
  2050. * \sa SDL_RenderTexture
  2051. */
  2052. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture9Grid(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float left_width, float right_width, float top_height, float bottom_height, float scale, const SDL_FRect *dstrect);
  2053. /**
  2054. * Render a list of triangles, optionally using a texture and indices into the
  2055. * vertex array Color and alpha modulation is done per vertex
  2056. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  2057. *
  2058. * \param renderer the rendering context.
  2059. * \param texture (optional) The SDL texture to use.
  2060. * \param vertices vertices.
  2061. * \param num_vertices number of vertices.
  2062. * \param indices (optional) An array of integer indices into the 'vertices'
  2063. * array, if NULL all vertices will be rendered in sequential
  2064. * order.
  2065. * \param num_indices number of indices.
  2066. * \returns true on success or false on failure; call SDL_GetError() for more
  2067. * information.
  2068. *
  2069. * \threadsafety You may only call this function from the main thread.
  2070. *
  2071. * \since This function is available since SDL 3.0.0.
  2072. *
  2073. * \sa SDL_RenderGeometryRaw
  2074. */
  2075. extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  2076. SDL_Texture *texture,
  2077. const SDL_Vertex *vertices, int num_vertices,
  2078. const int *indices, int num_indices);
  2079. /**
  2080. * Render a list of triangles, optionally using a texture and indices into the
  2081. * vertex arrays Color and alpha modulation is done per vertex
  2082. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  2083. *
  2084. * \param renderer the rendering context.
  2085. * \param texture (optional) The SDL texture to use.
  2086. * \param xy vertex positions.
  2087. * \param xy_stride byte size to move from one element to the next element.
  2088. * \param color vertex colors (as SDL_FColor).
  2089. * \param color_stride byte size to move from one element to the next element.
  2090. * \param uv vertex normalized texture coordinates.
  2091. * \param uv_stride byte size to move from one element to the next element.
  2092. * \param num_vertices number of vertices.
  2093. * \param indices (optional) An array of indices into the 'vertices' arrays,
  2094. * if NULL all vertices will be rendered in sequential order.
  2095. * \param num_indices number of indices.
  2096. * \param size_indices index size: 1 (byte), 2 (short), 4 (int).
  2097. * \returns true on success or false on failure; call SDL_GetError() for more
  2098. * information.
  2099. *
  2100. * \threadsafety You may only call this function from the main thread.
  2101. *
  2102. * \since This function is available since SDL 3.0.0.
  2103. *
  2104. * \sa SDL_RenderGeometry
  2105. */
  2106. extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  2107. SDL_Texture *texture,
  2108. const float *xy, int xy_stride,
  2109. const SDL_FColor *color, int color_stride,
  2110. const float *uv, int uv_stride,
  2111. int num_vertices,
  2112. const void *indices, int num_indices, int size_indices);
  2113. /**
  2114. * Read pixels from the current rendering target.
  2115. *
  2116. * The returned surface should be freed with SDL_DestroySurface()
  2117. *
  2118. * **WARNING**: This is a very slow operation, and should not be used
  2119. * frequently. If you're using this on the main rendering target, it should be
  2120. * called after rendering and before SDL_RenderPresent().
  2121. *
  2122. * \param renderer the rendering context.
  2123. * \param rect an SDL_Rect structure representing the area in pixels relative
  2124. * to the to current viewport, or NULL for the entire viewport.
  2125. * \returns a new SDL_Surface on success or NULL on failure; call
  2126. * SDL_GetError() for more information.
  2127. *
  2128. * \threadsafety You may only call this function from the main thread.
  2129. *
  2130. * \since This function is available since SDL 3.0.0.
  2131. */
  2132. extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
  2133. /**
  2134. * Update the screen with any rendering performed since the previous call.
  2135. *
  2136. * SDL's rendering functions operate on a backbuffer; that is, calling a
  2137. * rendering function such as SDL_RenderLine() does not directly put a line on
  2138. * the screen, but rather updates the backbuffer. As such, you compose your
  2139. * entire scene and *present* the composed backbuffer to the screen as a
  2140. * complete picture.
  2141. *
  2142. * Therefore, when using SDL's rendering API, one does all drawing intended
  2143. * for the frame, and then calls this function once per frame to present the
  2144. * final drawing to the user.
  2145. *
  2146. * The backbuffer should be considered invalidated after each present; do not
  2147. * assume that previous contents will exist between frames. You are strongly
  2148. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  2149. * starting each new frame's drawing, even if you plan to overwrite every
  2150. * pixel.
  2151. *
  2152. * Please note, that in case of rendering to a texture - there is **no need**
  2153. * to call `SDL_RenderPresent` after drawing needed objects to a texture, and
  2154. * should not be done; you are only required to change back the rendering
  2155. * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
  2156. * textures by themselves do not have a concept of backbuffers. Calling
  2157. * SDL_RenderPresent while rendering to a texture will still update the screen
  2158. * with any current drawing that has been done _to the window itself_.
  2159. *
  2160. * \param renderer the rendering context.
  2161. * \returns true on success or false on failure; call SDL_GetError() for more
  2162. * information.
  2163. *
  2164. * \threadsafety You may only call this function from the main thread.
  2165. *
  2166. * \since This function is available since SDL 3.0.0.
  2167. *
  2168. * \sa SDL_CreateRenderer
  2169. * \sa SDL_RenderClear
  2170. * \sa SDL_RenderFillRect
  2171. * \sa SDL_RenderFillRects
  2172. * \sa SDL_RenderLine
  2173. * \sa SDL_RenderLines
  2174. * \sa SDL_RenderPoint
  2175. * \sa SDL_RenderPoints
  2176. * \sa SDL_RenderRect
  2177. * \sa SDL_RenderRects
  2178. * \sa SDL_SetRenderDrawBlendMode
  2179. * \sa SDL_SetRenderDrawColor
  2180. */
  2181. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
  2182. /**
  2183. * Destroy the specified texture.
  2184. *
  2185. * Passing NULL or an otherwise invalid texture will set the SDL error message
  2186. * to "Invalid texture".
  2187. *
  2188. * \param texture the texture to destroy.
  2189. *
  2190. * \threadsafety You may only call this function from the main thread.
  2191. *
  2192. * \since This function is available since SDL 3.0.0.
  2193. *
  2194. * \sa SDL_CreateTexture
  2195. * \sa SDL_CreateTextureFromSurface
  2196. */
  2197. extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
  2198. /**
  2199. * Destroy the rendering context for a window and free all associated
  2200. * textures.
  2201. *
  2202. * This should be called before destroying the associated window.
  2203. *
  2204. * \param renderer the rendering context.
  2205. *
  2206. * \threadsafety You may only call this function from the main thread.
  2207. *
  2208. * \since This function is available since SDL 3.0.0.
  2209. *
  2210. * \sa SDL_CreateRenderer
  2211. */
  2212. extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
  2213. /**
  2214. * Force the rendering context to flush any pending commands and state.
  2215. *
  2216. * You do not need to (and in fact, shouldn't) call this function unless you
  2217. * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
  2218. * addition to using an SDL_Renderer.
  2219. *
  2220. * This is for a very-specific case: if you are using SDL's render API, and
  2221. * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
  2222. * calls. If this applies, you should call this function between calls to
  2223. * SDL's render API and the low-level API you're using in cooperation.
  2224. *
  2225. * In all other cases, you can ignore this function.
  2226. *
  2227. * This call makes SDL flush any pending rendering work it was queueing up to
  2228. * do later in a single batch, and marks any internal cached state as invalid,
  2229. * so it'll prepare all its state again later, from scratch.
  2230. *
  2231. * This means you do not need to save state in your rendering code to protect
  2232. * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
  2233. * OpenGL state that can confuse things; you should use your best judgment and
  2234. * be prepared to make changes if specific state needs to be protected.
  2235. *
  2236. * \param renderer the rendering context.
  2237. * \returns true on success or false on failure; call SDL_GetError() for more
  2238. * information.
  2239. *
  2240. * \threadsafety You may only call this function from the main thread.
  2241. *
  2242. * \since This function is available since SDL 3.0.0.
  2243. */
  2244. extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
  2245. /**
  2246. * Get the CAMetalLayer associated with the given Metal renderer.
  2247. *
  2248. * This function returns `void *`, so SDL doesn't have to include Metal's
  2249. * headers, but it can be safely cast to a `CAMetalLayer *`.
  2250. *
  2251. * \param renderer the renderer to query.
  2252. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  2253. * Metal renderer.
  2254. *
  2255. * \threadsafety You may only call this function from the main thread.
  2256. *
  2257. * \since This function is available since SDL 3.0.0.
  2258. *
  2259. * \sa SDL_GetRenderMetalCommandEncoder
  2260. */
  2261. extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);
  2262. /**
  2263. * Get the Metal command encoder for the current frame.
  2264. *
  2265. * This function returns `void *`, so SDL doesn't have to include Metal's
  2266. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  2267. *
  2268. * This will return NULL if Metal refuses to give SDL a drawable to render to,
  2269. * which might happen if the window is hidden/minimized/offscreen. This
  2270. * doesn't apply to command encoders for render targets, just the window's
  2271. * backbuffer. Check your return values!
  2272. *
  2273. * \param renderer the renderer to query.
  2274. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  2275. * renderer isn't a Metal renderer or there was an error.
  2276. *
  2277. * \threadsafety You may only call this function from the main thread.
  2278. *
  2279. * \since This function is available since SDL 3.0.0.
  2280. *
  2281. * \sa SDL_GetRenderMetalLayer
  2282. */
  2283. extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);
  2284. /**
  2285. * Add a set of synchronization semaphores for the current frame.
  2286. *
  2287. * The Vulkan renderer will wait for `wait_semaphore` before submitting
  2288. * rendering commands and signal `signal_semaphore` after rendering commands
  2289. * are complete for this frame.
  2290. *
  2291. * This should be called each frame that you want semaphore synchronization.
  2292. * The Vulkan renderer may have multiple frames in flight on the GPU, so you
  2293. * should have multiple semaphores that are used for synchronization. Querying
  2294. * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the
  2295. * maximum number of semaphores you'll need.
  2296. *
  2297. * \param renderer the rendering context.
  2298. * \param wait_stage_mask the VkPipelineStageFlags for the wait.
  2299. * \param wait_semaphore a VkSempahore to wait on before rendering the current
  2300. * frame, or 0 if not needed.
  2301. * \param signal_semaphore a VkSempahore that SDL will signal when rendering
  2302. * for the current frame is complete, or 0 if not
  2303. * needed.
  2304. * \returns true on success or false on failure; call SDL_GetError() for more
  2305. * information.
  2306. *
  2307. * \threadsafety It is **NOT** safe to call this function from two threads at
  2308. * once.
  2309. *
  2310. * \since This function is available since SDL 3.0.0.
  2311. */
  2312. extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
  2313. /**
  2314. * Toggle VSync of the given renderer.
  2315. *
  2316. * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
  2317. *
  2318. * The `vsync` parameter can be 1 to synchronize present with every vertical
  2319. * refresh, 2 to synchronize present with every second vertical refresh, etc.,
  2320. * SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync),
  2321. * or SDL_WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is
  2322. * supported by every driver, so you should check the return value to see
  2323. * whether the requested setting is supported.
  2324. *
  2325. * \param renderer the renderer to toggle.
  2326. * \param vsync the vertical refresh sync interval.
  2327. * \returns true on success or false on failure; call SDL_GetError() for more
  2328. * information.
  2329. *
  2330. * \threadsafety You may only call this function from the main thread.
  2331. *
  2332. * \since This function is available since SDL 3.0.0.
  2333. *
  2334. * \sa SDL_GetRenderVSync
  2335. */
  2336. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
  2337. #define SDL_RENDERER_VSYNC_DISABLED 0
  2338. #define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
  2339. /**
  2340. * Get VSync of the given renderer.
  2341. *
  2342. * \param renderer the renderer to toggle.
  2343. * \param vsync an int filled with the current vertical refresh sync interval.
  2344. * See SDL_SetRenderVSync() for the meaning of the value.
  2345. * \returns true on success or false on failure; call SDL_GetError() for more
  2346. * information.
  2347. *
  2348. * \threadsafety You may only call this function from the main thread.
  2349. *
  2350. * \since This function is available since SDL 3.0.0.
  2351. *
  2352. * \sa SDL_SetRenderVSync
  2353. */
  2354. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);
  2355. /* Ends C function definitions when using C++ */
  2356. #ifdef __cplusplus
  2357. }
  2358. #endif
  2359. #include <SDL3/SDL_close_code.h>
  2360. #endif /* SDL_render_h_ */