SDL_render.h 88 KB

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