SDL_render.h 124 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015
  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. * With the GPU renderer:
  731. *
  732. * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture
  733. * associated with the texture, if you want to wrap an existing texture.
  734. * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_NUMBER`: the SDL_GPUTexture
  735. * associated with the UV plane of an NV12 texture, if you want to wrap an
  736. * existing texture.
  737. * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_NUMBER`: the SDL_GPUTexture
  738. * associated with the U plane of a YUV texture, if you want to wrap an
  739. * existing texture.
  740. * - `SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_NUMBER`: the SDL_GPUTexture
  741. * associated with the V plane of a YUV texture, if you want to wrap an
  742. * existing texture.
  743. *
  744. * \param renderer the rendering context.
  745. * \param props the properties to use.
  746. * \returns the created texture or NULL on failure; call SDL_GetError() for
  747. * more information.
  748. *
  749. * \threadsafety This function should only be called on the main thread.
  750. *
  751. * \since This function is available since SDL 3.2.0.
  752. *
  753. * \sa SDL_CreateProperties
  754. * \sa SDL_CreateTexture
  755. * \sa SDL_CreateTextureFromSurface
  756. * \sa SDL_DestroyTexture
  757. * \sa SDL_GetTextureSize
  758. * \sa SDL_UpdateTexture
  759. */
  760. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
  761. #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace"
  762. #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format"
  763. #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access"
  764. #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width"
  765. #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height"
  766. #define SDL_PROP_TEXTURE_CREATE_PALETTE_POINTER "SDL.texture.create.palette"
  767. #define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point"
  768. #define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom"
  769. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture"
  770. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u"
  771. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v"
  772. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture"
  773. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u"
  774. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v"
  775. #define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer"
  776. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture"
  777. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv"
  778. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u"
  779. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v"
  780. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture"
  781. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv"
  782. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u"
  783. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v"
  784. #define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture"
  785. #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_POINTER "SDL.texture.create.gpu.texture"
  786. #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_UV_POINTER "SDL.texture.create.gpu.texture_uv"
  787. #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_U_POINTER "SDL.texture.create.gpu.texture_u"
  788. #define SDL_PROP_TEXTURE_CREATE_GPU_TEXTURE_V_POINTER "SDL.texture.create.gpu.texture_v"
  789. /**
  790. * Get the properties associated with a texture.
  791. *
  792. * The following read-only properties are provided by SDL:
  793. *
  794. * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_Colorspace value describing
  795. * the texture colorspace.
  796. * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in
  797. * SDL_PixelFormat.
  798. * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in
  799. * SDL_TextureAccess.
  800. * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels.
  801. * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels.
  802. * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point
  803. * textures, this defines the value of 100% diffuse white, with higher
  804. * values being displayed in the High Dynamic Range headroom. This defaults
  805. * to 100 for HDR10 textures and 1.0 for other textures.
  806. * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point
  807. * textures, this defines the maximum dynamic range used by the content, in
  808. * terms of the SDR white point. If this is defined, any values outside the
  809. * range supported by the display will be scaled into the available HDR
  810. * headroom, otherwise they are clipped. This defaults to 1.0 for SDR
  811. * textures, 4.0 for HDR10 textures, and no default for floating point
  812. * textures.
  813. *
  814. * With the direct3d11 renderer:
  815. *
  816. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated
  817. * with the texture
  818. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  819. * associated with the U plane of a YUV texture
  820. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  821. * associated with the V plane of a YUV texture
  822. *
  823. * With the direct3d12 renderer:
  824. *
  825. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated
  826. * with the texture
  827. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated
  828. * with the U plane of a YUV texture
  829. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated
  830. * with the V plane of a YUV texture
  831. *
  832. * With the vulkan renderer:
  833. *
  834. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the
  835. * texture
  836. *
  837. * With the opengl renderer:
  838. *
  839. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated
  840. * with the texture
  841. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  842. * associated with the UV plane of an NV12 texture
  843. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated
  844. * with the U plane of a YUV texture
  845. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated
  846. * with the V plane of a YUV texture
  847. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the
  848. * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
  849. * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of
  850. * the texture (0.0 - 1.0)
  851. * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of
  852. * the texture (0.0 - 1.0)
  853. *
  854. * With the opengles2 renderer:
  855. *
  856. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  857. * associated with the texture
  858. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  859. * associated with the UV plane of an NV12 texture
  860. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  861. * associated with the U plane of a YUV texture
  862. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  863. * associated with the V plane of a YUV texture
  864. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the
  865. * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
  866. *
  867. * With the gpu renderer:
  868. *
  869. * - `SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER`: the SDL_GPUTexture associated
  870. * with the texture
  871. * - `SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER`: the SDL_GPUTexture associated
  872. * with the UV plane of an NV12 texture
  873. * - `SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER`: the SDL_GPUTexture associated
  874. * with the U plane of a YUV texture
  875. * - `SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER`: the SDL_GPUTexture associated
  876. * with the V plane of a YUV texture
  877. *
  878. * \param texture the texture to query.
  879. * \returns a valid property ID on success or 0 on failure; call
  880. * SDL_GetError() for more information.
  881. *
  882. * \threadsafety It is safe to call this function from any thread.
  883. *
  884. * \since This function is available since SDL 3.2.0.
  885. */
  886. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
  887. #define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"
  888. #define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format"
  889. #define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access"
  890. #define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width"
  891. #define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height"
  892. #define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point"
  893. #define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom"
  894. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"
  895. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"
  896. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"
  897. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"
  898. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"
  899. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"
  900. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"
  901. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"
  902. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"
  903. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"
  904. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target"
  905. #define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"
  906. #define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"
  907. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"
  908. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"
  909. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"
  910. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
  911. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target"
  912. #define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture"
  913. #define SDL_PROP_TEXTURE_GPU_TEXTURE_POINTER "SDL.texture.gpu.texture"
  914. #define SDL_PROP_TEXTURE_GPU_TEXTURE_UV_POINTER "SDL.texture.gpu.texture_uv"
  915. #define SDL_PROP_TEXTURE_GPU_TEXTURE_U_POINTER "SDL.texture.gpu.texture_u"
  916. #define SDL_PROP_TEXTURE_GPU_TEXTURE_V_POINTER "SDL.texture.gpu.texture_v"
  917. /**
  918. * Get the renderer that created an SDL_Texture.
  919. *
  920. * \param texture the texture to query.
  921. * \returns a pointer to the SDL_Renderer that created the texture, or NULL on
  922. * failure; call SDL_GetError() for more information.
  923. *
  924. * \threadsafety It is safe to call this function from any thread.
  925. *
  926. * \since This function is available since SDL 3.2.0.
  927. */
  928. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);
  929. /**
  930. * Get the size of a texture, as floating point values.
  931. *
  932. * \param texture the texture to query.
  933. * \param w a pointer filled in with the width of the texture in pixels. This
  934. * argument can be NULL if you don't need this information.
  935. * \param h a pointer filled in with the height of the texture in pixels. This
  936. * argument can be NULL if you don't need this information.
  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.2.0.
  943. */
  944. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);
  945. /**
  946. * Set the palette used by a texture.
  947. *
  948. * Setting the palette keeps an internal reference to the palette, which can
  949. * be safely destroyed afterwards.
  950. *
  951. * A single palette can be shared with many textures.
  952. *
  953. * \param texture the texture to update.
  954. * \param palette the SDL_Palette structure to use.
  955. * \returns true on success or false on failure; call SDL_GetError() for more
  956. * information.
  957. *
  958. * \threadsafety This function should only be called on the main thread.
  959. *
  960. * \since This function is available since SDL 3.4.0.
  961. *
  962. * \sa SDL_CreatePalette
  963. * \sa SDL_GetTexturePalette
  964. */
  965. extern SDL_DECLSPEC bool SDLCALL SDL_SetTexturePalette(SDL_Texture *texture, SDL_Palette *palette);
  966. /**
  967. * Get the palette used by a texture.
  968. *
  969. * \param texture the texture to query.
  970. * \returns a pointer to the palette used by the texture, or NULL if there is
  971. * no palette used.
  972. *
  973. * \threadsafety This function should only be called on the main thread.
  974. *
  975. * \since This function is available since SDL 3.4.0.
  976. *
  977. * \sa SDL_SetTexturePalette
  978. */
  979. extern SDL_DECLSPEC SDL_Palette * SDLCALL SDL_GetTexturePalette(SDL_Texture *texture);
  980. /**
  981. * Set an additional color value multiplied into render copy operations.
  982. *
  983. * When this texture is rendered, during the copy operation each source color
  984. * channel is modulated by the appropriate color value according to the
  985. * following formula:
  986. *
  987. * `srcC = srcC * (color / 255)`
  988. *
  989. * Color modulation is not always supported by the renderer; it will return
  990. * false if color modulation is not supported.
  991. *
  992. * \param texture the texture to update.
  993. * \param r the red color value multiplied into copy operations.
  994. * \param g the green color value multiplied into copy operations.
  995. * \param b the blue color value multiplied into copy operations.
  996. * \returns true on success or false on failure; call SDL_GetError() for more
  997. * information.
  998. *
  999. * \threadsafety This function should only be called on the main thread.
  1000. *
  1001. * \since This function is available since SDL 3.2.0.
  1002. *
  1003. * \sa SDL_GetTextureColorMod
  1004. * \sa SDL_SetTextureAlphaMod
  1005. * \sa SDL_SetTextureColorModFloat
  1006. */
  1007. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);
  1008. /**
  1009. * Set an additional color value multiplied into render copy operations.
  1010. *
  1011. * When this texture is rendered, during the copy operation each source color
  1012. * channel is modulated by the appropriate color value according to the
  1013. * following formula:
  1014. *
  1015. * `srcC = srcC * color`
  1016. *
  1017. * Color modulation is not always supported by the renderer; it will return
  1018. * false if color modulation is not supported.
  1019. *
  1020. * \param texture the texture to update.
  1021. * \param r the red color value multiplied into copy operations.
  1022. * \param g the green color value multiplied into copy operations.
  1023. * \param b the blue color value multiplied into copy operations.
  1024. * \returns true on success or false on failure; call SDL_GetError() for more
  1025. * information.
  1026. *
  1027. * \threadsafety This function should only be called on the main thread.
  1028. *
  1029. * \since This function is available since SDL 3.2.0.
  1030. *
  1031. * \sa SDL_GetTextureColorModFloat
  1032. * \sa SDL_SetTextureAlphaModFloat
  1033. * \sa SDL_SetTextureColorMod
  1034. */
  1035. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);
  1036. /**
  1037. * Get the additional color value multiplied into render copy operations.
  1038. *
  1039. * \param texture the texture to query.
  1040. * \param r a pointer filled in with the current red color value.
  1041. * \param g a pointer filled in with the current green color value.
  1042. * \param b a pointer filled in with the current blue color value.
  1043. * \returns true on success or false on failure; call SDL_GetError() for more
  1044. * information.
  1045. *
  1046. * \threadsafety This function should only be called on the main thread.
  1047. *
  1048. * \since This function is available since SDL 3.2.0.
  1049. *
  1050. * \sa SDL_GetTextureAlphaMod
  1051. * \sa SDL_GetTextureColorModFloat
  1052. * \sa SDL_SetTextureColorMod
  1053. */
  1054. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);
  1055. /**
  1056. * Get the additional color value multiplied into render copy operations.
  1057. *
  1058. * \param texture the texture to query.
  1059. * \param r a pointer filled in with the current red color value.
  1060. * \param g a pointer filled in with the current green color value.
  1061. * \param b a pointer filled in with the current blue color value.
  1062. * \returns true on success or false on failure; call SDL_GetError() for more
  1063. * information.
  1064. *
  1065. * \threadsafety This function should only be called on the main thread.
  1066. *
  1067. * \since This function is available since SDL 3.2.0.
  1068. *
  1069. * \sa SDL_GetTextureAlphaModFloat
  1070. * \sa SDL_GetTextureColorMod
  1071. * \sa SDL_SetTextureColorModFloat
  1072. */
  1073. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);
  1074. /**
  1075. * Set an additional alpha value multiplied into render copy operations.
  1076. *
  1077. * When this texture is rendered, during the copy operation the source alpha
  1078. * value is modulated by this alpha value according to the following formula:
  1079. *
  1080. * `srcA = srcA * (alpha / 255)`
  1081. *
  1082. * Alpha modulation is not always supported by the renderer; it will return
  1083. * false if alpha modulation is not supported.
  1084. *
  1085. * \param texture the texture to update.
  1086. * \param alpha the source alpha value multiplied into copy operations.
  1087. * \returns true on success or false on failure; call SDL_GetError() for more
  1088. * information.
  1089. *
  1090. * \threadsafety This function should only be called on the main thread.
  1091. *
  1092. * \since This function is available since SDL 3.2.0.
  1093. *
  1094. * \sa SDL_GetTextureAlphaMod
  1095. * \sa SDL_SetTextureAlphaModFloat
  1096. * \sa SDL_SetTextureColorMod
  1097. */
  1098. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
  1099. /**
  1100. * Set an additional alpha value multiplied into render copy operations.
  1101. *
  1102. * When this texture is rendered, during the copy operation the source alpha
  1103. * value is modulated by this alpha value according to the following formula:
  1104. *
  1105. * `srcA = srcA * alpha`
  1106. *
  1107. * Alpha modulation is not always supported by the renderer; it will return
  1108. * false if alpha modulation is not supported.
  1109. *
  1110. * \param texture the texture to update.
  1111. * \param alpha the source alpha value multiplied into copy operations.
  1112. * \returns true on success or false on failure; call SDL_GetError() for more
  1113. * information.
  1114. *
  1115. * \threadsafety This function should only be called on the main thread.
  1116. *
  1117. * \since This function is available since SDL 3.2.0.
  1118. *
  1119. * \sa SDL_GetTextureAlphaModFloat
  1120. * \sa SDL_SetTextureAlphaMod
  1121. * \sa SDL_SetTextureColorModFloat
  1122. */
  1123. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);
  1124. /**
  1125. * Get the additional alpha value multiplied into render copy operations.
  1126. *
  1127. * \param texture the texture to query.
  1128. * \param alpha a pointer filled in with the current alpha value.
  1129. * \returns true on success or false on failure; call SDL_GetError() for more
  1130. * information.
  1131. *
  1132. * \threadsafety This function should only be called on the main thread.
  1133. *
  1134. * \since This function is available since SDL 3.2.0.
  1135. *
  1136. * \sa SDL_GetTextureAlphaModFloat
  1137. * \sa SDL_GetTextureColorMod
  1138. * \sa SDL_SetTextureAlphaMod
  1139. */
  1140. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);
  1141. /**
  1142. * Get the additional alpha value multiplied into render copy operations.
  1143. *
  1144. * \param texture the texture to query.
  1145. * \param alpha a pointer filled in with the current alpha value.
  1146. * \returns true on success or false on failure; call SDL_GetError() for more
  1147. * information.
  1148. *
  1149. * \threadsafety This function should only be called on the main thread.
  1150. *
  1151. * \since This function is available since SDL 3.2.0.
  1152. *
  1153. * \sa SDL_GetTextureAlphaMod
  1154. * \sa SDL_GetTextureColorModFloat
  1155. * \sa SDL_SetTextureAlphaModFloat
  1156. */
  1157. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);
  1158. /**
  1159. * Set the blend mode for a texture, used by SDL_RenderTexture().
  1160. *
  1161. * If the blend mode is not supported, the closest supported mode is chosen
  1162. * and this function returns false.
  1163. *
  1164. * \param texture the texture to update.
  1165. * \param blendMode the SDL_BlendMode to use for texture blending.
  1166. * \returns true on success or false on failure; call SDL_GetError() for more
  1167. * information.
  1168. *
  1169. * \threadsafety This function should only be called on the main thread.
  1170. *
  1171. * \since This function is available since SDL 3.2.0.
  1172. *
  1173. * \sa SDL_GetTextureBlendMode
  1174. */
  1175. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);
  1176. /**
  1177. * Get the blend mode used for texture copy operations.
  1178. *
  1179. * \param texture the texture to query.
  1180. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  1181. * \returns true on success or false on failure; call SDL_GetError() for more
  1182. * information.
  1183. *
  1184. * \threadsafety This function should only be called on the main thread.
  1185. *
  1186. * \since This function is available since SDL 3.2.0.
  1187. *
  1188. * \sa SDL_SetTextureBlendMode
  1189. */
  1190. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);
  1191. /**
  1192. * Set the scale mode used for texture scale operations.
  1193. *
  1194. * The default texture scale mode is SDL_SCALEMODE_LINEAR.
  1195. *
  1196. * If the scale mode is not supported, the closest supported mode is chosen.
  1197. *
  1198. * \param texture the texture to update.
  1199. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
  1200. * \returns true on success or false on failure; call SDL_GetError() for more
  1201. * information.
  1202. *
  1203. * \threadsafety This function should only be called on the main thread.
  1204. *
  1205. * \since This function is available since SDL 3.2.0.
  1206. *
  1207. * \sa SDL_GetTextureScaleMode
  1208. */
  1209. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);
  1210. /**
  1211. * Get the scale mode used for texture scale operations.
  1212. *
  1213. * \param texture the texture to query.
  1214. * \param scaleMode a pointer filled in with the current scale mode.
  1215. * \returns true on success or false on failure; call SDL_GetError() for more
  1216. * information.
  1217. *
  1218. * \threadsafety This function should only be called on the main thread.
  1219. *
  1220. * \since This function is available since SDL 3.2.0.
  1221. *
  1222. * \sa SDL_SetTextureScaleMode
  1223. */
  1224. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
  1225. /**
  1226. * Update the given texture rectangle with new pixel data.
  1227. *
  1228. * The pixel data must be in the pixel format of the texture, which can be
  1229. * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.
  1230. *
  1231. * This is a fairly slow function, intended for use with static textures that
  1232. * do not change often.
  1233. *
  1234. * If the texture is intended to be updated often, it is preferred to create
  1235. * the texture as streaming and use the locking functions referenced below.
  1236. * While this function will work with streaming textures, for optimization
  1237. * reasons you may not get the pixels back if you lock the texture afterward.
  1238. *
  1239. * \param texture the texture to update.
  1240. * \param rect an SDL_Rect structure representing the area to update, or NULL
  1241. * to update the entire texture.
  1242. * \param pixels the raw pixel data in the format of the texture.
  1243. * \param pitch the number of bytes in a row of pixel data, including padding
  1244. * between lines.
  1245. * \returns true on success or false on failure; call SDL_GetError() for more
  1246. * information.
  1247. *
  1248. * \threadsafety This function should only be called on the main thread.
  1249. *
  1250. * \since This function is available since SDL 3.2.0.
  1251. *
  1252. * \sa SDL_LockTexture
  1253. * \sa SDL_UnlockTexture
  1254. * \sa SDL_UpdateNVTexture
  1255. * \sa SDL_UpdateYUVTexture
  1256. */
  1257. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);
  1258. /**
  1259. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  1260. * data.
  1261. *
  1262. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  1263. * block of Y and U/V planes in the proper order, but this function is
  1264. * available if your pixel data is not contiguous.
  1265. *
  1266. * \param texture the texture to update.
  1267. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  1268. * update the entire texture.
  1269. * \param Yplane the raw pixel data for the Y plane.
  1270. * \param Ypitch the number of bytes between rows of pixel data for the Y
  1271. * plane.
  1272. * \param Uplane the raw pixel data for the U plane.
  1273. * \param Upitch the number of bytes between rows of pixel data for the U
  1274. * plane.
  1275. * \param Vplane the raw pixel data for the V plane.
  1276. * \param Vpitch the number of bytes between rows of pixel data for the V
  1277. * plane.
  1278. * \returns true on success or false on failure; call SDL_GetError() for more
  1279. * information.
  1280. *
  1281. * \threadsafety This function should only be called on the main thread.
  1282. *
  1283. * \since This function is available since SDL 3.2.0.
  1284. *
  1285. * \sa SDL_UpdateNVTexture
  1286. * \sa SDL_UpdateTexture
  1287. */
  1288. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
  1289. const SDL_Rect *rect,
  1290. const Uint8 *Yplane, int Ypitch,
  1291. const Uint8 *Uplane, int Upitch,
  1292. const Uint8 *Vplane, int Vpitch);
  1293. /**
  1294. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  1295. *
  1296. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  1297. * block of NV12/21 planes in the proper order, but this function is available
  1298. * if your pixel data is not contiguous.
  1299. *
  1300. * \param texture the texture to update.
  1301. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  1302. * update the entire texture.
  1303. * \param Yplane the raw pixel data for the Y plane.
  1304. * \param Ypitch the number of bytes between rows of pixel data for the Y
  1305. * plane.
  1306. * \param UVplane the raw pixel data for the UV plane.
  1307. * \param UVpitch the number of bytes between rows of pixel data for the UV
  1308. * plane.
  1309. * \returns true on success or false on failure; call SDL_GetError() for more
  1310. * information.
  1311. *
  1312. * \threadsafety This function should only be called on the main thread.
  1313. *
  1314. * \since This function is available since SDL 3.2.0.
  1315. *
  1316. * \sa SDL_UpdateTexture
  1317. * \sa SDL_UpdateYUVTexture
  1318. */
  1319. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,
  1320. const SDL_Rect *rect,
  1321. const Uint8 *Yplane, int Ypitch,
  1322. const Uint8 *UVplane, int UVpitch);
  1323. /**
  1324. * Lock a portion of the texture for **write-only** pixel access.
  1325. *
  1326. * As an optimization, the pixels made available for editing don't necessarily
  1327. * contain the old texture data. This is a write-only operation, and if you
  1328. * need to keep a copy of the texture data you should do that at the
  1329. * application level.
  1330. *
  1331. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1332. * changes.
  1333. *
  1334. * \param texture the texture to lock for access, which was created with
  1335. * `SDL_TEXTUREACCESS_STREAMING`.
  1336. * \param rect an SDL_Rect structure representing the area to lock for access;
  1337. * NULL to lock the entire texture.
  1338. * \param pixels this is filled in with a pointer to the locked pixels,
  1339. * appropriately offset by the locked area.
  1340. * \param pitch this is filled in with the pitch of the locked pixels; the
  1341. * pitch is the length of one row in bytes.
  1342. * \returns true on success or false if the texture is not valid or was not
  1343. * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError()
  1344. * for more information.
  1345. *
  1346. * \threadsafety This function should only be called on the main thread.
  1347. *
  1348. * \since This function is available since SDL 3.2.0.
  1349. *
  1350. * \sa SDL_LockTextureToSurface
  1351. * \sa SDL_UnlockTexture
  1352. */
  1353. extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture,
  1354. const SDL_Rect *rect,
  1355. void **pixels, int *pitch);
  1356. /**
  1357. * Lock a portion of the texture for **write-only** pixel access, and expose
  1358. * it as a SDL surface.
  1359. *
  1360. * Besides providing an SDL_Surface instead of raw pixel data, this function
  1361. * operates like SDL_LockTexture.
  1362. *
  1363. * As an optimization, the pixels made available for editing don't necessarily
  1364. * contain the old texture data. This is a write-only operation, and if you
  1365. * need to keep a copy of the texture data you should do that at the
  1366. * application level.
  1367. *
  1368. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1369. * changes.
  1370. *
  1371. * The returned surface is freed internally after calling SDL_UnlockTexture()
  1372. * or SDL_DestroyTexture(). The caller should not free it.
  1373. *
  1374. * \param texture the texture to lock for access, which must be created with
  1375. * `SDL_TEXTUREACCESS_STREAMING`.
  1376. * \param rect a pointer to the rectangle to lock for access. If the rect is
  1377. * NULL, the entire texture will be locked.
  1378. * \param surface a pointer to an SDL surface of size **rect**. Don't assume
  1379. * any specific pixel content.
  1380. * \returns true on success or false on failure; call SDL_GetError() for more
  1381. * information.
  1382. *
  1383. * \threadsafety This function should only be called on the main thread.
  1384. *
  1385. * \since This function is available since SDL 3.2.0.
  1386. *
  1387. * \sa SDL_LockTexture
  1388. * \sa SDL_UnlockTexture
  1389. */
  1390. extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface);
  1391. /**
  1392. * Unlock a texture, uploading the changes to video memory, if needed.
  1393. *
  1394. * **Warning**: Please note that SDL_LockTexture() is intended to be
  1395. * write-only; it will not guarantee the previous contents of the texture will
  1396. * be provided. You must fully initialize any area of a texture that you lock
  1397. * before unlocking it, as the pixels might otherwise be uninitialized memory.
  1398. *
  1399. * Which is to say: locking and immediately unlocking a texture can result in
  1400. * corrupted textures, depending on the renderer in use.
  1401. *
  1402. * \param texture a texture locked by SDL_LockTexture().
  1403. *
  1404. * \threadsafety This function should only be called on the main thread.
  1405. *
  1406. * \since This function is available since SDL 3.2.0.
  1407. *
  1408. * \sa SDL_LockTexture
  1409. */
  1410. extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
  1411. /**
  1412. * Set a texture as the current rendering target.
  1413. *
  1414. * The default render target is the window for which the renderer was created.
  1415. * To stop rendering to a texture and render to the window again, call this
  1416. * function with a NULL `texture`.
  1417. *
  1418. * Viewport, cliprect, scale, and logical presentation are unique to each
  1419. * render target. Get and set functions for these states apply to the current
  1420. * render target set by this function, and those states persist on each target
  1421. * when the current render target changes.
  1422. *
  1423. * \param renderer the rendering context.
  1424. * \param texture the targeted texture, which must be created with the
  1425. * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
  1426. * window instead of a texture.
  1427. * \returns true on success or false on failure; call SDL_GetError() for more
  1428. * information.
  1429. *
  1430. * \threadsafety This function should only be called on the main thread.
  1431. *
  1432. * \since This function is available since SDL 3.2.0.
  1433. *
  1434. * \sa SDL_GetRenderTarget
  1435. */
  1436. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);
  1437. /**
  1438. * Get the current render target.
  1439. *
  1440. * The default render target is the window for which the renderer was created,
  1441. * and is reported a NULL here.
  1442. *
  1443. * \param renderer the rendering context.
  1444. * \returns the current render target or NULL for the default render target.
  1445. *
  1446. * \threadsafety This function should only be called on the main thread.
  1447. *
  1448. * \since This function is available since SDL 3.2.0.
  1449. *
  1450. * \sa SDL_SetRenderTarget
  1451. */
  1452. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  1453. /**
  1454. * Set a device-independent resolution and presentation mode for rendering.
  1455. *
  1456. * This function sets the width and height of the logical rendering output.
  1457. * The renderer will act as if the current render target is always the
  1458. * requested dimensions, scaling to the actual resolution as necessary.
  1459. *
  1460. * This can be useful for games that expect a fixed size, but would like to
  1461. * scale the output to whatever is available, regardless of how a user resizes
  1462. * a window, or if the display is high DPI.
  1463. *
  1464. * Logical presentation can be used with both render target textures and the
  1465. * renderer's window; the state is unique to each render target, and this
  1466. * function sets the state for the current render target. It might be useful
  1467. * to draw to a texture that matches the window dimensions with logical
  1468. * presentation enabled, and then draw that texture across the entire window
  1469. * with logical presentation disabled. Be careful not to render both with
  1470. * logical presentation enabled, however, as this could produce
  1471. * double-letterboxing, etc.
  1472. *
  1473. * You can disable logical coordinates by setting the mode to
  1474. * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
  1475. * resolution of the render target; it is safe to toggle logical presentation
  1476. * during the rendering of a frame: perhaps most of the rendering is done to
  1477. * specific dimensions but to make fonts look sharp, the app turns off logical
  1478. * presentation while drawing text, for example.
  1479. *
  1480. * You can convert coordinates in an event into rendering coordinates using
  1481. * SDL_ConvertEventToRenderCoordinates().
  1482. *
  1483. * \param renderer the rendering context.
  1484. * \param w the width of the logical resolution.
  1485. * \param h the height of the logical resolution.
  1486. * \param mode the presentation mode used.
  1487. * \returns true on success or false on failure; call SDL_GetError() for more
  1488. * information.
  1489. *
  1490. * \threadsafety This function should only be called on the main thread.
  1491. *
  1492. * \since This function is available since SDL 3.2.0.
  1493. *
  1494. * \sa SDL_ConvertEventToRenderCoordinates
  1495. * \sa SDL_GetRenderLogicalPresentation
  1496. * \sa SDL_GetRenderLogicalPresentationRect
  1497. */
  1498. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode);
  1499. /**
  1500. * Get device independent resolution and presentation mode for rendering.
  1501. *
  1502. * This function gets the width and height of the logical rendering output, or
  1503. * 0 if a logical resolution is not enabled.
  1504. *
  1505. * Each render target has its own logical presentation state. This function
  1506. * gets the state for the current render target.
  1507. *
  1508. * \param renderer the rendering context.
  1509. * \param w an int filled with the logical presentation width.
  1510. * \param h an int filled with the logical presentation height.
  1511. * \param mode a variable filled with the logical presentation mode being
  1512. * used.
  1513. * \returns true on success or false on failure; call SDL_GetError() for more
  1514. * information.
  1515. *
  1516. * \threadsafety This function should only be called on the main thread.
  1517. *
  1518. * \since This function is available since SDL 3.2.0.
  1519. *
  1520. * \sa SDL_SetRenderLogicalPresentation
  1521. */
  1522. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode);
  1523. /**
  1524. * Get the final presentation rectangle for rendering.
  1525. *
  1526. * This function returns the calculated rectangle used for logical
  1527. * presentation, based on the presentation mode and output size. If logical
  1528. * presentation is disabled, it will fill the rectangle with the output size,
  1529. * in pixels.
  1530. *
  1531. * Each render target has its own logical presentation state. This function
  1532. * gets the rectangle for the current render target.
  1533. *
  1534. * \param renderer the rendering context.
  1535. * \param rect a pointer filled in with the final presentation rectangle, may
  1536. * be NULL.
  1537. * \returns true on success or false on failure; call SDL_GetError() for more
  1538. * information.
  1539. *
  1540. * \threadsafety This function should only be called on the main thread.
  1541. *
  1542. * \since This function is available since SDL 3.2.0.
  1543. *
  1544. * \sa SDL_SetRenderLogicalPresentation
  1545. */
  1546. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect);
  1547. /**
  1548. * Get a point in render coordinates when given a point in window coordinates.
  1549. *
  1550. * This takes into account several states:
  1551. *
  1552. * - The window dimensions.
  1553. * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
  1554. * - The scale (SDL_SetRenderScale)
  1555. * - The viewport (SDL_SetRenderViewport)
  1556. *
  1557. * \param renderer the rendering context.
  1558. * \param window_x the x coordinate in window coordinates.
  1559. * \param window_y the y coordinate in window coordinates.
  1560. * \param x a pointer filled with the x coordinate in render coordinates.
  1561. * \param y a pointer filled with the y coordinate in render coordinates.
  1562. * \returns true on success or false on failure; call SDL_GetError() for more
  1563. * information.
  1564. *
  1565. * \threadsafety This function should only be called on the main thread.
  1566. *
  1567. * \since This function is available since SDL 3.2.0.
  1568. *
  1569. * \sa SDL_SetRenderLogicalPresentation
  1570. * \sa SDL_SetRenderScale
  1571. */
  1572. extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
  1573. /**
  1574. * Get a point in window coordinates when given a point in render coordinates.
  1575. *
  1576. * This takes into account several states:
  1577. *
  1578. * - The window dimensions.
  1579. * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
  1580. * - The scale (SDL_SetRenderScale)
  1581. * - The viewport (SDL_SetRenderViewport)
  1582. *
  1583. * \param renderer the rendering context.
  1584. * \param x the x coordinate in render coordinates.
  1585. * \param y the y coordinate in render coordinates.
  1586. * \param window_x a pointer filled with the x coordinate in window
  1587. * coordinates.
  1588. * \param window_y a pointer filled with the y coordinate in window
  1589. * coordinates.
  1590. * \returns true on success or false on failure; call SDL_GetError() for more
  1591. * information.
  1592. *
  1593. * \threadsafety This function should only be called on the main thread.
  1594. *
  1595. * \since This function is available since SDL 3.2.0.
  1596. *
  1597. * \sa SDL_SetRenderLogicalPresentation
  1598. * \sa SDL_SetRenderScale
  1599. * \sa SDL_SetRenderViewport
  1600. */
  1601. extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
  1602. /**
  1603. * Convert the coordinates in an event to render coordinates.
  1604. *
  1605. * This takes into account several states:
  1606. *
  1607. * - The window dimensions.
  1608. * - The logical presentation settings (SDL_SetRenderLogicalPresentation)
  1609. * - The scale (SDL_SetRenderScale)
  1610. * - The viewport (SDL_SetRenderViewport)
  1611. *
  1612. * Various event types are converted with this function: mouse, touch, pen,
  1613. * etc.
  1614. *
  1615. * Touch coordinates are converted from normalized coordinates in the window
  1616. * to non-normalized rendering coordinates.
  1617. *
  1618. * Relative mouse coordinates (xrel and yrel event fields) are _also_
  1619. * converted. Applications that do not want these fields converted should use
  1620. * SDL_RenderCoordinatesFromWindow() on the specific event fields instead of
  1621. * converting the entire event structure.
  1622. *
  1623. * Once converted, coordinates may be outside the rendering area.
  1624. *
  1625. * \param renderer the rendering context.
  1626. * \param event the event to modify.
  1627. * \returns true on success or false on failure; call SDL_GetError() for more
  1628. * information.
  1629. *
  1630. * \threadsafety This function should only be called on the main thread.
  1631. *
  1632. * \since This function is available since SDL 3.2.0.
  1633. *
  1634. * \sa SDL_RenderCoordinatesFromWindow
  1635. */
  1636. extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
  1637. /**
  1638. * Set the drawing area for rendering on the current target.
  1639. *
  1640. * Drawing will clip to this area (separately from any clipping done with
  1641. * SDL_SetRenderClipRect), and the top left of the area will become coordinate
  1642. * (0, 0) for future drawing commands.
  1643. *
  1644. * The area's width and height must be >= 0.
  1645. *
  1646. * Each render target has its own viewport. This function sets the viewport
  1647. * for the current render target.
  1648. *
  1649. * \param renderer the rendering context.
  1650. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  1651. * to set the viewport to the entire target.
  1652. * \returns true on success or false on failure; call SDL_GetError() for more
  1653. * information.
  1654. *
  1655. * \threadsafety This function should only be called on the main thread.
  1656. *
  1657. * \since This function is available since SDL 3.2.0.
  1658. *
  1659. * \sa SDL_GetRenderViewport
  1660. * \sa SDL_RenderViewportSet
  1661. */
  1662. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);
  1663. /**
  1664. * Get the drawing area for the current target.
  1665. *
  1666. * Each render target has its own viewport. This function gets the viewport
  1667. * for the current render target.
  1668. *
  1669. * \param renderer the rendering context.
  1670. * \param rect an SDL_Rect structure filled in with the current drawing area.
  1671. * \returns true on success or false on failure; call SDL_GetError() for more
  1672. * information.
  1673. *
  1674. * \threadsafety This function should only be called on the main thread.
  1675. *
  1676. * \since This function is available since SDL 3.2.0.
  1677. *
  1678. * \sa SDL_RenderViewportSet
  1679. * \sa SDL_SetRenderViewport
  1680. */
  1681. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
  1682. /**
  1683. * Return whether an explicit rectangle was set as the viewport.
  1684. *
  1685. * This is useful if you're saving and restoring the viewport and want to know
  1686. * whether you should restore a specific rectangle or NULL.
  1687. *
  1688. * Each render target has its own viewport. This function checks the viewport
  1689. * for the current render target.
  1690. *
  1691. * \param renderer the rendering context.
  1692. * \returns true if the viewport was set to a specific rectangle, or false if
  1693. * it was set to NULL (the entire target).
  1694. *
  1695. * \threadsafety This function should only be called on the main thread.
  1696. *
  1697. * \since This function is available since SDL 3.2.0.
  1698. *
  1699. * \sa SDL_GetRenderViewport
  1700. * \sa SDL_SetRenderViewport
  1701. */
  1702. extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer);
  1703. /**
  1704. * Get the safe area for rendering within the current viewport.
  1705. *
  1706. * Some devices have portions of the screen which are partially obscured or
  1707. * not interactive, possibly due to on-screen controls, curved edges, camera
  1708. * notches, TV overscan, etc. This function provides the area of the current
  1709. * viewport which is safe to have interactible content. You should continue
  1710. * rendering into the rest of the render target, but it should not contain
  1711. * visually important or interactible content.
  1712. *
  1713. * \param renderer the rendering context.
  1714. * \param rect a pointer filled in with the area that is safe for interactive
  1715. * content.
  1716. * \returns true on success or false on failure; call SDL_GetError() for more
  1717. * information.
  1718. *
  1719. * \threadsafety This function should only be called on the main thread.
  1720. *
  1721. * \since This function is available since SDL 3.2.0.
  1722. */
  1723. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect);
  1724. /**
  1725. * Set the clip rectangle for rendering on the specified target.
  1726. *
  1727. * Each render target has its own clip rectangle. This function sets the
  1728. * cliprect for the current render target.
  1729. *
  1730. * \param renderer the rendering context.
  1731. * \param rect an SDL_Rect structure representing the clip area, relative to
  1732. * the viewport, or NULL to disable clipping.
  1733. * \returns true on success or false on failure; call SDL_GetError() for more
  1734. * information.
  1735. *
  1736. * \threadsafety This function should only be called on the main thread.
  1737. *
  1738. * \since This function is available since SDL 3.2.0.
  1739. *
  1740. * \sa SDL_GetRenderClipRect
  1741. * \sa SDL_RenderClipEnabled
  1742. */
  1743. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);
  1744. /**
  1745. * Get the clip rectangle for the current target.
  1746. *
  1747. * Each render target has its own clip rectangle. This function gets the
  1748. * cliprect for the current render target.
  1749. *
  1750. * \param renderer the rendering context.
  1751. * \param rect an SDL_Rect structure filled in with the current clipping area
  1752. * or an empty rectangle if clipping is disabled.
  1753. * \returns true on success or false on failure; call SDL_GetError() for more
  1754. * 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_RenderClipEnabled
  1761. * \sa SDL_SetRenderClipRect
  1762. */
  1763. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
  1764. /**
  1765. * Get whether clipping is enabled on the given render target.
  1766. *
  1767. * Each render target has its own clip rectangle. This function checks the
  1768. * cliprect for the current render target.
  1769. *
  1770. * \param renderer the rendering context.
  1771. * \returns true if clipping is enabled or false if not; call SDL_GetError()
  1772. * for more information.
  1773. *
  1774. * \threadsafety This function should only be called on the main thread.
  1775. *
  1776. * \since This function is available since SDL 3.2.0.
  1777. *
  1778. * \sa SDL_GetRenderClipRect
  1779. * \sa SDL_SetRenderClipRect
  1780. */
  1781. extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
  1782. /**
  1783. * Set the drawing scale for rendering on the current target.
  1784. *
  1785. * The drawing coordinates are scaled by the x/y scaling factors before they
  1786. * are used by the renderer. This allows resolution independent drawing with a
  1787. * single coordinate system.
  1788. *
  1789. * If this results in scaling or subpixel drawing by the rendering backend, it
  1790. * will be handled using the appropriate quality hints. For best results use
  1791. * integer scaling factors.
  1792. *
  1793. * Each render target has its own scale. This function sets the scale for the
  1794. * current render target.
  1795. *
  1796. * \param renderer the rendering context.
  1797. * \param scaleX the horizontal scaling factor.
  1798. * \param scaleY the vertical scaling factor.
  1799. * \returns true on success or false on failure; call SDL_GetError() for more
  1800. * information.
  1801. *
  1802. * \threadsafety This function should only be called on the main thread.
  1803. *
  1804. * \since This function is available since SDL 3.2.0.
  1805. *
  1806. * \sa SDL_GetRenderScale
  1807. */
  1808. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
  1809. /**
  1810. * Get the drawing scale for the current target.
  1811. *
  1812. * Each render target has its own scale. This function gets the scale for the
  1813. * current render target.
  1814. *
  1815. * \param renderer the rendering context.
  1816. * \param scaleX a pointer filled in with the horizontal scaling factor.
  1817. * \param scaleY a pointer filled in with the vertical scaling factor.
  1818. * \returns true on success or false on failure; call SDL_GetError() for more
  1819. * information.
  1820. *
  1821. * \threadsafety This function should only be called on the main thread.
  1822. *
  1823. * \since This function is available since SDL 3.2.0.
  1824. *
  1825. * \sa SDL_SetRenderScale
  1826. */
  1827. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
  1828. /**
  1829. * Set the color used for drawing operations.
  1830. *
  1831. * Set the color for drawing or filling rectangles, lines, and points, and for
  1832. * SDL_RenderClear().
  1833. *
  1834. * \param renderer the rendering context.
  1835. * \param r the red value used to draw on the rendering target.
  1836. * \param g the green value used to draw on the rendering target.
  1837. * \param b the blue value used to draw on the rendering target.
  1838. * \param a the alpha value used to draw on the rendering target; usually
  1839. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  1840. * specify how the alpha channel is used.
  1841. * \returns true on success or false on failure; call SDL_GetError() for more
  1842. * information.
  1843. *
  1844. * \threadsafety This function should only be called on the main thread.
  1845. *
  1846. * \since This function is available since SDL 3.2.0.
  1847. *
  1848. * \sa SDL_GetRenderDrawColor
  1849. * \sa SDL_SetRenderDrawColorFloat
  1850. */
  1851. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  1852. /**
  1853. * Set the color used for drawing operations (Rect, Line and Clear).
  1854. *
  1855. * Set the color for drawing or filling rectangles, lines, and points, and for
  1856. * SDL_RenderClear().
  1857. *
  1858. * \param renderer the rendering context.
  1859. * \param r the red value used to draw on the rendering target.
  1860. * \param g the green value used to draw on the rendering target.
  1861. * \param b the blue value used to draw on the rendering target.
  1862. * \param a the alpha value used to draw on the rendering target. Use
  1863. * SDL_SetRenderDrawBlendMode to specify how the alpha channel is
  1864. * used.
  1865. * \returns true on success or false on failure; call SDL_GetError() for more
  1866. * information.
  1867. *
  1868. * \threadsafety This function should only be called on the main thread.
  1869. *
  1870. * \since This function is available since SDL 3.2.0.
  1871. *
  1872. * \sa SDL_GetRenderDrawColorFloat
  1873. * \sa SDL_SetRenderDrawColor
  1874. */
  1875. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);
  1876. /**
  1877. * Get the color used for drawing operations (Rect, Line and Clear).
  1878. *
  1879. * \param renderer the rendering context.
  1880. * \param r a pointer filled in with the red value used to draw on the
  1881. * rendering target.
  1882. * \param g a pointer filled in with the green value used to draw on the
  1883. * rendering target.
  1884. * \param b a pointer filled in with the blue value used to draw on the
  1885. * rendering target.
  1886. * \param a a pointer filled in with the alpha value used to draw on the
  1887. * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
  1888. * \returns true on success or false on failure; call SDL_GetError() for more
  1889. * information.
  1890. *
  1891. * \threadsafety This function should only be called on the main thread.
  1892. *
  1893. * \since This function is available since SDL 3.2.0.
  1894. *
  1895. * \sa SDL_GetRenderDrawColorFloat
  1896. * \sa SDL_SetRenderDrawColor
  1897. */
  1898. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
  1899. /**
  1900. * Get the color used for drawing operations (Rect, Line and Clear).
  1901. *
  1902. * \param renderer the rendering context.
  1903. * \param r a pointer filled in with the red value used to draw on the
  1904. * rendering target.
  1905. * \param g a pointer filled in with the green value used to draw on the
  1906. * rendering target.
  1907. * \param b a pointer filled in with the blue value used to draw on the
  1908. * rendering target.
  1909. * \param a a pointer filled in with the alpha value used to draw on the
  1910. * rendering target.
  1911. * \returns true on success or false on failure; call SDL_GetError() for more
  1912. * information.
  1913. *
  1914. * \threadsafety This function should only be called on the main thread.
  1915. *
  1916. * \since This function is available since SDL 3.2.0.
  1917. *
  1918. * \sa SDL_SetRenderDrawColorFloat
  1919. * \sa SDL_GetRenderDrawColor
  1920. */
  1921. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);
  1922. /**
  1923. * Set the color scale used for render operations.
  1924. *
  1925. * The color scale is an additional scale multiplied into the pixel color
  1926. * value while rendering. This can be used to adjust the brightness of colors
  1927. * during HDR rendering, or changing HDR video brightness when playing on an
  1928. * SDR display.
  1929. *
  1930. * The color scale does not affect the alpha channel, only the color
  1931. * brightness.
  1932. *
  1933. * \param renderer the rendering context.
  1934. * \param scale the color scale value.
  1935. * \returns true on success or false on failure; call SDL_GetError() for more
  1936. * information.
  1937. *
  1938. * \threadsafety This function should only be called on the main thread.
  1939. *
  1940. * \since This function is available since SDL 3.2.0.
  1941. *
  1942. * \sa SDL_GetRenderColorScale
  1943. */
  1944. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);
  1945. /**
  1946. * Get the color scale used for render operations.
  1947. *
  1948. * \param renderer the rendering context.
  1949. * \param scale a pointer filled in with the current color scale value.
  1950. * \returns true on success or false on failure; call SDL_GetError() for more
  1951. * information.
  1952. *
  1953. * \threadsafety This function should only be called on the main thread.
  1954. *
  1955. * \since This function is available since SDL 3.2.0.
  1956. *
  1957. * \sa SDL_SetRenderColorScale
  1958. */
  1959. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale);
  1960. /**
  1961. * Set the blend mode used for drawing operations (Fill and Line).
  1962. *
  1963. * If the blend mode is not supported, the closest supported mode is chosen.
  1964. *
  1965. * \param renderer the rendering context.
  1966. * \param blendMode the SDL_BlendMode to use for blending.
  1967. * \returns true on success or false on failure; call SDL_GetError() for more
  1968. * information.
  1969. *
  1970. * \threadsafety This function should only be called on the main thread.
  1971. *
  1972. * \since This function is available since SDL 3.2.0.
  1973. *
  1974. * \sa SDL_GetRenderDrawBlendMode
  1975. */
  1976. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
  1977. /**
  1978. * Get the blend mode used for drawing operations.
  1979. *
  1980. * \param renderer the rendering context.
  1981. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  1982. * \returns true on success or false on failure; call SDL_GetError() for more
  1983. * information.
  1984. *
  1985. * \threadsafety This function should only be called on the main thread.
  1986. *
  1987. * \since This function is available since SDL 3.2.0.
  1988. *
  1989. * \sa SDL_SetRenderDrawBlendMode
  1990. */
  1991. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);
  1992. /**
  1993. * Clear the current rendering target with the drawing color.
  1994. *
  1995. * This function clears the entire rendering target, ignoring the viewport and
  1996. * the clip rectangle. Note, that clearing will also set/fill all pixels of
  1997. * the rendering target to current renderer draw color, so make sure to invoke
  1998. * SDL_SetRenderDrawColor() when needed.
  1999. *
  2000. * \param renderer the rendering context.
  2001. * \returns true on success or false on failure; call SDL_GetError() for more
  2002. * information.
  2003. *
  2004. * \threadsafety This function should only be called on the main thread.
  2005. *
  2006. * \since This function is available since SDL 3.2.0.
  2007. *
  2008. * \sa SDL_SetRenderDrawColor
  2009. */
  2010. extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
  2011. /**
  2012. * Draw a point on the current rendering target at subpixel precision.
  2013. *
  2014. * \param renderer the renderer which should draw a point.
  2015. * \param x the x coordinate of the point.
  2016. * \param y the y coordinate of the point.
  2017. * \returns true on success or false on failure; call SDL_GetError() for more
  2018. * information.
  2019. *
  2020. * \threadsafety This function should only be called on the main thread.
  2021. *
  2022. * \since This function is available since SDL 3.2.0.
  2023. *
  2024. * \sa SDL_RenderPoints
  2025. */
  2026. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);
  2027. /**
  2028. * Draw multiple points on the current rendering target at subpixel precision.
  2029. *
  2030. * \param renderer the renderer which should draw multiple points.
  2031. * \param points the points to draw.
  2032. * \param count the number of points to draw.
  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_RenderPoint
  2041. */
  2042. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  2043. /**
  2044. * Draw a line on the current rendering target at subpixel precision.
  2045. *
  2046. * \param renderer the renderer which should draw a line.
  2047. * \param x1 the x coordinate of the start point.
  2048. * \param y1 the y coordinate of the start point.
  2049. * \param x2 the x coordinate of the end point.
  2050. * \param y2 the y coordinate of the end point.
  2051. * \returns true on success or false on failure; call SDL_GetError() for more
  2052. * information.
  2053. *
  2054. * \threadsafety This function should only be called on the main thread.
  2055. *
  2056. * \since This function is available since SDL 3.2.0.
  2057. *
  2058. * \sa SDL_RenderLines
  2059. */
  2060. extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
  2061. /**
  2062. * Draw a series of connected lines on the current rendering target at
  2063. * subpixel precision.
  2064. *
  2065. * \param renderer the renderer which should draw multiple lines.
  2066. * \param points the points along the lines.
  2067. * \param count the number of points, drawing count-1 lines.
  2068. * \returns true on success or false on failure; call SDL_GetError() for more
  2069. * information.
  2070. *
  2071. * \threadsafety This function should only be called on the main thread.
  2072. *
  2073. * \since This function is available since SDL 3.2.0.
  2074. *
  2075. * \sa SDL_RenderLine
  2076. */
  2077. extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  2078. /**
  2079. * Draw a rectangle on the current rendering target at subpixel precision.
  2080. *
  2081. * \param renderer the renderer which should draw a rectangle.
  2082. * \param rect a pointer to the destination rectangle, or NULL to outline the
  2083. * entire rendering target.
  2084. * \returns true on success or false on failure; call SDL_GetError() for more
  2085. * information.
  2086. *
  2087. * \threadsafety This function should only be called on the main thread.
  2088. *
  2089. * \since This function is available since SDL 3.2.0.
  2090. *
  2091. * \sa SDL_RenderRects
  2092. */
  2093. extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  2094. /**
  2095. * Draw some number of rectangles on the current rendering target at subpixel
  2096. * precision.
  2097. *
  2098. * \param renderer the renderer which should draw multiple rectangles.
  2099. * \param rects a pointer to an array of destination rectangles.
  2100. * \param count the number of rectangles.
  2101. * \returns true on success or false on failure; call SDL_GetError() for more
  2102. * information.
  2103. *
  2104. * \threadsafety This function should only be called on the main thread.
  2105. *
  2106. * \since This function is available since SDL 3.2.0.
  2107. *
  2108. * \sa SDL_RenderRect
  2109. */
  2110. extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  2111. /**
  2112. * Fill a rectangle on the current rendering target with the drawing color at
  2113. * subpixel precision.
  2114. *
  2115. * \param renderer the renderer which should fill a rectangle.
  2116. * \param rect a pointer to the destination rectangle, or NULL for the entire
  2117. * rendering target.
  2118. * \returns true on success or false on failure; call SDL_GetError() for more
  2119. * information.
  2120. *
  2121. * \threadsafety This function should only be called on the main thread.
  2122. *
  2123. * \since This function is available since SDL 3.2.0.
  2124. *
  2125. * \sa SDL_RenderFillRects
  2126. */
  2127. extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  2128. /**
  2129. * Fill some number of rectangles on the current rendering target with the
  2130. * drawing color at subpixel precision.
  2131. *
  2132. * \param renderer the renderer which should fill multiple rectangles.
  2133. * \param rects a pointer to an array of destination rectangles.
  2134. * \param count the number of rectangles.
  2135. * \returns true on success or false on failure; call SDL_GetError() for more
  2136. * information.
  2137. *
  2138. * \threadsafety This function should only be called on the main thread.
  2139. *
  2140. * \since This function is available since SDL 3.2.0.
  2141. *
  2142. * \sa SDL_RenderFillRect
  2143. */
  2144. extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  2145. /**
  2146. * Copy a portion of the texture to the current rendering target at subpixel
  2147. * precision.
  2148. *
  2149. * \param renderer the renderer which should copy parts of a texture.
  2150. * \param texture the source texture.
  2151. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  2152. * texture.
  2153. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2154. * entire rendering target.
  2155. * \returns true on success or false on failure; call SDL_GetError() for more
  2156. * information.
  2157. *
  2158. * \threadsafety This function should only be called on the main thread.
  2159. *
  2160. * \since This function is available since SDL 3.2.0.
  2161. *
  2162. * \sa SDL_RenderTextureRotated
  2163. * \sa SDL_RenderTextureTiled
  2164. */
  2165. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);
  2166. /**
  2167. * Copy a portion of the source texture to the current rendering target, with
  2168. * rotation and flipping, at subpixel precision.
  2169. *
  2170. * \param renderer the renderer which should copy parts of a texture.
  2171. * \param texture the source texture.
  2172. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  2173. * texture.
  2174. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2175. * entire rendering target.
  2176. * \param angle an angle in degrees that indicates the rotation that will be
  2177. * applied to dstrect, rotating it in a clockwise direction.
  2178. * \param center a pointer to a point indicating the point around which
  2179. * dstrect will be rotated (if NULL, rotation will be done
  2180. * around dstrect.w/2, dstrect.h/2).
  2181. * \param flip an SDL_FlipMode value stating which flipping actions should be
  2182. * performed on the texture.
  2183. * \returns true on success or false on failure; call SDL_GetError() for more
  2184. * information.
  2185. *
  2186. * \threadsafety This function should only be called on the main thread.
  2187. *
  2188. * \since This function is available since SDL 3.2.0.
  2189. *
  2190. * \sa SDL_RenderTexture
  2191. */
  2192. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
  2193. const SDL_FRect *srcrect, const SDL_FRect *dstrect,
  2194. double angle, const SDL_FPoint *center,
  2195. SDL_FlipMode flip);
  2196. /**
  2197. * Copy a portion of the source texture to the current rendering target, with
  2198. * affine transform, at subpixel precision.
  2199. *
  2200. * \param renderer the renderer which should copy parts of a texture.
  2201. * \param texture the source texture.
  2202. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  2203. * texture.
  2204. * \param origin a pointer to a point indicating where the top-left corner of
  2205. * srcrect should be mapped to, or NULL for the rendering
  2206. * target's origin.
  2207. * \param right a pointer to a point indicating where the top-right corner of
  2208. * srcrect should be mapped to, or NULL for the rendering
  2209. * target's top-right corner.
  2210. * \param down a pointer to a point indicating where the bottom-left corner of
  2211. * srcrect should be mapped to, or NULL for the rendering target's
  2212. * bottom-left corner.
  2213. * \returns true on success or false on failure; call SDL_GetError() for more
  2214. * information.
  2215. *
  2216. * \threadsafety You may only call this function from the main thread.
  2217. *
  2218. * \since This function is available since SDL 3.2.0.
  2219. *
  2220. * \sa SDL_RenderTexture
  2221. */
  2222. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureAffine(SDL_Renderer *renderer, SDL_Texture *texture,
  2223. const SDL_FRect *srcrect, const SDL_FPoint *origin,
  2224. const SDL_FPoint *right, const SDL_FPoint *down);
  2225. /**
  2226. * Tile a portion of the texture to the current rendering target at subpixel
  2227. * precision.
  2228. *
  2229. * The pixels in `srcrect` will be repeated as many times as needed to
  2230. * completely fill `dstrect`.
  2231. *
  2232. * \param renderer the renderer which should copy parts of a texture.
  2233. * \param texture the source texture.
  2234. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  2235. * texture.
  2236. * \param scale the scale used to transform srcrect into the destination
  2237. * rectangle, e.g. a 32x32 texture with a scale of 2 would fill
  2238. * 64x64 tiles.
  2239. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2240. * entire rendering target.
  2241. * \returns true on success or false on failure; call SDL_GetError() for more
  2242. * information.
  2243. *
  2244. * \threadsafety This function should only be called on the main thread.
  2245. *
  2246. * \since This function is available since SDL 3.2.0.
  2247. *
  2248. * \sa SDL_RenderTexture
  2249. */
  2250. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect);
  2251. /**
  2252. * Perform a scaled copy using the 9-grid algorithm to the current rendering
  2253. * target at subpixel precision.
  2254. *
  2255. * The pixels in the texture are split into a 3x3 grid, using the different
  2256. * corner sizes for each corner, and the sides and center making up the
  2257. * remaining pixels. The corners are then scaled using `scale` and fit into
  2258. * the corners of the destination rectangle. The sides and center are then
  2259. * stretched into place to cover the remaining destination rectangle.
  2260. *
  2261. * \param renderer the renderer which should copy parts of a texture.
  2262. * \param texture the source texture.
  2263. * \param srcrect the SDL_Rect structure representing the rectangle to be used
  2264. * for the 9-grid, or NULL to use the entire texture.
  2265. * \param left_width the width, in pixels, of the left corners in `srcrect`.
  2266. * \param right_width the width, in pixels, of the right corners in `srcrect`.
  2267. * \param top_height the height, in pixels, of the top corners in `srcrect`.
  2268. * \param bottom_height the height, in pixels, of the bottom corners in
  2269. * `srcrect`.
  2270. * \param scale the scale used to transform the corner of `srcrect` into the
  2271. * corner of `dstrect`, or 0.0f for an unscaled copy.
  2272. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2273. * entire rendering target.
  2274. * \returns true on success or false on failure; call SDL_GetError() for more
  2275. * information.
  2276. *
  2277. * \threadsafety This function should only be called on the main thread.
  2278. *
  2279. * \since This function is available since SDL 3.2.0.
  2280. *
  2281. * \sa SDL_RenderTexture
  2282. */
  2283. 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);
  2284. /**
  2285. * Perform a scaled copy using the 9-grid algorithm to the current rendering
  2286. * target at subpixel precision.
  2287. *
  2288. * The pixels in the texture are split into a 3x3 grid, using the different
  2289. * corner sizes for each corner, and the sides and center making up the
  2290. * remaining pixels. The corners are then scaled using `scale` and fit into
  2291. * the corners of the destination rectangle. The sides and center are then
  2292. * tiled into place to cover the remaining destination rectangle.
  2293. *
  2294. * \param renderer the renderer which should copy parts of a texture.
  2295. * \param texture the source texture.
  2296. * \param srcrect the SDL_Rect structure representing the rectangle to be used
  2297. * for the 9-grid, or NULL to use the entire texture.
  2298. * \param left_width the width, in pixels, of the left corners in `srcrect`.
  2299. * \param right_width the width, in pixels, of the right corners in `srcrect`.
  2300. * \param top_height the height, in pixels, of the top corners in `srcrect`.
  2301. * \param bottom_height the height, in pixels, of the bottom corners in
  2302. * `srcrect`.
  2303. * \param scale the scale used to transform the corner of `srcrect` into the
  2304. * corner of `dstrect`, or 0.0f for an unscaled copy.
  2305. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2306. * entire rendering target.
  2307. * \param tileScale the scale used to transform the borders and center of
  2308. * `srcrect` into the borders and middle of `dstrect`, or
  2309. * 1.0f for an unscaled copy.
  2310. * \returns true on success or false on failure; call SDL_GetError() for more
  2311. * information.
  2312. *
  2313. * \threadsafety This function should only be called on the main thread.
  2314. *
  2315. * \since This function is available since SDL 3.4.0.
  2316. *
  2317. * \sa SDL_RenderTexture
  2318. */
  2319. 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);
  2320. /**
  2321. * Render a list of triangles, optionally using a texture and indices into the
  2322. * vertex array Color and alpha modulation is done per vertex
  2323. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  2324. *
  2325. * \param renderer the rendering context.
  2326. * \param texture (optional) The SDL texture to use.
  2327. * \param vertices vertices.
  2328. * \param num_vertices number of vertices.
  2329. * \param indices (optional) An array of integer indices into the 'vertices'
  2330. * array, if NULL all vertices will be rendered in sequential
  2331. * order.
  2332. * \param num_indices number of indices.
  2333. * \returns true on success or false on failure; call SDL_GetError() for more
  2334. * information.
  2335. *
  2336. * \threadsafety This function should only be called on the main thread.
  2337. *
  2338. * \since This function is available since SDL 3.2.0.
  2339. *
  2340. * \sa SDL_RenderGeometryRaw
  2341. * \sa SDL_SetRenderTextureAddressMode
  2342. */
  2343. extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  2344. SDL_Texture *texture,
  2345. const SDL_Vertex *vertices, int num_vertices,
  2346. const int *indices, int num_indices);
  2347. /**
  2348. * Render a list of triangles, optionally using a texture and indices into the
  2349. * vertex arrays Color and alpha modulation is done per vertex
  2350. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  2351. *
  2352. * \param renderer the rendering context.
  2353. * \param texture (optional) The SDL texture to use.
  2354. * \param xy vertex positions.
  2355. * \param xy_stride byte size to move from one element to the next element.
  2356. * \param color vertex colors (as SDL_FColor).
  2357. * \param color_stride byte size to move from one element to the next element.
  2358. * \param uv vertex normalized texture coordinates.
  2359. * \param uv_stride byte size to move from one element to the next element.
  2360. * \param num_vertices number of vertices.
  2361. * \param indices (optional) An array of indices into the 'vertices' arrays,
  2362. * if NULL all vertices will be rendered in sequential order.
  2363. * \param num_indices number of indices.
  2364. * \param size_indices index size: 1 (byte), 2 (short), 4 (int).
  2365. * \returns true on success or false on failure; call SDL_GetError() for more
  2366. * information.
  2367. *
  2368. * \threadsafety This function should only be called on the main thread.
  2369. *
  2370. * \since This function is available since SDL 3.2.0.
  2371. *
  2372. * \sa SDL_RenderGeometry
  2373. * \sa SDL_SetRenderTextureAddressMode
  2374. */
  2375. extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  2376. SDL_Texture *texture,
  2377. const float *xy, int xy_stride,
  2378. const SDL_FColor *color, int color_stride,
  2379. const float *uv, int uv_stride,
  2380. int num_vertices,
  2381. const void *indices, int num_indices, int size_indices);
  2382. /**
  2383. * Set the texture addressing mode used in SDL_RenderGeometry().
  2384. *
  2385. * \param renderer the rendering context.
  2386. * \param u_mode the SDL_TextureAddressMode to use for horizontal texture
  2387. * coordinates in SDL_RenderGeometry().
  2388. * \param v_mode the SDL_TextureAddressMode to use for vertical texture
  2389. * coordinates in SDL_RenderGeometry().
  2390. * \returns true on success or false on failure; call SDL_GetError() for more
  2391. * information.
  2392. *
  2393. * \since This function is available since SDL 3.4.0.
  2394. *
  2395. * \sa SDL_RenderGeometry
  2396. * \sa SDL_RenderGeometryRaw
  2397. * \sa SDL_GetRenderTextureAddressMode
  2398. */
  2399. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode u_mode, SDL_TextureAddressMode v_mode);
  2400. /**
  2401. * Get the texture addressing mode used in SDL_RenderGeometry().
  2402. *
  2403. * \param renderer the rendering context.
  2404. * \param u_mode a pointer filled in with the SDL_TextureAddressMode to use
  2405. * for horizontal texture coordinates in SDL_RenderGeometry(),
  2406. * may be NULL.
  2407. * \param v_mode a pointer filled in with the SDL_TextureAddressMode to use
  2408. * for vertical texture coordinates in SDL_RenderGeometry(), may
  2409. * be NULL.
  2410. * \returns true on success or false on failure; call SDL_GetError() for more
  2411. * information.
  2412. *
  2413. * \since This function is available since SDL 3.4.0.
  2414. *
  2415. * \sa SDL_SetRenderTextureAddressMode
  2416. */
  2417. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderTextureAddressMode(SDL_Renderer *renderer, SDL_TextureAddressMode *u_mode, SDL_TextureAddressMode *v_mode);
  2418. /**
  2419. * Read pixels from the current rendering target.
  2420. *
  2421. * The returned surface contains pixels inside the desired area clipped to the
  2422. * current viewport, and should be freed with SDL_DestroySurface().
  2423. *
  2424. * Note that this returns the actual pixels on the screen, so if you are using
  2425. * logical presentation you should use SDL_GetRenderLogicalPresentationRect()
  2426. * to get the area containing your content.
  2427. *
  2428. * **WARNING**: This is a very slow operation, and should not be used
  2429. * frequently. If you're using this on the main rendering target, it should be
  2430. * called after rendering and before SDL_RenderPresent().
  2431. *
  2432. * \param renderer the rendering context.
  2433. * \param rect an SDL_Rect structure representing the area to read, which will
  2434. * be clipped to the current viewport, or NULL for the entire
  2435. * viewport.
  2436. * \returns a new SDL_Surface on success or NULL on failure; call
  2437. * SDL_GetError() for more information.
  2438. *
  2439. * \threadsafety This function should only be called on the main thread.
  2440. *
  2441. * \since This function is available since SDL 3.2.0.
  2442. */
  2443. extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
  2444. /**
  2445. * Update the screen with any rendering performed since the previous call.
  2446. *
  2447. * SDL's rendering functions operate on a backbuffer; that is, calling a
  2448. * rendering function such as SDL_RenderLine() does not directly put a line on
  2449. * the screen, but rather updates the backbuffer. As such, you compose your
  2450. * entire scene and *present* the composed backbuffer to the screen as a
  2451. * complete picture.
  2452. *
  2453. * Therefore, when using SDL's rendering API, one does all drawing intended
  2454. * for the frame, and then calls this function once per frame to present the
  2455. * final drawing to the user.
  2456. *
  2457. * The backbuffer should be considered invalidated after each present; do not
  2458. * assume that previous contents will exist between frames. You are strongly
  2459. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  2460. * starting each new frame's drawing, even if you plan to overwrite every
  2461. * pixel.
  2462. *
  2463. * Please note, that in case of rendering to a texture - there is **no need**
  2464. * to call `SDL_RenderPresent` after drawing needed objects to a texture, and
  2465. * should not be done; you are only required to change back the rendering
  2466. * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
  2467. * textures by themselves do not have a concept of backbuffers. Calling
  2468. * SDL_RenderPresent while rendering to a texture will fail.
  2469. *
  2470. * \param renderer the rendering context.
  2471. * \returns true on success or false on failure; call SDL_GetError() for more
  2472. * information.
  2473. *
  2474. * \threadsafety This function should only be called on the main thread.
  2475. *
  2476. * \since This function is available since SDL 3.2.0.
  2477. *
  2478. * \sa SDL_CreateRenderer
  2479. * \sa SDL_RenderClear
  2480. * \sa SDL_RenderFillRect
  2481. * \sa SDL_RenderFillRects
  2482. * \sa SDL_RenderLine
  2483. * \sa SDL_RenderLines
  2484. * \sa SDL_RenderPoint
  2485. * \sa SDL_RenderPoints
  2486. * \sa SDL_RenderRect
  2487. * \sa SDL_RenderRects
  2488. * \sa SDL_SetRenderDrawBlendMode
  2489. * \sa SDL_SetRenderDrawColor
  2490. */
  2491. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
  2492. /**
  2493. * Destroy the specified texture.
  2494. *
  2495. * Passing NULL or an otherwise invalid texture will set the SDL error message
  2496. * to "Invalid texture".
  2497. *
  2498. * \param texture the texture to destroy.
  2499. *
  2500. * \threadsafety This function should only be called on the main thread.
  2501. *
  2502. * \since This function is available since SDL 3.2.0.
  2503. *
  2504. * \sa SDL_CreateTexture
  2505. * \sa SDL_CreateTextureFromSurface
  2506. */
  2507. extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
  2508. /**
  2509. * Destroy the rendering context for a window and free all associated
  2510. * textures.
  2511. *
  2512. * This should be called before destroying the associated window.
  2513. *
  2514. * \param renderer the rendering context.
  2515. *
  2516. * \threadsafety This function should only be called on the main thread.
  2517. *
  2518. * \since This function is available since SDL 3.2.0.
  2519. *
  2520. * \sa SDL_CreateRenderer
  2521. */
  2522. extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
  2523. /**
  2524. * Force the rendering context to flush any pending commands and state.
  2525. *
  2526. * You do not need to (and in fact, shouldn't) call this function unless you
  2527. * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
  2528. * addition to using an SDL_Renderer.
  2529. *
  2530. * This is for a very-specific case: if you are using SDL's render API, and
  2531. * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
  2532. * calls. If this applies, you should call this function between calls to
  2533. * SDL's render API and the low-level API you're using in cooperation.
  2534. *
  2535. * In all other cases, you can ignore this function.
  2536. *
  2537. * This call makes SDL flush any pending rendering work it was queueing up to
  2538. * do later in a single batch, and marks any internal cached state as invalid,
  2539. * so it'll prepare all its state again later, from scratch.
  2540. *
  2541. * This means you do not need to save state in your rendering code to protect
  2542. * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
  2543. * OpenGL state that can confuse things; you should use your best judgment and
  2544. * be prepared to make changes if specific state needs to be protected.
  2545. *
  2546. * \param renderer the rendering context.
  2547. * \returns true on success or false on failure; call SDL_GetError() for more
  2548. * information.
  2549. *
  2550. * \threadsafety This function should only be called on the main thread.
  2551. *
  2552. * \since This function is available since SDL 3.2.0.
  2553. */
  2554. extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
  2555. /**
  2556. * Get the CAMetalLayer associated with the given Metal renderer.
  2557. *
  2558. * This function returns `void *`, so SDL doesn't have to include Metal's
  2559. * headers, but it can be safely cast to a `CAMetalLayer *`.
  2560. *
  2561. * \param renderer the renderer to query.
  2562. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  2563. * Metal renderer.
  2564. *
  2565. * \threadsafety This function should only be called on the main thread.
  2566. *
  2567. * \since This function is available since SDL 3.2.0.
  2568. *
  2569. * \sa SDL_GetRenderMetalCommandEncoder
  2570. */
  2571. extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);
  2572. /**
  2573. * Get the Metal command encoder for the current frame.
  2574. *
  2575. * This function returns `void *`, so SDL doesn't have to include Metal's
  2576. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  2577. *
  2578. * This will return NULL if Metal refuses to give SDL a drawable to render to,
  2579. * which might happen if the window is hidden/minimized/offscreen. This
  2580. * doesn't apply to command encoders for render targets, just the window's
  2581. * backbuffer. Check your return values!
  2582. *
  2583. * \param renderer the renderer to query.
  2584. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  2585. * renderer isn't a Metal renderer or there was an error.
  2586. *
  2587. * \threadsafety This function should only be called on the main thread.
  2588. *
  2589. * \since This function is available since SDL 3.2.0.
  2590. *
  2591. * \sa SDL_GetRenderMetalLayer
  2592. */
  2593. extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);
  2594. /**
  2595. * Add a set of synchronization semaphores for the current frame.
  2596. *
  2597. * The Vulkan renderer will wait for `wait_semaphore` before submitting
  2598. * rendering commands and signal `signal_semaphore` after rendering commands
  2599. * are complete for this frame.
  2600. *
  2601. * This should be called each frame that you want semaphore synchronization.
  2602. * The Vulkan renderer may have multiple frames in flight on the GPU, so you
  2603. * should have multiple semaphores that are used for synchronization. Querying
  2604. * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the
  2605. * maximum number of semaphores you'll need.
  2606. *
  2607. * \param renderer the rendering context.
  2608. * \param wait_stage_mask the VkPipelineStageFlags for the wait.
  2609. * \param wait_semaphore a VkSempahore to wait on before rendering the current
  2610. * frame, or 0 if not needed.
  2611. * \param signal_semaphore a VkSempahore that SDL will signal when rendering
  2612. * for the current frame is complete, or 0 if not
  2613. * needed.
  2614. * \returns true on success or false on failure; call SDL_GetError() for more
  2615. * information.
  2616. *
  2617. * \threadsafety It is **NOT** safe to call this function from two threads at
  2618. * once.
  2619. *
  2620. * \since This function is available since SDL 3.2.0.
  2621. */
  2622. extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
  2623. /**
  2624. * Toggle VSync of the given renderer.
  2625. *
  2626. * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
  2627. *
  2628. * The `vsync` parameter can be 1 to synchronize present with every vertical
  2629. * refresh, 2 to synchronize present with every second vertical refresh, etc.,
  2630. * SDL_RENDERER_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync), or
  2631. * SDL_RENDERER_VSYNC_DISABLED to disable. Not every value is supported by
  2632. * every driver, so you should check the return value to see whether the
  2633. * requested setting is supported.
  2634. *
  2635. * \param renderer the renderer to toggle.
  2636. * \param vsync the vertical refresh sync interval.
  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_GetRenderVSync
  2645. */
  2646. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
  2647. #define SDL_RENDERER_VSYNC_DISABLED 0
  2648. #define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
  2649. /**
  2650. * Get VSync of the given renderer.
  2651. *
  2652. * \param renderer the renderer to toggle.
  2653. * \param vsync an int filled with the current vertical refresh sync interval.
  2654. * See SDL_SetRenderVSync() for the meaning of the value.
  2655. * \returns true on success or false on failure; call SDL_GetError() for more
  2656. * information.
  2657. *
  2658. * \threadsafety This function should only be called on the main thread.
  2659. *
  2660. * \since This function is available since SDL 3.2.0.
  2661. *
  2662. * \sa SDL_SetRenderVSync
  2663. */
  2664. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);
  2665. /**
  2666. * The size, in pixels, of a single SDL_RenderDebugText() character.
  2667. *
  2668. * The font is monospaced and square, so this applies to all characters.
  2669. *
  2670. * \since This macro is available since SDL 3.2.0.
  2671. *
  2672. * \sa SDL_RenderDebugText
  2673. */
  2674. #define SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE 8
  2675. /**
  2676. * Draw debug text to an SDL_Renderer.
  2677. *
  2678. * This function will render a string of text to an SDL_Renderer. Note that
  2679. * this is a convenience function for debugging, with severe limitations, and
  2680. * not intended to be used for production apps and games.
  2681. *
  2682. * Among these limitations:
  2683. *
  2684. * - It accepts UTF-8 strings, but will only renders ASCII characters.
  2685. * - It has a single, tiny size (8x8 pixels). You can use logical presentation
  2686. * or SDL_SetRenderScale() to adjust it.
  2687. * - It uses a simple, hardcoded bitmap font. It does not allow different font
  2688. * selections and it does not support truetype, for proper scaling.
  2689. * - It does no word-wrapping and does not treat newline characters as a line
  2690. * break. If the text goes out of the window, it's gone.
  2691. *
  2692. * For serious text rendering, there are several good options, such as
  2693. * SDL_ttf, stb_truetype, or other external libraries.
  2694. *
  2695. * On first use, this will create an internal texture for rendering glyphs.
  2696. * This texture will live until the renderer is destroyed.
  2697. *
  2698. * The text is drawn in the color specified by SDL_SetRenderDrawColor().
  2699. *
  2700. * \param renderer the renderer which should draw a line of text.
  2701. * \param x the x coordinate where the top-left corner of the text will draw.
  2702. * \param y the y coordinate where the top-left corner of the text will draw.
  2703. * \param str the string to render.
  2704. * \returns true on success or false on failure; call SDL_GetError() for more
  2705. * information.
  2706. *
  2707. * \threadsafety This function should only be called on the main thread.
  2708. *
  2709. * \since This function is available since SDL 3.2.0.
  2710. *
  2711. * \sa SDL_RenderDebugTextFormat
  2712. * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE
  2713. */
  2714. extern SDL_DECLSPEC bool SDLCALL SDL_RenderDebugText(SDL_Renderer *renderer, float x, float y, const char *str);
  2715. /**
  2716. * Draw debug text to an SDL_Renderer.
  2717. *
  2718. * This function will render a printf()-style format string to a renderer.
  2719. * Note that this is a convenience function for debugging, with severe
  2720. * limitations, and is not intended to be used for production apps and games.
  2721. *
  2722. * For the full list of limitations and other useful information, see
  2723. * SDL_RenderDebugText.
  2724. *
  2725. * \param renderer the renderer which should draw the text.
  2726. * \param x the x coordinate where the top-left corner of the text will draw.
  2727. * \param y the y coordinate where the top-left corner of the text will draw.
  2728. * \param fmt the format string to draw.
  2729. * \param ... additional parameters matching % tokens in the `fmt` string, if
  2730. * any.
  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.2.0.
  2737. *
  2738. * \sa SDL_RenderDebugText
  2739. * \sa SDL_DEBUG_TEXT_FONT_CHARACTER_SIZE
  2740. */
  2741. 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);
  2742. /**
  2743. * Set default scale mode for new textures for given renderer.
  2744. *
  2745. * When a renderer is created, scale_mode defaults to SDL_SCALEMODE_LINEAR.
  2746. *
  2747. * \param renderer the renderer to update.
  2748. * \param scale_mode the scale mode to change to for new textures.
  2749. * \returns true on success or false on failure; call SDL_GetError() for more
  2750. * information.
  2751. *
  2752. * \threadsafety This function should only be called on the main thread.
  2753. *
  2754. * \since This function is available since SDL 3.4.0.
  2755. *
  2756. * \sa SDL_GetDefaultTextureScaleMode
  2757. */
  2758. extern SDL_DECLSPEC bool SDLCALL SDL_SetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode scale_mode);
  2759. /**
  2760. * Get default texture scale mode of the given renderer.
  2761. *
  2762. * \param renderer the renderer to get data from.
  2763. * \param scale_mode a SDL_ScaleMode filled with current default scale mode.
  2764. * See SDL_SetDefaultTextureScaleMode() for the meaning of
  2765. * the value.
  2766. * \returns true on success or false on failure; call SDL_GetError() for more
  2767. * information.
  2768. *
  2769. * \threadsafety This function should only be called on the main thread.
  2770. *
  2771. * \since This function is available since SDL 3.4.0.
  2772. *
  2773. * \sa SDL_SetDefaultTextureScaleMode
  2774. */
  2775. extern SDL_DECLSPEC bool SDLCALL SDL_GetDefaultTextureScaleMode(SDL_Renderer *renderer, SDL_ScaleMode *scale_mode);
  2776. /**
  2777. * A structure specifying the parameters of a GPU render state.
  2778. *
  2779. * \since This struct is available since SDL 3.4.0.
  2780. *
  2781. * \sa SDL_CreateGPURenderState
  2782. */
  2783. typedef struct SDL_GPURenderStateCreateInfo
  2784. {
  2785. SDL_GPUShader *fragment_shader; /**< The fragment shader to use when this render state is active */
  2786. Sint32 num_sampler_bindings; /**< The number of additional fragment samplers to bind when this render state is active */
  2787. const SDL_GPUTextureSamplerBinding *sampler_bindings; /**< Additional fragment samplers to bind when this render state is active */
  2788. Sint32 num_storage_textures; /**< The number of storage textures to bind when this render state is active */
  2789. SDL_GPUTexture *const *storage_textures; /**< Storage textures to bind when this render state is active */
  2790. Sint32 num_storage_buffers; /**< The number of storage buffers to bind when this render state is active */
  2791. SDL_GPUBuffer *const *storage_buffers; /**< Storage buffers to bind when this render state is active */
  2792. SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
  2793. } SDL_GPURenderStateCreateInfo;
  2794. /**
  2795. * A custom GPU render state.
  2796. *
  2797. * \since This struct is available since SDL 3.4.0.
  2798. *
  2799. * \sa SDL_CreateGPURenderState
  2800. * \sa SDL_SetGPURenderStateFragmentUniforms
  2801. * \sa SDL_SetGPURenderState
  2802. * \sa SDL_DestroyGPURenderState
  2803. */
  2804. typedef struct SDL_GPURenderState SDL_GPURenderState;
  2805. /**
  2806. * Create custom GPU render state.
  2807. *
  2808. * \param renderer the renderer to use.
  2809. * \param createinfo a struct describing the GPU render state to create.
  2810. * \returns a custom GPU render state or NULL on failure; call SDL_GetError()
  2811. * for more information.
  2812. *
  2813. * \threadsafety This function should be called on the thread that created the
  2814. * renderer.
  2815. *
  2816. * \since This function is available since SDL 3.4.0.
  2817. *
  2818. * \sa SDL_SetGPURenderStateFragmentUniforms
  2819. * \sa SDL_SetGPURenderState
  2820. * \sa SDL_DestroyGPURenderState
  2821. */
  2822. extern SDL_DECLSPEC SDL_GPURenderState * SDLCALL SDL_CreateGPURenderState(SDL_Renderer *renderer, SDL_GPURenderStateCreateInfo *createinfo);
  2823. /**
  2824. * Set fragment shader uniform variables in a custom GPU render state.
  2825. *
  2826. * The data is copied and will be pushed using
  2827. * SDL_PushGPUFragmentUniformData() during draw call execution.
  2828. *
  2829. * \param state the state to modify.
  2830. * \param slot_index the fragment uniform slot to push data to.
  2831. * \param data client data to write.
  2832. * \param length the length of the data to write.
  2833. * \returns true on success or false on failure; call SDL_GetError() for more
  2834. * information.
  2835. *
  2836. * \threadsafety This function should be called on the thread that created the
  2837. * renderer.
  2838. *
  2839. * \since This function is available since SDL 3.4.0.
  2840. */
  2841. extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderStateFragmentUniforms(SDL_GPURenderState *state, Uint32 slot_index, const void *data, Uint32 length);
  2842. /**
  2843. * Set custom GPU render state.
  2844. *
  2845. * This function sets custom GPU render state for subsequent draw calls. This
  2846. * allows using custom shaders with the GPU renderer.
  2847. *
  2848. * \param renderer the renderer to use.
  2849. * \param state the state to to use, or NULL to clear custom GPU render state.
  2850. * \returns true on success or false on failure; call SDL_GetError() for more
  2851. * information.
  2852. *
  2853. * \threadsafety This function should be called on the thread that created the
  2854. * renderer.
  2855. *
  2856. * \since This function is available since SDL 3.4.0.
  2857. */
  2858. extern SDL_DECLSPEC bool SDLCALL SDL_SetGPURenderState(SDL_Renderer *renderer, SDL_GPURenderState *state);
  2859. /**
  2860. * Destroy custom GPU render state.
  2861. *
  2862. * \param state the state to destroy.
  2863. *
  2864. * \threadsafety This function should be called on the thread that created the
  2865. * renderer.
  2866. *
  2867. * \since This function is available since SDL 3.4.0.
  2868. *
  2869. * \sa SDL_CreateGPURenderState
  2870. */
  2871. extern SDL_DECLSPEC void SDLCALL SDL_DestroyGPURenderState(SDL_GPURenderState *state);
  2872. /* Ends C function definitions when using C++ */
  2873. #ifdef __cplusplus
  2874. }
  2875. #endif
  2876. #include <SDL3/SDL_close_code.h>
  2877. #endif /* SDL_render_h_ */