SDL_render.h 69 KB

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