SDL_render.h 90 KB

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