2
0

SDL_render.h 123 KB

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