SDL_render.h 94 KB

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