SDL_render.h 75 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911
  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_WINDOW_POINTER`: the window where rendering is
  218. * displayed
  219. * - `SDL_PROP_RENDERER_CREATE_SURFACE_POINTER`: the surface where rendering
  220. * is displayed, if you want a software renderer without a window
  221. * - `SDL_PROP_RENDERER_CREATE_NAME_STRING`: the name of the rendering driver
  222. * to use, if a specific one is desired
  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_WINDOW_POINTER "window"
  246. #define SDL_PROP_RENDERER_CREATE_SURFACE_POINTER "surface"
  247. #define SDL_PROP_RENDERER_CREATE_NAME_STRING "name"
  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_D3D9_DEVICE_POINTER`: the IDirect3DDevice9 associated
  312. * with the renderer
  313. * - `SDL_PROP_RENDERER_D3D11_DEVICE_POINTER`: the ID3D11Device associated
  314. * with the renderer
  315. * - `SDL_PROP_RENDERER_D3D12_DEVICE_POINTER`: the ID3D12Device associated
  316. * with the renderer
  317. * - `SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER`: the ID3D12CommandQueue
  318. * associated with the renderer
  319. *
  320. * \param renderer the rendering context
  321. * \returns a valid property ID on success or 0 on failure; call
  322. * SDL_GetError() for more information.
  323. *
  324. * \since This function is available since SDL 3.0.0.
  325. *
  326. * \sa SDL_GetProperty
  327. * \sa SDL_SetProperty
  328. */
  329. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetRendererProperties(SDL_Renderer *renderer);
  330. #define SDL_PROP_RENDERER_D3D9_DEVICE_POINTER "SDL.renderer.d3d9.device"
  331. #define SDL_PROP_RENDERER_D3D11_DEVICE_POINTER "SDL.renderer.d3d11.device"
  332. #define SDL_PROP_RENDERER_D3D12_DEVICE_POINTER "SDL.renderer.d3d12.device"
  333. #define SDL_PROP_RENDERER_D3D12_COMMAND_QUEUE_POINTER "SDL.renderer.d3d12.command_queue"
  334. /**
  335. * Get the output size in pixels of a rendering context.
  336. *
  337. * This returns the true output size in pixels, ignoring any render targets or
  338. * logical size and presentation.
  339. *
  340. * \param renderer the rendering context
  341. * \param w a pointer filled in with the width in pixels
  342. * \param h a pointer filled in with the height in pixels
  343. * \returns 0 on success or a negative error code on failure; call
  344. * SDL_GetError() for more information.
  345. *
  346. * \since This function is available since SDL 3.0.0.
  347. *
  348. * \sa SDL_GetRenderer
  349. */
  350. extern DECLSPEC int SDLCALL SDL_GetRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  351. /**
  352. * Get the current output size in pixels of a rendering context.
  353. *
  354. * If a rendering target is active, this will return the size of the rendering
  355. * target in pixels, otherwise if a logical size is set, it will return the
  356. * logical size, otherwise it will return the value of
  357. * SDL_GetRenderOutputSize().
  358. *
  359. * \param renderer the rendering context
  360. * \param w a pointer filled in with the current width
  361. * \param h a pointer filled in with the current height
  362. * \returns 0 on success or a negative error code on failure; call
  363. * SDL_GetError() for more information.
  364. *
  365. * \since This function is available since SDL 3.0.0.
  366. *
  367. * \sa SDL_GetRenderOutputSize
  368. * \sa SDL_GetRenderer
  369. */
  370. extern DECLSPEC int SDLCALL SDL_GetCurrentRenderOutputSize(SDL_Renderer *renderer, int *w, int *h);
  371. /**
  372. * Create a texture for a rendering context.
  373. *
  374. * You can set the texture scaling method by setting
  375. * `SDL_HINT_RENDER_SCALE_QUALITY` before creating the texture.
  376. *
  377. * \param renderer the rendering context
  378. * \param format one of the enumerated values in SDL_PixelFormatEnum
  379. * \param access one of the enumerated values in SDL_TextureAccess
  380. * \param w the width of the texture in pixels
  381. * \param h the height of the texture in pixels
  382. * \returns a pointer to the created texture or NULL if no rendering context
  383. * was active, the format was unsupported, or the width or height
  384. * were out of range; call SDL_GetError() for more information.
  385. *
  386. * \since This function is available since SDL 3.0.0.
  387. *
  388. * \sa SDL_CreateTextureFromSurface
  389. * \sa SDL_CreateTextureWithProperties
  390. * \sa SDL_DestroyTexture
  391. * \sa SDL_QueryTexture
  392. * \sa SDL_UpdateTexture
  393. */
  394. extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access, int w, int h);
  395. /**
  396. * Create a texture from an existing surface.
  397. *
  398. * The surface is not modified or freed by this function.
  399. *
  400. * The SDL_TextureAccess hint for the created texture is
  401. * `SDL_TEXTUREACCESS_STATIC`.
  402. *
  403. * The pixel format of the created texture may be different from the pixel
  404. * format of the surface. Use SDL_QueryTexture() to query the pixel format of
  405. * the texture.
  406. *
  407. * \param renderer the rendering context
  408. * \param surface the SDL_Surface structure containing pixel data used to fill
  409. * the texture
  410. * \returns the created texture or NULL on failure; call SDL_GetError() for
  411. * more information.
  412. *
  413. * \since This function is available since SDL 3.0.0.
  414. *
  415. * \sa SDL_CreateTexture
  416. * \sa SDL_CreateTextureWithProperties
  417. * \sa SDL_DestroyTexture
  418. * \sa SDL_QueryTexture
  419. */
  420. extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *surface);
  421. /**
  422. * Create a texture for a rendering context with the specified properties.
  423. *
  424. * These are the supported properties:
  425. *
  426. * - `SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER`: an SDL_ColorSpace value
  427. * describing the texture colorspace, defaults to SDL_COLORSPACE_SCRGB for
  428. * floating point textures, SDL_COLORSPACE_HDR10 for 10-bit textures,
  429. * SDL_COLORSPACE_SRGB for other RGB textures and SDL_COLORSPACE_JPEG for YUV textures.
  430. * - `SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER`: one of the enumerated values in
  431. * SDL_PixelFormatEnum, defaults to the best RGBA format for the renderer
  432. * - `SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER`: one of the enumerated values in
  433. * SDL_TextureAccess, defaults to SDL_TEXTUREACCESS_STATIC
  434. * - `SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER`: the width of the texture in
  435. * pixels, required
  436. * - `SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER`: the height of the texture in
  437. * pixels, required
  438. *
  439. * With the direct3d11 renderer:
  440. *
  441. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D
  442. * associated with the texture, if you want to wrap an existing texture.
  443. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  444. * associated with the U plane of a YUV texture, if you want to wrap an
  445. * existing texture.
  446. * - `SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  447. * associated with the V plane of a YUV texture, if you want to wrap an
  448. * existing texture.
  449. *
  450. * With the direct3d12 renderer:
  451. *
  452. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER`: the ID3D12Resource
  453. * associated with the texture, if you want to wrap an existing texture.
  454. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource
  455. * associated with the U plane of a YUV texture, if you want to wrap an
  456. * existing texture.
  457. * - `SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource
  458. * associated with the V plane of a YUV texture, if you want to wrap an
  459. * existing texture.
  460. *
  461. * With the opengl renderer:
  462. *
  463. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER`: the GLuint texture
  464. * associated with the texture, if you want to wrap an existing texture.
  465. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  466. * associated with the UV plane of an NV12 texture, if you want to wrap an
  467. * existing texture.
  468. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture
  469. * associated with the U plane of a YUV texture, if you want to wrap an
  470. * existing texture.
  471. * - `SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture
  472. * associated with the V plane of a YUV texture, if you want to wrap an
  473. * existing texture.
  474. *
  475. * With the opengles2 renderer:
  476. *
  477. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  478. * associated with the texture, if you want to wrap an existing texture.
  479. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  480. * associated with the texture, if you want to wrap an existing texture.
  481. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  482. * associated with the UV plane of an NV12 texture, if you want to wrap an
  483. * existing texture.
  484. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  485. * associated with the U plane of a YUV texture, if you want to wrap an
  486. * existing texture.
  487. * - `SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  488. * associated with the V plane of a YUV texture, if you want to wrap an
  489. * existing texture.
  490. *
  491. * \param renderer the rendering context
  492. * \param props the properties to use
  493. * \returns a pointer to the created texture or NULL if no rendering context
  494. * was active, the format was unsupported, or the width or height
  495. * were out of range; call SDL_GetError() for more information.
  496. *
  497. * \since This function is available since SDL 3.0.0.
  498. *
  499. * \sa SDL_CreateTextureFromSurface
  500. * \sa SDL_CreateTexture
  501. * \sa SDL_DestroyTexture
  502. * \sa SDL_QueryTexture
  503. * \sa SDL_UpdateTexture
  504. */
  505. extern DECLSPEC SDL_Texture *SDLCALL SDL_CreateTextureWithProperties(SDL_Renderer *renderer, SDL_PropertiesID props);
  506. #define SDL_PROP_TEXTURE_CREATE_COLORSPACE_NUMBER "colorspace"
  507. #define SDL_PROP_TEXTURE_CREATE_FORMAT_NUMBER "format"
  508. #define SDL_PROP_TEXTURE_CREATE_ACCESS_NUMBER "access"
  509. #define SDL_PROP_TEXTURE_CREATE_WIDTH_NUMBER "width"
  510. #define SDL_PROP_TEXTURE_CREATE_HEIGHT_NUMBER "height"
  511. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_POINTER "d3d11.texture"
  512. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_U_POINTER "d3d11.texture_u"
  513. #define SDL_PROP_TEXTURE_CREATE_D3D11_TEXTURE_V_POINTER "d3d11.texture_v"
  514. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_POINTER "d3d12.texture"
  515. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_U_POINTER "d3d12.texture_u"
  516. #define SDL_PROP_TEXTURE_CREATE_D3D12_TEXTURE_V_POINTER "d3d12.texture_v"
  517. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_NUMBER "opengl.texture"
  518. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_UV_NUMBER "opengl.texture_uv"
  519. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_U_NUMBER "opengl.texture_u"
  520. #define SDL_PROP_TEXTURE_CREATE_OPENGL_TEXTURE_V_NUMBER "opengl.texture_v"
  521. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "opengles2.texture"
  522. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_NUMBER "opengles2.texture"
  523. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_UV_NUMBER "opengles2.texture_uv"
  524. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_U_NUMBER "opengles2.texture_u"
  525. #define SDL_PROP_TEXTURE_CREATE_OPENGLES2_TEXTURE_V_NUMBER "opengles2.texture_v"
  526. /**
  527. * Get the properties associated with a texture.
  528. *
  529. * The following read-only properties are provided by SDL:
  530. *
  531. * - `SDL_PROP_TEXTURE_COLORSPACE_NUMBER`: an SDL_ColorSpace value describing
  532. * the colorspace used by the texture
  533. *
  534. * With the direct3d11 renderer:
  535. *
  536. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER`: the ID3D11Texture2D associated
  537. * with the texture
  538. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER`: the ID3D11Texture2D
  539. * associated with the U plane of a YUV texture
  540. * - `SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER`: the ID3D11Texture2D
  541. * associated with the V plane of a YUV texture
  542. *
  543. * With the direct3d12 renderer:
  544. *
  545. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER`: the ID3D12Resource associated
  546. * with the texture
  547. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER`: the ID3D12Resource associated
  548. * with the U plane of a YUV texture
  549. * - `SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER`: the ID3D12Resource associated
  550. * with the V plane of a YUV texture
  551. *
  552. * With the opengl renderer:
  553. *
  554. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER`: the GLuint texture associated
  555. * with the texture
  556. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER`: the GLuint texture
  557. * associated with the UV plane of an NV12 texture
  558. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER`: the GLuint texture associated
  559. * with the U plane of a YUV texture
  560. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER`: the GLuint texture associated
  561. * with the V plane of a YUV texture
  562. * - `SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET`: the GLenum for the texture
  563. * target (`GL_TEXTURE_2D`, `GL_TEXTURE_RECTANGLE_ARB`, etc)
  564. * - `SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT`: the texture coordinate width of
  565. * the texture (0.0 - 1.0)
  566. * - `SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT`: the texture coordinate height of
  567. * the texture (0.0 - 1.0)
  568. *
  569. * With the opengles2 renderer:
  570. *
  571. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER`: the GLuint texture
  572. * associated with the texture
  573. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER`: the GLuint texture
  574. * associated with the UV plane of an NV12 texture
  575. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER`: the GLuint texture
  576. * associated with the U plane of a YUV texture
  577. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER`: the GLuint texture
  578. * associated with the V plane of a YUV texture
  579. * - `SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET`: the GLenum for the texture
  580. * target (`GL_TEXTURE_2D`, `GL_TEXTURE_EXTERNAL_OES`, etc)
  581. *
  582. * \param texture the texture to query
  583. * \returns a valid property ID on success or 0 on failure; call
  584. * SDL_GetError() for more information.
  585. *
  586. * \since This function is available since SDL 3.0.0.
  587. *
  588. * \sa SDL_GetProperty
  589. * \sa SDL_SetProperty
  590. */
  591. extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetTextureProperties(SDL_Texture *texture);
  592. #define SDL_PROP_TEXTURE_COLORSPACE_NUMBER "SDL.texture.colorspace"
  593. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_POINTER "SDL.texture.d3d11.texture"
  594. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_U_POINTER "SDL.texture.d3d11.texture_u"
  595. #define SDL_PROP_TEXTURE_D3D11_TEXTURE_V_POINTER "SDL.texture.d3d11.texture_v"
  596. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_POINTER "SDL.texture.d3d12.texture"
  597. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_U_POINTER "SDL.texture.d3d12.texture_u"
  598. #define SDL_PROP_TEXTURE_D3D12_TEXTURE_V_POINTER "SDL.texture.d3d12.texture_v"
  599. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_NUMBER "SDL.texture.opengl.texture"
  600. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_UV_NUMBER "SDL.texture.opengl.texture_uv"
  601. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_U_NUMBER "SDL.texture.opengl.texture_u"
  602. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_V_NUMBER "SDL.texture.opengl.texture_v"
  603. #define SDL_PROP_TEXTURE_OPENGL_TEXTURE_TARGET "SDL.texture.opengl.target"
  604. #define SDL_PROP_TEXTURE_OPENGL_TEX_W_FLOAT "SDL.texture.opengl.tex_w"
  605. #define SDL_PROP_TEXTURE_OPENGL_TEX_H_FLOAT "SDL.texture.opengl.tex_h"
  606. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_NUMBER "SDL.texture.opengles2.texture"
  607. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_UV_NUMBER "SDL.texture.opengles2.texture_uv"
  608. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_U_NUMBER "SDL.texture.opengles2.texture_u"
  609. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_V_NUMBER "SDL.texture.opengles2.texture_v"
  610. #define SDL_PROP_TEXTURE_OPENGLES2_TEXTURE_TARGET "SDL.texture.opengles2.target"
  611. /**
  612. * Get the renderer that created an SDL_Texture.
  613. *
  614. * \param texture the texture to query
  615. * \returns a pointer to the SDL_Renderer that created the texture, or NULL on
  616. * failure; call SDL_GetError() for more information.
  617. *
  618. * \threadsafety It is safe to call this function from any thread.
  619. *
  620. * \since This function is available since SDL 3.0.0.
  621. *
  622. * \sa SDL_CreateTexture
  623. * \sa SDL_CreateTextureFromSurface
  624. * \sa SDL_CreateTextureWithProperties
  625. */
  626. extern DECLSPEC SDL_Renderer *SDLCALL SDL_GetRendererFromTexture(SDL_Texture *texture);
  627. /**
  628. * Query the attributes of a texture.
  629. *
  630. * \param texture the texture to query
  631. * \param format a pointer filled in with the raw format of the texture; the
  632. * actual format may differ, but pixel transfers will use this
  633. * format (one of the SDL_PixelFormatEnum values). This argument
  634. * can be NULL if you don't need this information.
  635. * \param access a pointer filled in with the actual access to the texture
  636. * (one of the SDL_TextureAccess values). This argument can be
  637. * NULL if you don't need this information.
  638. * \param w a pointer filled in with the width of the texture in pixels. This
  639. * argument can be NULL if you don't need this information.
  640. * \param h a pointer filled in with the height of the texture in pixels. This
  641. * argument can be NULL if you don't need this information.
  642. * \returns 0 on success or a negative error code on failure; call
  643. * SDL_GetError() for more information.
  644. *
  645. * \since This function is available since SDL 3.0.0.
  646. *
  647. * \sa SDL_CreateTexture
  648. */
  649. extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture *texture, Uint32 *format, int *access, int *w, int *h);
  650. /**
  651. * Set an additional color value multiplied into render copy operations.
  652. *
  653. * When this texture is rendered, during the copy operation each source color
  654. * channel is modulated by the appropriate color value according to the
  655. * following formula:
  656. *
  657. * `srcC = srcC * (color / 255)`
  658. *
  659. * Color modulation is not always supported by the renderer; it will return -1
  660. * if color modulation is not supported.
  661. *
  662. * \param texture the texture to update
  663. * \param r the red color value multiplied into copy operations
  664. * \param g the green color value multiplied into copy operations
  665. * \param b the blue color value multiplied into copy operations
  666. * \returns 0 on success or a negative error code on failure; call
  667. * SDL_GetError() for more information.
  668. *
  669. * \since This function is available since SDL 3.0.0.
  670. *
  671. * \sa SDL_GetTextureColorMod
  672. * \sa SDL_SetTextureAlphaMod
  673. * \sa SDL_SetTextureColorModFloat
  674. */
  675. extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture *texture, Uint8 r, Uint8 g, Uint8 b);
  676. /**
  677. * Set an additional color value multiplied into render copy operations.
  678. *
  679. * When this texture is rendered, during the copy operation each source color
  680. * channel is modulated by the appropriate color value according to the
  681. * following formula:
  682. *
  683. * `srcC = srcC * color`
  684. *
  685. * Color modulation is not always supported by the renderer; it will return -1
  686. * if color modulation is not supported.
  687. *
  688. * \param texture the texture to update
  689. * \param r the red color value multiplied into copy operations
  690. * \param g the green color value multiplied into copy operations
  691. * \param b the blue color value multiplied into copy operations
  692. * \returns 0 on success or a negative error code on failure; call
  693. * SDL_GetError() for more information.
  694. *
  695. * \since This function is available since SDL 3.0.0.
  696. *
  697. * \sa SDL_GetTextureColorModFloat
  698. * \sa SDL_SetTextureAlphaModFloat
  699. * \sa SDL_SetTextureColorMod
  700. */
  701. extern DECLSPEC int SDLCALL SDL_SetTextureColorModFloat(SDL_Texture *texture, float r, float g, float b);
  702. /**
  703. * Get the additional color value multiplied into render copy operations.
  704. *
  705. * \param texture the texture to query
  706. * \param r a pointer filled in with the current red color value
  707. * \param g a pointer filled in with the current green color value
  708. * \param b a pointer filled in with the current blue color value
  709. * \returns 0 on success or a negative error code on failure; call
  710. * SDL_GetError() for more information.
  711. *
  712. * \since This function is available since SDL 3.0.0.
  713. *
  714. * \sa SDL_GetTextureAlphaMod
  715. * \sa SDL_GetTextureColorModFloat
  716. * \sa SDL_SetTextureColorMod
  717. */
  718. extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture *texture, Uint8 *r, Uint8 *g, Uint8 *b);
  719. /**
  720. * Get the additional color value multiplied into render copy operations.
  721. *
  722. * \param texture the texture to query
  723. * \param r a pointer filled in with the current red color value
  724. * \param g a pointer filled in with the current green color value
  725. * \param b a pointer filled in with the current blue color value
  726. * \returns 0 on success or a negative error code on failure; call
  727. * SDL_GetError() for more information.
  728. *
  729. * \since This function is available since SDL 3.0.0.
  730. *
  731. * \sa SDL_GetTextureAlphaModFloat
  732. * \sa SDL_GetTextureColorMod
  733. * \sa SDL_SetTextureColorModFloat
  734. */
  735. extern DECLSPEC int SDLCALL SDL_GetTextureColorModFloat(SDL_Texture *texture, float *r, float *g, float *b);
  736. /**
  737. * Set an additional alpha value multiplied into render copy operations.
  738. *
  739. * When this texture is rendered, during the copy operation the source alpha
  740. * value is modulated by this alpha value according to the following formula:
  741. *
  742. * `srcA = srcA * (alpha / 255)`
  743. *
  744. * Alpha modulation is not always supported by the renderer; it will return -1
  745. * if alpha modulation is not supported.
  746. *
  747. * \param texture the texture to update
  748. * \param alpha the source alpha value multiplied into copy operations
  749. * \returns 0 on success or a negative error code on failure; call
  750. * SDL_GetError() for more information.
  751. *
  752. * \since This function is available since SDL 3.0.0.
  753. *
  754. * \sa SDL_GetTextureAlphaMod
  755. * \sa SDL_SetTextureAlphaModFloat
  756. * \sa SDL_SetTextureColorMod
  757. */
  758. extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture *texture, Uint8 alpha);
  759. /**
  760. * Set an additional alpha value multiplied into render copy operations.
  761. *
  762. * When this texture is rendered, during the copy operation the source alpha
  763. * value is modulated by this alpha value according to the following formula:
  764. *
  765. * `srcA = srcA * alpha`
  766. *
  767. * Alpha modulation is not always supported by the renderer; it will return -1
  768. * if alpha modulation is not supported.
  769. *
  770. * \param texture the texture to update
  771. * \param alpha the source alpha value multiplied into copy operations
  772. * \returns 0 on success or a negative error code on failure; call
  773. * SDL_GetError() for more information.
  774. *
  775. * \since This function is available since SDL 3.0.0.
  776. *
  777. * \sa SDL_GetTextureAlphaModFloat
  778. * \sa SDL_SetTextureAlphaMod
  779. * \sa SDL_SetTextureColorModFloat
  780. */
  781. extern DECLSPEC int SDLCALL SDL_SetTextureAlphaModFloat(SDL_Texture *texture, float alpha);
  782. /**
  783. * Get the additional alpha value multiplied into render copy operations.
  784. *
  785. * \param texture the texture to query
  786. * \param alpha a pointer filled in with the current alpha value
  787. * \returns 0 on success or a negative error code on failure; call
  788. * SDL_GetError() for more information.
  789. *
  790. * \since This function is available since SDL 3.0.0.
  791. *
  792. * \sa SDL_GetTextureAlphaModFloat
  793. * \sa SDL_GetTextureColorMod
  794. * \sa SDL_SetTextureAlphaMod
  795. */
  796. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture *texture, Uint8 *alpha);
  797. /**
  798. * Get the additional alpha value multiplied into render copy operations.
  799. *
  800. * \param texture the texture to query
  801. * \param alpha a pointer filled in with the current alpha value
  802. * \returns 0 on success or a negative error code on failure; call
  803. * SDL_GetError() for more information.
  804. *
  805. * \since This function is available since SDL 3.0.0.
  806. *
  807. * \sa SDL_GetTextureAlphaMod
  808. * \sa SDL_GetTextureColorModFloat
  809. * \sa SDL_SetTextureAlphaModFloat
  810. */
  811. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaModFloat(SDL_Texture *texture, float *alpha);
  812. /**
  813. * Set the blend mode for a texture, used by SDL_RenderTexture().
  814. *
  815. * If the blend mode is not supported, the closest supported mode is chosen
  816. * and this function returns -1.
  817. *
  818. * \param texture the texture to update
  819. * \param blendMode the SDL_BlendMode to use for texture blending
  820. * \returns 0 on success or a negative error code on failure; call
  821. * SDL_GetError() for more information.
  822. *
  823. * \since This function is available since SDL 3.0.0.
  824. *
  825. * \sa SDL_GetTextureBlendMode
  826. * \sa SDL_RenderTexture
  827. */
  828. extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode blendMode);
  829. /**
  830. * Get the blend mode used for texture copy operations.
  831. *
  832. * \param texture the texture to query
  833. * \param blendMode a pointer filled in with the current SDL_BlendMode
  834. * \returns 0 on success or a negative error code on failure; call
  835. * SDL_GetError() for more information.
  836. *
  837. * \since This function is available since SDL 3.0.0.
  838. *
  839. * \sa SDL_SetTextureBlendMode
  840. */
  841. extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture *texture, SDL_BlendMode *blendMode);
  842. /**
  843. * Set the scale mode used for texture scale operations.
  844. *
  845. * If the scale mode is not supported, the closest supported mode is chosen.
  846. *
  847. * \param texture The texture to update.
  848. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
  849. * \returns 0 on success or a negative error code on failure; call
  850. * SDL_GetError() for more information.
  851. *
  852. * \since This function is available since SDL 3.0.0.
  853. *
  854. * \sa SDL_GetTextureScaleMode
  855. */
  856. extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode scaleMode);
  857. /**
  858. * Get the scale mode used for texture scale operations.
  859. *
  860. * \param texture the texture to query.
  861. * \param scaleMode a pointer filled in with the current scale mode.
  862. * \returns 0 on success or a negative error code on failure; call
  863. * SDL_GetError() for more information.
  864. *
  865. * \since This function is available since SDL 3.0.0.
  866. *
  867. * \sa SDL_SetTextureScaleMode
  868. */
  869. extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture *texture, SDL_ScaleMode *scaleMode);
  870. /**
  871. * Update the given texture rectangle with new pixel data.
  872. *
  873. * The pixel data must be in the pixel format of the texture. Use
  874. * SDL_QueryTexture() to query the pixel format of the texture.
  875. *
  876. * This is a fairly slow function, intended for use with static textures that
  877. * do not change often.
  878. *
  879. * If the texture is intended to be updated often, it is preferred to create
  880. * the texture as streaming and use the locking functions referenced below.
  881. * While this function will work with streaming textures, for optimization
  882. * reasons you may not get the pixels back if you lock the texture afterward.
  883. *
  884. * \param texture the texture to update
  885. * \param rect an SDL_Rect structure representing the area to update, or NULL
  886. * to update the entire texture
  887. * \param pixels the raw pixel data in the format of the texture
  888. * \param pitch the number of bytes in a row of pixel data, including padding
  889. * between lines
  890. * \returns 0 on success or a negative error code on failure; call
  891. * SDL_GetError() for more information.
  892. *
  893. * \since This function is available since SDL 3.0.0.
  894. *
  895. * \sa SDL_CreateTexture
  896. * \sa SDL_LockTexture
  897. * \sa SDL_UnlockTexture
  898. */
  899. extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pixels, int pitch);
  900. /**
  901. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  902. * data.
  903. *
  904. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  905. * block of Y and U/V planes in the proper order, but this function is
  906. * available if your pixel data is not contiguous.
  907. *
  908. * \param texture the texture to update
  909. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  910. * update the entire texture
  911. * \param Yplane the raw pixel data for the Y plane
  912. * \param Ypitch the number of bytes between rows of pixel data for the Y
  913. * plane
  914. * \param Uplane the raw pixel data for the U plane
  915. * \param Upitch the number of bytes between rows of pixel data for the U
  916. * plane
  917. * \param Vplane the raw pixel data for the V plane
  918. * \param Vpitch the number of bytes between rows of pixel data for the V
  919. * plane
  920. * \returns 0 on success or a negative error code on failure; call
  921. * SDL_GetError() for more information.
  922. *
  923. * \since This function is available since SDL 3.0.0.
  924. *
  925. * \sa SDL_UpdateTexture
  926. */
  927. extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
  928. const SDL_Rect *rect,
  929. const Uint8 *Yplane, int Ypitch,
  930. const Uint8 *Uplane, int Upitch,
  931. const Uint8 *Vplane, int Vpitch);
  932. /**
  933. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  934. *
  935. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  936. * block of NV12/21 planes in the proper order, but this function is available
  937. * if your pixel data is not contiguous.
  938. *
  939. * \param texture the texture to update
  940. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  941. * update the entire texture.
  942. * \param Yplane the raw pixel data for the Y plane.
  943. * \param Ypitch the number of bytes between rows of pixel data for the Y
  944. * plane.
  945. * \param UVplane the raw pixel data for the UV plane.
  946. * \param UVpitch the number of bytes between rows of pixel data for the UV
  947. * plane.
  948. * \returns 0 on success or a negative error code on failure; call
  949. * SDL_GetError() for more information.
  950. *
  951. * \since This function is available since SDL 3.0.0.
  952. */
  953. extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture *texture,
  954. const SDL_Rect *rect,
  955. const Uint8 *Yplane, int Ypitch,
  956. const Uint8 *UVplane, int UVpitch);
  957. /**
  958. * Lock a portion of the texture for **write-only** pixel access.
  959. *
  960. * As an optimization, the pixels made available for editing don't necessarily
  961. * contain the old texture data. This is a write-only operation, and if you
  962. * need to keep a copy of the texture data you should do that at the
  963. * application level.
  964. *
  965. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  966. * changes.
  967. *
  968. * \param texture the texture to lock for access, which was created with
  969. * `SDL_TEXTUREACCESS_STREAMING`
  970. * \param rect an SDL_Rect structure representing the area to lock for access;
  971. * NULL to lock the entire texture
  972. * \param pixels this is filled in with a pointer to the locked pixels,
  973. * appropriately offset by the locked area
  974. * \param pitch this is filled in with the pitch of the locked pixels; the
  975. * pitch is the length of one row in bytes
  976. * \returns 0 on success or a negative error code if the texture is not valid
  977. * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call
  978. * SDL_GetError() for more information.
  979. *
  980. * \since This function is available since SDL 3.0.0.
  981. *
  982. * \sa SDL_UnlockTexture
  983. */
  984. extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture *texture,
  985. const SDL_Rect *rect,
  986. void **pixels, int *pitch);
  987. /**
  988. * Lock a portion of the texture for **write-only** pixel access, and expose
  989. * it as a SDL surface.
  990. *
  991. * Besides providing an SDL_Surface instead of raw pixel data, this function
  992. * operates like SDL_LockTexture.
  993. *
  994. * As an optimization, the pixels made available for editing don't necessarily
  995. * contain the old texture data. This is a write-only operation, and if you
  996. * need to keep a copy of the texture data you should do that at the
  997. * application level.
  998. *
  999. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  1000. * changes.
  1001. *
  1002. * The returned surface is freed internally after calling SDL_UnlockTexture()
  1003. * or SDL_DestroyTexture(). The caller should not free it.
  1004. *
  1005. * \param texture the texture to lock for access, which must be created with
  1006. * `SDL_TEXTUREACCESS_STREAMING`
  1007. * \param rect a pointer to the rectangle to lock for access. If the rect is
  1008. * NULL, the entire texture will be locked
  1009. * \param surface this is filled in with an SDL surface representing the
  1010. * locked area
  1011. * \returns 0 on success or a negative error code on failure; call
  1012. * SDL_GetError() for more information.
  1013. *
  1014. * \since This function is available since SDL 3.0.0.
  1015. *
  1016. * \sa SDL_LockTexture
  1017. * \sa SDL_UnlockTexture
  1018. */
  1019. extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
  1020. const SDL_Rect *rect,
  1021. SDL_Surface **surface);
  1022. /**
  1023. * Unlock a texture, uploading the changes to video memory, if needed.
  1024. *
  1025. * **Warning**: Please note that SDL_LockTexture() is intended to be
  1026. * write-only; it will not guarantee the previous contents of the texture will
  1027. * be provided. You must fully initialize any area of a texture that you lock
  1028. * before unlocking it, as the pixels might otherwise be uninitialized memory.
  1029. *
  1030. * Which is to say: locking and immediately unlocking a texture can result in
  1031. * corrupted textures, depending on the renderer in use.
  1032. *
  1033. * \param texture a texture locked by SDL_LockTexture()
  1034. *
  1035. * \since This function is available since SDL 3.0.0.
  1036. *
  1037. * \sa SDL_LockTexture
  1038. */
  1039. extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture *texture);
  1040. /**
  1041. * Set a texture as the current rendering target.
  1042. *
  1043. * The default render target is the window for which the renderer was created.
  1044. * To stop rendering to a texture and render to the window again, call this
  1045. * function with a NULL `texture`.
  1046. *
  1047. * \param renderer the rendering context
  1048. * \param texture the targeted texture, which must be created with the
  1049. * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
  1050. * window instead of a texture.
  1051. * \returns 0 on success or a negative error code on failure; call
  1052. * SDL_GetError() for more information.
  1053. *
  1054. * \since This function is available since SDL 3.0.0.
  1055. *
  1056. * \sa SDL_GetRenderTarget
  1057. */
  1058. extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture);
  1059. /**
  1060. * Get the current render target.
  1061. *
  1062. * The default render target is the window for which the renderer was created,
  1063. * and is reported a NULL here.
  1064. *
  1065. * \param renderer the rendering context
  1066. * \returns the current render target or NULL for the default render target.
  1067. *
  1068. * \since This function is available since SDL 3.0.0.
  1069. *
  1070. * \sa SDL_SetRenderTarget
  1071. */
  1072. extern DECLSPEC SDL_Texture *SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  1073. /**
  1074. * Set a device independent resolution and presentation mode for rendering.
  1075. *
  1076. * This function sets the width and height of the logical rendering output. A
  1077. * render target is created at the specified size and used for rendering and
  1078. * then copied to the output during presentation.
  1079. *
  1080. * You can disable logical coordinates by setting the mode to
  1081. * SDL_LOGICAL_PRESENTATION_DISABLED, and in that case you get the full pixel
  1082. * resolution of the output window.
  1083. *
  1084. * You can convert coordinates in an event into rendering coordinates using
  1085. * SDL_ConvertEventToRenderCoordinates().
  1086. *
  1087. * \param renderer the rendering context
  1088. * \param w the width of the logical resolution
  1089. * \param h the height of the logical resolution
  1090. * \param mode the presentation mode used
  1091. * \param scale_mode the scale mode used
  1092. * \returns 0 on success or a negative error code on failure; call
  1093. * SDL_GetError() for more information.
  1094. *
  1095. * \since This function is available since SDL 3.0.0.
  1096. *
  1097. * \sa SDL_ConvertEventToRenderCoordinates
  1098. * \sa SDL_GetRenderLogicalPresentation
  1099. */
  1100. extern DECLSPEC int SDLCALL SDL_SetRenderLogicalPresentation(SDL_Renderer *renderer, int w, int h, SDL_RendererLogicalPresentation mode, SDL_ScaleMode scale_mode);
  1101. /**
  1102. * Get device independent resolution and presentation mode for rendering.
  1103. *
  1104. * This function gets the width and height of the logical rendering output, or
  1105. * the output size in pixels if a logical resolution is not enabled.
  1106. *
  1107. * \param renderer the rendering context
  1108. * \param w an int to be filled with the width
  1109. * \param h an int to be filled with the height
  1110. * \param mode a pointer filled in with the presentation mode
  1111. * \param scale_mode a pointer filled in with the scale mode
  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_SetRenderLogicalPresentation
  1118. */
  1119. extern DECLSPEC int SDLCALL SDL_GetRenderLogicalPresentation(SDL_Renderer *renderer, int *w, int *h, SDL_RendererLogicalPresentation *mode, SDL_ScaleMode *scale_mode);
  1120. /**
  1121. * Get a point in render coordinates when given a point in window coordinates.
  1122. *
  1123. * \param renderer the rendering context
  1124. * \param window_x the x coordinate in window coordinates
  1125. * \param window_y the y coordinate in window coordinates
  1126. * \param x a pointer filled with the x coordinate in render coordinates
  1127. * \param y a pointer filled with the y coordinate in render coordinates
  1128. * \returns 0 on success or a negative error code on failure; call
  1129. * SDL_GetError() for more information.
  1130. *
  1131. * \since This function is available since SDL 3.0.0.
  1132. *
  1133. * \sa SDL_SetRenderLogicalPresentation
  1134. * \sa SDL_SetRenderScale
  1135. */
  1136. extern DECLSPEC int SDLCALL SDL_RenderCoordinatesFromWindow(SDL_Renderer *renderer, float window_x, float window_y, float *x, float *y);
  1137. /**
  1138. * Get a point in window coordinates when given a point in render coordinates.
  1139. *
  1140. * \param renderer the rendering context
  1141. * \param x the x coordinate in render coordinates
  1142. * \param y the y coordinate in render coordinates
  1143. * \param window_x a pointer filled with the x coordinate in window
  1144. * coordinates
  1145. * \param window_y a pointer filled with the y coordinate in window
  1146. * coordinates
  1147. * \returns 0 on success or a negative error code on failure; call
  1148. * SDL_GetError() for more information.
  1149. *
  1150. * \since This function is available since SDL 3.0.0.
  1151. *
  1152. * \sa SDL_SetRenderLogicalPresentation
  1153. * \sa SDL_SetRenderScale
  1154. */
  1155. extern DECLSPEC int SDLCALL SDL_RenderCoordinatesToWindow(SDL_Renderer *renderer, float x, float y, float *window_x, float *window_y);
  1156. /**
  1157. * Convert the coordinates in an event to render coordinates.
  1158. *
  1159. * Touch coordinates are converted from normalized coordinates in the window
  1160. * to non-normalized rendering coordinates.
  1161. *
  1162. * Once converted, the coordinates may be outside the rendering area.
  1163. *
  1164. * \param renderer the rendering context
  1165. * \param event the event to modify
  1166. * \returns 0 on success or a negative error code on failure; call
  1167. * SDL_GetError() for more information.
  1168. *
  1169. * \since This function is available since SDL 3.0.0.
  1170. *
  1171. * \sa SDL_GetRenderCoordinatesFromWindowCoordinates
  1172. */
  1173. extern DECLSPEC int SDLCALL SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);
  1174. /**
  1175. * Set the drawing area for rendering on the current target.
  1176. *
  1177. * \param renderer the rendering context
  1178. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  1179. * to set the viewport to the entire target
  1180. * \returns 0 on success or a negative error code on failure; call
  1181. * SDL_GetError() for more information.
  1182. *
  1183. * \since This function is available since SDL 3.0.0.
  1184. *
  1185. * \sa SDL_GetRenderViewport
  1186. */
  1187. extern DECLSPEC int SDLCALL SDL_SetRenderViewport(SDL_Renderer *renderer, const SDL_Rect *rect);
  1188. /**
  1189. * Get the drawing area for the current target.
  1190. *
  1191. * \param renderer the rendering context
  1192. * \param rect an SDL_Rect structure filled in with the current drawing area
  1193. * \returns 0 on success or a negative error code on failure; call
  1194. * SDL_GetError() for more information.
  1195. *
  1196. * \since This function is available since SDL 3.0.0.
  1197. *
  1198. * \sa SDL_SetRenderViewport
  1199. */
  1200. extern DECLSPEC int SDLCALL SDL_GetRenderViewport(SDL_Renderer *renderer, SDL_Rect *rect);
  1201. /**
  1202. * Set the clip rectangle for rendering on the specified target.
  1203. *
  1204. * \param renderer the rendering context
  1205. * \param rect an SDL_Rect structure representing the clip area, relative to
  1206. * the viewport, or NULL to disable clipping
  1207. * \returns 0 on success or a negative error code on failure; call
  1208. * SDL_GetError() for more information.
  1209. *
  1210. * \since This function is available since SDL 3.0.0.
  1211. *
  1212. * \sa SDL_GetRenderClipRect
  1213. * \sa SDL_RenderClipEnabled
  1214. */
  1215. extern DECLSPEC int SDLCALL SDL_SetRenderClipRect(SDL_Renderer *renderer, const SDL_Rect *rect);
  1216. /**
  1217. * Get the clip rectangle for the current target.
  1218. *
  1219. * \param renderer the rendering context
  1220. * \param rect an SDL_Rect structure filled in with the current clipping area
  1221. * or an empty rectangle if clipping is disabled
  1222. * \returns 0 on success or a negative error code on failure; call
  1223. * SDL_GetError() for more information.
  1224. *
  1225. * \since This function is available since SDL 3.0.0.
  1226. *
  1227. * \sa SDL_RenderClipEnabled
  1228. * \sa SDL_SetRenderClipRect
  1229. */
  1230. extern DECLSPEC int SDLCALL SDL_GetRenderClipRect(SDL_Renderer *renderer, SDL_Rect *rect);
  1231. /**
  1232. * Get whether clipping is enabled on the given renderer.
  1233. *
  1234. * \param renderer the rendering context
  1235. * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
  1236. * SDL_GetError() for more information.
  1237. *
  1238. * \since This function is available since SDL 3.0.0.
  1239. *
  1240. * \sa SDL_GetRenderClipRect
  1241. * \sa SDL_SetRenderClipRect
  1242. */
  1243. extern DECLSPEC SDL_bool SDLCALL SDL_RenderClipEnabled(SDL_Renderer *renderer);
  1244. /**
  1245. * Set the drawing scale for rendering on the current target.
  1246. *
  1247. * The drawing coordinates are scaled by the x/y scaling factors before they
  1248. * are used by the renderer. This allows resolution independent drawing with a
  1249. * single coordinate system.
  1250. *
  1251. * If this results in scaling or subpixel drawing by the rendering backend, it
  1252. * will be handled using the appropriate quality hints. For best results use
  1253. * integer scaling factors.
  1254. *
  1255. * \param renderer the rendering context
  1256. * \param scaleX the horizontal scaling factor
  1257. * \param scaleY the vertical scaling factor
  1258. * \returns 0 on success or a negative error code on failure; call
  1259. * SDL_GetError() for more information.
  1260. *
  1261. * \since This function is available since SDL 3.0.0.
  1262. *
  1263. * \sa SDL_GetRenderScale
  1264. */
  1265. extern DECLSPEC int SDLCALL SDL_SetRenderScale(SDL_Renderer *renderer, float scaleX, float scaleY);
  1266. /**
  1267. * Get the drawing scale for the current target.
  1268. *
  1269. * \param renderer the rendering context
  1270. * \param scaleX a pointer filled in with the horizontal scaling factor
  1271. * \param scaleY a pointer filled in with the vertical scaling factor
  1272. * \returns 0 on success or a negative error code on failure; call
  1273. * SDL_GetError() for more information.
  1274. *
  1275. * \since This function is available since SDL 3.0.0.
  1276. *
  1277. * \sa SDL_SetRenderScale
  1278. */
  1279. extern DECLSPEC int SDLCALL SDL_GetRenderScale(SDL_Renderer *renderer, float *scaleX, float *scaleY);
  1280. /**
  1281. * Set the color used for drawing operations.
  1282. *
  1283. * Set the color for drawing or filling rectangles, lines, and points, and for
  1284. * SDL_RenderClear().
  1285. *
  1286. * \param renderer the rendering context
  1287. * \param r the red value used to draw on the rendering target
  1288. * \param g the green value used to draw on the rendering target
  1289. * \param b the blue value used to draw on the rendering target
  1290. * \param a the alpha value used to draw on the rendering target; usually
  1291. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  1292. * specify how the alpha channel is used
  1293. * \returns 0 on success or a negative error code on failure; call
  1294. * SDL_GetError() for more information.
  1295. *
  1296. * \since This function is available since SDL 3.0.0.
  1297. *
  1298. * \sa SDL_GetRenderDrawColor
  1299. * \sa SDL_RenderClear
  1300. * \sa SDL_RenderFillRect
  1301. * \sa SDL_RenderFillRects
  1302. * \sa SDL_RenderLine
  1303. * \sa SDL_RenderLines
  1304. * \sa SDL_RenderPoint
  1305. * \sa SDL_RenderPoints
  1306. * \sa SDL_RenderRect
  1307. * \sa SDL_RenderRects
  1308. * \sa SDL_SetRenderDrawColorFloat
  1309. */
  1310. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
  1311. /**
  1312. * Set the color used for drawing operations (Rect, Line and Clear).
  1313. *
  1314. * Set the color for drawing or filling rectangles, lines, and points, and for
  1315. * SDL_RenderClear().
  1316. *
  1317. * \param renderer the rendering context
  1318. * \param r the red value used to draw on the rendering target
  1319. * \param g the green value used to draw on the rendering target
  1320. * \param b the blue value used to draw on the rendering target
  1321. * \param a the alpha value used to draw on the rendering target. Use
  1322. * SDL_SetRenderDrawBlendMode to specify how the alpha channel is
  1323. * used
  1324. * \returns 0 on success or a negative error code on failure; call
  1325. * SDL_GetError() for more information.
  1326. *
  1327. * \since This function is available since SDL 3.0.0.
  1328. *
  1329. * \sa SDL_GetRenderDrawColorFloat
  1330. * \sa SDL_RenderClear
  1331. * \sa SDL_RenderFillRect
  1332. * \sa SDL_RenderFillRects
  1333. * \sa SDL_RenderLine
  1334. * \sa SDL_RenderLines
  1335. * \sa SDL_RenderPoint
  1336. * \sa SDL_RenderPoints
  1337. * \sa SDL_RenderRect
  1338. * \sa SDL_RenderRects
  1339. * \sa SDL_SetRenderDrawColor
  1340. */
  1341. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColorFloat(SDL_Renderer *renderer, float r, float g, float b, float a);
  1342. /**
  1343. * Get the color used for drawing operations (Rect, Line and Clear).
  1344. *
  1345. * \param renderer the rendering context
  1346. * \param r a pointer filled in with the red value used to draw on the
  1347. * rendering target
  1348. * \param g a pointer filled in with the green value used to draw on the
  1349. * rendering target
  1350. * \param b a pointer filled in with the blue value used to draw on the
  1351. * rendering target
  1352. * \param a a pointer filled in with the alpha value used to draw on the
  1353. * rendering target; usually `SDL_ALPHA_OPAQUE` (255)
  1354. * \returns 0 on success or a negative error code on failure; call
  1355. * SDL_GetError() for more information.
  1356. *
  1357. * \since This function is available since SDL 3.0.0.
  1358. *
  1359. * \sa SDL_GetRenderDrawColorFloat
  1360. * \sa SDL_SetRenderDrawColor
  1361. */
  1362. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer *renderer, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
  1363. /**
  1364. * Get the color used for drawing operations (Rect, Line and Clear).
  1365. *
  1366. * \param renderer the rendering context
  1367. * \param r a pointer filled in with the red value used to draw on the
  1368. * rendering target
  1369. * \param g a pointer filled in with the green value used to draw on the
  1370. * rendering target
  1371. * \param b a pointer filled in with the blue value used to draw on the
  1372. * rendering target
  1373. * \param a a pointer filled in with the alpha value used to draw on the
  1374. * rendering target
  1375. * \returns 0 on success or a negative error code on failure; call
  1376. * SDL_GetError() for more information.
  1377. *
  1378. * \since This function is available since SDL 3.0.0.
  1379. *
  1380. * \sa SDL_SetRenderDrawColorFloat
  1381. * \sa SDL_GetRenderDrawColor
  1382. */
  1383. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColorFloat(SDL_Renderer *renderer, float *r, float *g, float *b, float *a);
  1384. /**
  1385. * Set the blend mode used for drawing operations (Fill and Line).
  1386. *
  1387. * If the blend mode is not supported, the closest supported mode is chosen.
  1388. *
  1389. * \param renderer the rendering context
  1390. * \param blendMode the SDL_BlendMode to use for blending
  1391. * \returns 0 on success or a negative error code on failure; call
  1392. * SDL_GetError() for more information.
  1393. *
  1394. * \since This function is available since SDL 3.0.0.
  1395. *
  1396. * \sa SDL_GetRenderDrawBlendMode
  1397. * \sa SDL_RenderLine
  1398. * \sa SDL_RenderLines
  1399. * \sa SDL_RenderPoint
  1400. * \sa SDL_RenderPoints
  1401. * \sa SDL_RenderRect
  1402. * \sa SDL_RenderRects
  1403. * \sa SDL_RenderFillRect
  1404. * \sa SDL_RenderFillRects
  1405. */
  1406. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode blendMode);
  1407. /**
  1408. * Get the blend mode used for drawing operations.
  1409. *
  1410. * \param renderer the rendering context
  1411. * \param blendMode a pointer filled in with the current SDL_BlendMode
  1412. * \returns 0 on success or a negative error code on failure; call
  1413. * SDL_GetError() for more information.
  1414. *
  1415. * \since This function is available since SDL 3.0.0.
  1416. *
  1417. * \sa SDL_SetRenderDrawBlendMode
  1418. */
  1419. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer *renderer, SDL_BlendMode *blendMode);
  1420. /**
  1421. * Clear the current rendering target with the drawing color.
  1422. *
  1423. * This function clears the entire rendering target, ignoring the viewport and
  1424. * the clip rectangle.
  1425. *
  1426. * \param renderer the rendering context
  1427. * \returns 0 on success or a negative error code on failure; call
  1428. * SDL_GetError() for more information.
  1429. *
  1430. * \since This function is available since SDL 3.0.0.
  1431. *
  1432. * \sa SDL_SetRenderDrawColor
  1433. */
  1434. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
  1435. /**
  1436. * Draw a point on the current rendering target at subpixel precision.
  1437. *
  1438. * \param renderer The renderer which should draw a point.
  1439. * \param x The x coordinate of the point.
  1440. * \param y The y coordinate of the point.
  1441. * \returns 0 on success, or -1 on error
  1442. *
  1443. * \since This function is available since SDL 3.0.0.
  1444. */
  1445. extern DECLSPEC int SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, float y);
  1446. /**
  1447. * Draw multiple points on the current rendering target at subpixel precision.
  1448. *
  1449. * \param renderer The renderer which should draw multiple points.
  1450. * \param points The points to draw
  1451. * \param count The number of points to draw
  1452. * \returns 0 on success or a negative error code on failure; call
  1453. * SDL_GetError() for more information.
  1454. *
  1455. * \since This function is available since SDL 3.0.0.
  1456. */
  1457. extern DECLSPEC int SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1458. /**
  1459. * Draw a line on the current rendering target at subpixel precision.
  1460. *
  1461. * \param renderer The renderer which should draw a line.
  1462. * \param x1 The x coordinate of the start point.
  1463. * \param y1 The y coordinate of the start point.
  1464. * \param x2 The x coordinate of the end point.
  1465. * \param y2 The y coordinate of the end point.
  1466. * \returns 0 on success, or -1 on error
  1467. *
  1468. * \since This function is available since SDL 3.0.0.
  1469. */
  1470. extern DECLSPEC int SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, float y1, float x2, float y2);
  1471. /**
  1472. * Draw a series of connected lines on the current rendering target at
  1473. * subpixel precision.
  1474. *
  1475. * \param renderer The renderer which should draw multiple lines.
  1476. * \param points The points along the lines
  1477. * \param count The number of points, drawing count-1 lines
  1478. * \returns 0 on success or a negative error code on failure; call
  1479. * SDL_GetError() for more information.
  1480. *
  1481. * \since This function is available since SDL 3.0.0.
  1482. */
  1483. extern DECLSPEC int SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count);
  1484. /**
  1485. * Draw a rectangle on the current rendering target at subpixel precision.
  1486. *
  1487. * \param renderer The renderer which should draw a rectangle.
  1488. * \param rect A pointer to the destination rectangle, or NULL to outline the
  1489. * entire rendering target.
  1490. * \returns 0 on success, or -1 on error
  1491. *
  1492. * \since This function is available since SDL 3.0.0.
  1493. */
  1494. extern DECLSPEC int SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1495. /**
  1496. * Draw some number of rectangles on the current rendering target at subpixel
  1497. * precision.
  1498. *
  1499. * \param renderer The renderer which should draw multiple rectangles.
  1500. * \param rects A pointer to an array of destination rectangles.
  1501. * \param count The number of rectangles.
  1502. * \returns 0 on success or a negative error code on failure; call
  1503. * SDL_GetError() for more information.
  1504. *
  1505. * \since This function is available since SDL 3.0.0.
  1506. */
  1507. extern DECLSPEC int SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1508. /**
  1509. * Fill a rectangle on the current rendering target with the drawing color at
  1510. * subpixel precision.
  1511. *
  1512. * \param renderer The renderer which should fill a rectangle.
  1513. * \param rect A pointer to the destination rectangle, or NULL for the entire
  1514. * rendering target.
  1515. * \returns 0 on success, or -1 on error
  1516. *
  1517. * \since This function is available since SDL 3.0.0.
  1518. */
  1519. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect);
  1520. /**
  1521. * Fill some number of rectangles on the current rendering target with the
  1522. * drawing color at subpixel precision.
  1523. *
  1524. * \param renderer The renderer which should fill multiple rectangles.
  1525. * \param rects A pointer to an array of destination rectangles.
  1526. * \param count The number of rectangles.
  1527. * \returns 0 on success or a negative error code on failure; call
  1528. * SDL_GetError() for more information.
  1529. *
  1530. * \since This function is available since SDL 3.0.0.
  1531. */
  1532. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count);
  1533. /**
  1534. * Copy a portion of the texture to the current rendering target at subpixel
  1535. * precision.
  1536. *
  1537. * \param renderer The renderer which should copy parts of a texture.
  1538. * \param texture The source texture.
  1539. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1540. * texture.
  1541. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1542. * entire rendering target.
  1543. * \returns 0 on success, or -1 on error
  1544. *
  1545. * \since This function is available since SDL 3.0.0.
  1546. */
  1547. extern DECLSPEC int SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FRect *srcrect, const SDL_FRect *dstrect);
  1548. /**
  1549. * Copy a portion of the source texture to the current rendering target, with
  1550. * rotation and flipping, at subpixel precision.
  1551. *
  1552. * \param renderer The renderer which should copy parts of a texture.
  1553. * \param texture The source texture.
  1554. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1555. * texture.
  1556. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1557. * entire rendering target.
  1558. * \param angle An angle in degrees that indicates the rotation that will be
  1559. * applied to dstrect, rotating it in a clockwise direction
  1560. * \param center A pointer to a point indicating the point around which
  1561. * dstrect will be rotated (if NULL, rotation will be done
  1562. * around dstrect.w/2, dstrect.h/2).
  1563. * \param flip An SDL_FlipMode value stating which flipping actions should be
  1564. * performed on the texture
  1565. * \returns 0 on success or a negative error code on failure; call
  1566. * SDL_GetError() for more information.
  1567. *
  1568. * \since This function is available since SDL 3.0.0.
  1569. */
  1570. extern DECLSPEC int SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture,
  1571. const SDL_FRect *srcrect, const SDL_FRect *dstrect,
  1572. const double angle, const SDL_FPoint *center,
  1573. const SDL_FlipMode flip);
  1574. /**
  1575. * Render a list of triangles, optionally using a texture and indices into the
  1576. * vertex array Color and alpha modulation is done per vertex
  1577. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1578. *
  1579. * \param renderer The rendering context.
  1580. * \param texture (optional) The SDL texture to use.
  1581. * \param vertices Vertices.
  1582. * \param num_vertices Number of vertices.
  1583. * \param indices (optional) An array of integer indices into the 'vertices'
  1584. * array, if NULL all vertices will be rendered in sequential
  1585. * order.
  1586. * \param num_indices Number of indices.
  1587. * \returns 0 on success, or -1 if the operation is not supported
  1588. *
  1589. * \since This function is available since SDL 3.0.0.
  1590. *
  1591. * \sa SDL_RenderGeometryRaw
  1592. * \sa SDL_Vertex
  1593. */
  1594. extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  1595. SDL_Texture *texture,
  1596. const SDL_Vertex *vertices, int num_vertices,
  1597. const int *indices, int num_indices);
  1598. /**
  1599. * Render a list of triangles, optionally using a texture and indices into the
  1600. * vertex arrays Color and alpha modulation is done per vertex
  1601. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1602. *
  1603. * \param renderer The rendering context.
  1604. * \param texture (optional) The SDL texture to use.
  1605. * \param xy Vertex positions
  1606. * \param xy_stride Byte size to move from one element to the next element
  1607. * \param color Vertex colors (as SDL_FColor)
  1608. * \param color_stride Byte size to move from one element to the next element
  1609. * \param uv Vertex normalized texture coordinates
  1610. * \param uv_stride Byte size to move from one element to the next element
  1611. * \param num_vertices Number of vertices.
  1612. * \param indices (optional) An array of indices into the 'vertices' arrays,
  1613. * if NULL all vertices will be rendered in sequential order.
  1614. * \param num_indices Number of indices.
  1615. * \param size_indices Index size: 1 (byte), 2 (short), 4 (int)
  1616. * \returns 0 on success or a negative error code on failure; call
  1617. * SDL_GetError() for more information.
  1618. *
  1619. * \since This function is available since SDL 3.0.0.
  1620. *
  1621. * \sa SDL_RenderGeometry
  1622. * \sa SDL_Vertex
  1623. */
  1624. extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  1625. SDL_Texture *texture,
  1626. const float *xy, int xy_stride,
  1627. const SDL_FColor *color, int color_stride,
  1628. const float *uv, int uv_stride,
  1629. int num_vertices,
  1630. const void *indices, int num_indices, int size_indices);
  1631. /**
  1632. * Read pixels from the current rendering target.
  1633. *
  1634. * The returned surface should be freed with SDL_DestroySurface()
  1635. *
  1636. * **WARNING**: This is a very slow operation, and should not be used
  1637. * frequently. If you're using this on the main rendering target, it should be
  1638. * called after rendering and before SDL_RenderPresent().
  1639. *
  1640. * \param renderer the rendering context
  1641. * \param rect an SDL_Rect structure representing the area in pixels relative
  1642. * to the to current viewport, or NULL for the entire viewport
  1643. * \returns a new SDL_Surface on success or NULL on failure; call
  1644. * SDL_GetError() for more information.
  1645. *
  1646. * \since This function is available since SDL 3.0.0.
  1647. */
  1648. extern DECLSPEC SDL_Surface * SDLCALL SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect);
  1649. /**
  1650. * Update the screen with any rendering performed since the previous call.
  1651. *
  1652. * SDL's rendering functions operate on a backbuffer; that is, calling a
  1653. * rendering function such as SDL_RenderLine() does not directly put a line on
  1654. * the screen, but rather updates the backbuffer. As such, you compose your
  1655. * entire scene and *present* the composed backbuffer to the screen as a
  1656. * complete picture.
  1657. *
  1658. * Therefore, when using SDL's rendering API, one does all drawing intended
  1659. * for the frame, and then calls this function once per frame to present the
  1660. * final drawing to the user.
  1661. *
  1662. * The backbuffer should be considered invalidated after each present; do not
  1663. * assume that previous contents will exist between frames. You are strongly
  1664. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  1665. * starting each new frame's drawing, even if you plan to overwrite every
  1666. * pixel.
  1667. *
  1668. * \param renderer the rendering context
  1669. * \returns 0 on success or a negative error code on failure; call
  1670. * SDL_GetError() for more information.
  1671. *
  1672. * \threadsafety You may only call this function on the main thread.
  1673. *
  1674. * \since This function is available since SDL 3.0.0.
  1675. *
  1676. * \sa SDL_RenderClear
  1677. * \sa SDL_RenderLine
  1678. * \sa SDL_RenderLines
  1679. * \sa SDL_RenderPoint
  1680. * \sa SDL_RenderPoints
  1681. * \sa SDL_RenderRect
  1682. * \sa SDL_RenderRects
  1683. * \sa SDL_RenderFillRect
  1684. * \sa SDL_RenderFillRects
  1685. * \sa SDL_SetRenderDrawBlendMode
  1686. * \sa SDL_SetRenderDrawColor
  1687. */
  1688. extern DECLSPEC int SDLCALL SDL_RenderPresent(SDL_Renderer *renderer);
  1689. /**
  1690. * Destroy the specified texture.
  1691. *
  1692. * Passing NULL or an otherwise invalid texture will set the SDL error message
  1693. * to "Invalid texture".
  1694. *
  1695. * \param texture the texture to destroy
  1696. *
  1697. * \since This function is available since SDL 3.0.0.
  1698. *
  1699. * \sa SDL_CreateTexture
  1700. * \sa SDL_CreateTextureFromSurface
  1701. */
  1702. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture *texture);
  1703. /**
  1704. * Destroy the rendering context for a window and free associated textures.
  1705. *
  1706. * If `renderer` is NULL, this function will return immediately after setting
  1707. * the SDL error message to "Invalid renderer". See SDL_GetError().
  1708. *
  1709. * \param renderer the rendering context
  1710. *
  1711. * \since This function is available since SDL 3.0.0.
  1712. *
  1713. * \sa SDL_CreateRenderer
  1714. */
  1715. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer *renderer);
  1716. /**
  1717. * Force the rendering context to flush any pending commands and state.
  1718. *
  1719. * You do not need to (and in fact, shouldn't) call this function unless you
  1720. * are planning to call into OpenGL/Direct3D/Metal/whatever directly, in
  1721. * addition to using an SDL_Renderer.
  1722. *
  1723. * This is for a very-specific case: if you are using SDL's render API, and
  1724. * you plan to make OpenGL/D3D/whatever calls in addition to SDL render API
  1725. * calls. If this applies, you should call this function between calls to
  1726. * SDL's render API and the low-level API you're using in cooperation.
  1727. *
  1728. * In all other cases, you can ignore this function.
  1729. *
  1730. * This call makes SDL flush any pending rendering work it was queueing up to
  1731. * do later in a single batch, and marks any internal cached state as invalid,
  1732. * so it'll prepare all its state again later, from scratch.
  1733. *
  1734. * This means you do not need to save state in your rendering code to protect
  1735. * the SDL renderer. However, there lots of arbitrary pieces of Direct3D and
  1736. * OpenGL state that can confuse things; you should use your best judgement
  1737. * and be prepared to make changes if specific state needs to be protected.
  1738. *
  1739. * \param renderer the rendering context
  1740. * \returns 0 on success or a negative error code on failure; call
  1741. * SDL_GetError() for more information.
  1742. *
  1743. * \since This function is available since SDL 3.0.0.
  1744. */
  1745. extern DECLSPEC int SDLCALL SDL_FlushRenderer(SDL_Renderer *renderer);
  1746. /**
  1747. * Get the CAMetalLayer associated with the given Metal renderer.
  1748. *
  1749. * This function returns `void *`, so SDL doesn't have to include Metal's
  1750. * headers, but it can be safely cast to a `CAMetalLayer *`.
  1751. *
  1752. * \param renderer The renderer to query
  1753. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  1754. * Metal renderer
  1755. *
  1756. * \since This function is available since SDL 3.0.0.
  1757. *
  1758. * \sa SDL_GetRenderMetalCommandEncoder
  1759. */
  1760. extern DECLSPEC void *SDLCALL SDL_GetRenderMetalLayer(SDL_Renderer *renderer);
  1761. /**
  1762. * Get the Metal command encoder for the current frame
  1763. *
  1764. * This function returns `void *`, so SDL doesn't have to include Metal's
  1765. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  1766. *
  1767. * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
  1768. * SDL a drawable to render to, which might happen if the window is
  1769. * hidden/minimized/offscreen. This doesn't apply to command encoders for
  1770. * render targets, just the window's backbuffer. Check your return values!
  1771. *
  1772. * \param renderer The renderer to query
  1773. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  1774. * renderer isn't a Metal renderer or there was an error.
  1775. *
  1776. * \since This function is available since SDL 3.0.0.
  1777. *
  1778. * \sa SDL_GetRenderMetalLayer
  1779. */
  1780. extern DECLSPEC void *SDLCALL SDL_GetRenderMetalCommandEncoder(SDL_Renderer *renderer);
  1781. /**
  1782. * Toggle VSync of the given renderer.
  1783. *
  1784. * \param renderer The renderer to toggle
  1785. * \param vsync 1 for on, 0 for off. All other values are reserved
  1786. * \returns 0 on success or a negative error code on failure; call
  1787. * SDL_GetError() for more information.
  1788. *
  1789. * \since This function is available since SDL 3.0.0.
  1790. */
  1791. extern DECLSPEC int SDLCALL SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync);
  1792. /**
  1793. * Get VSync of the given renderer.
  1794. *
  1795. * \param renderer The renderer to toggle
  1796. * \param vsync an int filled with 1 for on, 0 for off. All other values are
  1797. * reserved
  1798. * \returns 0 on success or a negative error code on failure; call
  1799. * SDL_GetError() for more information.
  1800. *
  1801. * \since This function is available since SDL 3.0.0.
  1802. */
  1803. extern DECLSPEC int SDLCALL SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync);
  1804. /* Ends C function definitions when using C++ */
  1805. #ifdef __cplusplus
  1806. }
  1807. #endif
  1808. #include <SDL3/SDL_close_code.h>
  1809. #endif /* SDL_render_h_ */