SDL_render.h 88 KB

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