SDL_render.h 104 KB

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