SDL_render.h 119 KB

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