SDL_render.h 121 KB

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