SDL_render.h 89 KB

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