SDL_render.h 79 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  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. * \file SDL_render.h
  20. *
  21. * Header file for SDL 2D rendering functions.
  22. *
  23. * This API supports the following features:
  24. * * single pixel points
  25. * * single pixel lines
  26. * * filled rectangles
  27. * * texture images
  28. *
  29. * The primitives may be drawn in opaque, blended, or additive modes.
  30. *
  31. * The texture images may be drawn in opaque, blended, or additive modes.
  32. * They can have an additional color tint or alpha modulation applied to
  33. * them, and may also be stretched with linear interpolation.
  34. *
  35. * This API is designed to accelerate simple 2D operations. You may
  36. * want more functionality such as polygons and particle effects and
  37. * in that case you should use SDL's OpenGL/Direct3D support or one
  38. * of the many good 3D engines.
  39. *
  40. * These functions must be called from the main thread.
  41. * See this bug for details: https://github.com/libsdl-org/SDL/issues/986
  42. */
  43. #ifndef SDL_render_h_
  44. #define SDL_render_h_
  45. #include <SDL3/SDL_stdinc.h>
  46. #include <SDL3/SDL_events.h>
  47. #include <SDL3/SDL_properties.h>
  48. #include <SDL3/SDL_rect.h>
  49. #include <SDL3/SDL_video.h>
  50. #include <SDL3/SDL_begin_code.h>
  51. /* Set up for C function definitions, even when using C++ */
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /**
  56. * Flags used when creating a rendering context
  57. */
  58. typedef enum
  59. {
  60. SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */
  61. SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware
  62. acceleration */
  63. SDL_RENDERER_PRESENTVSYNC = 0x00000004 /**< Present is synchronized
  64. with the refresh rate */
  65. } SDL_RendererFlags;
  66. /**
  67. * Information on the capabilities of a render driver or context.
  68. */
  69. typedef struct SDL_RendererInfo
  70. {
  71. const char *name; /**< The name of the renderer */
  72. Uint32 flags; /**< Supported ::SDL_RendererFlags */
  73. Uint32 num_texture_formats; /**< The number of available texture formats */
  74. Uint32 texture_formats[16]; /**< The available texture formats */
  75. int max_texture_width; /**< The maximum texture width */
  76. int max_texture_height; /**< The maximum texture height */
  77. } SDL_RendererInfo;
  78. /**
  79. * Vertex structure
  80. */
  81. typedef struct SDL_Vertex
  82. {
  83. SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */
  84. SDL_FColor color; /**< Vertex color */
  85. SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
  86. } SDL_Vertex;
  87. /**
  88. * The access pattern allowed for a texture.
  89. */
  90. typedef enum
  91. {
  92. SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
  93. SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
  94. SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
  95. } SDL_TextureAccess;
  96. /**
  97. * How the logical size is mapped to the output
  98. */
  99. typedef enum
  100. {
  101. SDL_LOGICAL_PRESENTATION_DISABLED, /**< There is no logical size in effect */
  102. SDL_LOGICAL_PRESENTATION_STRETCH, /**< The rendered content is stretched to the output resolution */
  103. SDL_LOGICAL_PRESENTATION_LETTERBOX, /**< The rendered content is fit to the largest dimension and the other dimension is letterboxed with black bars */
  104. SDL_LOGICAL_PRESENTATION_OVERSCAN, /**< The rendered content is fit to the smallest dimension and the other dimension extends beyond the output bounds */
  105. SDL_LOGICAL_PRESENTATION_INTEGER_SCALE /**< The rendered content is scaled up by integer multiples to fit the output resolution */
  106. } SDL_RendererLogicalPresentation;
  107. /**
  108. * A structure representing rendering state
  109. */
  110. struct SDL_Renderer;
  111. typedef struct SDL_Renderer SDL_Renderer;
  112. /**
  113. * An efficient driver-specific representation of pixel data
  114. */
  115. struct SDL_Texture;
  116. typedef struct SDL_Texture SDL_Texture;
  117. /* Function prototypes */
  118. /**
  119. * Get the number of 2D rendering drivers available for the current display.
  120. *
  121. * A render driver is a set of code that handles rendering and texture
  122. * management on a particular display. Normally there is only one, but some
  123. * drivers may have several available with different capabilities.
  124. *
  125. * There may be none if SDL was compiled without render support.
  126. *
  127. * \returns a number >= 0 on success or a negative error code on failure; call
  128. * SDL_GetError() for more information.
  129. *
  130. * \since This function is available since SDL 3.0.0.
  131. *
  132. * \sa SDL_CreateRenderer
  133. * \sa SDL_GetRenderDriver
  134. */
  135. extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
  136. /**
  137. * Use this function to get the name of a built in 2D rendering driver.
  138. *
  139. * The list of rendering drivers is given in the order that they are normally
  140. * initialized by default; the drivers that seem more reasonable to choose
  141. * first (as far as the SDL developers believe) are earlier in the list.
  142. *
  143. * The names of drivers are all simple, low-ASCII identifiers, like "opengl",
  144. * "direct3d12" or "metal". These never have Unicode characters, and are not
  145. * meant to be proper names.
  146. *
  147. * The returned value points to a static, read-only string; do not modify or
  148. * free it!
  149. *
  150. * \param index the index of the rendering driver; the value ranges from 0 to
  151. * SDL_GetNumRenderDrivers() - 1
  152. * \returns the name of the rendering driver at the requested index, or NULL
  153. * if an invalid index was specified.
  154. *
  155. * \since This function is available since SDL 3.0.0.
  156. *
  157. * \sa SDL_GetNumRenderDrivers
  158. */
  159. extern DECLSPEC const char *SDLCALL SDL_GetRenderDriver(int index);
  160. /**
  161. * Create a window and default renderer.
  162. *
  163. * \param width the width of the window
  164. * \param height the height of the window
  165. * \param window_flags the flags used to create the window (see
  166. * SDL_CreateWindow())
  167. * \param window a pointer filled with the window, or NULL on error
  168. * \param renderer a pointer filled with the renderer, or NULL on error
  169. * \returns 0 on success or a negative error code on failure; call
  170. * SDL_GetError() for more information.
  171. *
  172. * \since This function is available since SDL 3.0.0.
  173. *
  174. * \sa SDL_CreateRenderer
  175. * \sa SDL_CreateWindow
  176. */
  177. extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(int width, int height, Uint32 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. * If you pass SDL_RENDERER_SOFTWARE in the flags, you will get a software
  188. * renderer, otherwise you will get a hardware accelerated renderer if
  189. * available.
  190. *
  191. * By default the rendering size matches the window size in pixels, but you
  192. * can call SDL_SetRenderLogicalPresentation() to change the content size and
  193. * scaling options.
  194. *
  195. * \param window the window where rendering is displayed
  196. * \param name the name of the rendering driver to initialize, or NULL to
  197. * initialize the first one supporting the requested flags
  198. * \param flags 0, or one or more SDL_RendererFlags OR'd together
  199. * \returns a valid rendering context or NULL if there was an error; call
  200. * SDL_GetError() for more information.
  201. *
  202. * \since This function is available since SDL 3.0.0.
  203. *
  204. * \sa SDL_CreateRendererWithProperties
  205. * \sa SDL_CreateSoftwareRenderer
  206. * \sa SDL_DestroyRenderer
  207. * \sa SDL_GetNumRenderDrivers
  208. * \sa SDL_GetRenderDriver
  209. * \sa SDL_GetRendererInfo
  210. */
  211. extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 flags);
  212. /**
  213. * Create a 2D rendering context for a window, with the specified properties.
  214. *
  215. * These are the supported properties:
  216. *
  217. * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver
  218. * to use, if a specific one is desired
  219. * - `SDL_PROP_RENDERER_CREATE_WINDOW_POINTER`: the window where rendering is
  220. * displayed, required if this isn't a software renderer using a surface
  221. * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering
  222. * is displayed, if you want a software renderer without a window
  223. * - `SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace
  224. * value describing the colorspace for output to the display, defaults to
  225. * SDL_COLORSPACE_SRGB. The direct3d11 and direct3d12 renderers support
  226. * SDL_COLORSPACE_SCRGB, which is a linear color space and supports HDR
  227. * output. If you select SDL_COLORSPACE_SCRGB, drawing still uses the sRGB
  228. * colorspace, but values can go beyond 1.0 and float (linear) format
  229. * textures can be used for HDR content.
  230. * - `SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN`: true if you want
  231. * present synchronized with the refresh rate
  232. *
  233. * \param props the properties to use
  234. * \returns a valid rendering context or NULL if there was an error; call
  235. * SDL_GetError() for more information.
  236. *
  237. * \since This function is available since SDL 3.0.0.
  238. *
  239. * \sa SDL_CreateRenderer
  240. * \sa SDL_CreateSoftwareRenderer
  241. * \sa SDL_DestroyRenderer
  242. * \sa SDL_GetRendererInfo
  243. */
  244. extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRendererWithProperties(SDL_PropertiesID props);
  245. #define SDL_PROP_RENDERER_CREATE_NAME_STRING "name"
  246. #define SDL_PROP_RENDERER_CREATE_WINDOW_POINTER "window"
  247. #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "surface"
  248. #define SDL_PROP_RENDERER_CREATE_OUTPUT_COLORSPACE_NUMBER "output_colorspace"
  249. #define SDL_PROP_RENDERER_CREATE_PRESENT_VSYNC_BOOLEAN "present_vsync"
  250. /**
  251. * Create a 2D software rendering context for a surface.
  252. *
  253. * Two other API which can be used to create SDL_Renderer:
  254. * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_
  255. * create a software renderer, but they are intended to be used with an
  256. * SDL_Window as the final destination and not an SDL_Surface.
  257. *
  258. * \param surface the SDL_Surface structure representing the surface where
  259. * rendering is done
  260. * \returns a valid rendering context or NULL if there was an error; call
  261. * SDL_GetError() for more information.
  262. *
  263. * \since This function is available since SDL 3.0.0.
  264. *
  265. * \sa SDL_CreateRenderer
  266. * \sa SDL_CreateWindowRenderer
  267. * \sa SDL_DestroyRenderer
  268. */
  269. extern DECLSPEC SDL_Renderer *SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface *surface);
  270. /**
  271. * Get the renderer associated with a window.
  272. *
  273. * \param window the window to query
  274. * \returns the rendering context on success or NULL on failure; call
  275. * SDL_GetError() for more information.
  276. *
  277. * \since This function is available since SDL 3.0.0.
  278. *
  279. * \sa SDL_CreateRenderer
  280. */
  281. extern DECLSPEC SDL_Renderer *SDLCALL SDL_GetRenderer(SDL_Window *window);
  282. /**
  283. * Get the window associated with a renderer.
  284. *
  285. * \param renderer the renderer to query
  286. * \returns the window on success or NULL on failure; call SDL_GetError() for
  287. * more information.
  288. *
  289. * \since This function is available since SDL 3.0.0.
  290. */
  291. extern DECLSPEC SDL_Window *SDLCALL SDL_GetRenderWindow(SDL_Renderer *renderer);
  292. /**
  293. * Get information about a rendering context.
  294. *
  295. * \param renderer the rendering context
  296. * \param info an SDL_RendererInfo structure filled with information about the
  297. * current renderer
  298. * \returns 0 on success or a negative error code on failure; call
  299. * SDL_GetError() for more information.
  300. *
  301. * \since This function is available since SDL 3.0.0.
  302. *
  303. * \sa SDL_CreateRenderer
  304. */
  305. extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer *renderer, SDL_RendererInfo *info);
  306. /**
  307. * Get the properties associated with a renderer.
  308. *
  309. * The following read-only properties are provided by SDL:
  310. *
  311. * - `SDL_PROP_RENDERER_NAME_STRING`: the name of the rendering driver
  312. * - `SDL_PROP_RENDERER_WINDOW_POINTER`: the window where rendering is
  313. * displayed, if any
  314. * - `SDL_PROP_RENDERER_SURFACE_POINTER`: the surface where rendering is
  315. * displayed, if this is a software renderer without a window
  316. * - `SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER`: an SDL_ColorSpace value
  317. * describing the colorspace for output to the display, defaults to
  318. * SDL_COLORSPACE_SRGB.
  319. * - `SDL_PROP_RENDERER_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated
  320. * with the renderer
  321. * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated
  322. * with the renderer
  323. * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated
  324. * with the renderer
  325. * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue
  326. * associated with the renderer
  327. *
  328. * \param renderer the rendering context
  329. * \returns a valid property ID on success or 0 on failure; call
  330. * SDL_GetError() for more information.
  331. *
  332. * \since This function is available since SDL 3.0.0.
  333. *
  334. * \sa SDL_GetProperty
  335. * \sa SDL_SetProperty
  336. */
  337. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer);
  338. #define SDL_PROP_RENDERER_NAME_STRING "SDL.renderer.name"
  339. #define SDL_PROP_RENDERER_WINDOW_POINTER "SDL.renderer.window"
  340. #define SDL_PROP_RENDERER_SURFACE_POINTER "SDL.renderer.surface"
  341. #define SDL_PROP_RENDERER_OUTPUT_COLORSPACE_NUMBER "SDL.renderer.output_colorspace"
  342. #define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device"
  343. #define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device"
  344. #define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device"
  345. #define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue"
  346. /**
  347. * Get the output size in pixels of a rendering context.
  348. *
  349. * This returns the true output size in pixels, ignoring any render targets or
  350. * logical size and presentation.
  351. *
  352. * \param renderer the rendering context
  353. * \param w a pointer filled in with the width in pixels
  354. * \param h a pointer filled in with the height in pixels
  355. * \returns 0 on success or a negative error code on failure; call
  356. * SDL_GetError() for more information.
  357. *
  358. * \since This function is available since SDL 3.0.0.
  359. *
  360. * \sa SDL_GetRenderer
  361. */
  362. extern DECLSPEC int SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  363. /**
  364. * Get the current output size in pixels of a rendering context.
  365. *
  366. * If a rendering target is active, this will return the size of the rendering
  367. * target in pixels, otherwise if a logical size is set, it will return the
  368. * logical size, otherwise it will return the value of
  369. * SDL_GetRenderOutputSize().
  370. *
  371. * \param renderer the rendering context
  372. * \param w a pointer filled in with the current width
  373. * \param h a pointer filled in with the current height
  374. * \returns 0 on success or a negative error code on failure; call
  375. * SDL_GetError() for more information.
  376. *
  377. * \since This function is available since SDL 3.0.0.
  378. *
  379. * \sa SDL_GetRenderOutputSize
  380. * \sa SDL_GetRenderer
  381. */
  382. extern DECLSPEC int SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  383. /**
  384. * Create a texture for a rendering context.
  385. *
  386. * You can set the texture scaling method by setting
  387. * `SDL_HINT_RENDER_SCALE_QUALITY` before creating the texture.
  388. *
  389. * \param renderer the rendering context
  390. * \param format one of the enumerated values in SDL_PixelFormatEnum
  391. * \param access one of the enumerated values in SDL_TextureAccess
  392. * \param w the width of the texture in pixels
  393. * \param h the height of the texture in pixels
  394. * \returns a pointer to the created texture or NULL if no rendering context
  395. * was active, the format was unsupported, or the width or height
  396. * were out of range; call SDL_GetError() for more information.
  397. *
  398. * \since This function is available since SDL 3.0.0.
  399. *
  400. * \sa SDL_CreateTextureFromSurface
  401. * \sa SDL_CreateTextureWithProperties
  402. * \sa SDL_DestroyTexture
  403. * \sa SDL_QueryTexture
  404. * \sa SDL_UpdateTexture
  405. */
  406. extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h);
  407. /**
  408. * Create a texture from an existing surface.
  409. *
  410. * The surface is not modified or freed by this function.
  411. *
  412. * The SDL_TextureAccess hint for the created texture is
  413. * `SDL_TEXTUREACCESS_STATIC`.
  414. *
  415. * The pixel format of the created texture may be different from the pixel
  416. * format of the surface. Use SDL_QueryTexture() to query the pixel format of
  417. * the texture.
  418. *
  419. * \param renderer the rendering context
  420. * \param surface the SDL_Surface structure containing pixel data used to fill
  421. * the texture
  422. * \returns the created texture or NULL on failure; call SDL_GetError() for
  423. * more information.
  424. *
  425. * \since This function is available since SDL 3.0.0.
  426. *
  427. * \sa SDL_CreateTexture
  428. * \sa SDL_CreateTextureWithProperties
  429. * \sa SDL_DestroyTexture
  430. * \sa SDL_QueryTexture
  431. */
  432. extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
  433. /**
  434. * Create a texture for a rendering context with the specified properties.
  435. *
  436. * These are the supported properties:
  437. *
  438. * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_ColorSpace value
  439. * describing the texture colorspace, defaults to SDL_COLORSPACE_SCRGB for
  440. * floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures,
  441. * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for
  442. * YUV textures.
  443. * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in
  444. * SDL_PixelFormatEnum, defaults to the best RGBA format for the renderer
  445. * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in
  446. * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC
  447. * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in
  448. * pixels, required
  449. * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in
  450. * pixels, required
  451. *
  452. * With the direct3d11 renderer:
  453. *
  454. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D
  455. * associated with the texture, if you want to wrap an existing texture.
  456. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  457. * associated with the U plane of a YUV texture, if you want to wrap an
  458. * existing texture.
  459. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  460. * associated with the V plane of a YUV texture, if you want to wrap an
  461. * existing texture.
  462. *
  463. * With the direct3d12 renderer:
  464. *
  465. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource
  466. * associated with the texture, if you want to wrap an existing texture.
  467. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource
  468. * associated with the U plane of a YUV texture, if you want to wrap an
  469. * existing texture.
  470. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource
  471. * associated with the V plane of a YUV texture, if you want to wrap an
  472. * existing texture.
  473. *
  474. * With the metal renderer:
  475. *
  476. * - `SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER`: the CVPixelBufferRef
  477. * associated with the texture, if you want to create a texture from an
  478. * existing pixel buffer.
  479. *
  480. * With the opengl renderer:
  481. *
  482. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture
  483. * associated with the texture, if you want to wrap an existing texture.
  484. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  485. * associated with the UV plane of an NV12 texture, if you want to wrap an
  486. * existing texture.
  487. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture
  488. * associated with the U plane of a YUV texture, if you want to wrap an
  489. * existing texture.
  490. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture
  491. * associated with the V plane of a YUV texture, if you want to wrap an
  492. * existing texture.
  493. *
  494. * With the opengles2 renderer:
  495. *
  496. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  497. * associated with the texture, if you want to wrap an existing texture.
  498. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  499. * associated with the texture, if you want to wrap an existing texture.
  500. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  501. * associated with the UV plane of an NV12 texture, if you want to wrap an
  502. * existing texture.
  503. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  504. * associated with the U plane of a YUV texture, if you want to wrap an
  505. * existing texture.
  506. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  507. * associated with the V plane of a YUV texture, if you want to wrap an
  508. * existing texture.
  509. *
  510. * \param renderer the rendering context
  511. * \param props the properties to use
  512. * \returns a pointer to the created texture or NULL if no rendering context
  513. * was active, the format was unsupported, or the width or height
  514. * were out of range; call SDL_GetError() for more information.
  515. *
  516. * \since This function is available since SDL 3.0.0.
  517. *
  518. * \sa SDL_CreateTextureFromSurface
  519. * \sa SDL_CreateTexture
  520. * \sa SDL_DestroyTexture
  521. * \sa SDL_QueryTexture
  522. * \sa SDL_UpdateTexture
  523. */
  524. extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
  525. #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "colorspace"
  526. #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "format"
  527. #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "access"
  528. #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "width"
  529. #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "height"
  530. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "d3d11.texture"
  531. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "d3d11.texture_u"
  532. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "d3d11.texture_v"
  533. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "d3d12.texture"
  534. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "d3d12.texture_u"
  535. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "d3d12.texture_v"
  536. #define SDL_PROP_TEXTURE_CREATE_METAL_PIXELBUFFER_POINTER "metal.pixelbuffer"
  537. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "opengl.texture"
  538. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "opengl.texture_uv"
  539. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "opengl.texture_u"
  540. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "opengl.texture_v"
  541. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "opengles2.texture"
  542. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "opengles2.texture"
  543. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "opengles2.texture_uv"
  544. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "opengles2.texture_u"
  545. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "opengles2.texture_v"
  546. /**
  547. * Get the properties associated with a texture.
  548. *
  549. * The following read-only properties are provided by SDL:
  550. *
  551. * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing
  552. * the colorspace used by the texture
  553. *
  554. * With the direct3d11 renderer:
  555. *
  556. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated
  557. * with the texture
  558. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  559. * associated with the U plane of a YUV texture
  560. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  561. * associated with the V plane of a YUV texture
  562. *
  563. * With the direct3d12 renderer:
  564. *
  565. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated
  566. * with the texture
  567. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated
  568. * with the U plane of a YUV texture
  569. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated
  570. * with the V plane of a YUV texture
  571. *
  572. * With the opengl renderer:
  573. *
  574. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated
  575. * with the texture
  576. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  577. * associated with the UV plane of an NV12 texture
  578. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated
  579. * with the U plane of a YUV texture
  580. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated
  581. * with the V plane of a YUV texture
  582. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET`: the GLenum for the texture
  583. * target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
  584. * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of
  585. * the texture (0.0 - 1.0)
  586. * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of
  587. * the texture (0.0 - 1.0)
  588. *
  589. * With the opengles2 renderer:
  590. *
  591. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  592. * associated with the texture
  593. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  594. * associated with the UV plane of an NV12 texture
  595. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  596. * associated with the U plane of a YUV texture
  597. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  598. * associated with the V plane of a YUV texture
  599. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET`: the GLenum for the texture
  600. * target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
  601. *
  602. * \param texture the texture to query
  603. * \returns a valid property ID on success or 0 on failure; call
  604. * SDL_GetError() for more information.
  605. *
  606. * \since This function is available since SDL 3.0.0.
  607. *
  608. * \sa SDL_GetProperty
  609. * \sa SDL_SetProperty
  610. */
  611. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
  612. #define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"
  613. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"
  614. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"
  615. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"
  616. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"
  617. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"
  618. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"
  619. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"
  620. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"
  621. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"
  622. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"
  623. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET "SDL.texture.opengl.target"
  624. #define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"
  625. #define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"
  626. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"
  627. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"
  628. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"
  629. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
  630. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET "SDL.texture.opengles2.target"
  631. /**
  632. * Get the renderer that created an SDL_Texture.
  633. *
  634. * \param texture the texture to query
  635. * \returns a pointer to the SDL_Renderer that created the texture, or NULL on
  636. * failure; call SDL_GetError() for more information.
  637. *
  638. * \threadsafety It is safe to call this function from any thread.
  639. *
  640. * \since This function is available since SDL 3.0.0.
  641. *
  642. * \sa SDL_CreateTexture
  643. * \sa SDL_CreateTextureFromSurface
  644. * \sa SDL_CreateTextureWithProperties
  645. */
  646. extern DECLSPEC SDL_Renderer *SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);
  647. /**
  648. * Query the attributes of a texture.
  649. *
  650. * \param texture the texture to query
  651. * \param format a pointer filled in with the raw format of the texture; the
  652. * actual format may differ, but pixel transfers will use this
  653. * format (one of the SDL_PixelFormatEnum values). This argument
  654. * can be NULL if you don't need this information.
  655. * \param access a pointer filled in with the actual access to the texture
  656. * (one of the SDL_TextureAccess values). This argument can be
  657. * NULL if you don't need this information.
  658. * \param w a pointer filled in with the width of the texture in pixels. This
  659. * argument can be NULL if you don't need this information.
  660. * \param h a pointer filled in with the height of the texture in pixels. This
  661. * argument can be NULL if you don't need this information.
  662. * \returns 0 on success or a negative error code on failure; call
  663. * SDL_GetError() for more information.
  664. *
  665. * \since This function is available since SDL 3.0.0.
  666. *
  667. * \sa SDL_CreateTexture
  668. */
  669. extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h);
  670. /**
  671. * Set an additional color value multiplied into render copy operations.
  672. *
  673. * When this texture is rendered, during the copy operation each source color
  674. * channel is modulated by the appropriate color value according to the
  675. * following formula:
  676. *
  677. * `srcC = srcC * (color / 255)`
  678. *
  679. * Color modulation is not always supported by the renderer; it will return -1
  680. * if color modulation is not supported.
  681. *
  682. * \param texture the texture to update
  683. * \param r the red color value multiplied into copy operations
  684. * \param g the green color value multiplied into copy operations
  685. * \param b the blue color value multiplied into copy operations
  686. * \returns 0 on success or a negative error code on failure; call
  687. * SDL_GetError() for more information.
  688. *
  689. * \since This function is available since SDL 3.0.0.
  690. *
  691. * \sa SDL_GetTextureColorMod
  692. * \sa SDL_SetTextureAlphaMod
  693. * \sa SDL_SetTextureColorModFloat
  694. */
  695. extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);
  696. /**
  697. * Set an additional color value multiplied into render copy operations.
  698. *
  699. * When this texture is rendered, during the copy operation each source color
  700. * channel is modulated by the appropriate color value according to the
  701. * following formula:
  702. *
  703. * `srcC = srcC * color`
  704. *
  705. * Color modulation is not always supported by the renderer; it will return -1
  706. * if color modulation is not supported.
  707. *
  708. * \param texture the texture to update
  709. * \param r the red color value multiplied into copy operations
  710. * \param g the green color value multiplied into copy operations
  711. * \param b the blue color value multiplied into copy operations
  712. * \returns 0 on success or a negative error code on failure; call
  713. * SDL_GetError() for more information.
  714. *
  715. * \since This function is available since SDL 3.0.0.
  716. *
  717. * \sa SDL_GetTextureColorModFloat
  718. * \sa SDL_SetTextureAlphaModFloat
  719. * \sa SDL_SetTextureColorMod
  720. */
  721. extern DECLSPEC int SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);
  722. /**
  723. * Get the additional color value multiplied into render copy operations.
  724. *
  725. * \param texture the texture to query
  726. * \param r a pointer filled in with the current red color value
  727. * \param g a pointer filled in with the current green color value
  728. * \param b a pointer filled in with the current blue color value
  729. * \returns 0 on success or a negative error code on failure; call
  730. * SDL_GetError() for more information.
  731. *
  732. * \since This function is available since SDL 3.0.0.
  733. *
  734. * \sa SDL_GetTextureAlphaMod
  735. * \sa SDL_GetTextureColorModFloat
  736. * \sa SDL_SetTextureColorMod
  737. */
  738. extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);
  739. /**
  740. * Get the additional color value multiplied into render copy operations.
  741. *
  742. * \param texture the texture to query
  743. * \param r a pointer filled in with the current red color value
  744. * \param g a pointer filled in with the current green color value
  745. * \param b a pointer filled in with the current blue color value
  746. * \returns 0 on success or a negative error code on failure; call
  747. * SDL_GetError() for more information.
  748. *
  749. * \since This function is available since SDL 3.0.0.
  750. *
  751. * \sa SDL_GetTextureAlphaModFloat
  752. * \sa SDL_GetTextureColorMod
  753. * \sa SDL_SetTextureColorModFloat
  754. */
  755. extern DECLSPEC int SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);
  756. /**
  757. * Set an additional alpha value multiplied into render copy operations.
  758. *
  759. * When this texture is rendered, during the copy operation the source alpha
  760. * value is modulated by this alpha value according to the following formula:
  761. *
  762. * `srcA = srcA * (alpha / 255)`
  763. *
  764. * Alpha modulation is not always supported by the renderer; it will return -1
  765. * if alpha modulation is not supported.
  766. *
  767. * \param texture the texture to update
  768. * \param alpha the source alpha value multiplied into copy operations
  769. * \returns 0 on success or a negative error code on failure; call
  770. * SDL_GetError() for more information.
  771. *
  772. * \since This function is available since SDL 3.0.0.
  773. *
  774. * \sa SDL_GetTextureAlphaMod
  775. * \sa SDL_SetTextureAlphaModFloat
  776. * \sa SDL_SetTextureColorMod
  777. */
  778. extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
  779. /**
  780. * Set an additional alpha value multiplied into render copy operations.
  781. *
  782. * When this texture is rendered, during the copy operation the source alpha
  783. * value is modulated by this alpha value according to the following formula:
  784. *
  785. * `srcA = srcA * alpha`
  786. *
  787. * Alpha modulation is not always supported by the renderer; it will return -1
  788. * if alpha modulation is not supported.
  789. *
  790. * \param texture the texture to update
  791. * \param alpha the source alpha value multiplied into copy operations
  792. * \returns 0 on success or a negative error code on failure; call
  793. * SDL_GetError() for more information.
  794. *
  795. * \since This function is available since SDL 3.0.0.
  796. *
  797. * \sa SDL_GetTextureAlphaModFloat
  798. * \sa SDL_SetTextureAlphaMod
  799. * \sa SDL_SetTextureColorModFloat
  800. */
  801. extern DECLSPEC int SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);
  802. /**
  803. * Get the additional alpha value multiplied into render copy operations.
  804. *
  805. * \param texture the texture to query
  806. * \param alpha a pointer filled in with the current alpha value
  807. * \returns 0 on success or a negative error code on failure; call
  808. * SDL_GetError() for more information.
  809. *
  810. * \since This function is available since SDL 3.0.0.
  811. *
  812. * \sa SDL_GetTextureAlphaModFloat
  813. * \sa SDL_GetTextureColorMod
  814. * \sa SDL_SetTextureAlphaMod
  815. */
  816. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);
  817. /**
  818. * Get the additional alpha value multiplied into render copy operations.
  819. *
  820. * \param texture the texture to query
  821. * \param alpha a pointer filled in with the current alpha value
  822. * \returns 0 on success or a negative error code on failure; call
  823. * SDL_GetError() for more information.
  824. *
  825. * \since This function is available since SDL 3.0.0.
  826. *
  827. * \sa SDL_GetTextureAlphaMod
  828. * \sa SDL_GetTextureColorModFloat
  829. * \sa SDL_SetTextureAlphaModFloat
  830. */
  831. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);
  832. /**
  833. * Set the blend mode for a texture, used by SDL_RenderTexture().
  834. *
  835. * If the blend mode is not supported, the closest supported mode is chosen
  836. * and this function returns -1.
  837. *
  838. * \param texture the texture to update
  839. * \param blendMode the SDL_BlendMode to use for texture blending
  840. * \returns 0 on success or a negative error code on failure; call
  841. * SDL_GetError() for more information.
  842. *
  843. * \since This function is available since SDL 3.0.0.
  844. *
  845. * \sa SDL_GetTextureBlendMode
  846. * \sa SDL_RenderTexture
  847. */
  848. extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);
  849. /**
  850. * Get the blend mode used for texture copy operations.
  851. *
  852. * \param texture the texture to query
  853. * \param blendMode a pointer filled in with the current SDL_BlendMode
  854. * \returns 0 on success or a negative error code on failure; call
  855. * SDL_GetError() for more information.
  856. *
  857. * \since This function is available since SDL 3.0.0.
  858. *
  859. * \sa SDL_SetTextureBlendMode
  860. */
  861. extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);
  862. /**
  863. * Set the scale mode used for texture scale operations.
  864. *
  865. * If the scale mode is not supported, the closest supported mode is chosen.
  866. *
  867. * \param texture The texture to update.
  868. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
  869. * \returns 0 on success or a negative error code on failure; call
  870. * SDL_GetError() for more information.
  871. *
  872. * \since This function is available since SDL 3.0.0.
  873. *
  874. * \sa SDL_GetTextureScaleMode
  875. */
  876. extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);
  877. /**
  878. * Get the scale mode used for texture scale operations.
  879. *
  880. * \param texture the texture to query.
  881. * \param scaleMode a pointer filled in with the current scale mode.
  882. * \returns 0 on success or a negative error code on failure; call
  883. * SDL_GetError() for more information.
  884. *
  885. * \since This function is available since SDL 3.0.0.
  886. *
  887. * \sa SDL_SetTextureScaleMode
  888. */
  889. extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
  890. /**
  891. * Update the given texture rectangle with new pixel data.
  892. *
  893. * The pixel data must be in the pixel format of the texture. Use
  894. * SDL_QueryTexture() to query the pixel format of the texture.
  895. *
  896. * This is a fairly slow function, intended for use with static textures that
  897. * do not change often.
  898. *
  899. * If the texture is intended to be updated often, it is preferred to create
  900. * the texture as streaming and use the locking functions referenced below.
  901. * While this function will work with streaming textures, for optimization
  902. * reasons you may not get the pixels back if you lock the texture afterward.
  903. *
  904. * \param texture the texture to update
  905. * \param rect an SDL_Rect structure representing the area to update, or NULL
  906. * to update the entire texture
  907. * \param pixels the raw pixel data in the format of the texture
  908. * \param pitch the number of bytes in a row of pixel data, including padding
  909. * between lines
  910. * \returns 0 on success or a negative error code on failure; call
  911. * SDL_GetError() for more information.
  912. *
  913. * \since This function is available since SDL 3.0.0.
  914. *
  915. * \sa SDL_CreateTexture
  916. * \sa SDL_LockTexture
  917. * \sa SDL_UnlockTexture
  918. */
  919. extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);
  920. /**
  921. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  922. * data.
  923. *
  924. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  925. * block of Y and U/V planes in the proper order, but this function is
  926. * available if your pixel data is not contiguous.
  927. *
  928. * \param texture the texture to update
  929. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  930. * update the entire texture
  931. * \param Yplane the raw pixel data for the Y plane
  932. * \param Ypitch the number of bytes between rows of pixel data for the Y
  933. * plane
  934. * \param Uplane the raw pixel data for the U plane
  935. * \param Upitch the number of bytes between rows of pixel data for the U
  936. * plane
  937. * \param Vplane the raw pixel data for the V plane
  938. * \param Vpitch the number of bytes between rows of pixel data for the V
  939. * plane
  940. * \returns 0 on success or a negative error code on failure; call
  941. * SDL_GetError() for more information.
  942. *
  943. * \since This function is available since SDL 3.0.0.
  944. *
  945. * \sa SDL_UpdateTexture
  946. */
  947. extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
  948. const SDL_Rect *rect,
  949. const Uint8 *Yplane, int Ypitch,
  950. const Uint8 *Uplane, int Upitch,
  951. const Uint8 *Vplane, int Vpitch);
  952. /**
  953. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  954. *
  955. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  956. * block of NV12/21 planes in the proper order, but this function is available
  957. * if your pixel data is not contiguous.
  958. *
  959. * \param texture the texture to update
  960. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  961. * update the entire texture.
  962. * \param Yplane the raw pixel data for the Y plane.
  963. * \param Ypitch the number of bytes between rows of pixel data for the Y
  964. * plane.
  965. * \param UVplane the raw pixel data for the UV plane.
  966. * \param UVpitch the number of bytes between rows of pixel data for the UV
  967. * plane.
  968. * \returns 0 on success or a negative error code on failure; call
  969. * SDL_GetError() for more information.
  970. *
  971. * \since This function is available since SDL 3.0.0.
  972. */
  973. extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,
  974. const SDL_Rect *rect,
  975. const Uint8 *Yplane, int Ypitch,
  976. const Uint8 *UVplane, int UVpitch);
  977. /**
  978. * Lock a portion of the texture for **write-only** pixel access.
  979. *
  980. * As an optimization, the pixels made available for editing don't necessarily
  981. * contain the old texture data. This is a write-only operation, and if you
  982. * need to keep a copy of the texture data you should do that at the
  983. * application level.
  984. *
  985. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  986. * changes.
  987. *
  988. * \param texture the texture to lock for access, which was created with
  989. * `SDL_TEXTUREACCESS_STREAMING`
  990. * \param rect an SDL_Rect structure representing the area to lock for access;
  991. * NULL to lock the entire texture
  992. * \param pixels this is filled in with a pointer to the locked pixels,
  993. * appropriately offset by the locked area
  994. * \param pitch this is filled in with the pitch of the locked pixels; the
  995. * pitch is the length of one row in bytes
  996. * \returns 0 on success or a negative error code if the texture is not valid
  997. * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call
  998. * SDL_GetError() for more information.
  999. *
  1000. * \since This function is available since SDL 3.0.0.
  1001. *
  1002. * \sa SDL_UnlockTexture
  1003. */
  1004. extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture *texture,
  1005. const SDL_Rect *rect,
  1006. void **pixels, int *pitch);
  1007. /**
  1008. * Lock a portion of the texture for **write-only** pixel access, and expose
  1009. * it as a SDL surface.
  1010. *
  1011. * Besides providing an SDL_Surface instead of raw pixel data, this function
  1012. * operates like SDL_LockTexture.
  1013. *
  1014. * As an optimization, the pixels made available for editing don't necessarily
  1015. * contain the old texture data. This is a write-only operation, and if you
  1016. * need to keep a copy of the texture data you should do that at the
  1017. * application level.
  1018. *
  1019. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1020. * changes.
  1021. *
  1022. * The returned surface is freed internally after calling SDL_UnlockTexture()
  1023. * or SDL_DestroyTexture(). The caller should not free it.
  1024. *
  1025. * \param texture the texture to lock for access, which must be created with
  1026. * `SDL_TEXTUREACCESS_STREAMING`
  1027. * \param rect a pointer to the rectangle to lock for access. If the rect is
  1028. * NULL, the entire texture will be locked
  1029. * \param surface this is filled in with an SDL surface representing the
  1030. * locked area
  1031. * \returns 0 on success or a negative error code on failure; call
  1032. * SDL_GetError() for more information.
  1033. *
  1034. * \since This function is available since SDL 3.0.0.
  1035. *
  1036. * \sa SDL_LockTexture
  1037. * \sa SDL_UnlockTexture
  1038. */
  1039. extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
  1040. const SDL_Rect *rect,
  1041. SDL_Surface **surface);
  1042. /**
  1043. * Unlock a texture, uploading the changes to video memory, if needed.
  1044. *
  1045. * **Warning**: Please note that SDL_LockTexture() is intended to be
  1046. * write-only; it will not guarantee the previous contents of the texture will
  1047. * be provided. You must fully initialize any area of a texture that you lock
  1048. * before unlocking it, as the pixels might otherwise be uninitialized memory.
  1049. *
  1050. * Which is to say: locking and immediately unlocking a texture can result in
  1051. * corrupted textures, depending on the renderer in use.
  1052. *
  1053. * \param texture a texture locked by SDL_LockTexture()
  1054. *
  1055. * \since This function is available since SDL 3.0.0.
  1056. *
  1057. * \sa SDL_LockTexture
  1058. */
  1059. extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
  1060. /**
  1061. * Set a texture as the current rendering target.
  1062. *
  1063. * The default render target is the window for which the renderer was created.
  1064. * To stop rendering to a texture and render to the window again, call this
  1065. * function with a NULL `texture`.
  1066. *
  1067. * \param renderer the rendering context
  1068. * \param texture the targeted texture, which must be created with the
  1069. * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
  1070. * window instead of a texture.
  1071. * \returns 0 on success or a negative error code on failure; call
  1072. * SDL_GetError() for more information.
  1073. *
  1074. * \since This function is available since SDL 3.0.0.
  1075. *
  1076. * \sa SDL_GetRenderTarget
  1077. */
  1078. extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);
  1079. /**
  1080. * Get the current render target.
  1081. *
  1082. * The default render target is the window for which the renderer was created,
  1083. * and is reported a NULL here.
  1084. *
  1085. * \param renderer the rendering context
  1086. * \returns the current render target or NULL for the default render target.
  1087. *
  1088. * \since This function is available since SDL 3.0.0.
  1089. *
  1090. * \sa SDL_SetRenderTarget
  1091. */
  1092. extern DECLSPEC SDL_Texture *SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  1093. /**
  1094. * Set a device independent resolution and presentation mode for rendering.
  1095. *
  1096. * This function sets the width and height of the logical rendering output. A
  1097. * render target is created at the specified size and used for rendering and
  1098. * then copied to the output during presentation.
  1099. *
  1100. * You can disable logical coordinates by setting the mode to
  1101. * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
  1102. * resolution of the output window.
  1103. *
  1104. * You can convert coordinates in an event into rendering coordinates using
  1105. * SDL_ConvertEventToRenderCoordinates().
  1106. *
  1107. * \param renderer the rendering context
  1108. * \param w the width of the logical resolution
  1109. * \param h the height of the logical resolution
  1110. * \param mode the presentation mode used
  1111. * \param scale_mode the scale mode used
  1112. * \returns 0 on success or a negative error code on failure; call
  1113. * SDL_GetError() for more information.
  1114. *
  1115. * \since This function is available since SDL 3.0.0.
  1116. *
  1117. * \sa SDL_ConvertEventToRenderCoordinates
  1118. * \sa SDL_GetRenderLogicalPresentation
  1119. */
  1120. extern DECLSPEC int SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode, SDL_ScaleMode scale_mode);
  1121. /**
  1122. * Get device independent resolution and presentation mode for rendering.
  1123. *
  1124. * This function gets the width and height of the logical rendering output, or
  1125. * the output size in pixels if a logical resolution is not enabled.
  1126. *
  1127. * \param renderer the rendering context
  1128. * \param w an int to be filled with the width
  1129. * \param h an int to be filled with the height
  1130. * \param mode a pointer filled in with the presentation mode
  1131. * \param scale_mode a pointer filled in with the scale mode
  1132. * \returns 0 on success or a negative error code on failure; call
  1133. * SDL_GetError() for more information.
  1134. *
  1135. * \since This function is available since SDL 3.0.0.
  1136. *
  1137. * \sa SDL_SetRenderLogicalPresentation
  1138. */
  1139. extern DECLSPEC int SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode, SDL_ScaleMode *scale_mode);
  1140. /**
  1141. * Get a point in render coordinates when given a point in window coordinates.
  1142. *
  1143. * \param renderer the rendering context
  1144. * \param window_x the x coordinate in window coordinates
  1145. * \param window_y the y coordinate in window coordinates
  1146. * \param x a pointer filled with the x coordinate in render coordinates
  1147. * \param y a pointer filled with the y coordinate in render coordinates
  1148. * \returns 0 on success or a negative error code on failure; call
  1149. * SDL_GetError() for more information.
  1150. *
  1151. * \since This function is available since SDL 3.0.0.
  1152. *
  1153. * \sa SDL_SetRenderLogicalPresentation
  1154. * \sa SDL_SetRenderScale
  1155. */
  1156. extern DECLSPEC int SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
  1157. /**
  1158. * Get a point in window coordinates when given a point in render coordinates.
  1159. *
  1160. * \param renderer the rendering context
  1161. * \param x the x coordinate in render coordinates
  1162. * \param y the y coordinate in render coordinates
  1163. * \param window_x a pointer filled with the x coordinate in window
  1164. * coordinates
  1165. * \param window_y a pointer filled with the y coordinate in window
  1166. * coordinates
  1167. * \returns 0 on success or a negative error code on failure; call
  1168. * SDL_GetError() for more information.
  1169. *
  1170. * \since This function is available since SDL 3.0.0.
  1171. *
  1172. * \sa SDL_SetRenderLogicalPresentation
  1173. * \sa SDL_SetRenderScale
  1174. */
  1175. extern DECLSPEC int SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
  1176. /**
  1177. * Convert the coordinates in an event to render coordinates.
  1178. *
  1179. * Touch coordinates are converted from normalized coordinates in the window
  1180. * to non-normalized rendering coordinates.
  1181. *
  1182. * Once converted, the coordinates may be outside the rendering area.
  1183. *
  1184. * \param renderer the rendering context
  1185. * \param event the event to modify
  1186. * \returns 0 on success or a negative error code on failure; call
  1187. * SDL_GetError() for more information.
  1188. *
  1189. * \since This function is available since SDL 3.0.0.
  1190. *
  1191. * \sa SDL_GetRenderCoordinatesFromWindowCoordinates
  1192. */
  1193. extern DECLSPEC int SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
  1194. /**
  1195. * Set the drawing area for rendering on the current target.
  1196. *
  1197. * \param renderer the rendering context
  1198. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  1199. * to set the viewport to the entire target
  1200. * \returns 0 on success or a negative error code on failure; call
  1201. * SDL_GetError() for more information.
  1202. *
  1203. * \since This function is available since SDL 3.0.0.
  1204. *
  1205. * \sa SDL_GetRenderViewport
  1206. */
  1207. extern DECLSPEC int SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);
  1208. /**
  1209. * Get the drawing area for the current target.
  1210. *
  1211. * \param renderer the rendering context
  1212. * \param rect an SDL_Rect structure filled in with the current drawing area
  1213. * \returns 0 on success or a negative error code on failure; call
  1214. * SDL_GetError() for more information.
  1215. *
  1216. * \since This function is available since SDL 3.0.0.
  1217. *
  1218. * \sa SDL_SetRenderViewport
  1219. */
  1220. extern DECLSPEC int SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
  1221. /**
  1222. * Set the clip rectangle for rendering on the specified target.
  1223. *
  1224. * \param renderer the rendering context
  1225. * \param rect an SDL_Rect structure representing the clip area, relative to
  1226. * the viewport, or NULL to disable clipping
  1227. * \returns 0 on success or a negative error code on failure; call
  1228. * SDL_GetError() for more information.
  1229. *
  1230. * \since This function is available since SDL 3.0.0.
  1231. *
  1232. * \sa SDL_GetRenderClipRect
  1233. * \sa SDL_RenderClipEnabled
  1234. */
  1235. extern DECLSPEC int SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);
  1236. /**
  1237. * Get the clip rectangle for the current target.
  1238. *
  1239. * \param renderer the rendering context
  1240. * \param rect an SDL_Rect structure filled in with the current clipping area
  1241. * or an empty rectangle if clipping is disabled
  1242. * \returns 0 on success or a negative error code on failure; call
  1243. * SDL_GetError() for more information.
  1244. *
  1245. * \since This function is available since SDL 3.0.0.
  1246. *
  1247. * \sa SDL_RenderClipEnabled
  1248. * \sa SDL_SetRenderClipRect
  1249. */
  1250. extern DECLSPEC int SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
  1251. /**
  1252. * Get whether clipping is enabled on the given renderer.
  1253. *
  1254. * \param renderer the rendering context
  1255. * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
  1256. * SDL_GetError() for more information.
  1257. *
  1258. * \since This function is available since SDL 3.0.0.
  1259. *
  1260. * \sa SDL_GetRenderClipRect
  1261. * \sa SDL_SetRenderClipRect
  1262. */
  1263. extern DECLSPEC SDL_bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
  1264. /**
  1265. * Set the drawing scale for rendering on the current target.
  1266. *
  1267. * The drawing coordinates are scaled by the x/y scaling factors before they
  1268. * are used by the renderer. This allows resolution independent drawing with a
  1269. * single coordinate system.
  1270. *
  1271. * If this results in scaling or subpixel drawing by the rendering backend, it
  1272. * will be handled using the appropriate quality hints. For best results use
  1273. * integer scaling factors.
  1274. *
  1275. * \param renderer the rendering context
  1276. * \param scaleX the horizontal scaling factor
  1277. * \param scaleY the vertical scaling factor
  1278. * \returns 0 on success or a negative error code on failure; call
  1279. * SDL_GetError() for more information.
  1280. *
  1281. * \since This function is available since SDL 3.0.0.
  1282. *
  1283. * \sa SDL_GetRenderScale
  1284. */
  1285. extern DECLSPEC int SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
  1286. /**
  1287. * Get the drawing scale for the current target.
  1288. *
  1289. * \param renderer the rendering context
  1290. * \param scaleX a pointer filled in with the horizontal scaling factor
  1291. * \param scaleY a pointer filled in with the vertical scaling factor
  1292. * \returns 0 on success or a negative error code on failure; call
  1293. * SDL_GetError() for more information.
  1294. *
  1295. * \since This function is available since SDL 3.0.0.
  1296. *
  1297. * \sa SDL_SetRenderScale
  1298. */
  1299. extern DECLSPEC int SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
  1300. /**
  1301. * Set the color used for drawing operations.
  1302. *
  1303. * Set the color for drawing or filling rectangles, lines, and points, and for
  1304. * SDL_RenderClear().
  1305. *
  1306. * \param renderer the rendering context
  1307. * \param r the red value used to draw on the rendering target
  1308. * \param g the green value used to draw on the rendering target
  1309. * \param b the blue value used to draw on the rendering target
  1310. * \param a the alpha value used to draw on the rendering target; usually
  1311. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  1312. * specify how the alpha channel is used
  1313. * \returns 0 on success or a negative error code on failure; call
  1314. * SDL_GetError() for more information.
  1315. *
  1316. * \since This function is available since SDL 3.0.0.
  1317. *
  1318. * \sa SDL_GetRenderDrawColor
  1319. * \sa SDL_RenderClear
  1320. * \sa SDL_RenderFillRect
  1321. * \sa SDL_RenderFillRects
  1322. * \sa SDL_RenderLine
  1323. * \sa SDL_RenderLines
  1324. * \sa SDL_RenderPoint
  1325. * \sa SDL_RenderPoints
  1326. * \sa SDL_RenderRect
  1327. * \sa SDL_RenderRects
  1328. * \sa SDL_SetRenderDrawColorFloat
  1329. */
  1330. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  1331. /**
  1332. * Set the color used for drawing operations (Rect, Line and Clear).
  1333. *
  1334. * Set the color for drawing or filling rectangles, lines, and points, and for
  1335. * SDL_RenderClear().
  1336. *
  1337. * \param renderer the rendering context
  1338. * \param r the red value used to draw on the rendering target
  1339. * \param g the green value used to draw on the rendering target
  1340. * \param b the blue value used to draw on the rendering target
  1341. * \param a the alpha value used to draw on the rendering target. Use
  1342. * SDL_SetRenderDrawBlendMode to specify how the alpha channel is
  1343. * used
  1344. * \returns 0 on success or a negative error code on failure; call
  1345. * SDL_GetError() for more information.
  1346. *
  1347. * \since This function is available since SDL 3.0.0.
  1348. *
  1349. * \sa SDL_GetRenderDrawColorFloat
  1350. * \sa SDL_RenderClear
  1351. * \sa SDL_RenderFillRect
  1352. * \sa SDL_RenderFillRects
  1353. * \sa SDL_RenderLine
  1354. * \sa SDL_RenderLines
  1355. * \sa SDL_RenderPoint
  1356. * \sa SDL_RenderPoints
  1357. * \sa SDL_RenderRect
  1358. * \sa SDL_RenderRects
  1359. * \sa SDL_SetRenderDrawColor
  1360. */
  1361. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);
  1362. /**
  1363. * Get the color used for drawing operations (Rect, Line and Clear).
  1364. *
  1365. * \param renderer the rendering context
  1366. * \param r a pointer filled in with the red value used to draw on the
  1367. * rendering target
  1368. * \param g a pointer filled in with the green value used to draw on the
  1369. * rendering target
  1370. * \param b a pointer filled in with the blue value used to draw on the
  1371. * rendering target
  1372. * \param a a pointer filled in with the alpha value used to draw on the
  1373. * rendering target; usually `SDL_ALPHA_OPAQUE` (255)
  1374. * \returns 0 on success or a negative error code on failure; call
  1375. * SDL_GetError() for more information.
  1376. *
  1377. * \since This function is available since SDL 3.0.0.
  1378. *
  1379. * \sa SDL_GetRenderDrawColorFloat
  1380. * \sa SDL_SetRenderDrawColor
  1381. */
  1382. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
  1383. /**
  1384. * Get the color used for drawing operations (Rect, Line and Clear).
  1385. *
  1386. * \param renderer the rendering context
  1387. * \param r a pointer filled in with the red value used to draw on the
  1388. * rendering target
  1389. * \param g a pointer filled in with the green value used to draw on the
  1390. * rendering target
  1391. * \param b a pointer filled in with the blue value used to draw on the
  1392. * rendering target
  1393. * \param a a pointer filled in with the alpha value used to draw on the
  1394. * rendering target
  1395. * \returns 0 on success or a negative error code on failure; call
  1396. * SDL_GetError() for more information.
  1397. *
  1398. * \since This function is available since SDL 3.0.0.
  1399. *
  1400. * \sa SDL_SetRenderDrawColorFloat
  1401. * \sa SDL_GetRenderDrawColor
  1402. */
  1403. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);
  1404. /**
  1405. * Set the color scale used for render operations.
  1406. *
  1407. * The color scale is an additional scale multiplied into the pixel color
  1408. * value while rendering. This can be used to adjust the brightness of colors
  1409. * during HDR rendering, or changing HDR video brightness when playing on an
  1410. * SDR display.
  1411. *
  1412. * The color scale does not affect the alpha channel, only the color
  1413. * brightness.
  1414. *
  1415. * \param renderer the rendering context
  1416. * \param scale the color scale value
  1417. * \returns 0 on success or a negative error code on failure; call
  1418. * SDL_GetError() for more information.
  1419. *
  1420. * \since This function is available since SDL 3.0.0.
  1421. *
  1422. * \sa SDL_GetRenderColorScale
  1423. */
  1424. extern DECLSPEC int SDLCALL SDL_SetRenderColorScale(SDL_Renderer *renderer, float scale);
  1425. /**
  1426. * Get the color scale used for render operations.
  1427. *
  1428. * \param renderer the rendering context
  1429. * \param scale a pointer filled in with the current color scale value
  1430. * \returns 0 on success or a negative error code on failure; call
  1431. * SDL_GetError() for more information.
  1432. *
  1433. * \since This function is available since SDL 3.0.0.
  1434. *
  1435. * \sa SDL_SetRenderColorScale
  1436. */
  1437. extern DECLSPEC int SDLCALL SDL_GetRenderColorScale(SDL_Renderer *renderer, float *scale);
  1438. /**
  1439. * Set the blend mode used for drawing operations (Fill and Line).
  1440. *
  1441. * If the blend mode is not supported, the closest supported mode is chosen.
  1442. *
  1443. * \param renderer the rendering context
  1444. * \param blendMode the SDL_BlendMode to use for blending
  1445. * \returns 0 on success or a negative error code on failure; call
  1446. * SDL_GetError() for more information.
  1447. *
  1448. * \since This function is available since SDL 3.0.0.
  1449. *
  1450. * \sa SDL_GetRenderDrawBlendMode
  1451. * \sa SDL_RenderLine
  1452. * \sa SDL_RenderLines
  1453. * \sa SDL_RenderPoint
  1454. * \sa SDL_RenderPoints
  1455. * \sa SDL_RenderRect
  1456. * \sa SDL_RenderRects
  1457. * \sa SDL_RenderFillRect
  1458. * \sa SDL_RenderFillRects
  1459. */
  1460. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
  1461. /**
  1462. * Get the blend mode used for drawing operations.
  1463. *
  1464. * \param renderer the rendering context
  1465. * \param blendMode a pointer filled in with the current SDL_BlendMode
  1466. * \returns 0 on success or a negative error code on failure; call
  1467. * SDL_GetError() for more information.
  1468. *
  1469. * \since This function is available since SDL 3.0.0.
  1470. *
  1471. * \sa SDL_SetRenderDrawBlendMode
  1472. */
  1473. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);
  1474. /**
  1475. * Clear the current rendering target with the drawing color.
  1476. *
  1477. * This function clears the entire rendering target, ignoring the viewport and
  1478. * the clip rectangle.
  1479. *
  1480. * \param renderer the rendering context
  1481. * \returns 0 on success or a negative error code on failure; call
  1482. * SDL_GetError() for more information.
  1483. *
  1484. * \since This function is available since SDL 3.0.0.
  1485. *
  1486. * \sa SDL_SetRenderDrawColor
  1487. */
  1488. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
  1489. /**
  1490. * Draw a point on the current rendering target at subpixel precision.
  1491. *
  1492. * \param renderer The renderer which should draw a point.
  1493. * \param x The x coordinate of the point.
  1494. * \param y The y coordinate of the point.
  1495. * \returns 0 on success, or -1 on error
  1496. *
  1497. * \since This function is available since SDL 3.0.0.
  1498. */
  1499. extern DECLSPEC int SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);
  1500. /**
  1501. * Draw multiple points on the current rendering target at subpixel precision.
  1502. *
  1503. * \param renderer The renderer which should draw multiple points.
  1504. * \param points The points to draw
  1505. * \param count The number of points to draw
  1506. * \returns 0 on success or a negative error code on failure; call
  1507. * SDL_GetError() for more information.
  1508. *
  1509. * \since This function is available since SDL 3.0.0.
  1510. */
  1511. extern DECLSPEC int SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1512. /**
  1513. * Draw a line on the current rendering target at subpixel precision.
  1514. *
  1515. * \param renderer The renderer which should draw a line.
  1516. * \param x1 The x coordinate of the start point.
  1517. * \param y1 The y coordinate of the start point.
  1518. * \param x2 The x coordinate of the end point.
  1519. * \param y2 The y coordinate of the end point.
  1520. * \returns 0 on success, or -1 on error
  1521. *
  1522. * \since This function is available since SDL 3.0.0.
  1523. */
  1524. extern DECLSPEC int SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
  1525. /**
  1526. * Draw a series of connected lines on the current rendering target at
  1527. * subpixel precision.
  1528. *
  1529. * \param renderer The renderer which should draw multiple lines.
  1530. * \param points The points along the lines
  1531. * \param count The number of points, drawing count-1 lines
  1532. * \returns 0 on success or a negative error code on failure; call
  1533. * SDL_GetError() for more information.
  1534. *
  1535. * \since This function is available since SDL 3.0.0.
  1536. */
  1537. extern DECLSPEC int SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1538. /**
  1539. * Draw a rectangle on the current rendering target at subpixel precision.
  1540. *
  1541. * \param renderer The renderer which should draw a rectangle.
  1542. * \param rect A pointer to the destination rectangle, or NULL to outline the
  1543. * entire rendering target.
  1544. * \returns 0 on success, or -1 on error
  1545. *
  1546. * \since This function is available since SDL 3.0.0.
  1547. */
  1548. extern DECLSPEC int SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1549. /**
  1550. * Draw some number of rectangles on the current rendering target at subpixel
  1551. * precision.
  1552. *
  1553. * \param renderer The renderer which should draw multiple rectangles.
  1554. * \param rects A pointer to an array of destination rectangles.
  1555. * \param count The number of rectangles.
  1556. * \returns 0 on success or a negative error code on failure; call
  1557. * SDL_GetError() for more information.
  1558. *
  1559. * \since This function is available since SDL 3.0.0.
  1560. */
  1561. extern DECLSPEC int SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1562. /**
  1563. * Fill a rectangle on the current rendering target with the drawing color at
  1564. * subpixel precision.
  1565. *
  1566. * \param renderer The renderer which should fill a rectangle.
  1567. * \param rect A pointer to the destination rectangle, or NULL for the entire
  1568. * rendering target.
  1569. * \returns 0 on success, or -1 on error
  1570. *
  1571. * \since This function is available since SDL 3.0.0.
  1572. */
  1573. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1574. /**
  1575. * Fill some number of rectangles on the current rendering target with the
  1576. * drawing color at subpixel precision.
  1577. *
  1578. * \param renderer The renderer which should fill multiple rectangles.
  1579. * \param rects A pointer to an array of destination rectangles.
  1580. * \param count The number of rectangles.
  1581. * \returns 0 on success or a negative error code on failure; call
  1582. * SDL_GetError() for more information.
  1583. *
  1584. * \since This function is available since SDL 3.0.0.
  1585. */
  1586. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1587. /**
  1588. * Copy a portion of the texture to the current rendering target at subpixel
  1589. * precision.
  1590. *
  1591. * \param renderer The renderer which should copy parts of a texture.
  1592. * \param texture The source texture.
  1593. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1594. * texture.
  1595. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1596. * entire rendering target.
  1597. * \returns 0 on success, or -1 on error
  1598. *
  1599. * \since This function is available since SDL 3.0.0.
  1600. */
  1601. extern DECLSPEC int SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);
  1602. /**
  1603. * Copy a portion of the source texture to the current rendering target, with
  1604. * rotation and flipping, at subpixel precision.
  1605. *
  1606. * \param renderer The renderer which should copy parts of a texture.
  1607. * \param texture The source texture.
  1608. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1609. * texture.
  1610. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1611. * entire rendering target.
  1612. * \param angle An angle in degrees that indicates the rotation that will be
  1613. * applied to dstrect, rotating it in a clockwise direction
  1614. * \param center A pointer to a point indicating the point around which
  1615. * dstrect will be rotated (if NULL, rotation will be done
  1616. * around dstrect.w/2, dstrect.h/2).
  1617. * \param flip An SDL_FlipMode value stating which flipping actions should be
  1618. * performed on the texture
  1619. * \returns 0 on success or a negative error code on failure; call
  1620. * SDL_GetError() for more information.
  1621. *
  1622. * \since This function is available since SDL 3.0.0.
  1623. */
  1624. extern DECLSPEC int SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
  1625. const SDL_FRect *srcrect, const SDL_FRect *dstrect,
  1626. const double angle, const SDL_FPoint *center,
  1627. const SDL_FlipMode flip);
  1628. /**
  1629. * Render a list of triangles, optionally using a texture and indices into the
  1630. * vertex array Color and alpha modulation is done per vertex
  1631. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1632. *
  1633. * \param renderer The rendering context.
  1634. * \param texture (optional) The SDL texture to use.
  1635. * \param vertices Vertices.
  1636. * \param num_vertices Number of vertices.
  1637. * \param indices (optional) An array of integer indices into the 'vertices'
  1638. * array, if NULL all vertices will be rendered in sequential
  1639. * order.
  1640. * \param num_indices Number of indices.
  1641. * \returns 0 on success, or -1 if the operation is not supported
  1642. *
  1643. * \since This function is available since SDL 3.0.0.
  1644. *
  1645. * \sa SDL_RenderGeometryRaw
  1646. * \sa SDL_Vertex
  1647. */
  1648. extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  1649. SDL_Texture *texture,
  1650. const SDL_Vertex *vertices, int num_vertices,
  1651. const int *indices, int num_indices);
  1652. /**
  1653. * Render a list of triangles, optionally using a texture and indices into the
  1654. * vertex arrays Color and alpha modulation is done per vertex
  1655. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1656. *
  1657. * \param renderer The rendering context.
  1658. * \param texture (optional) The SDL texture to use.
  1659. * \param xy Vertex positions
  1660. * \param xy_stride Byte size to move from one element to the next element
  1661. * \param color Vertex colors (as SDL_Color)
  1662. * \param color_stride Byte size to move from one element to the next element
  1663. * \param uv Vertex normalized texture coordinates
  1664. * \param uv_stride Byte size to move from one element to the next element
  1665. * \param num_vertices Number of vertices.
  1666. * \param indices (optional) An array of indices into the 'vertices' arrays,
  1667. * if NULL all vertices will be rendered in sequential order.
  1668. * \param num_indices Number of indices.
  1669. * \param size_indices Index size: 1 (byte), 2 (short), 4 (int)
  1670. * \returns 0 on success or a negative error code on failure; call
  1671. * SDL_GetError() for more information.
  1672. *
  1673. * \since This function is available since SDL 3.0.0.
  1674. *
  1675. * \sa SDL_RenderGeometry
  1676. * \sa SDL_Vertex
  1677. */
  1678. extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  1679. SDL_Texture *texture,
  1680. const float *xy, int xy_stride,
  1681. const SDL_Color *color, int color_stride,
  1682. const float *uv, int uv_stride,
  1683. int num_vertices,
  1684. const void *indices, int num_indices, int size_indices);
  1685. /**
  1686. * Render a list of triangles, optionally using a texture and indices into the
  1687. * vertex arrays Color and alpha modulation is done per vertex
  1688. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1689. *
  1690. * \param renderer The rendering context.
  1691. * \param texture (optional) The SDL texture to use.
  1692. * \param xy Vertex positions
  1693. * \param xy_stride Byte size to move from one element to the next element
  1694. * \param color Vertex colors (as SDL_FColor)
  1695. * \param color_stride Byte size to move from one element to the next element
  1696. * \param uv Vertex normalized texture coordinates
  1697. * \param uv_stride Byte size to move from one element to the next element
  1698. * \param num_vertices Number of vertices.
  1699. * \param indices (optional) An array of indices into the 'vertices' arrays,
  1700. * if NULL all vertices will be rendered in sequential order.
  1701. * \param num_indices Number of indices.
  1702. * \param size_indices Index size: 1 (byte), 2 (short), 4 (int)
  1703. * \returns 0 on success or a negative error code on failure; call
  1704. * SDL_GetError() for more information.
  1705. *
  1706. * \since This function is available since SDL 3.0.0.
  1707. *
  1708. * \sa SDL_RenderGeometry
  1709. * \sa SDL_Vertex
  1710. */
  1711. extern DECLSPEC int SDLCALL SDL_RenderGeometryRawFloat(SDL_Renderer *renderer,
  1712. SDL_Texture *texture,
  1713. const float *xy, int xy_stride,
  1714. const SDL_FColor *color, int color_stride,
  1715. const float *uv, int uv_stride,
  1716. int num_vertices,
  1717. const void *indices, int num_indices, int size_indices);
  1718. /**
  1719. * Read pixels from the current rendering target.
  1720. *
  1721. * The returned surface should be freed with SDL_DestroySurface()
  1722. *
  1723. * **WARNING**: This is a very slow operation, and should not be used
  1724. * frequently. If you're using this on the main rendering target, it should be
  1725. * called after rendering and before SDL_RenderPresent().
  1726. *
  1727. * \param renderer the rendering context
  1728. * \param rect an SDL_Rect structure representing the area in pixels relative
  1729. * to the to current viewport, or NULL for the entire viewport
  1730. * \returns a new SDL_Surface on success or NULL on failure; call
  1731. * SDL_GetError() for more information.
  1732. *
  1733. * \since This function is available since SDL 3.0.0.
  1734. */
  1735. extern DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
  1736. /**
  1737. * Update the screen with any rendering performed since the previous call.
  1738. *
  1739. * SDL's rendering functions operate on a backbuffer; that is, calling a
  1740. * rendering function such as SDL_RenderLine() does not directly put a line on
  1741. * the screen, but rather updates the backbuffer. As such, you compose your
  1742. * entire scene and *present* the composed backbuffer to the screen as a
  1743. * complete picture.
  1744. *
  1745. * Therefore, when using SDL's rendering API, one does all drawing intended
  1746. * for the frame, and then calls this function once per frame to present the
  1747. * final drawing to the user.
  1748. *
  1749. * The backbuffer should be considered invalidated after each present; do not
  1750. * assume that previous contents will exist between frames. You are strongly
  1751. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  1752. * starting each new frame's drawing, even if you plan to overwrite every
  1753. * pixel.
  1754. *
  1755. * \param renderer the rendering context
  1756. * \returns 0 on success or a negative error code on failure; call
  1757. * SDL_GetError() for more information.
  1758. *
  1759. * \threadsafety You may only call this function on the main thread.
  1760. *
  1761. * \since This function is available since SDL 3.0.0.
  1762. *
  1763. * \sa SDL_RenderClear
  1764. * \sa SDL_RenderLine
  1765. * \sa SDL_RenderLines
  1766. * \sa SDL_RenderPoint
  1767. * \sa SDL_RenderPoints
  1768. * \sa SDL_RenderRect
  1769. * \sa SDL_RenderRects
  1770. * \sa SDL_RenderFillRect
  1771. * \sa SDL_RenderFillRects
  1772. * \sa SDL_SetRenderDrawBlendMode
  1773. * \sa SDL_SetRenderDrawColor
  1774. */
  1775. extern DECLSPEC int SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
  1776. /**
  1777. * Destroy the specified texture.
  1778. *
  1779. * Passing NULL or an otherwise invalid texture will set the SDL error message
  1780. * to "Invalid texture".
  1781. *
  1782. * \param texture the texture to destroy
  1783. *
  1784. * \since This function is available since SDL 3.0.0.
  1785. *
  1786. * \sa SDL_CreateTexture
  1787. * \sa SDL_CreateTextureFromSurface
  1788. */
  1789. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
  1790. /**
  1791. * Destroy the rendering context for a window and free associated textures.
  1792. *
  1793. * If `renderer` is NULL, this function will return immediately after setting
  1794. * the SDL error message to "Invalid renderer". See SDL_GetError().
  1795. *
  1796. * \param renderer the rendering context
  1797. *
  1798. * \since This function is available since SDL 3.0.0.
  1799. *
  1800. * \sa SDL_CreateRenderer
  1801. */
  1802. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
  1803. /**
  1804. * Force the rendering context to flush any pending commands and state.
  1805. *
  1806. * You do not need to (and in fact, shouldn't) call this function unless you
  1807. * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
  1808. * addition to using an SDL_Renderer.
  1809. *
  1810. * This is for a very-specific case: if you are using SDL's render API, and
  1811. * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
  1812. * calls. If this applies, you should call this function between calls to
  1813. * SDL's render API and the low-level API you're using in cooperation.
  1814. *
  1815. * In all other cases, you can ignore this function.
  1816. *
  1817. * This call makes SDL flush any pending rendering work it was queueing up to
  1818. * do later in a single batch, and marks any internal cached state as invalid,
  1819. * so it'll prepare all its state again later, from scratch.
  1820. *
  1821. * This means you do not need to save state in your rendering code to protect
  1822. * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
  1823. * OpenGL state that can confuse things; you should use your best judgement
  1824. * and be prepared to make changes if specific state needs to be protected.
  1825. *
  1826. * \param renderer the rendering context
  1827. * \returns 0 on success or a negative error code on failure; call
  1828. * SDL_GetError() for more information.
  1829. *
  1830. * \since This function is available since SDL 3.0.0.
  1831. */
  1832. extern DECLSPEC int SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
  1833. /**
  1834. * Get the CAMetalLayer associated with the given Metal renderer.
  1835. *
  1836. * This function returns `void *`, so SDL doesn't have to include Metal's
  1837. * headers, but it can be safely cast to a `CAMetalLayer *`.
  1838. *
  1839. * \param renderer The renderer to query
  1840. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  1841. * Metal renderer
  1842. *
  1843. * \since This function is available since SDL 3.0.0.
  1844. *
  1845. * \sa SDL_GetRenderMetalCommandEncoder
  1846. */
  1847. extern DECLSPEC void *SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);
  1848. /**
  1849. * Get the Metal command encoder for the current frame
  1850. *
  1851. * This function returns `void *`, so SDL doesn't have to include Metal's
  1852. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  1853. *
  1854. * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
  1855. * SDL a drawable to render to, which might happen if the window is
  1856. * hidden/minimized/offscreen. This doesn't apply to command encoders for
  1857. * render targets, just the window's backbuffer. Check your return values!
  1858. *
  1859. * \param renderer The renderer to query
  1860. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  1861. * renderer isn't a Metal renderer or there was an error.
  1862. *
  1863. * \since This function is available since SDL 3.0.0.
  1864. *
  1865. * \sa SDL_GetRenderMetalLayer
  1866. */
  1867. extern DECLSPEC void *SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);
  1868. /**
  1869. * Toggle VSync of the given renderer.
  1870. *
  1871. * \param renderer The renderer to toggle
  1872. * \param vsync 1 for on, 0 for off. All other values are reserved
  1873. * \returns 0 on success or a negative error code on failure; call
  1874. * SDL_GetError() for more information.
  1875. *
  1876. * \since This function is available since SDL 3.0.0.
  1877. */
  1878. extern DECLSPEC int SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
  1879. /**
  1880. * Get VSync of the given renderer.
  1881. *
  1882. * \param renderer The renderer to toggle
  1883. * \param vsync an int filled with 1 for on, 0 for off. All other values are
  1884. * reserved
  1885. * \returns 0 on success or a negative error code on failure; call
  1886. * SDL_GetError() for more information.
  1887. *
  1888. * \since This function is available since SDL 3.0.0.
  1889. */
  1890. extern DECLSPEC int SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);
  1891. /* Ends C function definitions when using C++ */
  1892. #ifdef __cplusplus
  1893. }
  1894. #endif
  1895. #include <SDL3/SDL_close_code.h>
  1896. #endif /* SDL_render_h_ */