SDL_render.h 106 KB

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