SDL_render.h 89 KB

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