SDL_render.h 125 KB

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