SDL_render.h 89 KB

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