SDL_render.h 71 KB

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