SDL_render.h 73 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2025 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. *
  30. * The primitives may be drawn in opaque, blended, or additive modes.
  31. *
  32. * The texture images may be drawn in opaque, blended, or additive modes. They
  33. * can have an additional color tint or alpha modulation applied to them, and
  34. * may also be stretched with linear interpolation.
  35. *
  36. * This API is designed to accelerate simple 2D operations. You may want more
  37. * functionality such as polygons and particle effects and in that case you
  38. * should use SDL's OpenGL/Direct3D support or one of the many good 3D
  39. * engines.
  40. *
  41. * These functions must be called from the main thread. See this bug for
  42. * details: https://github.com/libsdl-org/SDL/issues/986
  43. */
  44. #ifndef SDL_render_h_
  45. #define SDL_render_h_
  46. #include "SDL_stdinc.h"
  47. #include "SDL_rect.h"
  48. #include "SDL_video.h"
  49. #include "begin_code.h"
  50. /* Set up for C function definitions, even when using C++ */
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. /**
  55. * Flags used when creating a rendering context
  56. */
  57. typedef enum SDL_RendererFlags
  58. {
  59. SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */
  60. SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware
  61. acceleration */
  62. SDL_RENDERER_PRESENTVSYNC = 0x00000004, /**< Present is synchronized
  63. with the refresh rate */
  64. SDL_RENDERER_TARGETTEXTURE = 0x00000008 /**< The renderer supports
  65. rendering to texture */
  66. } SDL_RendererFlags;
  67. /**
  68. * Information on the capabilities of a render driver or context.
  69. */
  70. typedef struct SDL_RendererInfo
  71. {
  72. const char *name; /**< The name of the renderer */
  73. Uint32 flags; /**< Supported SDL_RendererFlags */
  74. Uint32 num_texture_formats; /**< The number of available texture formats */
  75. Uint32 texture_formats[16]; /**< The available texture formats */
  76. int max_texture_width; /**< The maximum texture width */
  77. int max_texture_height; /**< The maximum texture height */
  78. } SDL_RendererInfo;
  79. /**
  80. * Vertex structure
  81. */
  82. typedef struct SDL_Vertex
  83. {
  84. SDL_FPoint position; /**< Vertex position, in SDL_Renderer coordinates */
  85. SDL_Color color; /**< Vertex color */
  86. SDL_FPoint tex_coord; /**< Normalized texture coordinates, if needed */
  87. } SDL_Vertex;
  88. /**
  89. * The scaling mode for a texture.
  90. */
  91. typedef enum SDL_ScaleMode
  92. {
  93. SDL_ScaleModeNearest, /**< nearest pixel sampling */
  94. SDL_ScaleModeLinear, /**< linear filtering */
  95. SDL_ScaleModeBest /**< anisotropic filtering */
  96. } SDL_ScaleMode;
  97. /**
  98. * The access pattern allowed for a texture.
  99. */
  100. typedef enum SDL_TextureAccess
  101. {
  102. SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */
  103. SDL_TEXTUREACCESS_STREAMING, /**< Changes frequently, lockable */
  104. SDL_TEXTUREACCESS_TARGET /**< Texture can be used as a render target */
  105. } SDL_TextureAccess;
  106. /**
  107. * The texture channel modulation used in SDL_RenderCopy().
  108. */
  109. typedef enum SDL_TextureModulate
  110. {
  111. SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */
  112. SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */
  113. SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */
  114. } SDL_TextureModulate;
  115. /**
  116. * Flip constants for SDL_RenderCopyEx
  117. */
  118. typedef enum SDL_RendererFlip
  119. {
  120. SDL_FLIP_NONE = 0x00000000, /**< Do not flip */
  121. SDL_FLIP_HORIZONTAL = 0x00000001, /**< flip horizontally */
  122. SDL_FLIP_VERTICAL = 0x00000002 /**< flip vertically */
  123. } SDL_RendererFlip;
  124. /**
  125. * A structure representing rendering state
  126. */
  127. struct SDL_Renderer;
  128. typedef struct SDL_Renderer SDL_Renderer;
  129. /**
  130. * An efficient driver-specific representation of pixel data
  131. */
  132. struct SDL_Texture;
  133. typedef struct SDL_Texture SDL_Texture;
  134. /* Function prototypes */
  135. /**
  136. * Get the number of 2D rendering drivers available for the current display.
  137. *
  138. * A render driver is a set of code that handles rendering and texture
  139. * management on a particular display. Normally there is only one, but some
  140. * drivers may have several available with different capabilities.
  141. *
  142. * There may be none if SDL was compiled without render support.
  143. *
  144. * \returns a number >= 0 on success or a negative error code on failure; call
  145. * SDL_GetError() for more information.
  146. *
  147. * \since This function is available since SDL 2.0.0.
  148. *
  149. * \sa SDL_CreateRenderer
  150. * \sa SDL_GetRenderDriverInfo
  151. */
  152. extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void);
  153. /**
  154. * Get info about a specific 2D rendering driver for the current display.
  155. *
  156. * \param index the index of the driver to query information about.
  157. * \param info an SDL_RendererInfo structure to be filled with information on
  158. * the rendering driver.
  159. * \returns 0 on success or a negative error code on failure; call
  160. * SDL_GetError() for more information.
  161. *
  162. * \since This function is available since SDL 2.0.0.
  163. *
  164. * \sa SDL_CreateRenderer
  165. * \sa SDL_GetNumRenderDrivers
  166. */
  167. extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index,
  168. SDL_RendererInfo * info);
  169. /**
  170. * Create a window and default renderer.
  171. *
  172. * \param width the width of the window.
  173. * \param height the height of the window.
  174. * \param window_flags the flags used to create the window (see
  175. * SDL_CreateWindow()).
  176. * \param window a pointer filled with the window, or NULL on error.
  177. * \param renderer a pointer filled with the renderer, or NULL on error.
  178. * \returns 0 on success, or -1 on error; call SDL_GetError() for more
  179. * information.
  180. *
  181. * \since This function is available since SDL 2.0.0.
  182. *
  183. * \sa SDL_CreateRenderer
  184. * \sa SDL_CreateWindow
  185. */
  186. extern DECLSPEC int SDLCALL SDL_CreateWindowAndRenderer(
  187. int width, int height, Uint32 window_flags,
  188. SDL_Window **window, SDL_Renderer **renderer);
  189. /**
  190. * Create a 2D rendering context for a window.
  191. *
  192. * \param window the window where rendering is displayed.
  193. * \param index the index of the rendering driver to initialize, or -1 to
  194. * initialize the first one supporting the requested flags.
  195. * \param flags 0, or one or more SDL_RendererFlags OR'd together.
  196. * \returns a valid rendering context or NULL if there was an error; call
  197. * SDL_GetError() for more information.
  198. *
  199. * \since This function is available since SDL 2.0.0.
  200. *
  201. * \sa SDL_CreateSoftwareRenderer
  202. * \sa SDL_DestroyRenderer
  203. * \sa SDL_GetNumRenderDrivers
  204. * \sa SDL_GetRendererInfo
  205. */
  206. extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window,
  207. int index, Uint32 flags);
  208. /**
  209. * Create a 2D software rendering context for a surface.
  210. *
  211. * Two other API which can be used to create SDL_Renderer:
  212. * SDL_CreateRenderer() and SDL_CreateWindowAndRenderer(). These can _also_
  213. * create a software renderer, but they are intended to be used with an
  214. * SDL_Window as the final destination and not an SDL_Surface.
  215. *
  216. * \param surface the SDL_Surface structure representing the surface where
  217. * rendering is done.
  218. * \returns a valid rendering context or NULL if there was an error; call
  219. * SDL_GetError() for more information.
  220. *
  221. * \since This function is available since SDL 2.0.0.
  222. *
  223. * \sa SDL_CreateRenderer
  224. * \sa SDL_CreateWindowRenderer
  225. * \sa SDL_DestroyRenderer
  226. */
  227. extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface);
  228. /**
  229. * Get the renderer associated with a window.
  230. *
  231. * \param window the window to query.
  232. * \returns the rendering context on success or NULL on failure; call
  233. * SDL_GetError() for more information.
  234. *
  235. * \since This function is available since SDL 2.0.0.
  236. *
  237. * \sa SDL_CreateRenderer
  238. */
  239. extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window);
  240. /**
  241. * Get the window associated with a renderer.
  242. *
  243. * \param renderer the renderer to query.
  244. * \returns the window on success or NULL on failure; call SDL_GetError() for
  245. * more information.
  246. *
  247. * \since This function is available since SDL 2.0.22.
  248. */
  249. extern DECLSPEC SDL_Window * SDLCALL SDL_RenderGetWindow(SDL_Renderer *renderer);
  250. /**
  251. * Get information about a rendering context.
  252. *
  253. * \param renderer the rendering context.
  254. * \param info an SDL_RendererInfo structure filled with information about the
  255. * current renderer.
  256. * \returns 0 on success or a negative error code on failure; call
  257. * SDL_GetError() for more information.
  258. *
  259. * \since This function is available since SDL 2.0.0.
  260. *
  261. * \sa SDL_CreateRenderer
  262. */
  263. extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer,
  264. SDL_RendererInfo * info);
  265. /**
  266. * Get the output size in pixels of a rendering context.
  267. *
  268. * Due to high-dpi displays, you might end up with a rendering context that
  269. * has more pixels than the window that contains it, so use this instead of
  270. * SDL_GetWindowSize() to decide how much drawing area you have.
  271. *
  272. * \param renderer the rendering context.
  273. * \param w an int filled with the width.
  274. * \param h an int filled with the height.
  275. * \returns 0 on success or a negative error code on failure; call
  276. * SDL_GetError() for more information.
  277. *
  278. * \since This function is available since SDL 2.0.0.
  279. *
  280. * \sa SDL_GetRenderer
  281. */
  282. extern DECLSPEC int SDLCALL SDL_GetRendererOutputSize(SDL_Renderer * renderer,
  283. int *w, int *h);
  284. /**
  285. * Create a texture for a rendering context.
  286. *
  287. * You can set the texture scaling method by setting
  288. * `SDL_HINT_RENDER_SCALE_QUALITY` before creating the texture.
  289. *
  290. * \param renderer the rendering context.
  291. * \param format one of the enumerated values in SDL_PixelFormatEnum.
  292. * \param access one of the enumerated values in SDL_TextureAccess.
  293. * \param w the width of the texture in pixels.
  294. * \param h the height of the texture in pixels.
  295. * \returns a pointer to the created texture or NULL if no rendering context
  296. * was active, the format was unsupported, or the width or height
  297. * were out of range; call SDL_GetError() for more information.
  298. *
  299. * \since This function is available since SDL 2.0.0.
  300. *
  301. * \sa SDL_CreateTextureFromSurface
  302. * \sa SDL_DestroyTexture
  303. * \sa SDL_QueryTexture
  304. * \sa SDL_UpdateTexture
  305. */
  306. extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer,
  307. Uint32 format,
  308. int access, int w,
  309. int h);
  310. /**
  311. * Create a texture from an existing surface.
  312. *
  313. * The surface is not modified or freed by this function.
  314. *
  315. * The SDL_TextureAccess hint for the created texture is
  316. * `SDL_TEXTUREACCESS_STATIC`.
  317. *
  318. * The pixel format of the created texture may be different from the pixel
  319. * format of the surface. Use SDL_QueryTexture() to query the pixel format of
  320. * the texture.
  321. *
  322. * \param renderer the rendering context.
  323. * \param surface the SDL_Surface structure containing pixel data used to fill
  324. * the texture.
  325. * \returns the created texture or NULL on failure; call SDL_GetError() for
  326. * more information.
  327. *
  328. * \since This function is available since SDL 2.0.0.
  329. *
  330. * \sa SDL_CreateTexture
  331. * \sa SDL_DestroyTexture
  332. * \sa SDL_QueryTexture
  333. */
  334. extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface);
  335. /**
  336. * Query the attributes of a texture.
  337. *
  338. * \param texture the texture to query.
  339. * \param format a pointer filled in with the raw format of the texture; the
  340. * actual format may differ, but pixel transfers will use this
  341. * format (one of the SDL_PixelFormatEnum values). This argument
  342. * can be NULL if you don't need this information.
  343. * \param access a pointer filled in with the actual access to the texture
  344. * (one of the SDL_TextureAccess values). This argument can be
  345. * NULL if you don't need this information.
  346. * \param w a pointer filled in with the width of the texture in pixels. This
  347. * argument can be NULL if you don't need this information.
  348. * \param h a pointer filled in with the height of the texture in pixels. This
  349. * argument can be NULL if you don't need this information.
  350. * \returns 0 on success or a negative error code on failure; call
  351. * SDL_GetError() for more information.
  352. *
  353. * \since This function is available since SDL 2.0.0.
  354. *
  355. * \sa SDL_CreateTexture
  356. */
  357. extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture,
  358. Uint32 * format, int *access,
  359. int *w, int *h);
  360. /**
  361. * Set an additional color value multiplied into render copy operations.
  362. *
  363. * When this texture is rendered, during the copy operation each source color
  364. * channel is modulated by the appropriate color value according to the
  365. * following formula:
  366. *
  367. * `srcC = srcC * (color / 255)`
  368. *
  369. * Color modulation is not always supported by the renderer; it will return -1
  370. * if color modulation is not supported.
  371. *
  372. * \param texture the texture to update.
  373. * \param r the red color value multiplied into copy operations.
  374. * \param g the green color value multiplied into copy operations.
  375. * \param b the blue color value multiplied into copy operations.
  376. * \returns 0 on success or a negative error code on failure; call
  377. * SDL_GetError() for more information.
  378. *
  379. * \since This function is available since SDL 2.0.0.
  380. *
  381. * \sa SDL_GetTextureColorMod
  382. * \sa SDL_SetTextureAlphaMod
  383. */
  384. extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture,
  385. Uint8 r, Uint8 g, Uint8 b);
  386. /**
  387. * Get the additional color value multiplied into render copy operations.
  388. *
  389. * \param texture the texture to query.
  390. * \param r a pointer filled in with the current red color value.
  391. * \param g a pointer filled in with the current green color value.
  392. * \param b a pointer filled in with the current blue color value.
  393. * \returns 0 on success or a negative error code on failure; call
  394. * SDL_GetError() for more information.
  395. *
  396. * \since This function is available since SDL 2.0.0.
  397. *
  398. * \sa SDL_GetTextureAlphaMod
  399. * \sa SDL_SetTextureColorMod
  400. */
  401. extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture,
  402. Uint8 * r, Uint8 * g,
  403. Uint8 * b);
  404. /**
  405. * Set an additional alpha value multiplied into render copy operations.
  406. *
  407. * When this texture is rendered, during the copy operation the source alpha
  408. * value is modulated by this alpha value according to the following formula:
  409. *
  410. * `srcA = srcA * (alpha / 255)`
  411. *
  412. * Alpha modulation is not always supported by the renderer; it will return -1
  413. * if alpha modulation is not supported.
  414. *
  415. * \param texture the texture to update.
  416. * \param alpha the source alpha value multiplied into copy operations.
  417. * \returns 0 on success or a negative error code on failure; call
  418. * SDL_GetError() for more information.
  419. *
  420. * \since This function is available since SDL 2.0.0.
  421. *
  422. * \sa SDL_GetTextureAlphaMod
  423. * \sa SDL_SetTextureColorMod
  424. */
  425. extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture,
  426. Uint8 alpha);
  427. /**
  428. * Get the additional alpha value multiplied into render copy operations.
  429. *
  430. * \param texture the texture to query.
  431. * \param alpha a pointer filled in with the current alpha value.
  432. * \returns 0 on success or a negative error code on failure; call
  433. * SDL_GetError() for more information.
  434. *
  435. * \since This function is available since SDL 2.0.0.
  436. *
  437. * \sa SDL_GetTextureColorMod
  438. * \sa SDL_SetTextureAlphaMod
  439. */
  440. extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture,
  441. Uint8 * alpha);
  442. /**
  443. * Set the blend mode for a texture, used by SDL_RenderCopy().
  444. *
  445. * If the blend mode is not supported, the closest supported mode is chosen
  446. * and this function returns -1.
  447. *
  448. * \param texture the texture to update.
  449. * \param blendMode the SDL_BlendMode to use for texture blending.
  450. * \returns 0 on success or a negative error code on failure; call
  451. * SDL_GetError() for more information.
  452. *
  453. * \since This function is available since SDL 2.0.0.
  454. *
  455. * \sa SDL_GetTextureBlendMode
  456. * \sa SDL_RenderCopy
  457. */
  458. extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture,
  459. SDL_BlendMode blendMode);
  460. /**
  461. * Get the blend mode used for texture copy operations.
  462. *
  463. * \param texture the texture to query.
  464. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  465. * \returns 0 on success or a negative error code on failure; call
  466. * SDL_GetError() for more information.
  467. *
  468. * \since This function is available since SDL 2.0.0.
  469. *
  470. * \sa SDL_SetTextureBlendMode
  471. */
  472. extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture,
  473. SDL_BlendMode *blendMode);
  474. /**
  475. * Set the scale mode used for texture scale operations.
  476. *
  477. * If the scale mode is not supported, the closest supported mode is chosen.
  478. *
  479. * \param texture The texture to update.
  480. * \param scaleMode the SDL_ScaleMode to use for texture scaling.
  481. * \returns 0 on success, or -1 if the texture is not valid.
  482. *
  483. * \since This function is available since SDL 2.0.12.
  484. *
  485. * \sa SDL_GetTextureScaleMode
  486. */
  487. extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture,
  488. SDL_ScaleMode scaleMode);
  489. /**
  490. * Get the scale mode used for texture scale operations.
  491. *
  492. * \param texture the texture to query.
  493. * \param scaleMode a pointer filled in with the current scale mode.
  494. * \return 0 on success, or -1 if the texture is not valid.
  495. *
  496. * \since This function is available since SDL 2.0.12.
  497. *
  498. * \sa SDL_SetTextureScaleMode
  499. */
  500. extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture,
  501. SDL_ScaleMode *scaleMode);
  502. /**
  503. * Associate a user-specified pointer with a texture.
  504. *
  505. * \param texture the texture to update.
  506. * \param userdata the pointer to associate with the texture.
  507. * \returns 0 on success, or -1 if the texture is not valid.
  508. *
  509. * \since This function is available since SDL 2.0.18.
  510. *
  511. * \sa SDL_GetTextureUserData
  512. */
  513. extern DECLSPEC int SDLCALL SDL_SetTextureUserData(SDL_Texture * texture,
  514. void *userdata);
  515. /**
  516. * Get the user-specified pointer associated with a texture
  517. *
  518. * \param texture the texture to query.
  519. * \return the pointer associated with the texture, or NULL if the texture is
  520. * not valid.
  521. *
  522. * \since This function is available since SDL 2.0.18.
  523. *
  524. * \sa SDL_SetTextureUserData
  525. */
  526. extern DECLSPEC void * SDLCALL SDL_GetTextureUserData(SDL_Texture * texture);
  527. /**
  528. * Update the given texture rectangle with new pixel data.
  529. *
  530. * The pixel data must be in the pixel format of the texture. Use
  531. * SDL_QueryTexture() to query the pixel format of the texture.
  532. *
  533. * This is a fairly slow function, intended for use with static textures that
  534. * do not change often.
  535. *
  536. * If the texture is intended to be updated often, it is preferred to create
  537. * the texture as streaming and use the locking functions referenced below.
  538. * While this function will work with streaming textures, for optimization
  539. * reasons you may not get the pixels back if you lock the texture afterward.
  540. *
  541. * \param texture the texture to update.
  542. * \param rect an SDL_Rect structure representing the area to update, or NULL
  543. * to update the entire texture.
  544. * \param pixels the raw pixel data in the format of the texture.
  545. * \param pitch the number of bytes in a row of pixel data, including padding
  546. * between lines.
  547. * \returns 0 on success or a negative error code on failure; call
  548. * SDL_GetError() for more information.
  549. *
  550. * \since This function is available since SDL 2.0.0.
  551. *
  552. * \sa SDL_CreateTexture
  553. * \sa SDL_LockTexture
  554. * \sa SDL_UnlockTexture
  555. */
  556. extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
  557. const SDL_Rect * rect,
  558. const void *pixels, int pitch);
  559. /**
  560. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  561. * data.
  562. *
  563. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  564. * block of Y and U/V planes in the proper order, but this function is
  565. * available if your pixel data is not contiguous.
  566. *
  567. * \param texture the texture to update.
  568. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  569. * update the entire texture.
  570. * \param Yplane the raw pixel data for the Y plane.
  571. * \param Ypitch the number of bytes between rows of pixel data for the Y
  572. * plane.
  573. * \param Uplane the raw pixel data for the U plane.
  574. * \param Upitch the number of bytes between rows of pixel data for the U
  575. * plane.
  576. * \param Vplane the raw pixel data for the V plane.
  577. * \param Vpitch the number of bytes between rows of pixel data for the V
  578. * plane.
  579. * \returns 0 on success or -1 if the texture is not valid; call
  580. * SDL_GetError() for more information.
  581. *
  582. * \since This function is available since SDL 2.0.1.
  583. *
  584. * \sa SDL_UpdateTexture
  585. */
  586. extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
  587. const SDL_Rect * rect,
  588. const Uint8 *Yplane, int Ypitch,
  589. const Uint8 *Uplane, int Upitch,
  590. const Uint8 *Vplane, int Vpitch);
  591. /**
  592. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  593. *
  594. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  595. * block of NV12/21 planes in the proper order, but this function is available
  596. * if your pixel data is not contiguous.
  597. *
  598. * \param texture the texture to update.
  599. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  600. * update the entire texture.
  601. * \param Yplane the raw pixel data for the Y plane.
  602. * \param Ypitch the number of bytes between rows of pixel data for the Y
  603. * plane.
  604. * \param UVplane the raw pixel data for the UV plane.
  605. * \param UVpitch the number of bytes between rows of pixel data for the UV
  606. * plane.
  607. * \return 0 on success, or -1 if the texture is not valid.
  608. *
  609. * \since This function is available since SDL 2.0.16.
  610. */
  611. extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture,
  612. const SDL_Rect * rect,
  613. const Uint8 *Yplane, int Ypitch,
  614. const Uint8 *UVplane, int UVpitch);
  615. /**
  616. * Lock a portion of the texture for **write-only** pixel access.
  617. *
  618. * As an optimization, the pixels made available for editing don't necessarily
  619. * contain the old texture data. This is a write-only operation, and if you
  620. * need to keep a copy of the texture data you should do that at the
  621. * application level.
  622. *
  623. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  624. * changes.
  625. *
  626. * \param texture the texture to lock for access, which was created with
  627. * `SDL_TEXTUREACCESS_STREAMING`.
  628. * \param rect an SDL_Rect structure representing the area to lock for access;
  629. * NULL to lock the entire texture.
  630. * \param pixels this is filled in with a pointer to the locked pixels,
  631. * appropriately offset by the locked area.
  632. * \param pitch this is filled in with the pitch of the locked pixels; the
  633. * pitch is the length of one row in bytes.
  634. * \returns 0 on success or a negative error code if the texture is not valid
  635. * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call
  636. * SDL_GetError() for more information.
  637. *
  638. * \since This function is available since SDL 2.0.0.
  639. *
  640. * \sa SDL_UnlockTexture
  641. */
  642. extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
  643. const SDL_Rect * rect,
  644. void **pixels, int *pitch);
  645. /**
  646. * Lock a portion of the texture for **write-only** pixel access, and expose
  647. * it as a SDL surface.
  648. *
  649. * Besides providing an SDL_Surface instead of raw pixel data, this function
  650. * operates like SDL_LockTexture.
  651. *
  652. * As an optimization, the pixels made available for editing don't necessarily
  653. * contain the old texture data. This is a write-only operation, and if you
  654. * need to keep a copy of the texture data you should do that at the
  655. * application level.
  656. *
  657. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  658. * changes.
  659. *
  660. * The returned surface is freed internally after calling SDL_UnlockTexture()
  661. * or SDL_DestroyTexture(). The caller should not free it.
  662. *
  663. * \param texture the texture to lock for access, which was created with
  664. * `SDL_TEXTUREACCESS_STREAMING`.
  665. * \param rect a pointer to the rectangle to lock for access. If the rect is
  666. * NULL, the entire texture will be locked.
  667. * \param surface this is filled in with an SDL surface representing the
  668. * locked area.
  669. * \returns 0 on success, or -1 if the texture is not valid or was not created
  670. * with `SDL_TEXTUREACCESS_STREAMING`.
  671. *
  672. * \since This function is available since SDL 2.0.12.
  673. *
  674. * \sa SDL_LockTexture
  675. * \sa SDL_UnlockTexture
  676. */
  677. extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
  678. const SDL_Rect *rect,
  679. SDL_Surface **surface);
  680. /**
  681. * Unlock a texture, uploading the changes to video memory, if needed.
  682. *
  683. * **Warning**: Please note that SDL_LockTexture() is intended to be
  684. * write-only; it will not guarantee the previous contents of the texture will
  685. * be provided. You must fully initialize any area of a texture that you lock
  686. * before unlocking it, as the pixels might otherwise be uninitialized memory.
  687. *
  688. * Which is to say: locking and immediately unlocking a texture can result in
  689. * corrupted textures, depending on the renderer in use.
  690. *
  691. * \param texture a texture locked by SDL_LockTexture().
  692. *
  693. * \since This function is available since SDL 2.0.0.
  694. *
  695. * \sa SDL_LockTexture
  696. */
  697. extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
  698. /**
  699. * Determine whether a renderer supports the use of render targets.
  700. *
  701. * \param renderer the renderer that will be checked.
  702. * \returns SDL_TRUE if supported or SDL_FALSE if not.
  703. *
  704. * \since This function is available since SDL 2.0.0.
  705. *
  706. * \sa SDL_SetRenderTarget
  707. */
  708. extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
  709. /**
  710. * Set a texture as the current rendering target.
  711. *
  712. * Before using this function, you should check the
  713. * `SDL_RENDERER_TARGETTEXTURE` bit in the flags of SDL_RendererInfo to see if
  714. * render targets are supported.
  715. *
  716. * The default render target is the window for which the renderer was created.
  717. * To stop rendering to a texture and render to the window again, call this
  718. * function with a NULL `texture`. This will reset the renderer's viewport,
  719. * clipping rectangle, and scaling settings to the state they were in before
  720. * setting a non-NULL `texture` target, losing any changes made in the
  721. * meantime.
  722. *
  723. * \param renderer the rendering context.
  724. * \param texture the targeted texture, which must be created with the
  725. * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
  726. * window instead of a texture.
  727. * \returns 0 on success or a negative error code on failure; call
  728. * SDL_GetError() for more information.
  729. *
  730. * \since This function is available since SDL 2.0.0.
  731. *
  732. * \sa SDL_GetRenderTarget
  733. */
  734. extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
  735. SDL_Texture *texture);
  736. /**
  737. * Get the current render target.
  738. *
  739. * The default render target is the window for which the renderer was created,
  740. * and is reported a NULL here.
  741. *
  742. * \param renderer the rendering context.
  743. * \returns the current render target or NULL for the default render target.
  744. *
  745. * \since This function is available since SDL 2.0.0.
  746. *
  747. * \sa SDL_SetRenderTarget
  748. */
  749. extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  750. /**
  751. * Set a device independent resolution for rendering.
  752. *
  753. * This function uses the viewport and scaling functionality to allow a fixed
  754. * logical resolution for rendering, regardless of the actual output
  755. * resolution. If the actual output resolution doesn't have the same aspect
  756. * ratio the output rendering will be centered within the output display.
  757. *
  758. * If the output display is a window, mouse and touch events in the window
  759. * will be filtered and scaled so they seem to arrive within the logical
  760. * resolution. The SDL_HINT_MOUSE_RELATIVE_SCALING hint controls whether
  761. * relative motion events are also scaled.
  762. *
  763. * If this function results in scaling or subpixel drawing by the rendering
  764. * backend, it will be handled using the appropriate quality hints.
  765. *
  766. * \param renderer the renderer for which resolution should be set.
  767. * \param w the width of the logical resolution.
  768. * \param h the height of the logical resolution.
  769. * \returns 0 on success or a negative error code on failure; call
  770. * SDL_GetError() for more information.
  771. *
  772. * \since This function is available since SDL 2.0.0.
  773. *
  774. * \sa SDL_RenderGetLogicalSize
  775. */
  776. extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
  777. /**
  778. * Get device independent resolution for rendering.
  779. *
  780. * When using the main rendering target (eg no target texture is set): this
  781. * may return 0 for `w` and `h` if the SDL_Renderer has never had its logical
  782. * size set by SDL_RenderSetLogicalSize(). Otherwise it returns the logical
  783. * width and height.
  784. *
  785. * When using a target texture: Never return 0 for `w` and `h` at first. Then
  786. * it returns the logical width and height that are set.
  787. *
  788. * \param renderer a rendering context.
  789. * \param w an int to be filled with the width.
  790. * \param h an int to be filled with the height.
  791. *
  792. * \since This function is available since SDL 2.0.0.
  793. *
  794. * \sa SDL_RenderSetLogicalSize
  795. */
  796. extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
  797. /**
  798. * Set whether to force integer scales for resolution-independent rendering.
  799. *
  800. * This function restricts the logical viewport to integer values - that is,
  801. * when a resolution is between two multiples of a logical size, the viewport
  802. * size is rounded down to the lower multiple.
  803. *
  804. * \param renderer the renderer for which integer scaling should be set.
  805. * \param enable enable or disable the integer scaling for rendering.
  806. * \returns 0 on success or a negative error code on failure; call
  807. * SDL_GetError() for more information.
  808. *
  809. * \since This function is available since SDL 2.0.5.
  810. *
  811. * \sa SDL_RenderGetIntegerScale
  812. * \sa SDL_RenderSetLogicalSize
  813. */
  814. extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
  815. SDL_bool enable);
  816. /**
  817. * Get whether integer scales are forced for resolution-independent rendering.
  818. *
  819. * \param renderer the renderer from which integer scaling should be queried.
  820. * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on
  821. * failure; call SDL_GetError() for more information.
  822. *
  823. * \since This function is available since SDL 2.0.5.
  824. *
  825. * \sa SDL_RenderSetIntegerScale
  826. */
  827. extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
  828. /**
  829. * Set the drawing area for rendering on the current target.
  830. *
  831. * When the window is resized, the viewport is reset to fill the entire new
  832. * window size.
  833. *
  834. * \param renderer the rendering context.
  835. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  836. * to set the viewport to the entire target.
  837. * \returns 0 on success or a negative error code on failure; call
  838. * SDL_GetError() for more information.
  839. *
  840. * \since This function is available since SDL 2.0.0.
  841. *
  842. * \sa SDL_RenderGetViewport
  843. */
  844. extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
  845. const SDL_Rect * rect);
  846. /**
  847. * Get the drawing area for the current target.
  848. *
  849. * \param renderer the rendering context.
  850. * \param rect an SDL_Rect structure filled in with the current drawing area.
  851. *
  852. * \since This function is available since SDL 2.0.0.
  853. *
  854. * \sa SDL_RenderSetViewport
  855. */
  856. extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
  857. SDL_Rect * rect);
  858. /**
  859. * Set the clip rectangle for rendering on the specified target.
  860. *
  861. * \param renderer the rendering context for which clip rectangle should be
  862. * set.
  863. * \param rect an SDL_Rect structure representing the clip area, relative to
  864. * the viewport, or NULL to disable clipping.
  865. * \returns 0 on success or a negative error code on failure; call
  866. * SDL_GetError() for more information.
  867. *
  868. * \since This function is available since SDL 2.0.0.
  869. *
  870. * \sa SDL_RenderGetClipRect
  871. * \sa SDL_RenderIsClipEnabled
  872. */
  873. extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
  874. const SDL_Rect * rect);
  875. /**
  876. * Get the clip rectangle for the current target.
  877. *
  878. * \param renderer the rendering context from which clip rectangle should be
  879. * queried.
  880. * \param rect an SDL_Rect structure filled in with the current clipping area
  881. * or an empty rectangle if clipping is disabled.
  882. *
  883. * \since This function is available since SDL 2.0.0.
  884. *
  885. * \sa SDL_RenderIsClipEnabled
  886. * \sa SDL_RenderSetClipRect
  887. */
  888. extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
  889. SDL_Rect * rect);
  890. /**
  891. * Get whether clipping is enabled on the given renderer.
  892. *
  893. * \param renderer the renderer from which clip state should be queried.
  894. * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
  895. * SDL_GetError() for more information.
  896. *
  897. * \since This function is available since SDL 2.0.4.
  898. *
  899. * \sa SDL_RenderGetClipRect
  900. * \sa SDL_RenderSetClipRect
  901. */
  902. extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
  903. /**
  904. * Set the drawing scale for rendering on the current target.
  905. *
  906. * The drawing coordinates are scaled by the x/y scaling factors before they
  907. * are used by the renderer. This allows resolution independent drawing with a
  908. * single coordinate system.
  909. *
  910. * If this results in scaling or subpixel drawing by the rendering backend, it
  911. * will be handled using the appropriate quality hints. For best results use
  912. * integer scaling factors.
  913. *
  914. * \param renderer a rendering context.
  915. * \param scaleX the horizontal scaling factor.
  916. * \param scaleY the vertical scaling factor.
  917. * \returns 0 on success or a negative error code on failure; call
  918. * SDL_GetError() for more information.
  919. *
  920. * \since This function is available since SDL 2.0.0.
  921. *
  922. * \sa SDL_RenderGetScale
  923. * \sa SDL_RenderSetLogicalSize
  924. */
  925. extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
  926. float scaleX, float scaleY);
  927. /**
  928. * Get the drawing scale for the current target.
  929. *
  930. * \param renderer the renderer from which drawing scale should be queried.
  931. * \param scaleX a pointer filled in with the horizontal scaling factor.
  932. * \param scaleY a pointer filled in with the vertical scaling factor.
  933. *
  934. * \since This function is available since SDL 2.0.0.
  935. *
  936. * \sa SDL_RenderSetScale
  937. */
  938. extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
  939. float *scaleX, float *scaleY);
  940. /**
  941. * Get logical coordinates of point in renderer when given real coordinates of
  942. * point in window.
  943. *
  944. * Logical coordinates will differ from real coordinates when render is scaled
  945. * and logical renderer size set
  946. *
  947. * \param renderer the renderer from which the logical coordinates should be
  948. * calculated.
  949. * \param windowX the real X coordinate in the window.
  950. * \param windowY the real Y coordinate in the window.
  951. * \param logicalX the pointer filled with the logical x coordinate.
  952. * \param logicalY the pointer filled with the logical y coordinate.
  953. *
  954. * \since This function is available since SDL 2.0.18.
  955. *
  956. * \sa SDL_RenderGetScale
  957. * \sa SDL_RenderSetScale
  958. * \sa SDL_RenderGetLogicalSize
  959. * \sa SDL_RenderSetLogicalSize
  960. */
  961. extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
  962. int windowX, int windowY,
  963. float *logicalX, float *logicalY);
  964. /**
  965. * Get real coordinates of point in window when given logical coordinates of
  966. * point in renderer.
  967. *
  968. * Logical coordinates will differ from real coordinates when render is scaled
  969. * and logical renderer size set
  970. *
  971. * \param renderer the renderer from which the window coordinates should be
  972. * calculated.
  973. * \param logicalX the logical x coordinate.
  974. * \param logicalY the logical y coordinate.
  975. * \param windowX the pointer filled with the real X coordinate in the window.
  976. * \param windowY the pointer filled with the real Y coordinate in the window.
  977. *
  978. * \since This function is available since SDL 2.0.18.
  979. *
  980. * \sa SDL_RenderGetScale
  981. * \sa SDL_RenderSetScale
  982. * \sa SDL_RenderGetLogicalSize
  983. * \sa SDL_RenderSetLogicalSize
  984. */
  985. extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer,
  986. float logicalX, float logicalY,
  987. int *windowX, int *windowY);
  988. /**
  989. * Set the color used for drawing operations (Rect, Line and Clear).
  990. *
  991. * Set the color for drawing or filling rectangles, lines, and points, and for
  992. * SDL_RenderClear().
  993. *
  994. * \param renderer the rendering context.
  995. * \param r the red value used to draw on the rendering target.
  996. * \param g the green value used to draw on the rendering target.
  997. * \param b the blue value used to draw on the rendering target.
  998. * \param a the alpha value used to draw on the rendering target; usually
  999. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  1000. * specify how the alpha channel is used.
  1001. * \returns 0 on success or a negative error code on failure; call
  1002. * SDL_GetError() for more information.
  1003. *
  1004. * \since This function is available since SDL 2.0.0.
  1005. *
  1006. * \sa SDL_GetRenderDrawColor
  1007. * \sa SDL_RenderClear
  1008. * \sa SDL_RenderDrawLine
  1009. * \sa SDL_RenderDrawLines
  1010. * \sa SDL_RenderDrawPoint
  1011. * \sa SDL_RenderDrawPoints
  1012. * \sa SDL_RenderDrawRect
  1013. * \sa SDL_RenderDrawRects
  1014. * \sa SDL_RenderFillRect
  1015. * \sa SDL_RenderFillRects
  1016. */
  1017. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
  1018. Uint8 r, Uint8 g, Uint8 b,
  1019. Uint8 a);
  1020. /**
  1021. * Get the color used for drawing operations (Rect, Line and Clear).
  1022. *
  1023. * \param renderer the rendering context.
  1024. * \param r a pointer filled in with the red value used to draw on the
  1025. * rendering target.
  1026. * \param g a pointer filled in with the green value used to draw on the
  1027. * rendering target.
  1028. * \param b a pointer filled in with the blue value used to draw on the
  1029. * rendering target.
  1030. * \param a a pointer filled in with the alpha value used to draw on the
  1031. * rendering target; usually `SDL_ALPHA_OPAQUE` (255).
  1032. * \returns 0 on success or a negative error code on failure; call
  1033. * SDL_GetError() for more information.
  1034. *
  1035. * \since This function is available since SDL 2.0.0.
  1036. *
  1037. * \sa SDL_SetRenderDrawColor
  1038. */
  1039. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
  1040. Uint8 * r, Uint8 * g, Uint8 * b,
  1041. Uint8 * a);
  1042. /**
  1043. * Set the blend mode used for drawing operations (Fill and Line).
  1044. *
  1045. * If the blend mode is not supported, the closest supported mode is chosen.
  1046. *
  1047. * \param renderer the rendering context.
  1048. * \param blendMode the SDL_BlendMode to use for blending.
  1049. * \returns 0 on success or a negative error code on failure; call
  1050. * SDL_GetError() for more information.
  1051. *
  1052. * \since This function is available since SDL 2.0.0.
  1053. *
  1054. * \sa SDL_GetRenderDrawBlendMode
  1055. * \sa SDL_RenderDrawLine
  1056. * \sa SDL_RenderDrawLines
  1057. * \sa SDL_RenderDrawPoint
  1058. * \sa SDL_RenderDrawPoints
  1059. * \sa SDL_RenderDrawRect
  1060. * \sa SDL_RenderDrawRects
  1061. * \sa SDL_RenderFillRect
  1062. * \sa SDL_RenderFillRects
  1063. */
  1064. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
  1065. SDL_BlendMode blendMode);
  1066. /**
  1067. * Get the blend mode used for drawing operations.
  1068. *
  1069. * \param renderer the rendering context.
  1070. * \param blendMode a pointer filled in with the current SDL_BlendMode.
  1071. * \returns 0 on success or a negative error code on failure; call
  1072. * SDL_GetError() for more information.
  1073. *
  1074. * \since This function is available since SDL 2.0.0.
  1075. *
  1076. * \sa SDL_SetRenderDrawBlendMode
  1077. */
  1078. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
  1079. SDL_BlendMode *blendMode);
  1080. /**
  1081. * Clear the current rendering target with the drawing color.
  1082. *
  1083. * This function clears the entire rendering target, ignoring the viewport and
  1084. * the clip rectangle.
  1085. *
  1086. * \param renderer the rendering context.
  1087. * \returns 0 on success or a negative error code on failure; call
  1088. * SDL_GetError() for more information.
  1089. *
  1090. * \since This function is available since SDL 2.0.0.
  1091. *
  1092. * \sa SDL_SetRenderDrawColor
  1093. */
  1094. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
  1095. /**
  1096. * Draw a point on the current rendering target.
  1097. *
  1098. * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple,
  1099. * use SDL_RenderDrawPoints() instead.
  1100. *
  1101. * \param renderer the rendering context.
  1102. * \param x the x coordinate of the point.
  1103. * \param y the y coordinate of the point.
  1104. * \returns 0 on success or a negative error code on failure; call
  1105. * SDL_GetError() for more information.
  1106. *
  1107. * \since This function is available since SDL 2.0.0.
  1108. *
  1109. * \sa SDL_RenderDrawLine
  1110. * \sa SDL_RenderDrawLines
  1111. * \sa SDL_RenderDrawPoints
  1112. * \sa SDL_RenderDrawRect
  1113. * \sa SDL_RenderDrawRects
  1114. * \sa SDL_RenderFillRect
  1115. * \sa SDL_RenderFillRects
  1116. * \sa SDL_RenderPresent
  1117. * \sa SDL_SetRenderDrawBlendMode
  1118. * \sa SDL_SetRenderDrawColor
  1119. */
  1120. extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
  1121. int x, int y);
  1122. /**
  1123. * Draw multiple points on the current rendering target.
  1124. *
  1125. * \param renderer the rendering context.
  1126. * \param points an array of SDL_Point structures that represent the points to
  1127. * draw.
  1128. * \param count the number of points to draw.
  1129. * \returns 0 on success or a negative error code on failure; call
  1130. * SDL_GetError() for more information.
  1131. *
  1132. * \since This function is available since SDL 2.0.0.
  1133. *
  1134. * \sa SDL_RenderDrawLine
  1135. * \sa SDL_RenderDrawLines
  1136. * \sa SDL_RenderDrawPoint
  1137. * \sa SDL_RenderDrawRect
  1138. * \sa SDL_RenderDrawRects
  1139. * \sa SDL_RenderFillRect
  1140. * \sa SDL_RenderFillRects
  1141. * \sa SDL_RenderPresent
  1142. * \sa SDL_SetRenderDrawBlendMode
  1143. * \sa SDL_SetRenderDrawColor
  1144. */
  1145. extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
  1146. const SDL_Point * points,
  1147. int count);
  1148. /**
  1149. * Draw a line on the current rendering target.
  1150. *
  1151. * SDL_RenderDrawLine() draws the line to include both end points. If you want
  1152. * to draw multiple, connecting lines use SDL_RenderDrawLines() instead.
  1153. *
  1154. * \param renderer the rendering context.
  1155. * \param x1 the x coordinate of the start point.
  1156. * \param y1 the y coordinate of the start point.
  1157. * \param x2 the x coordinate of the end point.
  1158. * \param y2 the y coordinate of the end point.
  1159. * \returns 0 on success or a negative error code on failure; call
  1160. * SDL_GetError() for more information.
  1161. *
  1162. * \since This function is available since SDL 2.0.0.
  1163. *
  1164. * \sa SDL_RenderDrawLines
  1165. * \sa SDL_RenderDrawPoint
  1166. * \sa SDL_RenderDrawPoints
  1167. * \sa SDL_RenderDrawRect
  1168. * \sa SDL_RenderDrawRects
  1169. * \sa SDL_RenderFillRect
  1170. * \sa SDL_RenderFillRects
  1171. * \sa SDL_RenderPresent
  1172. * \sa SDL_SetRenderDrawBlendMode
  1173. * \sa SDL_SetRenderDrawColor
  1174. */
  1175. extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
  1176. int x1, int y1, int x2, int y2);
  1177. /**
  1178. * Draw a series of connected lines on the current rendering target.
  1179. *
  1180. * \param renderer the rendering context.
  1181. * \param points an array of SDL_Point structures representing points along
  1182. * the lines.
  1183. * \param count the number of points, drawing count-1 lines.
  1184. * \returns 0 on success or a negative error code on failure; call
  1185. * SDL_GetError() for more information.
  1186. *
  1187. * \since This function is available since SDL 2.0.0.
  1188. *
  1189. * \sa SDL_RenderDrawLine
  1190. * \sa SDL_RenderDrawPoint
  1191. * \sa SDL_RenderDrawPoints
  1192. * \sa SDL_RenderDrawRect
  1193. * \sa SDL_RenderDrawRects
  1194. * \sa SDL_RenderFillRect
  1195. * \sa SDL_RenderFillRects
  1196. * \sa SDL_RenderPresent
  1197. * \sa SDL_SetRenderDrawBlendMode
  1198. * \sa SDL_SetRenderDrawColor
  1199. */
  1200. extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
  1201. const SDL_Point * points,
  1202. int count);
  1203. /**
  1204. * Draw a rectangle on the current rendering target.
  1205. *
  1206. * \param renderer the rendering context.
  1207. * \param rect an SDL_Rect structure representing the rectangle to draw, or
  1208. * NULL to outline the entire rendering target.
  1209. * \returns 0 on success or a negative error code on failure; call
  1210. * SDL_GetError() for more information.
  1211. *
  1212. * \since This function is available since SDL 2.0.0.
  1213. *
  1214. * \sa SDL_RenderDrawLine
  1215. * \sa SDL_RenderDrawLines
  1216. * \sa SDL_RenderDrawPoint
  1217. * \sa SDL_RenderDrawPoints
  1218. * \sa SDL_RenderDrawRects
  1219. * \sa SDL_RenderFillRect
  1220. * \sa SDL_RenderFillRects
  1221. * \sa SDL_RenderPresent
  1222. * \sa SDL_SetRenderDrawBlendMode
  1223. * \sa SDL_SetRenderDrawColor
  1224. */
  1225. extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
  1226. const SDL_Rect * rect);
  1227. /**
  1228. * Draw some number of rectangles on the current rendering target.
  1229. *
  1230. * \param renderer the rendering context.
  1231. * \param rects an array of SDL_Rect structures representing the rectangles to
  1232. * be drawn.
  1233. * \param count the number of rectangles.
  1234. * \returns 0 on success or a negative error code on failure; call
  1235. * SDL_GetError() for more information.
  1236. *
  1237. * \since This function is available since SDL 2.0.0.
  1238. *
  1239. * \sa SDL_RenderDrawLine
  1240. * \sa SDL_RenderDrawLines
  1241. * \sa SDL_RenderDrawPoint
  1242. * \sa SDL_RenderDrawPoints
  1243. * \sa SDL_RenderDrawRect
  1244. * \sa SDL_RenderFillRect
  1245. * \sa SDL_RenderFillRects
  1246. * \sa SDL_RenderPresent
  1247. * \sa SDL_SetRenderDrawBlendMode
  1248. * \sa SDL_SetRenderDrawColor
  1249. */
  1250. extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
  1251. const SDL_Rect * rects,
  1252. int count);
  1253. /**
  1254. * Fill a rectangle on the current rendering target with the drawing color.
  1255. *
  1256. * The current drawing color is set by SDL_SetRenderDrawColor(), and the
  1257. * color's alpha value is ignored unless blending is enabled with the
  1258. * appropriate call to SDL_SetRenderDrawBlendMode().
  1259. *
  1260. * \param renderer the rendering context.
  1261. * \param rect the SDL_Rect structure representing the rectangle to fill, or
  1262. * NULL for the entire rendering target.
  1263. * \returns 0 on success or a negative error code on failure; call
  1264. * SDL_GetError() for more information.
  1265. *
  1266. * \since This function is available since SDL 2.0.0.
  1267. *
  1268. * \sa SDL_RenderDrawLine
  1269. * \sa SDL_RenderDrawLines
  1270. * \sa SDL_RenderDrawPoint
  1271. * \sa SDL_RenderDrawPoints
  1272. * \sa SDL_RenderDrawRect
  1273. * \sa SDL_RenderDrawRects
  1274. * \sa SDL_RenderFillRects
  1275. * \sa SDL_RenderPresent
  1276. * \sa SDL_SetRenderDrawBlendMode
  1277. * \sa SDL_SetRenderDrawColor
  1278. */
  1279. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
  1280. const SDL_Rect * rect);
  1281. /**
  1282. * Fill some number of rectangles on the current rendering target with the
  1283. * drawing color.
  1284. *
  1285. * \param renderer the rendering context.
  1286. * \param rects an array of SDL_Rect structures representing the rectangles to
  1287. * be filled.
  1288. * \param count the number of rectangles.
  1289. * \returns 0 on success or a negative error code on failure; call
  1290. * SDL_GetError() for more information.
  1291. *
  1292. * \since This function is available since SDL 2.0.0.
  1293. *
  1294. * \sa SDL_RenderDrawLine
  1295. * \sa SDL_RenderDrawLines
  1296. * \sa SDL_RenderDrawPoint
  1297. * \sa SDL_RenderDrawPoints
  1298. * \sa SDL_RenderDrawRect
  1299. * \sa SDL_RenderDrawRects
  1300. * \sa SDL_RenderFillRect
  1301. * \sa SDL_RenderPresent
  1302. */
  1303. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
  1304. const SDL_Rect * rects,
  1305. int count);
  1306. /**
  1307. * Copy a portion of the texture to the current rendering target.
  1308. *
  1309. * The texture is blended with the destination based on its blend mode set
  1310. * with SDL_SetTextureBlendMode().
  1311. *
  1312. * The texture color is affected based on its color modulation set by
  1313. * SDL_SetTextureColorMod().
  1314. *
  1315. * The texture alpha is affected based on its alpha modulation set by
  1316. * SDL_SetTextureAlphaMod().
  1317. *
  1318. * \param renderer the rendering context.
  1319. * \param texture the source texture.
  1320. * \param srcrect the source SDL_Rect structure or NULL for the entire
  1321. * texture.
  1322. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1323. * rendering target; the texture will be stretched to fill the
  1324. * given rectangle.
  1325. * \returns 0 on success or a negative error code on failure; call
  1326. * SDL_GetError() for more information.
  1327. *
  1328. * \since This function is available since SDL 2.0.0.
  1329. *
  1330. * \sa SDL_RenderCopyEx
  1331. * \sa SDL_SetTextureAlphaMod
  1332. * \sa SDL_SetTextureBlendMode
  1333. * \sa SDL_SetTextureColorMod
  1334. */
  1335. extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
  1336. SDL_Texture * texture,
  1337. const SDL_Rect * srcrect,
  1338. const SDL_Rect * dstrect);
  1339. /**
  1340. * Copy a portion of the texture to the current rendering, with optional
  1341. * rotation and flipping.
  1342. *
  1343. * Copy a portion of the texture to the current rendering target, optionally
  1344. * rotating it by angle around the given center and also flipping it
  1345. * top-bottom and/or left-right.
  1346. *
  1347. * The texture is blended with the destination based on its blend mode set
  1348. * with SDL_SetTextureBlendMode().
  1349. *
  1350. * The texture color is affected based on its color modulation set by
  1351. * SDL_SetTextureColorMod().
  1352. *
  1353. * The texture alpha is affected based on its alpha modulation set by
  1354. * SDL_SetTextureAlphaMod().
  1355. *
  1356. * \param renderer the rendering context.
  1357. * \param texture the source texture.
  1358. * \param srcrect the source SDL_Rect structure or NULL for the entire
  1359. * texture.
  1360. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1361. * rendering target.
  1362. * \param angle an angle in degrees that indicates the rotation that will be
  1363. * applied to dstrect, rotating it in a clockwise direction.
  1364. * \param center a pointer to a point indicating the point around which
  1365. * dstrect will be rotated (if NULL, rotation will be done
  1366. * around `dstrect.w / 2`, `dstrect.h / 2`).
  1367. * \param flip a SDL_RendererFlip value stating which flipping actions should
  1368. * be performed on the texture.
  1369. * \returns 0 on success or a negative error code on failure; call
  1370. * SDL_GetError() for more information.
  1371. *
  1372. * \since This function is available since SDL 2.0.0.
  1373. *
  1374. * \sa SDL_RenderCopy
  1375. * \sa SDL_SetTextureAlphaMod
  1376. * \sa SDL_SetTextureBlendMode
  1377. * \sa SDL_SetTextureColorMod
  1378. */
  1379. extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
  1380. SDL_Texture * texture,
  1381. const SDL_Rect * srcrect,
  1382. const SDL_Rect * dstrect,
  1383. const double angle,
  1384. const SDL_Point *center,
  1385. const SDL_RendererFlip flip);
  1386. /**
  1387. * Draw a point on the current rendering target at subpixel precision.
  1388. *
  1389. * \param renderer The renderer which should draw a point.
  1390. * \param x The x coordinate of the point.
  1391. * \param y The y coordinate of the point.
  1392. * \return 0 on success, or -1 on error.
  1393. *
  1394. * \since This function is available since SDL 2.0.10.
  1395. */
  1396. extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
  1397. float x, float y);
  1398. /**
  1399. * Draw multiple points on the current rendering target at subpixel precision.
  1400. *
  1401. * \param renderer The renderer which should draw multiple points.
  1402. * \param points The points to draw.
  1403. * \param count The number of points to draw.
  1404. * \return 0 on success, or -1 on error.
  1405. *
  1406. * \since This function is available since SDL 2.0.10.
  1407. */
  1408. extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
  1409. const SDL_FPoint * points,
  1410. int count);
  1411. /**
  1412. * Draw a line on the current rendering target at subpixel precision.
  1413. *
  1414. * \param renderer The renderer which should draw a line.
  1415. * \param x1 The x coordinate of the start point.
  1416. * \param y1 The y coordinate of the start point.
  1417. * \param x2 The x coordinate of the end point.
  1418. * \param y2 The y coordinate of the end point.
  1419. * \return 0 on success, or -1 on error.
  1420. *
  1421. * \since This function is available since SDL 2.0.10.
  1422. */
  1423. extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
  1424. float x1, float y1, float x2, float y2);
  1425. /**
  1426. * Draw a series of connected lines on the current rendering target at
  1427. * subpixel precision.
  1428. *
  1429. * \param renderer The renderer which should draw multiple lines.
  1430. * \param points The points along the lines.
  1431. * \param count The number of points, drawing count-1 lines.
  1432. * \return 0 on success, or -1 on error.
  1433. *
  1434. * \since This function is available since SDL 2.0.10.
  1435. */
  1436. extern DECLSPEC int SDLCALL SDL_RenderDrawLinesF(SDL_Renderer * renderer,
  1437. const SDL_FPoint * points,
  1438. int count);
  1439. /**
  1440. * Draw a rectangle on the current rendering target at subpixel precision.
  1441. *
  1442. * \param renderer The renderer which should draw a rectangle.
  1443. * \param rect A pointer to the destination rectangle, or NULL to outline the
  1444. * entire rendering target.
  1445. * \return 0 on success, or -1 on error.
  1446. *
  1447. * \since This function is available since SDL 2.0.10.
  1448. */
  1449. extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
  1450. const SDL_FRect * rect);
  1451. /**
  1452. * Draw some number of rectangles on the current rendering target at subpixel
  1453. * precision.
  1454. *
  1455. * \param renderer The renderer which should draw multiple rectangles.
  1456. * \param rects A pointer to an array of destination rectangles.
  1457. * \param count The number of rectangles.
  1458. * \return 0 on success, or -1 on error.
  1459. *
  1460. * \since This function is available since SDL 2.0.10.
  1461. */
  1462. extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
  1463. const SDL_FRect * rects,
  1464. int count);
  1465. /**
  1466. * Fill a rectangle on the current rendering target with the drawing color at
  1467. * subpixel precision.
  1468. *
  1469. * \param renderer The renderer which should fill a rectangle.
  1470. * \param rect A pointer to the destination rectangle, or NULL for the entire
  1471. * rendering target.
  1472. * \return 0 on success, or -1 on error.
  1473. *
  1474. * \since This function is available since SDL 2.0.10.
  1475. */
  1476. extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
  1477. const SDL_FRect * rect);
  1478. /**
  1479. * Fill some number of rectangles on the current rendering target with the
  1480. * drawing color at subpixel precision.
  1481. *
  1482. * \param renderer The renderer which should fill multiple rectangles.
  1483. * \param rects A pointer to an array of destination rectangles.
  1484. * \param count The number of rectangles.
  1485. * \return 0 on success, or -1 on error.
  1486. *
  1487. * \since This function is available since SDL 2.0.10.
  1488. */
  1489. extern DECLSPEC int SDLCALL SDL_RenderFillRectsF(SDL_Renderer * renderer,
  1490. const SDL_FRect * rects,
  1491. int count);
  1492. /**
  1493. * Copy a portion of the texture to the current rendering target at subpixel
  1494. * precision.
  1495. *
  1496. * \param renderer The renderer which should copy parts of a texture.
  1497. * \param texture The source texture.
  1498. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1499. * texture.
  1500. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1501. * entire rendering target.
  1502. * \return 0 on success, or -1 on error.
  1503. *
  1504. * \since This function is available since SDL 2.0.10.
  1505. */
  1506. extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
  1507. SDL_Texture * texture,
  1508. const SDL_Rect * srcrect,
  1509. const SDL_FRect * dstrect);
  1510. /**
  1511. * Copy a portion of the source texture to the current rendering target, with
  1512. * rotation and flipping, at subpixel precision.
  1513. *
  1514. * \param renderer The renderer which should copy parts of a texture.
  1515. * \param texture The source texture.
  1516. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1517. * texture.
  1518. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1519. * entire rendering target.
  1520. * \param angle An angle in degrees that indicates the rotation that will be
  1521. * applied to dstrect, rotating it in a clockwise direction.
  1522. * \param center A pointer to a point indicating the point around which
  1523. * dstrect will be rotated (if NULL, rotation will be done
  1524. * around dstrect.w/2, dstrect.h/2).
  1525. * \param flip An SDL_RendererFlip value stating which flipping actions should
  1526. * be performed on the texture.
  1527. * \return 0 on success, or -1 on error.
  1528. *
  1529. * \since This function is available since SDL 2.0.10.
  1530. */
  1531. extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
  1532. SDL_Texture * texture,
  1533. const SDL_Rect * srcrect,
  1534. const SDL_FRect * dstrect,
  1535. const double angle,
  1536. const SDL_FPoint *center,
  1537. const SDL_RendererFlip flip);
  1538. /**
  1539. * Render a list of triangles, optionally using a texture and indices into the
  1540. * vertex array Color and alpha modulation is done per vertex
  1541. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1542. *
  1543. * \param renderer The rendering context.
  1544. * \param texture (optional) The SDL texture to use.
  1545. * \param vertices Vertices.
  1546. * \param num_vertices Number of vertices.
  1547. * \param indices (optional) An array of integer indices into the 'vertices'
  1548. * array, if NULL all vertices will be rendered in sequential
  1549. * order.
  1550. * \param num_indices Number of indices.
  1551. * \return 0 on success, or -1 if the operation is not supported.
  1552. *
  1553. * \since This function is available since SDL 2.0.18.
  1554. *
  1555. * \sa SDL_RenderGeometryRaw
  1556. * \sa SDL_Vertex
  1557. */
  1558. extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  1559. SDL_Texture *texture,
  1560. const SDL_Vertex *vertices, int num_vertices,
  1561. const int *indices, int num_indices);
  1562. /**
  1563. * Render a list of triangles, optionally using a texture and indices into the
  1564. * vertex arrays Color and alpha modulation is done per vertex
  1565. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1566. *
  1567. * \param renderer The rendering context.
  1568. * \param texture (optional) The SDL texture to use.
  1569. * \param xy Vertex positions.
  1570. * \param xy_stride Byte size to move from one element to the next element.
  1571. * \param color Vertex colors (as SDL_Color).
  1572. * \param color_stride Byte size to move from one element to the next element.
  1573. * \param uv Vertex normalized texture coordinates.
  1574. * \param uv_stride Byte size to move from one element to the next element.
  1575. * \param num_vertices Number of vertices.
  1576. * \param indices (optional) An array of indices into the 'vertices' arrays,
  1577. * if NULL all vertices will be rendered in sequential order.
  1578. * \param num_indices Number of indices.
  1579. * \param size_indices Index size: 1 (byte), 2 (short), 4 (int).
  1580. * \return 0 on success, or -1 if the operation is not supported.
  1581. *
  1582. * \since This function is available since SDL 2.0.18.
  1583. *
  1584. * \sa SDL_RenderGeometry
  1585. * \sa SDL_Vertex
  1586. */
  1587. extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  1588. SDL_Texture *texture,
  1589. const float *xy, int xy_stride,
  1590. const SDL_Color *color, int color_stride,
  1591. const float *uv, int uv_stride,
  1592. int num_vertices,
  1593. const void *indices, int num_indices, int size_indices);
  1594. /**
  1595. * Read pixels from the current rendering target to an array of pixels.
  1596. *
  1597. * **WARNING**: This is a very slow operation, and should not be used
  1598. * frequently. If you're using this on the main rendering target, it should be
  1599. * called after rendering and before SDL_RenderPresent().
  1600. *
  1601. * `pitch` specifies the number of bytes between rows in the destination
  1602. * `pixels` data. This allows you to write to a subrectangle or have padded
  1603. * rows in the destination. Generally, `pitch` should equal the number of
  1604. * pixels per row in the `pixels` data times the number of bytes per pixel,
  1605. * but it might contain additional padding (for example, 24bit RGB Windows
  1606. * Bitmap data pads all rows to multiples of 4 bytes).
  1607. *
  1608. * \param renderer the rendering context.
  1609. * \param rect an SDL_Rect structure representing the area to read, or NULL
  1610. * for the entire render target.
  1611. * \param format an SDL_PixelFormatEnum value of the desired format of the
  1612. * pixel data, or 0 to use the format of the rendering target.
  1613. * \param pixels a pointer to the pixel data to copy into.
  1614. * \param pitch the pitch of the `pixels` parameter.
  1615. * \returns 0 on success or a negative error code on failure; call
  1616. * SDL_GetError() for more information.
  1617. *
  1618. * \since This function is available since SDL 2.0.0.
  1619. */
  1620. extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
  1621. const SDL_Rect * rect,
  1622. Uint32 format,
  1623. void *pixels, int pitch);
  1624. /**
  1625. * Update the screen with any rendering performed since the previous call.
  1626. *
  1627. * SDL's rendering functions operate on a backbuffer; that is, calling a
  1628. * rendering function such as SDL_RenderDrawLine() does not directly put a
  1629. * line on the screen, but rather updates the backbuffer. As such, you compose
  1630. * your entire scene and *present* the composed backbuffer to the screen as a
  1631. * complete picture.
  1632. *
  1633. * Therefore, when using SDL's rendering API, one does all drawing intended
  1634. * for the frame, and then calls this function once per frame to present the
  1635. * final drawing to the user.
  1636. *
  1637. * The backbuffer should be considered invalidated after each present; do not
  1638. * assume that previous contents will exist between frames. You are strongly
  1639. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  1640. * starting each new frame's drawing, even if you plan to overwrite every
  1641. * pixel.
  1642. *
  1643. * \param renderer the rendering context.
  1644. *
  1645. * \threadsafety You may only call this function on the main thread. If this
  1646. * happens to work on a background thread on any given platform
  1647. * or backend, it's purely by luck and you should not rely on it
  1648. * to work next time.
  1649. *
  1650. * \since This function is available since SDL 2.0.0.
  1651. *
  1652. * \sa SDL_CreateRenderer
  1653. * \sa SDL_RenderClear
  1654. * \sa SDL_RenderDrawLine
  1655. * \sa SDL_RenderDrawLines
  1656. * \sa SDL_RenderDrawPoint
  1657. * \sa SDL_RenderDrawPoints
  1658. * \sa SDL_RenderDrawRect
  1659. * \sa SDL_RenderDrawRects
  1660. * \sa SDL_RenderFillRect
  1661. * \sa SDL_RenderFillRects
  1662. * \sa SDL_SetRenderDrawBlendMode
  1663. * \sa SDL_SetRenderDrawColor
  1664. */
  1665. extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
  1666. /**
  1667. * Destroy the specified texture.
  1668. *
  1669. * Passing NULL or an otherwise invalid texture will set the SDL error message
  1670. * to "Invalid texture".
  1671. *
  1672. * \param texture the texture to destroy.
  1673. *
  1674. * \since This function is available since SDL 2.0.0.
  1675. *
  1676. * \sa SDL_CreateTexture
  1677. * \sa SDL_CreateTextureFromSurface
  1678. */
  1679. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
  1680. /**
  1681. * Destroy the rendering context for a window and free associated textures.
  1682. *
  1683. * If `renderer` is NULL, this function will return immediately after setting
  1684. * the SDL error message to "Invalid renderer". See SDL_GetError().
  1685. *
  1686. * \param renderer the rendering context.
  1687. *
  1688. * \since This function is available since SDL 2.0.0.
  1689. *
  1690. * \sa SDL_CreateRenderer
  1691. */
  1692. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
  1693. /**
  1694. * Force the rendering context to flush any pending commands to the underlying
  1695. * rendering API.
  1696. *
  1697. * You do not need to (and in fact, shouldn't) call this function unless you
  1698. * are planning to call into OpenGL/Direct3D/Metal/whatever directly in
  1699. * addition to using an SDL_Renderer.
  1700. *
  1701. * This is for a very-specific case: if you are using SDL's render API, you
  1702. * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set
  1703. * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
  1704. * calls in addition to SDL render API calls. If all of this applies, you
  1705. * should call SDL_RenderFlush() between calls to SDL's render API and the
  1706. * low-level API you're using in cooperation.
  1707. *
  1708. * In all other cases, you can ignore this function. This is only here to get
  1709. * maximum performance out of a specific situation. In all other cases, SDL
  1710. * will do the right thing, perhaps at a performance loss.
  1711. *
  1712. * This function is first available in SDL 2.0.10, and is not needed in 2.0.9
  1713. * and earlier, as earlier versions did not queue rendering commands at all,
  1714. * instead flushing them to the OS immediately.
  1715. *
  1716. * \param renderer the rendering context.
  1717. * \returns 0 on success or a negative error code on failure; call
  1718. * SDL_GetError() for more information.
  1719. *
  1720. * \since This function is available since SDL 2.0.10.
  1721. */
  1722. extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
  1723. /**
  1724. * Bind an OpenGL/ES/ES2 texture to the current context.
  1725. *
  1726. * This is for use with OpenGL instructions when rendering OpenGL primitives
  1727. * directly.
  1728. *
  1729. * If not NULL, `texw` and `texh` will be filled with the width and height
  1730. * values suitable for the provided texture. In most cases, both will be 1.0,
  1731. * however, on systems that support the GL_ARB_texture_rectangle extension,
  1732. * these values will actually be the pixel width and height used to create the
  1733. * texture, so this factor needs to be taken into account when providing
  1734. * texture coordinates to OpenGL.
  1735. *
  1736. * You need a renderer to create an SDL_Texture, therefore you can only use
  1737. * this function with an implicit OpenGL context from SDL_CreateRenderer(),
  1738. * not with your own OpenGL context. If you need control over your OpenGL
  1739. * context, you need to write your own texture-loading methods.
  1740. *
  1741. * Also note that SDL may upload RGB textures as BGR (or vice-versa), and
  1742. * re-order the color channels in the shaders phase, so the uploaded texture
  1743. * may have swapped color channels.
  1744. *
  1745. * \param texture the texture to bind to the current OpenGL/ES/ES2 context.
  1746. * \param texw a pointer to a float value which will be filled with the
  1747. * texture width or NULL if you don't need that value.
  1748. * \param texh a pointer to a float value which will be filled with the
  1749. * texture height or NULL if you don't need that value.
  1750. * \returns 0 on success, or -1 if the operation is not supported; call
  1751. * SDL_GetError() for more information.
  1752. *
  1753. * \since This function is available since SDL 2.0.0.
  1754. *
  1755. * \sa SDL_GL_MakeCurrent
  1756. * \sa SDL_GL_UnbindTexture
  1757. */
  1758. extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
  1759. /**
  1760. * Unbind an OpenGL/ES/ES2 texture from the current context.
  1761. *
  1762. * See SDL_GL_BindTexture() for examples on how to use these functions
  1763. *
  1764. * \param texture the texture to unbind from the current OpenGL/ES/ES2
  1765. * context.
  1766. * \returns 0 on success, or -1 if the operation is not supported.
  1767. *
  1768. * \since This function is available since SDL 2.0.0.
  1769. *
  1770. * \sa SDL_GL_BindTexture
  1771. * \sa SDL_GL_MakeCurrent
  1772. */
  1773. extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
  1774. /**
  1775. * Get the CAMetalLayer associated with the given Metal renderer.
  1776. *
  1777. * This function returns `void *`, so SDL doesn't have to include Metal's
  1778. * headers, but it can be safely cast to a `CAMetalLayer *`.
  1779. *
  1780. * \param renderer The renderer to query.
  1781. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  1782. * Metal renderer.
  1783. *
  1784. * \since This function is available since SDL 2.0.8.
  1785. *
  1786. * \sa SDL_RenderGetMetalCommandEncoder
  1787. */
  1788. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
  1789. /**
  1790. * Get the Metal command encoder for the current frame
  1791. *
  1792. * This function returns `void *`, so SDL doesn't have to include Metal's
  1793. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  1794. *
  1795. * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
  1796. * SDL a drawable to render to, which might happen if the window is
  1797. * hidden/minimized/offscreen. This doesn't apply to command encoders for
  1798. * render targets, just the window's backbuffer. Check your return values!
  1799. *
  1800. * \param renderer The renderer to query.
  1801. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  1802. * renderer isn't a Metal renderer or there was an error.
  1803. *
  1804. * \since This function is available since SDL 2.0.8.
  1805. *
  1806. * \sa SDL_RenderGetMetalLayer
  1807. */
  1808. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
  1809. /**
  1810. * Toggle VSync of the given renderer.
  1811. *
  1812. * \param renderer The renderer to toggle.
  1813. * \param vsync 1 for on, 0 for off. All other values are reserved.
  1814. * \returns a 0 int on success, or non-zero on failure.
  1815. *
  1816. * \since This function is available since SDL 2.0.18.
  1817. */
  1818. extern DECLSPEC int SDLCALL SDL_RenderSetVSync(SDL_Renderer* renderer, int vsync);
  1819. /* Ends C function definitions when using C++ */
  1820. #ifdef __cplusplus
  1821. }
  1822. #endif
  1823. #include "close_code.h"
  1824. #endif /* SDL_render_h_ */
  1825. /* vi: set ts=4 sw=4 expandtab: */