SDL_render.h 93 KB

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