SDL_render.h 90 KB

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