SDL_render.h 90 KB

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