SDL_render.h 70 KB

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