SDL_render.h 121 KB

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