SDL_render.h 84 KB

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