SDL_render.h 70 KB

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