SDL_render.h 100 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 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 polygons and particle effects and in that case you
  39. * should use SDL's OpenGL/Direct3D support, the SDL3 GPU API, or one of the
  40. * 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_begin_code.h>
  57. /* Set up for C function definitions, even when using C++ */
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. /**
  62. * The name of the software renderer.
  63. *
  64. * \since This macro is available since SDL 3.0.0.
  65. */
  66. #define SDL_SOFTWARE_RENDERER "software"
  67. /**
  68. * Vertex structure.
  69. *
  70. * \since This struct is available since SDL 3.0.0.
  71. */
  72. typedef struct SDL_Vertex
  73. {
  74. SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */
  75. SDL_FColor color; /**< Vertex color */
  76. SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
  77. } SDL_Vertex;
  78. /**
  79. * The access pattern allowed for a texture.
  80. *
  81. * \since This enum is available since SDL 3.0.0.
  82. */
  83. typedef enum SDL_TextureAccess
  84. {
  85. SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
  86. SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
  87. SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
  88. } SDL_TextureAccess;
  89. /**
  90. * How the logical size is mapped to the output.
  91. *
  92. * \since This enum is available since SDL 3.0.0.
  93. */
  94. typedef enum SDL_RendererLogicalPresentation
  95. {
  96. SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */
  97. SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */
  98. SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */
  99. SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */
  100. SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */
  101. } SDL_RendererLogicalPresentation;
  102. /**
  103. * A structure representing rendering state
  104. *
  105. * \since This struct is available since SDL 3.0.0.
  106. */
  107. typedef struct SDL_Renderer SDL_Renderer;
  108. /**
  109. * An efficient driver-specific representation of pixel data
  110. *
  111. * \since This struct is available since SDL 3.0.0.
  112. */
  113. typedef struct SDL_Texture SDL_Texture;
  114. /* Function prototypes */
  115. /**
  116. * Get the number of 2D rendering drivers available for the current display.
  117. *
  118. * A render driver is a set of code that handles rendering and texture
  119. * management on a particular display. Normally there is only one, but some
  120. * drivers may have several available with different capabilities.
  121. *
  122. * There may be none if SDL was compiled without render support.
  123. *
  124. * \returns the number of built in render drivers.
  125. *
  126. * \since This function is available since SDL 3.0.0.
  127. *
  128. * \threadsafety It is safe to call this function from any thread.
  129. *
  130. * \sa SDL_CreateRenderer
  131. * \sa SDL_GetRenderDriver
  132. */
  133. extern SDL_DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
  134. /**
  135. * Use this function to get the name of a built in 2D rendering driver.
  136. *
  137. * The list of rendering drivers is given in the order that they are normally
  138. * initialized by default; the drivers that seem more reasonable to choose
  139. * first (as far as the SDL developers believe) are earlier in the list.
  140. *
  141. * The names of drivers are all simple, low-ASCII identifiers, like "opengl",
  142. * "direct3d12" or "metal". These never have Unicode characters, and are not
  143. * meant to be proper names.
  144. *
  145. * \param index the index of the rendering driver; the value ranges from 0 to
  146. * SDL_GetNumRenderDrivers() - 1.
  147. * \returns the name of the rendering driver at the requested index, or NULL
  148. * if an invalid index was specified.
  149. *
  150. * \since This function is available since SDL 3.0.0.
  151. *
  152. * \threadsafety It is safe to call this function from any thread.
  153. *
  154. * \sa SDL_GetNumRenderDrivers
  155. */
  156. extern SDL_DECLSPEC const char * SDLCALL SDL_GetRenderDriver(int index);
  157. /**
  158. * Create a window and default renderer.
  159. *
  160. * \param title the title of the window, in UTF-8 encoding.
  161. * \param width the width of the window.
  162. * \param height the height of the window.
  163. * \param window_flags the flags used to create the window (see
  164. * SDL_CreateWindow()).
  165. * \param window a pointer filled with the window, or NULL on error.
  166. * \param renderer a pointer filled with the renderer, or NULL on error.
  167. * \returns true on success or false on failure; call SDL_GetError() for more
  168. * information.
  169. *
  170. * \since This function is available since SDL 3.0.0.
  171. *
  172. * \threadsafety You may only call this function from the main thread.
  173. *
  174. * \sa SDL_CreateRenderer
  175. * \sa SDL_CreateWindow
  176. */
  177. extern SDL_DECLSPEC bool SDLCALL SDL_CreateWindowAndRenderer(const char *title, int width, int height, SDL_WindowFlags window_flags, SDL_Window **window, SDL_Renderer **renderer);
  178. /**
  179. * Create a 2D rendering context for a window.
  180. *
  181. * If you want a specific renderer, you can specify its name here. A list of
  182. * available renderers can be obtained by calling SDL_GetRenderDriver multiple
  183. * times, with indices from 0 to SDL_GetNumRenderDrivers()-1. If you don't
  184. * need a specific renderer, specify NULL and SDL will attempt to choose the
  185. * best option for you, based on what is available on the user's system.
  186. *
  187. * By default the rendering size matches the window size in pixels, but you
  188. * can call SDL_SetRenderLogicalPresentation() to change the content size and
  189. * scaling options.
  190. *
  191. * \param window the window where rendering is displayed.
  192. * \param name the name of the rendering driver to initialize, or NULL to
  193. * initialize the first one supporting the requested flags.
  194. * \returns a valid rendering context or NULL if there was an error; call
  195. * SDL_GetError() for more information.
  196. *
  197. * \threadsafety You may only call this function from the main thread.
  198. *
  199. * \since This function is available since SDL 3.0.0.
  200. *
  201. * \sa SDL_CreateRendererWithProperties
  202. * \sa SDL_CreateSoftwareRenderer
  203. * \sa SDL_DestroyRenderer
  204. * \sa SDL_GetNumRenderDrivers
  205. * \sa SDL_GetRenderDriver
  206. * \sa SDL_GetRendererName
  207. */
  208. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name);
  209. /**
  210. * Create a 2D rendering context for a window, with the specified properties.
  211. *
  212. * These are the supported properties:
  213. *
  214. * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver
  215. * to use, if a specific one is desired
  216. * - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is
  217. * displayed, required if this isn't a software renderer using a surface
  218. * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering
  219. * is displayed, if you want a software renderer without a window
  220. * - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace
  221. * value describing the colorspace for output to the display, defaults to
  222. * SDL_COLORSPACE_SRGB. The direct3d11, direct3d12, and metal renderers
  223. * support SDL_COLORSPACE_SRGB_LINEAR, which is a linear color space and
  224. * supports HDR output. If you select SDL_COLORSPACE_SRGB_LINEAR, drawing
  225. * still uses the sRGB colorspace, but values can go beyond 1.0 and float
  226. * (linear) format textures can be used for HDR content.
  227. * - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER`: non-zero if you want
  228. * present synchronized with the refresh rate. This property can take any
  229. * value that is supported by SDL_SetRenderVSync() for the renderer.
  230. *
  231. * With the vulkan renderer:
  232. *
  233. * - `SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER`: the VkInstance to use
  234. * with the renderer, optional.
  235. * - `SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR to use
  236. * with the renderer, optional.
  237. * - `SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER`: the
  238. * VkPhysicalDevice to use with the renderer, optional.
  239. * - `SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER`: the VkDevice to use
  240. * with the renderer, optional.
  241. * - `SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the
  242. * queue family index used for rendering.
  243. * - `SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the
  244. * queue family index used for presentation.
  245. *
  246. * \param props the properties to use.
  247. * \returns a valid rendering context or NULL if there was an error; call
  248. * SDL_GetError() for more information.
  249. *
  250. * \threadsafety You may only call this function from the main thread.
  251. *
  252. * \since This function is available since SDL 3.0.0.
  253. *
  254. * \sa SDL_CreateProperties
  255. * \sa SDL_CreateRenderer
  256. * \sa SDL_CreateSoftwareRenderer
  257. * \sa SDL_DestroyRenderer
  258. * \sa SDL_GetRendererName
  259. */
  260. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props);
  261. #define SDL_PROP_RENDERER_CREATE_NAME_STRING "SDL.renderer.create.name"
  262. #define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "SDL.renderer.create.window"
  263. #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "SDL.renderer.create.surface"
  264. #define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.create.output_colorspace"
  265. #define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_NUMBER "SDL.renderer.create.present_vsync"
  266. #define SDL_PROP_RENDERER_CREATE_VULKAN_INSTANCE_POINTER "SDL.renderer.create.vulkan.instance"
  267. #define SDL_PROP_RENDERER_CREATE_VULKAN_SURFACE_NUMBER "SDL.renderer.create.vulkan.surface"
  268. #define SDL_PROP_RENDERER_CREATE_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.create.vulkan.physical_device"
  269. #define SDL_PROP_RENDERER_CREATE_VULKAN_DEVICE_POINTER "SDL.renderer.create.vulkan.device"
  270. #define SDL_PROP_RENDERER_CREATE_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.graphics_queue_family_index"
  271. #define SDL_PROP_RENDERER_CREATE_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.create.vulkan.present_queue_family_index"
  272. /**
  273. * Create a 2D software rendering context for a surface.
  274. *
  275. * Two other API which can be used to create SDL_Renderer:
  276. * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_
  277. * create a software renderer, but they are intended to be used with an
  278. * SDL_Window as the final destination and not an SDL_Surface.
  279. *
  280. * \param surface the SDL_Surface structure representing the surface where
  281. * rendering is done.
  282. * \returns a valid rendering context or NULL if there was an error; call
  283. * SDL_GetError() for more information.
  284. *
  285. * \threadsafety You may only call this function from the main thread.
  286. *
  287. * \since This function is available since SDL 3.0.0.
  288. *
  289. * \sa SDL_DestroyRenderer
  290. */
  291. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface);
  292. /**
  293. * Get the renderer associated with a window.
  294. *
  295. * \param window the window to query.
  296. * \returns the rendering context on success or NULL on failure; call
  297. * SDL_GetError() for more information.
  298. *
  299. * \threadsafety It is safe to call this function from any thread.
  300. *
  301. * \since This function is available since SDL 3.0.0.
  302. */
  303. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window *window);
  304. /**
  305. * Get the window associated with a renderer.
  306. *
  307. * \param renderer the renderer to query.
  308. * \returns the window on success or NULL on failure; call SDL_GetError() for
  309. * more information.
  310. *
  311. * \threadsafety It is safe to call this function from any thread.
  312. *
  313. * \since This function is available since SDL 3.0.0.
  314. */
  315. extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);
  316. /**
  317. * Get the name of a renderer.
  318. *
  319. * \param renderer the rendering context.
  320. * \returns the name of the selected renderer, or NULL on failure; call
  321. * SDL_GetError() for more information.
  322. *
  323. * \threadsafety It is safe to call this function from any thread.
  324. *
  325. * \since This function is available since SDL 3.0.0.
  326. *
  327. * \sa SDL_CreateRenderer
  328. * \sa SDL_CreateRendererWithProperties
  329. */
  330. extern SDL_DECLSPEC const char * SDLCALL SDL_GetRendererName(SDL_Renderer *renderer);
  331. /**
  332. * Get the properties associated with a renderer.
  333. *
  334. * The following read-only properties are provided by SDL:
  335. *
  336. * - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver
  337. * - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is
  338. * displayed, if any
  339. * - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is
  340. * displayed, if this is a software renderer without a window
  341. * - `SDL_PROP_RENDERER_VSYNC_NUMBER`: the current vsync setting
  342. * - `SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER`: the maximum texture width
  343. * and height
  344. * - `SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER`: a (const SDL_PixelFormat *)
  345. * array of pixel formats, terminated with SDL_PIXELFORMAT_UNKNOWN,
  346. * representing the available texture formats for this renderer.
  347. * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace value
  348. * describing the colorspace for output to the display, defaults to
  349. * SDL_COLORSPACE_SRGB.
  350. * - `SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN`: true if the output colorspace is
  351. * SDL_COLORSPACE_SRGB_LINEAR and the renderer is showing on a display with
  352. * HDR enabled. This property can change dynamically when
  353. * SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
  354. * - `SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT`: the value of SDR white in the
  355. * SDL_COLORSPACE_SRGB_LINEAR colorspace. When HDR is enabled, this value is
  356. * automatically multiplied into the color scale. This property can change
  357. * dynamically when SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
  358. * - `SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT`: the additional high dynamic range
  359. * that can be displayed, in terms of the SDR white point. When HDR is not
  360. * enabled, this will be 1.0. This property can change dynamically when
  361. * SDL_EVENT_DISPLAY_HDR_STATE_CHANGED is sent.
  362. *
  363. * With the direct3d renderer:
  364. *
  365. * - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated
  366. * with the renderer
  367. *
  368. * With the direct3d11 renderer:
  369. *
  370. * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated
  371. * with the renderer
  372. * - `SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER`: the IDXGISwapChain1
  373. * associated with the renderer. This may change when the window is resized.
  374. *
  375. * With the direct3d12 renderer:
  376. *
  377. * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated
  378. * with the renderer
  379. * - `SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER`: the IDXGISwapChain4
  380. * associated with the renderer.
  381. * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue
  382. * associated with the renderer
  383. *
  384. * With the vulkan renderer:
  385. *
  386. * - `SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER`: the VkInstance associated
  387. * with the renderer
  388. * - `SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER`: the VkSurfaceKHR associated
  389. * with the renderer
  390. * - `SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER`: the VkPhysicalDevice
  391. * associated with the renderer
  392. * - `SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER`: the VkDevice associated with
  393. * the renderer
  394. * - `SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER`: the queue
  395. * family index used for rendering
  396. * - `SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER`: the queue
  397. * family index used for presentation
  398. * - `SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER`: the number of
  399. * swapchain images, or potential frames in flight, used by the Vulkan
  400. * renderer
  401. *
  402. * \param renderer the rendering context.
  403. * \returns a valid property ID on success or 0 on failure; call
  404. * SDL_GetError() for more information.
  405. *
  406. * \threadsafety It is safe to call this function from any thread.
  407. *
  408. * \since This function is available since SDL 3.0.0.
  409. */
  410. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer);
  411. #define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name"
  412. #define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window"
  413. #define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface"
  414. #define SDL_PROP_RENDERER_VSYNC_NUMBER "SDL.renderer.vsync"
  415. #define SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER "SDL.renderer.max_texture_size"
  416. #define SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER "SDL.renderer.texture_formats"
  417. #define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace"
  418. #define SDL_PROP_RENDERER_HDR_ENABLED_BOOLEAN "SDL.renderer.HDR_enabled"
  419. #define SDL_PROP_RENDERER_SDR_WHITE_POINT_FLOAT "SDL.renderer.SDR_white_point"
  420. #define SDL_PROP_RENDERER_HDR_HEADROOM_FLOAT "SDL.renderer.HDR_headroom"
  421. #define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device"
  422. #define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device"
  423. #define SDL_PROP_RENDERER_D3D11_SWAPCHAIN_POINTER "SDL.renderer.d3d11.swap_chain"
  424. #define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device"
  425. #define SDL_PROP_RENDERER_D3D12_SWAPCHAIN_POINTER "SDL.renderer.d3d12.swap_chain"
  426. #define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue"
  427. #define SDL_PROP_RENDERER_VULKAN_INSTANCE_POINTER "SDL.renderer.vulkan.instance"
  428. #define SDL_PROP_RENDERER_VULKAN_SURFACE_NUMBER "SDL.renderer.vulkan.surface"
  429. #define SDL_PROP_RENDERER_VULKAN_PHYSICAL_DEVICE_POINTER "SDL.renderer.vulkan.physical_device"
  430. #define SDL_PROP_RENDERER_VULKAN_DEVICE_POINTER "SDL.renderer.vulkan.device"
  431. #define SDL_PROP_RENDERER_VULKAN_GRAPHICS_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.graphics_queue_family_index"
  432. #define SDL_PROP_RENDERER_VULKAN_PRESENT_QUEUE_FAMILY_INDEX_NUMBER "SDL.renderer.vulkan.present_queue_family_index"
  433. #define SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER "SDL.renderer.vulkan.swapchain_image_count"
  434. /**
  435. * Get the output size in pixels of a rendering context.
  436. *
  437. * This returns the true output size in pixels, ignoring any render targets or
  438. * logical size and presentation.
  439. *
  440. * \param renderer the rendering context.
  441. * \param w a pointer filled in with the width in pixels.
  442. * \param h a pointer filled in with the height in pixels.
  443. * \returns true on success or false on failure; call SDL_GetError() for more
  444. * information.
  445. *
  446. * \threadsafety You may only call this function from the main thread.
  447. *
  448. * \since This function is available since SDL 3.0.0.
  449. *
  450. * \sa SDL_GetCurrentRenderOutputSize
  451. */
  452. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  453. /**
  454. * Get the current output size in pixels of a rendering context.
  455. *
  456. * If a rendering target is active, this will return the size of the rendering
  457. * target in pixels, otherwise if a logical size is set, it will return the
  458. * logical size, otherwise it will return the value of
  459. * SDL_GetRenderOutputSize().
  460. *
  461. * \param renderer the rendering context.
  462. * \param w a pointer filled in with the current width.
  463. * \param h a pointer filled in with the current height.
  464. * \returns true on success or false on failure; call SDL_GetError() for more
  465. * information.
  466. *
  467. * \threadsafety You may only call this function from the main thread.
  468. *
  469. * \since This function is available since SDL 3.0.0.
  470. *
  471. * \sa SDL_GetRenderOutputSize
  472. */
  473. extern SDL_DECLSPEC bool SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  474. /**
  475. * Create a texture for a rendering context.
  476. *
  477. * The contents of a texture when first created are not defined.
  478. *
  479. * \param renderer the rendering context.
  480. * \param format one of the enumerated values in SDL_PixelFormat.
  481. * \param access one of the enumerated values in SDL_TextureAccess.
  482. * \param w the width of the texture in pixels.
  483. * \param h the height of the texture in pixels.
  484. * \returns a pointer to the created texture or NULL if no rendering context
  485. * was active, the format was unsupported, or the width or height
  486. * were out of range; call SDL_GetError() for more information.
  487. *
  488. * \threadsafety You may only call this function from the main thread.
  489. *
  490. * \since This function is available since SDL 3.0.0.
  491. *
  492. * \sa SDL_CreateTextureFromSurface
  493. * \sa SDL_CreateTextureWithProperties
  494. * \sa SDL_DestroyTexture
  495. * \sa SDL_GetTextureSize
  496. * \sa SDL_UpdateTexture
  497. */
  498. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, SDL_PixelFormat format, SDL_TextureAccess access, int w, int h);
  499. /**
  500. * Create a texture from an existing surface.
  501. *
  502. * The surface is not modified or freed by this function.
  503. *
  504. * The SDL_TextureAccess hint for the created texture is
  505. * `SDL_TEXTUREACCESS_STATIC`.
  506. *
  507. * The pixel format of the created texture may be different from the pixel
  508. * format of the surface, and can be queried using the
  509. * SDL_PROP_TEXTURE_FORMAT_NUMBER property.
  510. *
  511. * \param renderer the rendering context.
  512. * \param surface the SDL_Surface structure containing pixel data used to fill
  513. * the texture.
  514. * \returns the created texture or NULL on failure; call SDL_GetError() for
  515. * more information.
  516. *
  517. * \threadsafety You may only call this function from the main thread.
  518. *
  519. * \since This function is available since SDL 3.0.0.
  520. *
  521. * \sa SDL_CreateTexture
  522. * \sa SDL_CreateTextureWithProperties
  523. * \sa SDL_DestroyTexture
  524. */
  525. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
  526. /**
  527. * Create a texture for a rendering context with the specified properties.
  528. *
  529. * These are the supported properties:
  530. *
  531. * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_ColorSpace value
  532. * describing the texture colorspace, defaults to SDL_COLORSPACE_SRGB_LINEAR
  533. * for floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures,
  534. * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for
  535. * YUV textures.
  536. * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in
  537. * SDL_PixelFormat, defaults to the best RGBA format for the renderer
  538. * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in
  539. * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC
  540. * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in
  541. * pixels, required
  542. * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in
  543. * pixels, required
  544. * - `SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating
  545. * point textures, this defines the value of 100% diffuse white, with higher
  546. * values being displayed in the High Dynamic Range headroom. This defaults
  547. * to 100 for HDR10 textures and 1.0 for floating point textures.
  548. * - `SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT`: for HDR10 and floating
  549. * point textures, this defines the maximum dynamic range used by the
  550. * content, in terms of the SDR white point. This would be equivalent to
  551. * maxCLL / SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT for HDR10 content.
  552. * If this is defined, any values outside the range supported by the display
  553. * will be scaled into the available HDR headroom, otherwise they are
  554. * clipped.
  555. *
  556. * With the direct3d11 renderer:
  557. *
  558. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D
  559. * associated with the texture, if you want to wrap an existing texture.
  560. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  561. * associated with the U plane of a YUV texture, if you want to wrap an
  562. * existing texture.
  563. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  564. * associated with the V plane of a YUV texture, if you want to wrap an
  565. * existing texture.
  566. *
  567. * With the direct3d12 renderer:
  568. *
  569. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource
  570. * associated with the texture, if you want to wrap an existing texture.
  571. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource
  572. * associated with the U plane of a YUV texture, if you want to wrap an
  573. * existing texture.
  574. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource
  575. * associated with the V plane of a YUV texture, if you want to wrap an
  576. * existing texture.
  577. *
  578. * With the metal renderer:
  579. *
  580. * - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef
  581. * associated with the texture, if you want to create a texture from an
  582. * existing pixel buffer.
  583. *
  584. * With the opengl renderer:
  585. *
  586. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture
  587. * associated with the texture, if you want to wrap an existing texture.
  588. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  589. * associated with the UV plane of an NV12 texture, if you want to wrap an
  590. * existing texture.
  591. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture
  592. * associated with the U plane of a YUV texture, if you want to wrap an
  593. * existing texture.
  594. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture
  595. * associated with the V plane of a YUV texture, if you want to wrap an
  596. * existing texture.
  597. *
  598. * With the opengles2 renderer:
  599. *
  600. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  601. * associated with the texture, if you want to wrap an existing texture.
  602. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  603. * associated with the texture, if you want to wrap an existing texture.
  604. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  605. * associated with the UV plane of an NV12 texture, if you want to wrap an
  606. * existing texture.
  607. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  608. * associated with the U plane of a YUV texture, if you want to wrap an
  609. * existing texture.
  610. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  611. * associated with the V plane of a YUV texture, if you want to wrap an
  612. * existing texture.
  613. *
  614. * With the vulkan renderer:
  615. *
  616. * - `SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER`: the VkImage with layout
  617. * VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL associated with the texture, if
  618. * you want to wrap an existing texture.
  619. *
  620. * \param renderer the rendering context.
  621. * \param props the properties to use.
  622. * \returns a pointer to the created texture or NULL if no rendering context
  623. * was active, the format was unsupported, or the width or height
  624. * were out of range; call SDL_GetError() for more information.
  625. *
  626. * \threadsafety You may only call this function from the main thread.
  627. *
  628. * \since This function is available since SDL 3.0.0.
  629. *
  630. * \sa SDL_CreateProperties
  631. * \sa SDL_CreateTexture
  632. * \sa SDL_CreateTextureFromSurface
  633. * \sa SDL_DestroyTexture
  634. * \sa SDL_GetTextureSize
  635. * \sa SDL_UpdateTexture
  636. */
  637. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
  638. #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "SDL.texture.create.colorspace"
  639. #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "SDL.texture.create.format"
  640. #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "SDL.texture.create.access"
  641. #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "SDL.texture.create.width"
  642. #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "SDL.texture.create.height"
  643. #define SDL_PROP_TEXTURE_CREATE_SDR_WHITE_POINT_FLOAT "SDL.texture.create.SDR_white_point"
  644. #define SDL_PROP_TEXTURE_CREATE_HDR_HEADROOM_FLOAT "SDL.texture.create.HDR_headroom"
  645. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "SDL.texture.create.d3d11.texture"
  646. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "SDL.texture.create.d3d11.texture_u"
  647. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "SDL.texture.create.d3d11.texture_v"
  648. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "SDL.texture.create.d3d12.texture"
  649. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "SDL.texture.create.d3d12.texture_u"
  650. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "SDL.texture.create.d3d12.texture_v"
  651. #define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "SDL.texture.create.metal.pixelbuffer"
  652. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "SDL.texture.create.opengl.texture"
  653. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.create.opengl.texture_uv"
  654. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.create.opengl.texture_u"
  655. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.create.opengl.texture_v"
  656. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.create.opengles2.texture"
  657. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.create.opengles2.texture_uv"
  658. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.create.opengles2.texture_u"
  659. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.create.opengles2.texture_v"
  660. #define SDL_PROP_TEXTURE_CREATE_VULKAN_TEXTURE_NUMBER "SDL.texture.create.vulkan.texture"
  661. /**
  662. * Get the properties associated with a texture.
  663. *
  664. * The following read-only properties are provided by SDL:
  665. *
  666. * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing
  667. * the texture colorspace.
  668. * - `SDL_PROP_TEXTURE_FORMAT_NUMBER`: one of the enumerated values in
  669. * SDL_PixelFormat.
  670. * - `SDL_PROP_TEXTURE_ACCESS_NUMBER`: one of the enumerated values in
  671. * SDL_TextureAccess.
  672. * - `SDL_PROP_TEXTURE_WIDTH_NUMBER`: the width of the texture in pixels.
  673. * - `SDL_PROP_TEXTURE_HEIGHT_NUMBER`: the height of the texture in pixels.
  674. * - `SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT`: for HDR10 and floating point
  675. * textures, this defines the value of 100% diffuse white, with higher
  676. * values being displayed in the High Dynamic Range headroom. This defaults
  677. * to 100 for HDR10 textures and 1.0 for other textures.
  678. * - `SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT`: for HDR10 and floating point
  679. * textures, this defines the maximum dynamic range used by the content, in
  680. * terms of the SDR white point. If this is defined, any values outside the
  681. * range supported by the display will be scaled into the available HDR
  682. * headroom, otherwise they are clipped. This defaults to 1.0 for SDR
  683. * textures, 4.0 for HDR10 textures, and no default for floating point
  684. * textures.
  685. *
  686. * With the direct3d11 renderer:
  687. *
  688. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated
  689. * with the texture
  690. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  691. * associated with the U plane of a YUV texture
  692. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  693. * associated with the V plane of a YUV texture
  694. *
  695. * With the direct3d12 renderer:
  696. *
  697. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated
  698. * with the texture
  699. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated
  700. * with the U plane of a YUV texture
  701. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated
  702. * with the V plane of a YUV texture
  703. *
  704. * With the vulkan renderer:
  705. *
  706. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_POINTER`: the VkImage associated with
  707. * the texture
  708. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_U_POINTER`: the VkImage associated with
  709. * the U plane of a YUV texture
  710. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_V_POINTER`: the VkImage associated with
  711. * the V plane of a YUV texture
  712. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_UV_POINTER`: the VkImage associated with
  713. * the UV plane of a NV12/NV21 texture
  714. *
  715. * With the opengl renderer:
  716. *
  717. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated
  718. * with the texture
  719. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  720. * associated with the UV plane of an NV12 texture
  721. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated
  722. * with the U plane of a YUV texture
  723. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated
  724. * with the V plane of a YUV texture
  725. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER`: the GLenum for the
  726. * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
  727. * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of
  728. * the texture (0.0 - 1.0)
  729. * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of
  730. * the texture (0.0 - 1.0)
  731. *
  732. * With the opengles2 renderer:
  733. *
  734. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  735. * associated with the texture
  736. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  737. * associated with the UV plane of an NV12 texture
  738. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  739. * associated with the U plane of a YUV texture
  740. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  741. * associated with the V plane of a YUV texture
  742. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER`: the GLenum for the
  743. * texture target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
  744. *
  745. * With the vulkan renderer:
  746. *
  747. * - `SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER`: the VkImage associated with the
  748. * texture
  749. *
  750. * \param texture the texture to query.
  751. * \returns a valid property ID on success or 0 on failure; call
  752. * SDL_GetError() for more information.
  753. *
  754. * \threadsafety It is safe to call this function from any thread.
  755. *
  756. * \since This function is available since SDL 3.0.0.
  757. */
  758. extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
  759. #define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"
  760. #define SDL_PROP_TEXTURE_FORMAT_NUMBER "SDL.texture.format"
  761. #define SDL_PROP_TEXTURE_ACCESS_NUMBER "SDL.texture.access"
  762. #define SDL_PROP_TEXTURE_WIDTH_NUMBER "SDL.texture.width"
  763. #define SDL_PROP_TEXTURE_HEIGHT_NUMBER "SDL.texture.height"
  764. #define SDL_PROP_TEXTURE_SDR_WHITE_POINT_FLOAT "SDL.texture.SDR_white_point"
  765. #define SDL_PROP_TEXTURE_HDR_HEADROOM_FLOAT "SDL.texture.HDR_headroom"
  766. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"
  767. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"
  768. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"
  769. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"
  770. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"
  771. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"
  772. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"
  773. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"
  774. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"
  775. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"
  776. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET_NUMBER "SDL.texture.opengl.target"
  777. #define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"
  778. #define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"
  779. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"
  780. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"
  781. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"
  782. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
  783. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET_NUMBER "SDL.texture.opengles2.target"
  784. #define SDL_PROP_TEXTURE_VULKAN_TEXTURE_NUMBER "SDL.texture.vulkan.texture"
  785. /**
  786. * Get the renderer that created an SDL_Texture.
  787. *
  788. * \param texture the texture to query.
  789. * \returns a pointer to the SDL_Renderer that created the texture, or NULL on
  790. * failure; call SDL_GetError() for more information.
  791. *
  792. * \threadsafety It is safe to call this function from any thread.
  793. *
  794. * \since This function is available since SDL 3.0.0.
  795. */
  796. extern SDL_DECLSPEC SDL_Renderer * SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);
  797. /**
  798. * Get the size of a texture, as floating point values.
  799. *
  800. * \param texture the texture to query.
  801. * \param w a pointer filled in with the width of the texture in pixels. This
  802. * argument can be NULL if you don't need this information.
  803. * \param h a pointer filled in with the height of the texture in pixels. This
  804. * argument can be NULL if you don't need this information.
  805. * \returns true on success or false on failure; call SDL_GetError() for more
  806. * information.
  807. *
  808. * \threadsafety You may only call this function from the main thread.
  809. *
  810. * \since This function is available since SDL 3.0.0.
  811. */
  812. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureSize(SDL_Texture *texture, float *w, float *h);
  813. /**
  814. * Set an additional color value multiplied into render copy operations.
  815. *
  816. * When this texture is rendered, during the copy operation each source color
  817. * channel is modulated by the appropriate color value according to the
  818. * following formula:
  819. *
  820. * `srcC = srcC * (color / 255)`
  821. *
  822. * Color modulation is not always supported by the renderer; it will return
  823. * false if color modulation is not supported.
  824. *
  825. * \param texture the texture to update.
  826. * \param r the red color value multiplied into copy operations.
  827. * \param g the green color value multiplied into copy operations.
  828. * \param b the blue color value multiplied into copy operations.
  829. * \returns true on success or false on failure; call SDL_GetError() for more
  830. * information.
  831. *
  832. * \threadsafety You may only call this function from the main thread.
  833. *
  834. * \since This function is available since SDL 3.0.0.
  835. *
  836. * \sa SDL_GetTextureColorMod
  837. * \sa SDL_SetTextureAlphaMod
  838. * \sa SDL_SetTextureColorModFloat
  839. */
  840. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);
  841. /**
  842. * Set an additional color value multiplied into render copy operations.
  843. *
  844. * When this texture is rendered, during the copy operation each source color
  845. * channel is modulated by the appropriate color value according to the
  846. * following formula:
  847. *
  848. * `srcC = srcC * color`
  849. *
  850. * Color modulation is not always supported by the renderer; it will return
  851. * false if color modulation is not supported.
  852. *
  853. * \param texture the texture to update.
  854. * \param r the red color value multiplied into copy operations.
  855. * \param g the green color value multiplied into copy operations.
  856. * \param b the blue color value multiplied into copy operations.
  857. * \returns true on success or false on failure; call SDL_GetError() for more
  858. * information.
  859. *
  860. * \threadsafety You may only call this function from the main thread.
  861. *
  862. * \since This function is available since SDL 3.0.0.
  863. *
  864. * \sa SDL_GetTextureColorModFloat
  865. * \sa SDL_SetTextureAlphaModFloat
  866. * \sa SDL_SetTextureColorMod
  867. */
  868. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);
  869. /**
  870. * Get the additional color value multiplied into render copy operations.
  871. *
  872. * \param texture the texture to query.
  873. * \param r a pointer filled in with the current red color value.
  874. * \param g a pointer filled in with the current green color value.
  875. * \param b a pointer filled in with the current blue color value.
  876. * \returns true on success or false on failure; call SDL_GetError() for more
  877. * information.
  878. *
  879. * \threadsafety You may only call this function from the main thread.
  880. *
  881. * \since This function is available since SDL 3.0.0.
  882. *
  883. * \sa SDL_GetTextureAlphaMod
  884. * \sa SDL_GetTextureColorModFloat
  885. * \sa SDL_SetTextureColorMod
  886. */
  887. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);
  888. /**
  889. * Get the additional color value multiplied into render copy operations.
  890. *
  891. * \param texture the texture to query.
  892. * \param r a pointer filled in with the current red color value.
  893. * \param g a pointer filled in with the current green color value.
  894. * \param b a pointer filled in with the current blue color value.
  895. * \returns true on success or false on failure; call SDL_GetError() for more
  896. * information.
  897. *
  898. * \threadsafety You may only call this function from the main thread.
  899. *
  900. * \since This function is available since SDL 3.0.0.
  901. *
  902. * \sa SDL_GetTextureAlphaModFloat
  903. * \sa SDL_GetTextureColorMod
  904. * \sa SDL_SetTextureColorModFloat
  905. */
  906. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);
  907. /**
  908. * Set an additional alpha value multiplied into render copy operations.
  909. *
  910. * When this texture is rendered, during the copy operation the source alpha
  911. * value is modulated by this alpha value according to the following formula:
  912. *
  913. * `srcA = srcA * (alpha / 255)`
  914. *
  915. * Alpha modulation is not always supported by the renderer; it will return
  916. * false if alpha modulation is not supported.
  917. *
  918. * \param texture the texture to update.
  919. * \param alpha the source alpha value multiplied into copy operations.
  920. * \returns true on success or false on failure; call SDL_GetError() for more
  921. * information.
  922. *
  923. * \threadsafety You may only call this function from the main thread.
  924. *
  925. * \since This function is available since SDL 3.0.0.
  926. *
  927. * \sa SDL_GetTextureAlphaMod
  928. * \sa SDL_SetTextureAlphaModFloat
  929. * \sa SDL_SetTextureColorMod
  930. */
  931. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
  932. /**
  933. * Set an additional alpha value multiplied into render copy operations.
  934. *
  935. * When this texture is rendered, during the copy operation the source alpha
  936. * value is modulated by this alpha value according to the following formula:
  937. *
  938. * `srcA = srcA * alpha`
  939. *
  940. * Alpha modulation is not always supported by the renderer; it will return
  941. * false if alpha modulation is not supported.
  942. *
  943. * \param texture the texture to update.
  944. * \param alpha the source alpha value multiplied into copy operations.
  945. * \returns true on success or false on failure; call SDL_GetError() for more
  946. * information.
  947. *
  948. * \threadsafety You may only call this function from the main thread.
  949. *
  950. * \since This function is available since SDL 3.0.0.
  951. *
  952. * \sa SDL_GetTextureAlphaModFloat
  953. * \sa SDL_SetTextureAlphaMod
  954. * \sa SDL_SetTextureColorModFloat
  955. */
  956. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);
  957. /**
  958. * Get the additional alpha value multiplied into render copy operations.
  959. *
  960. * \param texture the texture to query.
  961. * \param alpha a pointer filled in with the current alpha value.
  962. * \returns true on success or false on failure; call SDL_GetError() for more
  963. * information.
  964. *
  965. * \threadsafety You may only call this function from the main thread.
  966. *
  967. * \since This function is available since SDL 3.0.0.
  968. *
  969. * \sa SDL_GetTextureAlphaModFloat
  970. * \sa SDL_GetTextureColorMod
  971. * \sa SDL_SetTextureAlphaMod
  972. */
  973. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);
  974. /**
  975. * Get the additional alpha value multiplied into render copy operations.
  976. *
  977. * \param texture the texture to query.
  978. * \param alpha a pointer filled in with the current alpha value.
  979. * \returns true on success or false on failure; call SDL_GetError() for more
  980. * information.
  981. *
  982. * \threadsafety You may only call this function from the main thread.
  983. *
  984. * \since This function is available since SDL 3.0.0.
  985. *
  986. * \sa SDL_GetTextureAlphaMod
  987. * \sa SDL_GetTextureColorModFloat
  988. * \sa SDL_SetTextureAlphaModFloat
  989. */
  990. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);
  991. /**
  992. * Set the blend mode for a texture, used by SDL_RenderTexture().
  993. *
  994. * If the blend mode is not supported, the closest supported mode is chosen
  995. * and this function returns false.
  996. *
  997. * \param texture the texture to update.
  998. * \param blendMode the SDL_BlendMode to use for texture blending.
  999. * \returns true on success or false on failure; call SDL_GetError() for more
  1000. * information.
  1001. *
  1002. * \threadsafety You may only call this function from the main thread.
  1003. *
  1004. * \since This function is available since SDL 3.0.0.
  1005. *
  1006. * \sa SDL_GetTextureBlendMode
  1007. */
  1008. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);
  1009. /**
  1010. * Get the blend mode used for texture copy operations.
  1011. *
  1012. * \param texture the texture to query.
  1013. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  1014. * \returns true on success or false on failure; call SDL_GetError() for more
  1015. * information.
  1016. *
  1017. * \threadsafety You may only call this function from the main thread.
  1018. *
  1019. * \since This function is available since SDL 3.0.0.
  1020. *
  1021. * \sa SDL_SetTextureBlendMode
  1022. */
  1023. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);
  1024. /**
  1025. * Set the scale mode used for texture scale operations.
  1026. *
  1027. * The default texture scale mode is SDL_SCALEMODE_LINEAR.
  1028. *
  1029. * If the scale mode is not supported, the closest supported mode is chosen.
  1030. *
  1031. * \param texture the texture to update.
  1032. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
  1033. * \returns true on success or false on failure; call SDL_GetError() for more
  1034. * information.
  1035. *
  1036. * \threadsafety You may only call this function from the main thread.
  1037. *
  1038. * \since This function is available since SDL 3.0.0.
  1039. *
  1040. * \sa SDL_GetTextureScaleMode
  1041. */
  1042. extern SDL_DECLSPEC bool SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);
  1043. /**
  1044. * Get the scale mode used for texture scale operations.
  1045. *
  1046. * \param texture the texture to query.
  1047. * \param scaleMode a pointer filled in with the current scale mode.
  1048. * \returns true on success or false on failure; call SDL_GetError() for more
  1049. * information.
  1050. *
  1051. * \threadsafety You may only call this function from the main thread.
  1052. *
  1053. * \since This function is available since SDL 3.0.0.
  1054. *
  1055. * \sa SDL_SetTextureScaleMode
  1056. */
  1057. extern SDL_DECLSPEC bool SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
  1058. /**
  1059. * Update the given texture rectangle with new pixel data.
  1060. *
  1061. * The pixel data must be in the pixel format of the texture, which can be
  1062. * queried using the SDL_PROP_TEXTURE_FORMAT_NUMBER property.
  1063. *
  1064. * This is a fairly slow function, intended for use with static textures that
  1065. * do not change often.
  1066. *
  1067. * If the texture is intended to be updated often, it is preferred to create
  1068. * the texture as streaming and use the locking functions referenced below.
  1069. * While this function will work with streaming textures, for optimization
  1070. * reasons you may not get the pixels back if you lock the texture afterward.
  1071. *
  1072. * \param texture the texture to update.
  1073. * \param rect an SDL_Rect structure representing the area to update, or NULL
  1074. * to update the entire texture.
  1075. * \param pixels the raw pixel data in the format of the texture.
  1076. * \param pitch the number of bytes in a row of pixel data, including padding
  1077. * between lines.
  1078. * \returns true on success or false on failure; call SDL_GetError() for more
  1079. * information.
  1080. *
  1081. * \threadsafety You may only call this function from the main thread.
  1082. *
  1083. * \since This function is available since SDL 3.0.0.
  1084. *
  1085. * \sa SDL_LockTexture
  1086. * \sa SDL_UnlockTexture
  1087. * \sa SDL_UpdateNVTexture
  1088. * \sa SDL_UpdateYUVTexture
  1089. */
  1090. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);
  1091. /**
  1092. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  1093. * data.
  1094. *
  1095. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  1096. * block of Y and U/V planes in the proper order, but this function is
  1097. * available if your pixel data is not contiguous.
  1098. *
  1099. * \param texture the texture to update.
  1100. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  1101. * update the entire texture.
  1102. * \param Yplane the raw pixel data for the Y plane.
  1103. * \param Ypitch the number of bytes between rows of pixel data for the Y
  1104. * plane.
  1105. * \param Uplane the raw pixel data for the U plane.
  1106. * \param Upitch the number of bytes between rows of pixel data for the U
  1107. * plane.
  1108. * \param Vplane the raw pixel data for the V plane.
  1109. * \param Vpitch the number of bytes between rows of pixel data for the V
  1110. * plane.
  1111. * \returns true on success or false on failure; call SDL_GetError() for more
  1112. * information.
  1113. *
  1114. * \threadsafety You may only call this function from the main thread.
  1115. *
  1116. * \since This function is available since SDL 3.0.0.
  1117. *
  1118. * \sa SDL_UpdateNVTexture
  1119. * \sa SDL_UpdateTexture
  1120. */
  1121. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
  1122. const SDL_Rect *rect,
  1123. const Uint8 *Yplane, int Ypitch,
  1124. const Uint8 *Uplane, int Upitch,
  1125. const Uint8 *Vplane, int Vpitch);
  1126. /**
  1127. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  1128. *
  1129. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  1130. * block of NV12/21 planes in the proper order, but this function is available
  1131. * if your pixel data is not contiguous.
  1132. *
  1133. * \param texture the texture to update.
  1134. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  1135. * update the entire texture.
  1136. * \param Yplane the raw pixel data for the Y plane.
  1137. * \param Ypitch the number of bytes between rows of pixel data for the Y
  1138. * plane.
  1139. * \param UVplane the raw pixel data for the UV plane.
  1140. * \param UVpitch the number of bytes between rows of pixel data for the UV
  1141. * plane.
  1142. * \returns true on success or false on failure; call SDL_GetError() for more
  1143. * information.
  1144. *
  1145. * \threadsafety You may only call this function from the main thread.
  1146. *
  1147. * \since This function is available since SDL 3.0.0.
  1148. *
  1149. * \sa SDL_UpdateTexture
  1150. * \sa SDL_UpdateYUVTexture
  1151. */
  1152. extern SDL_DECLSPEC bool SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,
  1153. const SDL_Rect *rect,
  1154. const Uint8 *Yplane, int Ypitch,
  1155. const Uint8 *UVplane, int UVpitch);
  1156. /**
  1157. * Lock a portion of the texture for **write-only** pixel access.
  1158. *
  1159. * As an optimization, the pixels made available for editing don't necessarily
  1160. * contain the old texture data. This is a write-only operation, and if you
  1161. * need to keep a copy of the texture data you should do that at the
  1162. * application level.
  1163. *
  1164. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1165. * changes.
  1166. *
  1167. * \param texture the texture to lock for access, which was created with
  1168. * `SDL_TEXTUREACCESS_STREAMING`.
  1169. * \param rect an SDL_Rect structure representing the area to lock for access;
  1170. * NULL to lock the entire texture.
  1171. * \param pixels this is filled in with a pointer to the locked pixels,
  1172. * appropriately offset by the locked area.
  1173. * \param pitch this is filled in with the pitch of the locked pixels; the
  1174. * pitch is the length of one row in bytes.
  1175. * \returns true on success or false if the texture is not valid or was not
  1176. * created with `SDL_TEXTUREACCESS_STREAMING`; call SDL_GetError()
  1177. * for more information.
  1178. *
  1179. * \threadsafety You may only call this function from the main thread.
  1180. *
  1181. * \since This function is available since SDL 3.0.0.
  1182. *
  1183. * \sa SDL_LockTextureToSurface
  1184. * \sa SDL_UnlockTexture
  1185. */
  1186. extern SDL_DECLSPEC bool SDLCALL SDL_LockTexture(SDL_Texture *texture,
  1187. const SDL_Rect *rect,
  1188. void **pixels, int *pitch);
  1189. /**
  1190. * Lock a portion of the texture for **write-only** pixel access, and expose
  1191. * it as a SDL surface.
  1192. *
  1193. * Besides providing an SDL_Surface instead of raw pixel data, this function
  1194. * operates like SDL_LockTexture.
  1195. *
  1196. * As an optimization, the pixels made available for editing don't necessarily
  1197. * contain the old texture data. This is a write-only operation, and if you
  1198. * need to keep a copy of the texture data you should do that at the
  1199. * application level.
  1200. *
  1201. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1202. * changes.
  1203. *
  1204. * The returned surface is freed internally after calling SDL_UnlockTexture()
  1205. * or SDL_DestroyTexture(). The caller should not free it.
  1206. *
  1207. * \param texture the texture to lock for access, which must be created with
  1208. * `SDL_TEXTUREACCESS_STREAMING`.
  1209. * \param rect a pointer to the rectangle to lock for access. If the rect is
  1210. * NULL, the entire texture will be locked.
  1211. * \param surface this is filled in with an SDL surface representing the
  1212. * locked area.
  1213. * \returns true on success or false on failure; call SDL_GetError() for more
  1214. * information.
  1215. *
  1216. * \threadsafety You may only call this function from the main thread.
  1217. *
  1218. * \since This function is available since SDL 3.0.0.
  1219. *
  1220. * \sa SDL_LockTexture
  1221. * \sa SDL_UnlockTexture
  1222. */
  1223. extern SDL_DECLSPEC bool SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Surface **surface);
  1224. /**
  1225. * Unlock a texture, uploading the changes to video memory, if needed.
  1226. *
  1227. * **Warning**: Please note that SDL_LockTexture() is intended to be
  1228. * write-only; it will not guarantee the previous contents of the texture will
  1229. * be provided. You must fully initialize any area of a texture that you lock
  1230. * before unlocking it, as the pixels might otherwise be uninitialized memory.
  1231. *
  1232. * Which is to say: locking and immediately unlocking a texture can result in
  1233. * corrupted textures, depending on the renderer in use.
  1234. *
  1235. * \param texture a texture locked by SDL_LockTexture().
  1236. *
  1237. * \threadsafety You may only call this function from the main thread.
  1238. *
  1239. * \since This function is available since SDL 3.0.0.
  1240. *
  1241. * \sa SDL_LockTexture
  1242. */
  1243. extern SDL_DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
  1244. /**
  1245. * Set a texture as the current rendering target.
  1246. *
  1247. * The default render target is the window for which the renderer was created.
  1248. * To stop rendering to a texture and render to the window again, call this
  1249. * function with a NULL `texture`.
  1250. *
  1251. * \param renderer the rendering context.
  1252. * \param texture the targeted texture, which must be created with the
  1253. * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
  1254. * window instead of a texture.
  1255. * \returns true on success or false on failure; call SDL_GetError() for more
  1256. * information.
  1257. *
  1258. * \threadsafety You may only call this function from the main thread.
  1259. *
  1260. * \since This function is available since SDL 3.0.0.
  1261. *
  1262. * \sa SDL_GetRenderTarget
  1263. */
  1264. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);
  1265. /**
  1266. * Get the current render target.
  1267. *
  1268. * The default render target is the window for which the renderer was created,
  1269. * and is reported a NULL here.
  1270. *
  1271. * \param renderer the rendering context.
  1272. * \returns the current render target or NULL for the default render target.
  1273. *
  1274. * \threadsafety You may only call this function from the main thread.
  1275. *
  1276. * \since This function is available since SDL 3.0.0.
  1277. *
  1278. * \sa SDL_SetRenderTarget
  1279. */
  1280. extern SDL_DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  1281. /**
  1282. * Set a device independent resolution and presentation mode for rendering.
  1283. *
  1284. * This function sets the width and height of the logical rendering output.
  1285. * The renderer will act as if the window is always the requested dimensions,
  1286. * scaling to the actual window resolution as necessary.
  1287. *
  1288. * This can be useful for games that expect a fixed size, but would like to
  1289. * scale the output to whatever is available, regardless of how a user resizes
  1290. * a window, or if the display is high DPI.
  1291. *
  1292. * You can disable logical coordinates by setting the mode to
  1293. * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
  1294. * resolution of the output window; it is safe to toggle logical presentation
  1295. * during the rendering of a frame: perhaps most of the rendering is done to
  1296. * specific dimensions but to make fonts look sharp, the app turns off logical
  1297. * presentation while drawing text.
  1298. *
  1299. * Letterboxing will only happen if logical presentation is enabled during
  1300. * SDL_RenderPresent; be sure to reenable it first if you were using it.
  1301. *
  1302. * You can convert coordinates in an event into rendering coordinates using
  1303. * SDL_ConvertEventToRenderCoordinates().
  1304. *
  1305. * \param renderer the rendering context.
  1306. * \param w the width of the logical resolution.
  1307. * \param h the height of the logical resolution.
  1308. * \param mode the presentation mode used.
  1309. * \returns true on success or false on failure; call SDL_GetError() for more
  1310. * information.
  1311. *
  1312. * \threadsafety You may only call this function from the main thread.
  1313. *
  1314. * \since This function is available since SDL 3.0.0.
  1315. *
  1316. * \sa SDL_ConvertEventToRenderCoordinates
  1317. * \sa SDL_GetRenderLogicalPresentation
  1318. * \sa SDL_GetRenderLogicalPresentationRect
  1319. */
  1320. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode);
  1321. /**
  1322. * Get device independent resolution and presentation mode for rendering.
  1323. *
  1324. * This function gets the width and height of the logical rendering output, or
  1325. * the output size in pixels if a logical resolution is not enabled.
  1326. *
  1327. * \param renderer the rendering context.
  1328. * \param w an int to be filled with the width.
  1329. * \param h an int to be filled with the height.
  1330. * \returns true on success or false on failure; call SDL_GetError() for more
  1331. * information.
  1332. *
  1333. * \threadsafety You may only call this function from the main thread.
  1334. *
  1335. * \since This function is available since SDL 3.0.0.
  1336. *
  1337. * \sa SDL_SetRenderLogicalPresentation
  1338. */
  1339. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode);
  1340. /**
  1341. * Get the final presentation rectangle for rendering.
  1342. *
  1343. * This function returns the calculated rectangle used for logical
  1344. * presentation, based on the presentation mode and output size. If logical
  1345. * presentation is disabled, it will fill the rectangle with the output size,
  1346. * in pixels.
  1347. *
  1348. * \param renderer the rendering context.
  1349. * \param rect a pointer filled in with the final presentation rectangle, may
  1350. * be NULL.
  1351. * \returns true on success or false on failure; call SDL_GetError() for more
  1352. * information.
  1353. *
  1354. * \threadsafety You may only call this function from the main thread.
  1355. *
  1356. * \since This function is available since SDL 3.0.0.
  1357. *
  1358. * \sa SDL_SetRenderLogicalPresentation
  1359. */
  1360. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderLogicalPresentationRect(SDL_Renderer *renderer, SDL_FRect *rect);
  1361. /**
  1362. * Get a point in render coordinates when given a point in window coordinates.
  1363. *
  1364. * \param renderer the rendering context.
  1365. * \param window_x the x coordinate in window coordinates.
  1366. * \param window_y the y coordinate in window coordinates.
  1367. * \param x a pointer filled with the x coordinate in render coordinates.
  1368. * \param y a pointer filled with the y coordinate in render coordinates.
  1369. * \returns true on success or false on failure; call SDL_GetError() for more
  1370. * information.
  1371. *
  1372. * \threadsafety You may only call this function from the main thread.
  1373. *
  1374. * \since This function is available since SDL 3.0.0.
  1375. *
  1376. * \sa SDL_SetRenderLogicalPresentation
  1377. * \sa SDL_SetRenderScale
  1378. */
  1379. extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
  1380. /**
  1381. * Get a point in window coordinates when given a point in render coordinates.
  1382. *
  1383. * \param renderer the rendering context.
  1384. * \param x the x coordinate in render coordinates.
  1385. * \param y the y coordinate in render coordinates.
  1386. * \param window_x a pointer filled with the x coordinate in window
  1387. * coordinates.
  1388. * \param window_y a pointer filled with the y coordinate in window
  1389. * coordinates.
  1390. * \returns true on success or false on failure; call SDL_GetError() for more
  1391. * information.
  1392. *
  1393. * \threadsafety You may only call this function from the main thread.
  1394. *
  1395. * \since This function is available since SDL 3.0.0.
  1396. *
  1397. * \sa SDL_SetRenderLogicalPresentation
  1398. * \sa SDL_SetRenderScale
  1399. */
  1400. extern SDL_DECLSPEC bool SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
  1401. /**
  1402. * Convert the coordinates in an event to render coordinates.
  1403. *
  1404. * Touch coordinates are converted from normalized coordinates in the window
  1405. * to non-normalized rendering coordinates.
  1406. *
  1407. * Once converted, the coordinates may be outside the rendering area.
  1408. *
  1409. * \param renderer the rendering context.
  1410. * \param event the event to modify.
  1411. * \returns true on success or false on failure; call SDL_GetError() for more
  1412. * information.
  1413. *
  1414. * \threadsafety You may only call this function from the main thread.
  1415. *
  1416. * \since This function is available since SDL 3.0.0.
  1417. *
  1418. * \sa SDL_RenderCoordinatesFromWindow
  1419. */
  1420. extern SDL_DECLSPEC bool SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
  1421. /**
  1422. * Set the drawing area for rendering on the current target.
  1423. *
  1424. * Drawing will clip to this area (separately from any clipping done with
  1425. * SDL_SetRenderClipRect), and the top left of the area will become coordinate
  1426. * (0, 0) for future drawing commands.
  1427. *
  1428. * The area's width and height must be >= 0.
  1429. *
  1430. * \param renderer the rendering context.
  1431. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  1432. * to set the viewport to the entire target.
  1433. * \returns true on success or false on failure; call SDL_GetError() for more
  1434. * information.
  1435. *
  1436. * \threadsafety You may only call this function from the main thread.
  1437. *
  1438. * \since This function is available since SDL 3.0.0.
  1439. *
  1440. * \sa SDL_GetRenderViewport
  1441. * \sa SDL_RenderViewportSet
  1442. */
  1443. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);
  1444. /**
  1445. * Get the drawing area for the current target.
  1446. *
  1447. * \param renderer the rendering context.
  1448. * \param rect an SDL_Rect structure filled in with the current drawing area.
  1449. * \returns true on success or false on failure; call SDL_GetError() for more
  1450. * information.
  1451. *
  1452. * \threadsafety You may only call this function from the main thread.
  1453. *
  1454. * \since This function is available since SDL 3.0.0.
  1455. *
  1456. * \sa SDL_RenderViewportSet
  1457. * \sa SDL_SetRenderViewport
  1458. */
  1459. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
  1460. /**
  1461. * Return whether an explicit rectangle was set as the viewport.
  1462. *
  1463. * This is useful if you're saving and restoring the viewport and want to know
  1464. * whether you should restore a specific rectangle or NULL. Note that the
  1465. * viewport is always reset when changing rendering targets.
  1466. *
  1467. * \param renderer the rendering context.
  1468. * \returns true if the viewport was set to a specific rectangle, or false if
  1469. * it was set to NULL (the entire target).
  1470. *
  1471. * \threadsafety You may only call this function from the main thread.
  1472. *
  1473. * \since This function is available since SDL 3.0.0.
  1474. *
  1475. * \sa SDL_GetRenderViewport
  1476. * \sa SDL_SetRenderViewport
  1477. */
  1478. extern SDL_DECLSPEC bool SDLCALL SDL_RenderViewportSet(SDL_Renderer *renderer);
  1479. /**
  1480. * Get the safe area for rendering within the current viewport.
  1481. *
  1482. * Some devices have portions of the screen which are partially obscured or
  1483. * not interactive, possibly due to on-screen controls, curved edges, camera
  1484. * notches, TV overscan, etc. This function provides the area of the current
  1485. * viewport which is safe to have interactible content. You should continue
  1486. * rendering into the rest of the render target, but it should not contain
  1487. * visually important or interactible content.
  1488. *
  1489. * \param renderer the rendering context.
  1490. * \param rect a pointer filled in with the area that is safe for interactive
  1491. * content.
  1492. * \returns true on success or false on failure; call SDL_GetError() for more
  1493. * information.
  1494. *
  1495. * \threadsafety You may only call this function from the main thread.
  1496. *
  1497. * \since This function is available since SDL 3.0.0.
  1498. */
  1499. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderSafeArea(SDL_Renderer *renderer, SDL_Rect *rect);
  1500. /**
  1501. * Set the clip rectangle for rendering on the specified target.
  1502. *
  1503. * \param renderer the rendering context.
  1504. * \param rect an SDL_Rect structure representing the clip area, relative to
  1505. * the viewport, or NULL to disable clipping.
  1506. * \returns true on success or false on failure; call SDL_GetError() for more
  1507. * information.
  1508. *
  1509. * \threadsafety You may only call this function from the main thread.
  1510. *
  1511. * \since This function is available since SDL 3.0.0.
  1512. *
  1513. * \sa SDL_GetRenderClipRect
  1514. * \sa SDL_RenderClipEnabled
  1515. */
  1516. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);
  1517. /**
  1518. * Get the clip rectangle for the current target.
  1519. *
  1520. * \param renderer the rendering context.
  1521. * \param rect an SDL_Rect structure filled in with the current clipping area
  1522. * or an empty rectangle if clipping is disabled.
  1523. * \returns true on success or false on failure; call SDL_GetError() for more
  1524. * information.
  1525. *
  1526. * \threadsafety You may only call this function from the main thread.
  1527. *
  1528. * \since This function is available since SDL 3.0.0.
  1529. *
  1530. * \sa SDL_RenderClipEnabled
  1531. * \sa SDL_SetRenderClipRect
  1532. */
  1533. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
  1534. /**
  1535. * Get whether clipping is enabled on the given renderer.
  1536. *
  1537. * \param renderer the rendering context.
  1538. * \returns true if clipping is enabled or false if not; call SDL_GetError()
  1539. * for more information.
  1540. *
  1541. * \threadsafety You may only call this function from the main thread.
  1542. *
  1543. * \since This function is available since SDL 3.0.0.
  1544. *
  1545. * \sa SDL_GetRenderClipRect
  1546. * \sa SDL_SetRenderClipRect
  1547. */
  1548. extern SDL_DECLSPEC bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
  1549. /**
  1550. * Set the drawing scale for rendering on the current target.
  1551. *
  1552. * The drawing coordinates are scaled by the x/y scaling factors before they
  1553. * are used by the renderer. This allows resolution independent drawing with a
  1554. * single coordinate system.
  1555. *
  1556. * If this results in scaling or subpixel drawing by the rendering backend, it
  1557. * will be handled using the appropriate quality hints. For best results use
  1558. * integer scaling factors.
  1559. *
  1560. * \param renderer the rendering context.
  1561. * \param scaleX the horizontal scaling factor.
  1562. * \param scaleY the vertical scaling factor.
  1563. * \returns true on success or false on failure; call SDL_GetError() for more
  1564. * information.
  1565. *
  1566. * \threadsafety You may only call this function from the main thread.
  1567. *
  1568. * \since This function is available since SDL 3.0.0.
  1569. *
  1570. * \sa SDL_GetRenderScale
  1571. */
  1572. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
  1573. /**
  1574. * Get the drawing scale for the current target.
  1575. *
  1576. * \param renderer the rendering context.
  1577. * \param scaleX a pointer filled in with the horizontal scaling factor.
  1578. * \param scaleY a pointer filled in with the vertical scaling factor.
  1579. * \returns true on success or false on failure; call SDL_GetError() for more
  1580. * information.
  1581. *
  1582. * \threadsafety You may only call this function from the main thread.
  1583. *
  1584. * \since This function is available since SDL 3.0.0.
  1585. *
  1586. * \sa SDL_SetRenderScale
  1587. */
  1588. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
  1589. /**
  1590. * Set the color used for drawing operations.
  1591. *
  1592. * Set the color for drawing or filling rectangles, lines, and points, and for
  1593. * SDL_RenderClear().
  1594. *
  1595. * \param renderer the rendering context.
  1596. * \param r the red value used to draw on the rendering target.
  1597. * \param g the green value used to draw on the rendering target.
  1598. * \param b the blue value used to draw on the rendering target.
  1599. * \param a the alpha value used to draw on the rendering target; usually
  1600. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  1601. * specify how the alpha channel is used.
  1602. * \returns true on success or false on failure; call SDL_GetError() for more
  1603. * information.
  1604. *
  1605. * \threadsafety You may only call this function from the main thread.
  1606. *
  1607. * \since This function is available since SDL 3.0.0.
  1608. *
  1609. * \sa SDL_GetRenderDrawColor
  1610. * \sa SDL_SetRenderDrawColorFloat
  1611. */
  1612. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  1613. /**
  1614. * Set the color used for drawing operations (Rect, Line and Clear).
  1615. *
  1616. * Set the color for drawing or filling rectangles, lines, and points, and for
  1617. * SDL_RenderClear().
  1618. *
  1619. * \param renderer the rendering context.
  1620. * \param r the red value used to draw on the rendering target.
  1621. * \param g the green value used to draw on the rendering target.
  1622. * \param b the blue value used to draw on the rendering target.
  1623. * \param a the alpha value used to draw on the rendering target. Use
  1624. * SDL_SetRenderDrawBlendMode to specify how the alpha channel is
  1625. * used.
  1626. * \returns true on success or false on failure; call SDL_GetError() for more
  1627. * information.
  1628. *
  1629. * \threadsafety You may only call this function from the main thread.
  1630. *
  1631. * \since This function is available since SDL 3.0.0.
  1632. *
  1633. * \sa SDL_GetRenderDrawColorFloat
  1634. * \sa SDL_SetRenderDrawColor
  1635. */
  1636. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);
  1637. /**
  1638. * Get the color used for drawing operations (Rect, Line and Clear).
  1639. *
  1640. * \param renderer the rendering context.
  1641. * \param r a pointer filled in with the red value used to draw on the
  1642. * rendering target.
  1643. * \param g a pointer filled in with the green value used to draw on the
  1644. * rendering target.
  1645. * \param b a pointer filled in with the blue value used to draw on the
  1646. * rendering target.
  1647. * \param a a pointer filled in with the alpha value used to draw on the
  1648. * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
  1649. * \returns true on success or false on failure; call SDL_GetError() for more
  1650. * information.
  1651. *
  1652. * \threadsafety You may only call this function from the main thread.
  1653. *
  1654. * \since This function is available since SDL 3.0.0.
  1655. *
  1656. * \sa SDL_GetRenderDrawColorFloat
  1657. * \sa SDL_SetRenderDrawColor
  1658. */
  1659. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
  1660. /**
  1661. * Get the color used for drawing operations (Rect, Line and Clear).
  1662. *
  1663. * \param renderer the rendering context.
  1664. * \param r a pointer filled in with the red value used to draw on the
  1665. * rendering target.
  1666. * \param g a pointer filled in with the green value used to draw on the
  1667. * rendering target.
  1668. * \param b a pointer filled in with the blue value used to draw on the
  1669. * rendering target.
  1670. * \param a a pointer filled in with the alpha value used to draw on the
  1671. * rendering target.
  1672. * \returns true on success or false on failure; call SDL_GetError() for more
  1673. * information.
  1674. *
  1675. * \threadsafety You may only call this function from the main thread.
  1676. *
  1677. * \since This function is available since SDL 3.0.0.
  1678. *
  1679. * \sa SDL_SetRenderDrawColorFloat
  1680. * \sa SDL_GetRenderDrawColor
  1681. */
  1682. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);
  1683. /**
  1684. * Set the color scale used for render operations.
  1685. *
  1686. * The color scale is an additional scale multiplied into the pixel color
  1687. * value while rendering. This can be used to adjust the brightness of colors
  1688. * during HDR rendering, or changing HDR video brightness when playing on an
  1689. * SDR display.
  1690. *
  1691. * The color scale does not affect the alpha channel, only the color
  1692. * brightness.
  1693. *
  1694. * \param renderer the rendering context.
  1695. * \param scale the color scale value.
  1696. * \returns true on success or false on failure; call SDL_GetError() for more
  1697. * information.
  1698. *
  1699. * \threadsafety You may only call this function from the main thread.
  1700. *
  1701. * \since This function is available since SDL 3.0.0.
  1702. *
  1703. * \sa SDL_GetRenderColorScale
  1704. */
  1705. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);
  1706. /**
  1707. * Get the color scale used for render operations.
  1708. *
  1709. * \param renderer the rendering context.
  1710. * \param scale a pointer filled in with the current color scale value.
  1711. * \returns true on success or false on failure; call SDL_GetError() for more
  1712. * information.
  1713. *
  1714. * \threadsafety You may only call this function from the main thread.
  1715. *
  1716. * \since This function is available since SDL 3.0.0.
  1717. *
  1718. * \sa SDL_SetRenderColorScale
  1719. */
  1720. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale);
  1721. /**
  1722. * Set the blend mode used for drawing operations (Fill and Line).
  1723. *
  1724. * If the blend mode is not supported, the closest supported mode is chosen.
  1725. *
  1726. * \param renderer the rendering context.
  1727. * \param blendMode the SDL_BlendMode to use for blending.
  1728. * \returns true on success or false on failure; call SDL_GetError() for more
  1729. * information.
  1730. *
  1731. * \threadsafety You may only call this function from the main thread.
  1732. *
  1733. * \since This function is available since SDL 3.0.0.
  1734. *
  1735. * \sa SDL_GetRenderDrawBlendMode
  1736. */
  1737. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
  1738. /**
  1739. * Get the blend mode used for drawing operations.
  1740. *
  1741. * \param renderer the rendering context.
  1742. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  1743. * \returns true on success or false on failure; call SDL_GetError() for more
  1744. * information.
  1745. *
  1746. * \threadsafety You may only call this function from the main thread.
  1747. *
  1748. * \since This function is available since SDL 3.0.0.
  1749. *
  1750. * \sa SDL_SetRenderDrawBlendMode
  1751. */
  1752. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);
  1753. /**
  1754. * Clear the current rendering target with the drawing color.
  1755. *
  1756. * This function clears the entire rendering target, ignoring the viewport and
  1757. * the clip rectangle. Note, that clearing will also set/fill all pixels of
  1758. * the rendering target to current renderer draw color, so make sure to invoke
  1759. * SDL_SetRenderDrawColor() when needed.
  1760. *
  1761. * \param renderer the rendering context.
  1762. * \returns true on success or false on failure; call SDL_GetError() for more
  1763. * information.
  1764. *
  1765. * \threadsafety You may only call this function from the main thread.
  1766. *
  1767. * \since This function is available since SDL 3.0.0.
  1768. *
  1769. * \sa SDL_SetRenderDrawColor
  1770. */
  1771. extern SDL_DECLSPEC bool SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
  1772. /**
  1773. * Draw a point on the current rendering target at subpixel precision.
  1774. *
  1775. * \param renderer the renderer which should draw a point.
  1776. * \param x the x coordinate of the point.
  1777. * \param y the y coordinate of the point.
  1778. * \returns true on success or false on failure; call SDL_GetError() for more
  1779. * information.
  1780. *
  1781. * \threadsafety You may only call this function from the main thread.
  1782. *
  1783. * \since This function is available since SDL 3.0.0.
  1784. *
  1785. * \sa SDL_RenderPoints
  1786. */
  1787. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);
  1788. /**
  1789. * Draw multiple points on the current rendering target at subpixel precision.
  1790. *
  1791. * \param renderer the renderer which should draw multiple points.
  1792. * \param points the points to draw.
  1793. * \param count the number of points to draw.
  1794. * \returns true on success or false on failure; call SDL_GetError() for more
  1795. * information.
  1796. *
  1797. * \threadsafety You may only call this function from the main thread.
  1798. *
  1799. * \since This function is available since SDL 3.0.0.
  1800. *
  1801. * \sa SDL_RenderPoint
  1802. */
  1803. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1804. /**
  1805. * Draw a line on the current rendering target at subpixel precision.
  1806. *
  1807. * \param renderer the renderer which should draw a line.
  1808. * \param x1 the x coordinate of the start point.
  1809. * \param y1 the y coordinate of the start point.
  1810. * \param x2 the x coordinate of the end point.
  1811. * \param y2 the y coordinate of the end point.
  1812. * \returns true on success or false on failure; call SDL_GetError() for more
  1813. * information.
  1814. *
  1815. * \threadsafety You may only call this function from the main thread.
  1816. *
  1817. * \since This function is available since SDL 3.0.0.
  1818. *
  1819. * \sa SDL_RenderLines
  1820. */
  1821. extern SDL_DECLSPEC bool SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
  1822. /**
  1823. * Draw a series of connected lines on the current rendering target at
  1824. * subpixel precision.
  1825. *
  1826. * \param renderer the renderer which should draw multiple lines.
  1827. * \param points the points along the lines.
  1828. * \param count the number of points, drawing count-1 lines.
  1829. * \returns true on success or false on failure; call SDL_GetError() for more
  1830. * information.
  1831. *
  1832. * \threadsafety You may only call this function from the main thread.
  1833. *
  1834. * \since This function is available since SDL 3.0.0.
  1835. *
  1836. * \sa SDL_RenderLine
  1837. */
  1838. extern SDL_DECLSPEC bool SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1839. /**
  1840. * Draw a rectangle on the current rendering target at subpixel precision.
  1841. *
  1842. * \param renderer the renderer which should draw a rectangle.
  1843. * \param rect a pointer to the destination rectangle, or NULL to outline the
  1844. * entire rendering target.
  1845. * \returns true on success or false on failure; call SDL_GetError() for more
  1846. * information.
  1847. *
  1848. * \threadsafety You may only call this function from the main thread.
  1849. *
  1850. * \since This function is available since SDL 3.0.0.
  1851. *
  1852. * \sa SDL_RenderRects
  1853. */
  1854. extern SDL_DECLSPEC bool SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1855. /**
  1856. * Draw some number of rectangles on the current rendering target at subpixel
  1857. * precision.
  1858. *
  1859. * \param renderer the renderer which should draw multiple rectangles.
  1860. * \param rects a pointer to an array of destination rectangles.
  1861. * \param count the number of rectangles.
  1862. * \returns true on success or false on failure; call SDL_GetError() for more
  1863. * information.
  1864. *
  1865. * \threadsafety You may only call this function from the main thread.
  1866. *
  1867. * \since This function is available since SDL 3.0.0.
  1868. *
  1869. * \sa SDL_RenderRect
  1870. */
  1871. extern SDL_DECLSPEC bool SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1872. /**
  1873. * Fill a rectangle on the current rendering target with the drawing color at
  1874. * subpixel precision.
  1875. *
  1876. * \param renderer the renderer which should fill a rectangle.
  1877. * \param rect a pointer to the destination rectangle, or NULL for the entire
  1878. * rendering target.
  1879. * \returns true on success or false on failure; call SDL_GetError() for more
  1880. * information.
  1881. *
  1882. * \threadsafety You may only call this function from the main thread.
  1883. *
  1884. * \since This function is available since SDL 3.0.0.
  1885. *
  1886. * \sa SDL_RenderFillRects
  1887. */
  1888. extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1889. /**
  1890. * Fill some number of rectangles on the current rendering target with the
  1891. * drawing color at subpixel precision.
  1892. *
  1893. * \param renderer the renderer which should fill multiple rectangles.
  1894. * \param rects a pointer to an array of destination rectangles.
  1895. * \param count the number of rectangles.
  1896. * \returns true on success or false on failure; call SDL_GetError() for more
  1897. * information.
  1898. *
  1899. * \threadsafety You may only call this function from the main thread.
  1900. *
  1901. * \since This function is available since SDL 3.0.0.
  1902. *
  1903. * \sa SDL_RenderFillRect
  1904. */
  1905. extern SDL_DECLSPEC bool SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1906. /**
  1907. * Copy a portion of the texture to the current rendering target at subpixel
  1908. * precision.
  1909. *
  1910. * \param renderer the renderer which should copy parts of a texture.
  1911. * \param texture the source texture.
  1912. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  1913. * texture.
  1914. * \param dstrect a pointer to the destination rectangle, or NULL for the
  1915. * entire rendering target.
  1916. * \returns true on success or false on failure; call SDL_GetError() for more
  1917. * information.
  1918. *
  1919. * \threadsafety You may only call this function from the main thread.
  1920. *
  1921. * \since This function is available since SDL 3.0.0.
  1922. *
  1923. * \sa SDL_RenderTextureRotated
  1924. * \sa SDL_RenderTextureTiled
  1925. */
  1926. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);
  1927. /**
  1928. * Copy a portion of the source texture to the current rendering target, with
  1929. * rotation and flipping, at subpixel precision.
  1930. *
  1931. * \param renderer the renderer which should copy parts of a texture.
  1932. * \param texture the source texture.
  1933. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  1934. * texture.
  1935. * \param dstrect a pointer to the destination rectangle, or NULL for the
  1936. * entire rendering target.
  1937. * \param angle an angle in degrees that indicates the rotation that will be
  1938. * applied to dstrect, rotating it in a clockwise direction.
  1939. * \param center a pointer to a point indicating the point around which
  1940. * dstrect will be rotated (if NULL, rotation will be done
  1941. * around dstrect.w/2, dstrect.h/2).
  1942. * \param flip an SDL_FlipMode value stating which flipping actions should be
  1943. * performed on the texture.
  1944. * \returns true on success or false on failure; call SDL_GetError() for more
  1945. * information.
  1946. *
  1947. * \threadsafety You may only call this function from the main thread.
  1948. *
  1949. * \since This function is available since SDL 3.0.0.
  1950. *
  1951. * \sa SDL_RenderTexture
  1952. */
  1953. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
  1954. const SDL_FRect *srcrect, const SDL_FRect *dstrect,
  1955. const double angle, const SDL_FPoint *center,
  1956. const SDL_FlipMode flip);
  1957. /**
  1958. * Tile a portion of the texture to the current rendering target at subpixel
  1959. * precision.
  1960. *
  1961. * The pixels in `srcrect` will be repeated as many times as needed to
  1962. * completely fill `dstrect`.
  1963. *
  1964. * \param renderer the renderer which should copy parts of a texture.
  1965. * \param texture the source texture.
  1966. * \param srcrect a pointer to the source rectangle, or NULL for the entire
  1967. * texture.
  1968. * \param scale the scale used to transform srcrect into the destination
  1969. * rectangle, e.g. a 32x32 texture with a scale of 2 would fill
  1970. * 64x64 tiles.
  1971. * \param dstrect a pointer to the destination rectangle, or NULL for the
  1972. * entire rendering target.
  1973. * \returns true on success or false on failure; call SDL_GetError() for more
  1974. * information.
  1975. *
  1976. * \threadsafety You may only call this function from the main thread.
  1977. *
  1978. * \since This function is available since SDL 3.0.0.
  1979. *
  1980. * \sa SDL_RenderTexture
  1981. */
  1982. extern SDL_DECLSPEC bool SDLCALL SDL_RenderTextureTiled(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, float scale, const SDL_FRect *dstrect);
  1983. /**
  1984. * Perform a scaled copy using the 9-grid algorithm to the current rendering
  1985. * target at subpixel precision.
  1986. *
  1987. * The pixels in the texture are split into a 3x3 grid, using the different
  1988. * corner sizes for each corner, and the sides and center making up the
  1989. * remaining pixels. The corners are then scaled using `scale` and fit into
  1990. * the corners of the destination rectangle. The sides and center are then
  1991. * stretched into place to cover the remaining destination rectangle.
  1992. *
  1993. * \param renderer the renderer which should copy parts of a texture.
  1994. * \param texture the source texture.
  1995. * \param srcrect the SDL_Rect structure representing the rectangle to be used
  1996. * for the 9-grid, or NULL to use the entire texture.
  1997. * \param left_width the width, in pixels, of the left corners in `srcrect`.
  1998. * \param right_width the width, in pixels, of the right corners in `srcrect`.
  1999. * \param top_height the height, in pixels, of the top corners in `srcrect`.
  2000. * \param bottom_height the height, in pixels, of the bottom corners in
  2001. * `srcrect`.
  2002. * \param scale the scale used to transform the corner of `srcrect` into the
  2003. * corner of `dstrect`, or 0.0f for an unscaled copy.
  2004. * \param dstrect a pointer to the destination rectangle, or NULL for the
  2005. * entire rendering target.
  2006. * \returns true on success or false on failure; call SDL_GetError() for more
  2007. * information.
  2008. *
  2009. * \threadsafety You may only call this function from the main thread.
  2010. *
  2011. * \since This function is available since SDL 3.0.0.
  2012. *
  2013. * \sa SDL_RenderTexture
  2014. */
  2015. 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);
  2016. /**
  2017. * Render a list of triangles, optionally using a texture and indices into the
  2018. * vertex array Color and alpha modulation is done per vertex
  2019. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  2020. *
  2021. * \param renderer the rendering context.
  2022. * \param texture (optional) The SDL texture to use.
  2023. * \param vertices vertices.
  2024. * \param num_vertices number of vertices.
  2025. * \param indices (optional) An array of integer indices into the 'vertices'
  2026. * array, if NULL all vertices will be rendered in sequential
  2027. * order.
  2028. * \param num_indices number of indices.
  2029. * \returns true on success or false on failure; call SDL_GetError() for more
  2030. * information.
  2031. *
  2032. * \threadsafety You may only call this function from the main thread.
  2033. *
  2034. * \since This function is available since SDL 3.0.0.
  2035. *
  2036. * \sa SDL_RenderGeometryRaw
  2037. */
  2038. extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  2039. SDL_Texture *texture,
  2040. const SDL_Vertex *vertices, int num_vertices,
  2041. const int *indices, int num_indices);
  2042. /**
  2043. * Render a list of triangles, optionally using a texture and indices into the
  2044. * vertex arrays Color and alpha modulation is done per vertex
  2045. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  2046. *
  2047. * \param renderer the rendering context.
  2048. * \param texture (optional) The SDL texture to use.
  2049. * \param xy vertex positions.
  2050. * \param xy_stride byte size to move from one element to the next element.
  2051. * \param color vertex colors (as SDL_FColor).
  2052. * \param color_stride byte size to move from one element to the next element.
  2053. * \param uv vertex normalized texture coordinates.
  2054. * \param uv_stride byte size to move from one element to the next element.
  2055. * \param num_vertices number of vertices.
  2056. * \param indices (optional) An array of indices into the 'vertices' arrays,
  2057. * if NULL all vertices will be rendered in sequential order.
  2058. * \param num_indices number of indices.
  2059. * \param size_indices index size: 1 (byte), 2 (short), 4 (int).
  2060. * \returns true on success or false on failure; call SDL_GetError() for more
  2061. * information.
  2062. *
  2063. * \threadsafety You may only call this function from the main thread.
  2064. *
  2065. * \since This function is available since SDL 3.0.0.
  2066. *
  2067. * \sa SDL_RenderGeometry
  2068. */
  2069. extern SDL_DECLSPEC bool SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  2070. SDL_Texture *texture,
  2071. const float *xy, int xy_stride,
  2072. const SDL_FColor *color, int color_stride,
  2073. const float *uv, int uv_stride,
  2074. int num_vertices,
  2075. const void *indices, int num_indices, int size_indices);
  2076. /**
  2077. * Read pixels from the current rendering target.
  2078. *
  2079. * The returned surface should be freed with SDL_DestroySurface()
  2080. *
  2081. * **WARNING**: This is a very slow operation, and should not be used
  2082. * frequently. If you're using this on the main rendering target, it should be
  2083. * called after rendering and before SDL_RenderPresent().
  2084. *
  2085. * \param renderer the rendering context.
  2086. * \param rect an SDL_Rect structure representing the area in pixels relative
  2087. * to the to current viewport, or NULL for the entire viewport.
  2088. * \returns a new SDL_Surface on success or NULL on failure; call
  2089. * SDL_GetError() for more information.
  2090. *
  2091. * \threadsafety You may only call this function from the main thread.
  2092. *
  2093. * \since This function is available since SDL 3.0.0.
  2094. */
  2095. extern SDL_DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
  2096. /**
  2097. * Update the screen with any rendering performed since the previous call.
  2098. *
  2099. * SDL's rendering functions operate on a backbuffer; that is, calling a
  2100. * rendering function such as SDL_RenderLine() does not directly put a line on
  2101. * the screen, but rather updates the backbuffer. As such, you compose your
  2102. * entire scene and *present* the composed backbuffer to the screen as a
  2103. * complete picture.
  2104. *
  2105. * Therefore, when using SDL's rendering API, one does all drawing intended
  2106. * for the frame, and then calls this function once per frame to present the
  2107. * final drawing to the user.
  2108. *
  2109. * The backbuffer should be considered invalidated after each present; do not
  2110. * assume that previous contents will exist between frames. You are strongly
  2111. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  2112. * starting each new frame's drawing, even if you plan to overwrite every
  2113. * pixel.
  2114. *
  2115. * Please note, that in case of rendering to a texture - there is **no need**
  2116. * to call `SDL_RenderPresent` after drawing needed objects to a texture, and
  2117. * should not be done; you are only required to change back the rendering
  2118. * target to default via `SDL_SetRenderTarget(renderer, NULL)` afterwards, as
  2119. * textures by themselves do not have a concept of backbuffers. Calling
  2120. * SDL_RenderPresent while rendering to a texture will still update the screen
  2121. * with any current drawing that has been done _to the window itself_.
  2122. *
  2123. * \param renderer the rendering context.
  2124. * \returns true on success or false on failure; call SDL_GetError() for more
  2125. * information.
  2126. *
  2127. * \threadsafety You may only call this function from the main thread.
  2128. *
  2129. * \since This function is available since SDL 3.0.0.
  2130. *
  2131. * \sa SDL_CreateRenderer
  2132. * \sa SDL_RenderClear
  2133. * \sa SDL_RenderFillRect
  2134. * \sa SDL_RenderFillRects
  2135. * \sa SDL_RenderLine
  2136. * \sa SDL_RenderLines
  2137. * \sa SDL_RenderPoint
  2138. * \sa SDL_RenderPoints
  2139. * \sa SDL_RenderRect
  2140. * \sa SDL_RenderRects
  2141. * \sa SDL_SetRenderDrawBlendMode
  2142. * \sa SDL_SetRenderDrawColor
  2143. */
  2144. extern SDL_DECLSPEC bool SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
  2145. /**
  2146. * Destroy the specified texture.
  2147. *
  2148. * Passing NULL or an otherwise invalid texture will set the SDL error message
  2149. * to "Invalid texture".
  2150. *
  2151. * \param texture the texture to destroy.
  2152. *
  2153. * \threadsafety You may only call this function from the main thread.
  2154. *
  2155. * \since This function is available since SDL 3.0.0.
  2156. *
  2157. * \sa SDL_CreateTexture
  2158. * \sa SDL_CreateTextureFromSurface
  2159. */
  2160. extern SDL_DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
  2161. /**
  2162. * Destroy the rendering context for a window and free all associated
  2163. * textures.
  2164. *
  2165. * This should be called before destroying the associated window.
  2166. *
  2167. * \param renderer the rendering context.
  2168. *
  2169. * \threadsafety You may only call this function from the main thread.
  2170. *
  2171. * \since This function is available since SDL 3.0.0.
  2172. *
  2173. * \sa SDL_CreateRenderer
  2174. */
  2175. extern SDL_DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
  2176. /**
  2177. * Force the rendering context to flush any pending commands and state.
  2178. *
  2179. * You do not need to (and in fact, shouldn't) call this function unless you
  2180. * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
  2181. * addition to using an SDL_Renderer.
  2182. *
  2183. * This is for a very-specific case: if you are using SDL's render API, and
  2184. * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
  2185. * calls. If this applies, you should call this function between calls to
  2186. * SDL's render API and the low-level API you're using in cooperation.
  2187. *
  2188. * In all other cases, you can ignore this function.
  2189. *
  2190. * This call makes SDL flush any pending rendering work it was queueing up to
  2191. * do later in a single batch, and marks any internal cached state as invalid,
  2192. * so it'll prepare all its state again later, from scratch.
  2193. *
  2194. * This means you do not need to save state in your rendering code to protect
  2195. * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
  2196. * OpenGL state that can confuse things; you should use your best judgment and
  2197. * be prepared to make changes if specific state needs to be protected.
  2198. *
  2199. * \param renderer the rendering context.
  2200. * \returns true on success or false on failure; call SDL_GetError() for more
  2201. * information.
  2202. *
  2203. * \threadsafety You may only call this function from the main thread.
  2204. *
  2205. * \since This function is available since SDL 3.0.0.
  2206. */
  2207. extern SDL_DECLSPEC bool SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
  2208. /**
  2209. * Get the CAMetalLayer associated with the given Metal renderer.
  2210. *
  2211. * This function returns `void *`, so SDL doesn't have to include Metal's
  2212. * headers, but it can be safely cast to a `CAMetalLayer *`.
  2213. *
  2214. * \param renderer the renderer to query.
  2215. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  2216. * Metal renderer.
  2217. *
  2218. * \threadsafety You may only call this function from the main thread.
  2219. *
  2220. * \since This function is available since SDL 3.0.0.
  2221. *
  2222. * \sa SDL_GetRenderMetalCommandEncoder
  2223. */
  2224. extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);
  2225. /**
  2226. * Get the Metal command encoder for the current frame.
  2227. *
  2228. * This function returns `void *`, so SDL doesn't have to include Metal's
  2229. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  2230. *
  2231. * This will return NULL if Metal refuses to give SDL a drawable to render to,
  2232. * which might happen if the window is hidden/minimized/offscreen. This
  2233. * doesn't apply to command encoders for render targets, just the window's
  2234. * backbuffer. Check your return values!
  2235. *
  2236. * \param renderer the renderer to query.
  2237. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  2238. * renderer isn't a Metal renderer or there was an error.
  2239. *
  2240. * \threadsafety You may only call this function from the main thread.
  2241. *
  2242. * \since This function is available since SDL 3.0.0.
  2243. *
  2244. * \sa SDL_GetRenderMetalLayer
  2245. */
  2246. extern SDL_DECLSPEC void * SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);
  2247. /**
  2248. * Add a set of synchronization semaphores for the current frame.
  2249. *
  2250. * The Vulkan renderer will wait for `wait_semaphore` before submitting
  2251. * rendering commands and signal `signal_semaphore` after rendering commands
  2252. * are complete for this frame.
  2253. *
  2254. * This should be called each frame that you want semaphore synchronization.
  2255. * The Vulkan renderer may have multiple frames in flight on the GPU, so you
  2256. * should have multiple semaphores that are used for synchronization. Querying
  2257. * SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the
  2258. * maximum number of semaphores you'll need.
  2259. *
  2260. * \param renderer the rendering context.
  2261. * \param wait_stage_mask the VkPipelineStageFlags for the wait.
  2262. * \param wait_semaphore a VkSempahore to wait on before rendering the current
  2263. * frame, or 0 if not needed.
  2264. * \param signal_semaphore a VkSempahore that SDL will signal when rendering
  2265. * for the current frame is complete, or 0 if not
  2266. * needed.
  2267. * \returns true on success or false on failure; call SDL_GetError() for more
  2268. * information.
  2269. *
  2270. * \threadsafety It is **NOT** safe to call this function from two threads at
  2271. * once.
  2272. *
  2273. * \since This function is available since SDL 3.0.0.
  2274. */
  2275. extern SDL_DECLSPEC bool SDLCALL SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);
  2276. /**
  2277. * Toggle VSync of the given renderer.
  2278. *
  2279. * When a renderer is created, vsync defaults to SDL_RENDERER_VSYNC_DISABLED.
  2280. *
  2281. * The `vsync` parameter can be 1 to synchronize present with every vertical
  2282. * refresh, 2 to synchronize present with every second vertical refresh, etc.,
  2283. * SDL_WINDOW_SURFACE_VSYNC_ADAPTIVE for late swap tearing (adaptive vsync),
  2284. * or SDL_WINDOW_SURFACE_VSYNC_DISABLED to disable. Not every value is
  2285. * supported by every driver, so you should check the return value to see
  2286. * whether the requested setting is supported.
  2287. *
  2288. * \param renderer the renderer to toggle.
  2289. * \param vsync the vertical refresh sync interval.
  2290. * \returns true on success or false on failure; call SDL_GetError() for more
  2291. * information.
  2292. *
  2293. * \threadsafety You may only call this function from the main thread.
  2294. *
  2295. * \since This function is available since SDL 3.0.0.
  2296. *
  2297. * \sa SDL_GetRenderVSync
  2298. */
  2299. extern SDL_DECLSPEC bool SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
  2300. #define SDL_RENDERER_VSYNC_DISABLED 0
  2301. #define SDL_RENDERER_VSYNC_ADAPTIVE (-1)
  2302. /**
  2303. * Get VSync of the given renderer.
  2304. *
  2305. * \param renderer the renderer to toggle.
  2306. * \param vsync an int filled with the current vertical refresh sync interval.
  2307. * See SDL_SetRenderVSync() for the meaning of the value.
  2308. * \returns true on success or false on failure; call SDL_GetError() for more
  2309. * information.
  2310. *
  2311. * \threadsafety You may only call this function from the main thread.
  2312. *
  2313. * \since This function is available since SDL 3.0.0.
  2314. *
  2315. * \sa SDL_SetRenderVSync
  2316. */
  2317. extern SDL_DECLSPEC bool SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);
  2318. /* Ends C function definitions when using C++ */
  2319. #ifdef __cplusplus
  2320. }
  2321. #endif
  2322. #include <SDL3/SDL_close_code.h>
  2323. #endif /* SDL_render_h_ */