SDL_render.h 89 KB

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