SDL_render.h 123 KB

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