SDL_render.h 121 KB

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