SDL_render.h 89 KB

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