SDL_render.h 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 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 2.0.18.
  495. *
  496. * \sa SDL_GetTextureUserData
  497. */
  498. extern DECLSPEC int SDLCALL SDL_SetTextureUserData(SDL_Texture * texture,
  499. void *userdata);
  500. /**
  501. * Get the user-specified pointer associated with a texture
  502. *
  503. * \param texture the texture to query.
  504. * \return the pointer associated with the texture, or NULL if the texture is
  505. * not valid.
  506. *
  507. * \since This function is available since SDL 2.0.18.
  508. *
  509. * \sa SDL_SetTextureUserData
  510. */
  511. extern DECLSPEC void * SDLCALL SDL_GetTextureUserData(SDL_Texture * texture);
  512. /**
  513. * Update the given texture rectangle with new pixel data.
  514. *
  515. * The pixel data must be in the pixel format of the texture. Use
  516. * SDL_QueryTexture() to query the pixel format of the texture.
  517. *
  518. * This is a fairly slow function, intended for use with static textures that
  519. * do not change often.
  520. *
  521. * If the texture is intended to be updated often, it is preferred to create
  522. * the texture as streaming and use the locking functions referenced below.
  523. * While this function will work with streaming textures, for optimization
  524. * reasons you may not get the pixels back if you lock the texture afterward.
  525. *
  526. * \param texture the texture to update
  527. * \param rect an SDL_Rect structure representing the area to update, or NULL
  528. * to update the entire texture
  529. * \param pixels the raw pixel data in the format of the texture
  530. * \param pitch the number of bytes in a row of pixel data, including padding
  531. * between lines
  532. * \returns 0 on success or a negative error code on failure; call
  533. * SDL_GetError() for more information.
  534. *
  535. * \since This function is available since SDL 2.0.0.
  536. *
  537. * \sa SDL_CreateTexture
  538. * \sa SDL_LockTexture
  539. * \sa SDL_UnlockTexture
  540. */
  541. extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture,
  542. const SDL_Rect * rect,
  543. const void *pixels, int pitch);
  544. /**
  545. * Update a rectangle within a planar YV12 or IYUV texture with new pixel
  546. * data.
  547. *
  548. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  549. * block of Y and U/V planes in the proper order, but this function is
  550. * available if your pixel data is not contiguous.
  551. *
  552. * \param texture the texture to update
  553. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  554. * update the entire texture
  555. * \param Yplane the raw pixel data for the Y plane
  556. * \param Ypitch the number of bytes between rows of pixel data for the Y
  557. * plane
  558. * \param Uplane the raw pixel data for the U plane
  559. * \param Upitch the number of bytes between rows of pixel data for the U
  560. * plane
  561. * \param Vplane the raw pixel data for the V plane
  562. * \param Vpitch the number of bytes between rows of pixel data for the V
  563. * plane
  564. * \returns 0 on success or -1 if the texture is not valid; call
  565. * SDL_GetError() for more information.
  566. *
  567. * \since This function is available since SDL 2.0.1.
  568. *
  569. * \sa SDL_UpdateTexture
  570. */
  571. extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture * texture,
  572. const SDL_Rect * rect,
  573. const Uint8 *Yplane, int Ypitch,
  574. const Uint8 *Uplane, int Upitch,
  575. const Uint8 *Vplane, int Vpitch);
  576. /**
  577. * Update a rectangle within a planar NV12 or NV21 texture with new pixels.
  578. *
  579. * You can use SDL_UpdateTexture() as long as your pixel data is a contiguous
  580. * block of NV12/21 planes in the proper order, but this function is available
  581. * if your pixel data is not contiguous.
  582. *
  583. * \param texture the texture to update
  584. * \param rect a pointer to the rectangle of pixels to update, or NULL to
  585. * update the entire texture.
  586. * \param Yplane the raw pixel data for the Y plane.
  587. * \param Ypitch the number of bytes between rows of pixel data for the Y
  588. * plane.
  589. * \param UVplane the raw pixel data for the UV plane.
  590. * \param UVpitch the number of bytes between rows of pixel data for the UV
  591. * plane.
  592. * \return 0 on success, or -1 if the texture is not valid.
  593. *
  594. * \since This function is available since SDL 2.0.16.
  595. */
  596. extern DECLSPEC int SDLCALL SDL_UpdateNVTexture(SDL_Texture * texture,
  597. const SDL_Rect * rect,
  598. const Uint8 *Yplane, int Ypitch,
  599. const Uint8 *UVplane, int UVpitch);
  600. /**
  601. * Lock a portion of the texture for **write-only** pixel access.
  602. *
  603. * As an optimization, the pixels made available for editing don't necessarily
  604. * contain the old texture data. This is a write-only operation, and if you
  605. * need to keep a copy of the texture data you should do that at the
  606. * application level.
  607. *
  608. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  609. * changes.
  610. *
  611. * \param texture the texture to lock for access, which was created with
  612. * `SDL_TEXTUREACCESS_STREAMING`
  613. * \param rect an SDL_Rect structure representing the area to lock for access;
  614. * NULL to lock the entire texture
  615. * \param pixels this is filled in with a pointer to the locked pixels,
  616. * appropriately offset by the locked area
  617. * \param pitch this is filled in with the pitch of the locked pixels; the
  618. * pitch is the length of one row in bytes
  619. * \returns 0 on success or a negative error code if the texture is not valid
  620. * or was not created with `SDL_TEXTUREACCESS_STREAMING`; call
  621. * SDL_GetError() for more information.
  622. *
  623. * \since This function is available since SDL 2.0.0.
  624. *
  625. * \sa SDL_UnlockTexture
  626. */
  627. extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture,
  628. const SDL_Rect * rect,
  629. void **pixels, int *pitch);
  630. /**
  631. * Lock a portion of the texture for **write-only** pixel access, and expose
  632. * it as a SDL surface.
  633. *
  634. * Besides providing an SDL_Surface instead of raw pixel data, this function
  635. * operates like SDL_LockTexture.
  636. *
  637. * As an optimization, the pixels made available for editing don't necessarily
  638. * contain the old texture data. This is a write-only operation, and if you
  639. * need to keep a copy of the texture data you should do that at the
  640. * application level.
  641. *
  642. * You must use SDL_UnlockTexture() to unlock the pixels and apply any
  643. * changes.
  644. *
  645. * The returned surface is freed internally after calling SDL_UnlockTexture()
  646. * or SDL_DestroyTexture(). The caller should not free it.
  647. *
  648. * \param texture the texture to lock for access, which was created with
  649. * `SDL_TEXTUREACCESS_STREAMING`
  650. * \param rect a pointer to the rectangle to lock for access. If the rect is
  651. * NULL, the entire texture will be locked
  652. * \param surface this is filled in with an SDL surface representing the
  653. * locked area
  654. * \returns 0 on success, or -1 if the texture is not valid or was not created
  655. * with `SDL_TEXTUREACCESS_STREAMING`
  656. *
  657. * \since This function is available since SDL 2.0.12.
  658. *
  659. * \sa SDL_LockTexture
  660. * \sa SDL_UnlockTexture
  661. */
  662. extern DECLSPEC int SDLCALL SDL_LockTextureToSurface(SDL_Texture *texture,
  663. const SDL_Rect *rect,
  664. SDL_Surface **surface);
  665. /**
  666. * Unlock a texture, uploading the changes to video memory, if needed.
  667. *
  668. * **Warning**: Please note that SDL_LockTexture() is intended to be
  669. * write-only; it will not guarantee the previous contents of the texture will
  670. * be provided. You must fully initialize any area of a texture that you lock
  671. * before unlocking it, as the pixels might otherwise be uninitialized memory.
  672. *
  673. * Which is to say: locking and immediately unlocking a texture can result in
  674. * corrupted textures, depending on the renderer in use.
  675. *
  676. * \param texture a texture locked by SDL_LockTexture()
  677. *
  678. * \since This function is available since SDL 2.0.0.
  679. *
  680. * \sa SDL_LockTexture
  681. */
  682. extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture);
  683. /**
  684. * Determine whether a renderer supports the use of render targets.
  685. *
  686. * \param renderer the renderer that will be checked
  687. * \returns SDL_TRUE if supported or SDL_FALSE if not.
  688. *
  689. * \since This function is available since SDL 2.0.0.
  690. *
  691. * \sa SDL_SetRenderTarget
  692. */
  693. extern DECLSPEC SDL_bool SDLCALL SDL_RenderTargetSupported(SDL_Renderer *renderer);
  694. /**
  695. * Set a texture as the current rendering target.
  696. *
  697. * Before using this function, you should check the
  698. * `SDL_RENDERER_TARGETTEXTURE` bit in the flags of SDL_RendererInfo to see if
  699. * render targets are supported.
  700. *
  701. * The default render target is the window for which the renderer was created.
  702. * To stop rendering to a texture and render to the window again, call this
  703. * function with a NULL `texture`.
  704. *
  705. * \param renderer the rendering context
  706. * \param texture the targeted texture, which must be created with the
  707. * `SDL_TEXTUREACCESS_TARGET` flag, or NULL to render to the
  708. * window instead of a texture.
  709. * \returns 0 on success or a negative error code on failure; call
  710. * SDL_GetError() for more information.
  711. *
  712. * \since This function is available since SDL 2.0.0.
  713. *
  714. * \sa SDL_GetRenderTarget
  715. */
  716. extern DECLSPEC int SDLCALL SDL_SetRenderTarget(SDL_Renderer *renderer,
  717. SDL_Texture *texture);
  718. /**
  719. * Get the current render target.
  720. *
  721. * The default render target is the window for which the renderer was created,
  722. * and is reported a NULL here.
  723. *
  724. * \param renderer the rendering context
  725. * \returns the current render target or NULL for the default render target.
  726. *
  727. * \since This function is available since SDL 2.0.0.
  728. *
  729. * \sa SDL_SetRenderTarget
  730. */
  731. extern DECLSPEC SDL_Texture * SDLCALL SDL_GetRenderTarget(SDL_Renderer *renderer);
  732. /**
  733. * Set a device independent resolution for rendering.
  734. *
  735. * This function uses the viewport and scaling functionality to allow a fixed
  736. * logical resolution for rendering, regardless of the actual output
  737. * resolution. If the actual output resolution doesn't have the same aspect
  738. * ratio the output rendering will be centered within the output display.
  739. *
  740. * If the output display is a window, mouse and touch events in the window
  741. * will be filtered and scaled so they seem to arrive within the logical
  742. * resolution. The SDL_HINT_MOUSE_RELATIVE_SCALING hint controls whether
  743. * relative motion events are also scaled.
  744. *
  745. * If this function results in scaling or subpixel drawing by the rendering
  746. * backend, it will be handled using the appropriate quality hints.
  747. *
  748. * \param renderer the renderer for which resolution should be set
  749. * \param w the width of the logical resolution
  750. * \param h the height of the logical resolution
  751. * \returns 0 on success or a negative error code on failure; call
  752. * SDL_GetError() for more information.
  753. *
  754. * \since This function is available since SDL 2.0.0.
  755. *
  756. * \sa SDL_RenderGetLogicalSize
  757. */
  758. extern DECLSPEC int SDLCALL SDL_RenderSetLogicalSize(SDL_Renderer * renderer, int w, int h);
  759. /**
  760. * Get device independent resolution for rendering.
  761. *
  762. * This may return 0 for `w` and `h` if the SDL_Renderer has never had its
  763. * logical size set by SDL_RenderSetLogicalSize() and never had a render
  764. * target set.
  765. *
  766. * \param renderer a rendering context
  767. * \param w an int to be filled with the width
  768. * \param h an int to be filled with the height
  769. *
  770. * \since This function is available since SDL 2.0.0.
  771. *
  772. * \sa SDL_RenderSetLogicalSize
  773. */
  774. extern DECLSPEC void SDLCALL SDL_RenderGetLogicalSize(SDL_Renderer * renderer, int *w, int *h);
  775. /**
  776. * Set whether to force integer scales for resolution-independent rendering.
  777. *
  778. * This function restricts the logical viewport to integer values - that is,
  779. * when a resolution is between two multiples of a logical size, the viewport
  780. * size is rounded down to the lower multiple.
  781. *
  782. * \param renderer the renderer for which integer scaling should be set
  783. * \param enable enable or disable the integer scaling for rendering
  784. * \returns 0 on success or a negative error code on failure; call
  785. * SDL_GetError() for more information.
  786. *
  787. * \since This function is available since SDL 2.0.5.
  788. *
  789. * \sa SDL_RenderGetIntegerScale
  790. * \sa SDL_RenderSetLogicalSize
  791. */
  792. extern DECLSPEC int SDLCALL SDL_RenderSetIntegerScale(SDL_Renderer * renderer,
  793. SDL_bool enable);
  794. /**
  795. * Get whether integer scales are forced for resolution-independent rendering.
  796. *
  797. * \param renderer the renderer from which integer scaling should be queried
  798. * \returns SDL_TRUE if integer scales are forced or SDL_FALSE if not and on
  799. * failure; call SDL_GetError() for more information.
  800. *
  801. * \since This function is available since SDL 2.0.5.
  802. *
  803. * \sa SDL_RenderSetIntegerScale
  804. */
  805. extern DECLSPEC SDL_bool SDLCALL SDL_RenderGetIntegerScale(SDL_Renderer * renderer);
  806. /**
  807. * Set the drawing area for rendering on the current target.
  808. *
  809. * When the window is resized, the viewport is reset to fill the entire new
  810. * window size.
  811. *
  812. * \param renderer the rendering context
  813. * \param rect the SDL_Rect structure representing the drawing area, or NULL
  814. * to set the viewport to the entire target
  815. * \returns 0 on success or a negative error code on failure; call
  816. * SDL_GetError() for more information.
  817. *
  818. * \since This function is available since SDL 2.0.0.
  819. *
  820. * \sa SDL_RenderGetViewport
  821. */
  822. extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer,
  823. const SDL_Rect * rect);
  824. /**
  825. * Get the drawing area for the current target.
  826. *
  827. * \param renderer the rendering context
  828. * \param rect an SDL_Rect structure filled in with the current drawing area
  829. *
  830. * \since This function is available since SDL 2.0.0.
  831. *
  832. * \sa SDL_RenderSetViewport
  833. */
  834. extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer,
  835. SDL_Rect * rect);
  836. /**
  837. * Set the clip rectangle for rendering on the specified target.
  838. *
  839. * \param renderer the rendering context for which clip rectangle should be
  840. * set
  841. * \param rect an SDL_Rect structure representing the clip area, relative to
  842. * the viewport, or NULL to disable clipping
  843. * \returns 0 on success or a negative error code on failure; call
  844. * SDL_GetError() for more information.
  845. *
  846. * \since This function is available since SDL 2.0.0.
  847. *
  848. * \sa SDL_RenderGetClipRect
  849. * \sa SDL_RenderIsClipEnabled
  850. */
  851. extern DECLSPEC int SDLCALL SDL_RenderSetClipRect(SDL_Renderer * renderer,
  852. const SDL_Rect * rect);
  853. /**
  854. * Get the clip rectangle for the current target.
  855. *
  856. * \param renderer the rendering context from which clip rectangle should be
  857. * queried
  858. * \param rect an SDL_Rect structure filled in with the current clipping area
  859. * or an empty rectangle if clipping is disabled
  860. *
  861. * \since This function is available since SDL 2.0.0.
  862. *
  863. * \sa SDL_RenderIsClipEnabled
  864. * \sa SDL_RenderSetClipRect
  865. */
  866. extern DECLSPEC void SDLCALL SDL_RenderGetClipRect(SDL_Renderer * renderer,
  867. SDL_Rect * rect);
  868. /**
  869. * Get whether clipping is enabled on the given renderer.
  870. *
  871. * \param renderer the renderer from which clip state should be queried
  872. * \returns SDL_TRUE if clipping is enabled or SDL_FALSE if not; call
  873. * SDL_GetError() for more information.
  874. *
  875. * \since This function is available since SDL 2.0.4.
  876. *
  877. * \sa SDL_RenderGetClipRect
  878. * \sa SDL_RenderSetClipRect
  879. */
  880. extern DECLSPEC SDL_bool SDLCALL SDL_RenderIsClipEnabled(SDL_Renderer * renderer);
  881. /**
  882. * Set the drawing scale for rendering on the current target.
  883. *
  884. * The drawing coordinates are scaled by the x/y scaling factors before they
  885. * are used by the renderer. This allows resolution independent drawing with a
  886. * single coordinate system.
  887. *
  888. * If this results in scaling or subpixel drawing by the rendering backend, it
  889. * will be handled using the appropriate quality hints. For best results use
  890. * integer scaling factors.
  891. *
  892. * \param renderer a rendering context
  893. * \param scaleX the horizontal scaling factor
  894. * \param scaleY the vertical scaling factor
  895. * \returns 0 on success or a negative error code on failure; call
  896. * SDL_GetError() for more information.
  897. *
  898. * \since This function is available since SDL 2.0.0.
  899. *
  900. * \sa SDL_RenderGetScale
  901. * \sa SDL_RenderSetLogicalSize
  902. */
  903. extern DECLSPEC int SDLCALL SDL_RenderSetScale(SDL_Renderer * renderer,
  904. float scaleX, float scaleY);
  905. /**
  906. * Get the drawing scale for the current target.
  907. *
  908. * \param renderer the renderer from which drawing scale should be queried
  909. * \param scaleX a pointer filled in with the horizontal scaling factor
  910. * \param scaleY a pointer filled in with the vertical scaling factor
  911. *
  912. * \since This function is available since SDL 2.0.0.
  913. *
  914. * \sa SDL_RenderSetScale
  915. */
  916. extern DECLSPEC void SDLCALL SDL_RenderGetScale(SDL_Renderer * renderer,
  917. float *scaleX, float *scaleY);
  918. /**
  919. * Get logical coordinates of point in renderer when given real coordinates of
  920. * point in window.
  921. *
  922. * Logical coordinates will differ from real coordinates when render is scaled
  923. * and logical renderer size set
  924. *
  925. * \param renderer the renderer from which the logical coordinates should be
  926. * calcualted
  927. * \param windowX the real X coordinate in the window
  928. * \param windowY the real Y coordinate in the window
  929. * \param logicalX the pointer filled with the logical x coordinate
  930. * \param logicalY the pointer filled with the logical y coordinate
  931. *
  932. * \since This function is available since SDL 2.0.18.
  933. *
  934. * \sa SDL_RenderGetScale
  935. * \sa SDL_RenderSetScale
  936. * \sa SDL_RenderGetLogicalSize
  937. * \sa SDL_RenderSetLogicalSize
  938. */
  939. extern DECLSPEC void SDLCALL SDL_RenderWindowToLogical(SDL_Renderer * renderer,
  940. int windowX, int windowY,
  941. float *logicalX, float *logicalY);
  942. /**
  943. * Get real coordinates of point in window when given logical coordinates of point in renderer.
  944. * Logical coordinates will differ from real coordinates when render is scaled and logical renderer size set
  945. *
  946. * \param renderer the renderer from which the window coordinates should be calculated
  947. * \param logicalX the logical x coordinate
  948. * \param logicalY the logical y coordinate
  949. * \param windowX the pointer filled with the real X coordinate in the window
  950. * \param windowY the pointer filled with the real Y coordinate in the window
  951. *
  952. * \since This function is available since SDL 2.0.18.
  953. *
  954. * \sa SDL_RenderGetScale
  955. * \sa SDL_RenderSetScale
  956. * \sa SDL_RenderGetLogicalSize
  957. * \sa SDL_RenderSetLogicalSize
  958. */
  959. extern DECLSPEC void SDLCALL SDL_RenderLogicalToWindow(SDL_Renderer * renderer,
  960. float logicalX, float logicalY,
  961. int *windowX, int *windowY);
  962. /**
  963. * Set the color used for drawing operations (Rect, Line and Clear).
  964. *
  965. * Set the color for drawing or filling rectangles, lines, and points, and for
  966. * SDL_RenderClear().
  967. *
  968. * \param renderer the rendering context
  969. * \param r the red value used to draw on the rendering target
  970. * \param g the green value used to draw on the rendering target
  971. * \param b the blue value used to draw on the rendering target
  972. * \param a the alpha value used to draw on the rendering target; usually
  973. * `SDL_ALPHA_OPAQUE` (255). Use SDL_SetRenderDrawBlendMode to
  974. * specify how the alpha channel is used
  975. * \returns 0 on success or a negative error code on failure; call
  976. * SDL_GetError() for more information.
  977. *
  978. * \since This function is available since SDL 2.0.0.
  979. *
  980. * \sa SDL_GetRenderDrawColor
  981. * \sa SDL_RenderClear
  982. * \sa SDL_RenderDrawLine
  983. * \sa SDL_RenderDrawLines
  984. * \sa SDL_RenderDrawPoint
  985. * \sa SDL_RenderDrawPoints
  986. * \sa SDL_RenderDrawRect
  987. * \sa SDL_RenderDrawRects
  988. * \sa SDL_RenderFillRect
  989. * \sa SDL_RenderFillRects
  990. */
  991. extern DECLSPEC int SDLCALL SDL_SetRenderDrawColor(SDL_Renderer * renderer,
  992. Uint8 r, Uint8 g, Uint8 b,
  993. Uint8 a);
  994. /**
  995. * Get the color used for drawing operations (Rect, Line and Clear).
  996. *
  997. * \param renderer the rendering context
  998. * \param r a pointer filled in with the red value used to draw on the
  999. * rendering target
  1000. * \param g a pointer filled in with the green value used to draw on the
  1001. * rendering target
  1002. * \param b a pointer filled in with the blue value used to draw on the
  1003. * rendering target
  1004. * \param a a pointer filled in with the alpha value used to draw on the
  1005. * rendering target; usually `SDL_ALPHA_OPAQUE` (255)
  1006. * \returns 0 on success or a negative error code on failure; call
  1007. * SDL_GetError() for more information.
  1008. *
  1009. * \since This function is available since SDL 2.0.0.
  1010. *
  1011. * \sa SDL_SetRenderDrawColor
  1012. */
  1013. extern DECLSPEC int SDLCALL SDL_GetRenderDrawColor(SDL_Renderer * renderer,
  1014. Uint8 * r, Uint8 * g, Uint8 * b,
  1015. Uint8 * a);
  1016. /**
  1017. * Set the blend mode used for drawing operations (Fill and Line).
  1018. *
  1019. * If the blend mode is not supported, the closest supported mode is chosen.
  1020. *
  1021. * \param renderer the rendering context
  1022. * \param blendMode the SDL_BlendMode to use for blending
  1023. * \returns 0 on success or a negative error code on failure; call
  1024. * SDL_GetError() for more information.
  1025. *
  1026. * \since This function is available since SDL 2.0.0.
  1027. *
  1028. * \sa SDL_GetRenderDrawBlendMode
  1029. * \sa SDL_RenderDrawLine
  1030. * \sa SDL_RenderDrawLines
  1031. * \sa SDL_RenderDrawPoint
  1032. * \sa SDL_RenderDrawPoints
  1033. * \sa SDL_RenderDrawRect
  1034. * \sa SDL_RenderDrawRects
  1035. * \sa SDL_RenderFillRect
  1036. * \sa SDL_RenderFillRects
  1037. */
  1038. extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer,
  1039. SDL_BlendMode blendMode);
  1040. /**
  1041. * Get the blend mode used for drawing operations.
  1042. *
  1043. * \param renderer the rendering context
  1044. * \param blendMode a pointer filled in with the current SDL_BlendMode
  1045. * \returns 0 on success or a negative error code on failure; call
  1046. * SDL_GetError() for more information.
  1047. *
  1048. * \since This function is available since SDL 2.0.0.
  1049. *
  1050. * \sa SDL_SetRenderDrawBlendMode
  1051. */
  1052. extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer,
  1053. SDL_BlendMode *blendMode);
  1054. /**
  1055. * Clear the current rendering target with the drawing color.
  1056. *
  1057. * This function clears the entire rendering target, ignoring the viewport and
  1058. * the clip rectangle.
  1059. *
  1060. * \param renderer the rendering context
  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_SetRenderDrawColor
  1067. */
  1068. extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer);
  1069. /**
  1070. * Draw a point on the current rendering target.
  1071. *
  1072. * SDL_RenderDrawPoint() draws a single point. If you want to draw multiple,
  1073. * use SDL_RenderDrawPoints() instead.
  1074. *
  1075. * \param renderer the rendering context
  1076. * \param x the x coordinate of the point
  1077. * \param y the y coordinate of the point
  1078. * \returns 0 on success or a negative error code on failure; call
  1079. * SDL_GetError() for more information.
  1080. *
  1081. * \since This function is available since SDL 2.0.0.
  1082. *
  1083. * \sa SDL_RenderDrawLine
  1084. * \sa SDL_RenderDrawLines
  1085. * \sa SDL_RenderDrawPoints
  1086. * \sa SDL_RenderDrawRect
  1087. * \sa SDL_RenderDrawRects
  1088. * \sa SDL_RenderFillRect
  1089. * \sa SDL_RenderFillRects
  1090. * \sa SDL_RenderPresent
  1091. * \sa SDL_SetRenderDrawBlendMode
  1092. * \sa SDL_SetRenderDrawColor
  1093. */
  1094. extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer,
  1095. int x, int y);
  1096. /**
  1097. * Draw multiple points on the current rendering target.
  1098. *
  1099. * \param renderer the rendering context
  1100. * \param points an array of SDL_Point structures that represent the points to
  1101. * draw
  1102. * \param count the number of points to draw
  1103. * \returns 0 on success or a negative error code on failure; call
  1104. * SDL_GetError() for more information.
  1105. *
  1106. * \since This function is available since SDL 2.0.0.
  1107. *
  1108. * \sa SDL_RenderDrawLine
  1109. * \sa SDL_RenderDrawLines
  1110. * \sa SDL_RenderDrawPoint
  1111. * \sa SDL_RenderDrawRect
  1112. * \sa SDL_RenderDrawRects
  1113. * \sa SDL_RenderFillRect
  1114. * \sa SDL_RenderFillRects
  1115. * \sa SDL_RenderPresent
  1116. * \sa SDL_SetRenderDrawBlendMode
  1117. * \sa SDL_SetRenderDrawColor
  1118. */
  1119. extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer,
  1120. const SDL_Point * points,
  1121. int count);
  1122. /**
  1123. * Draw a line on the current rendering target.
  1124. *
  1125. * SDL_RenderDrawLine() draws the line to include both end points. If you want
  1126. * to draw multiple, connecting lines use SDL_RenderDrawLines() instead.
  1127. *
  1128. * \param renderer the rendering context
  1129. * \param x1 the x coordinate of the start point
  1130. * \param y1 the y coordinate of the start point
  1131. * \param x2 the x coordinate of the end point
  1132. * \param y2 the y coordinate of the end point
  1133. * \returns 0 on success or a negative error code on failure; call
  1134. * SDL_GetError() for more information.
  1135. *
  1136. * \since This function is available since SDL 2.0.0.
  1137. *
  1138. * \sa SDL_RenderDrawLines
  1139. * \sa SDL_RenderDrawPoint
  1140. * \sa SDL_RenderDrawPoints
  1141. * \sa SDL_RenderDrawRect
  1142. * \sa SDL_RenderDrawRects
  1143. * \sa SDL_RenderFillRect
  1144. * \sa SDL_RenderFillRects
  1145. * \sa SDL_RenderPresent
  1146. * \sa SDL_SetRenderDrawBlendMode
  1147. * \sa SDL_SetRenderDrawColor
  1148. */
  1149. extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer,
  1150. int x1, int y1, int x2, int y2);
  1151. /**
  1152. * Draw a series of connected lines on the current rendering target.
  1153. *
  1154. * \param renderer the rendering context
  1155. * \param points an array of SDL_Point structures representing points along
  1156. * the lines
  1157. * \param count the number of points, drawing count-1 lines
  1158. * \returns 0 on success or a negative error code on failure; call
  1159. * SDL_GetError() for more information.
  1160. *
  1161. * \since This function is available since SDL 2.0.0.
  1162. *
  1163. * \sa SDL_RenderDrawLine
  1164. * \sa SDL_RenderDrawPoint
  1165. * \sa SDL_RenderDrawPoints
  1166. * \sa SDL_RenderDrawRect
  1167. * \sa SDL_RenderDrawRects
  1168. * \sa SDL_RenderFillRect
  1169. * \sa SDL_RenderFillRects
  1170. * \sa SDL_RenderPresent
  1171. * \sa SDL_SetRenderDrawBlendMode
  1172. * \sa SDL_SetRenderDrawColor
  1173. */
  1174. extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer,
  1175. const SDL_Point * points,
  1176. int count);
  1177. /**
  1178. * Draw a rectangle on the current rendering target.
  1179. *
  1180. * \param renderer the rendering context
  1181. * \param rect an SDL_Rect structure representing the rectangle to draw, or
  1182. * NULL to outline the entire rendering target
  1183. * \returns 0 on success or a negative error code on failure; call
  1184. * SDL_GetError() for more information.
  1185. *
  1186. * \since This function is available since SDL 2.0.0.
  1187. *
  1188. * \sa SDL_RenderDrawLine
  1189. * \sa SDL_RenderDrawLines
  1190. * \sa SDL_RenderDrawPoint
  1191. * \sa SDL_RenderDrawPoints
  1192. * \sa SDL_RenderDrawRects
  1193. * \sa SDL_RenderFillRect
  1194. * \sa SDL_RenderFillRects
  1195. * \sa SDL_RenderPresent
  1196. * \sa SDL_SetRenderDrawBlendMode
  1197. * \sa SDL_SetRenderDrawColor
  1198. */
  1199. extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer,
  1200. const SDL_Rect * rect);
  1201. /**
  1202. * Draw some number of rectangles on the current rendering target.
  1203. *
  1204. * \param renderer the rendering context
  1205. * \param rects an array of SDL_Rect structures representing the rectangles to
  1206. * be drawn
  1207. * \param count the number of rectangles
  1208. * \returns 0 on success or a negative error code on failure; call
  1209. * SDL_GetError() for more information.
  1210. *
  1211. * \since This function is available since SDL 2.0.0.
  1212. *
  1213. * \sa SDL_RenderDrawLine
  1214. * \sa SDL_RenderDrawLines
  1215. * \sa SDL_RenderDrawPoint
  1216. * \sa SDL_RenderDrawPoints
  1217. * \sa SDL_RenderDrawRect
  1218. * \sa SDL_RenderFillRect
  1219. * \sa SDL_RenderFillRects
  1220. * \sa SDL_RenderPresent
  1221. * \sa SDL_SetRenderDrawBlendMode
  1222. * \sa SDL_SetRenderDrawColor
  1223. */
  1224. extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer,
  1225. const SDL_Rect * rects,
  1226. int count);
  1227. /**
  1228. * Fill a rectangle on the current rendering target with the drawing color.
  1229. *
  1230. * The current drawing color is set by SDL_SetRenderDrawColor(), and the
  1231. * color's alpha value is ignored unless blending is enabled with the
  1232. * appropriate call to SDL_SetRenderDrawBlendMode().
  1233. *
  1234. * \param renderer the rendering context
  1235. * \param rect the SDL_Rect structure representing the rectangle to fill, or
  1236. * NULL for the entire rendering target
  1237. * \returns 0 on success or a negative error code on failure; call
  1238. * SDL_GetError() for more information.
  1239. *
  1240. * \since This function is available since SDL 2.0.0.
  1241. *
  1242. * \sa SDL_RenderDrawLine
  1243. * \sa SDL_RenderDrawLines
  1244. * \sa SDL_RenderDrawPoint
  1245. * \sa SDL_RenderDrawPoints
  1246. * \sa SDL_RenderDrawRect
  1247. * \sa SDL_RenderDrawRects
  1248. * \sa SDL_RenderFillRects
  1249. * \sa SDL_RenderPresent
  1250. * \sa SDL_SetRenderDrawBlendMode
  1251. * \sa SDL_SetRenderDrawColor
  1252. */
  1253. extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer,
  1254. const SDL_Rect * rect);
  1255. /**
  1256. * Fill some number of rectangles on the current rendering target with the
  1257. * drawing color.
  1258. *
  1259. * \param renderer the rendering context
  1260. * \param rects an array of SDL_Rect structures representing the rectangles to
  1261. * be filled
  1262. * \param count the number of rectangles
  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_RenderFillRect
  1275. * \sa SDL_RenderPresent
  1276. */
  1277. extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer,
  1278. const SDL_Rect * rects,
  1279. int count);
  1280. /**
  1281. * Copy a portion of the texture to the current rendering target.
  1282. *
  1283. * The texture is blended with the destination based on its blend mode set
  1284. * with SDL_SetTextureBlendMode().
  1285. *
  1286. * The texture color is affected based on its color modulation set by
  1287. * SDL_SetTextureColorMod().
  1288. *
  1289. * The texture alpha is affected based on its alpha modulation set by
  1290. * SDL_SetTextureAlphaMod().
  1291. *
  1292. * \param renderer the rendering context
  1293. * \param texture the source texture
  1294. * \param srcrect the source SDL_Rect structure or NULL for the entire texture
  1295. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1296. * rendering target; the texture will be stretched to fill the
  1297. * given rectangle
  1298. * \returns 0 on success or a negative error code on failure; call
  1299. * SDL_GetError() for more information.
  1300. *
  1301. * \since This function is available since SDL 2.0.0.
  1302. *
  1303. * \sa SDL_RenderCopyEx
  1304. * \sa SDL_SetTextureAlphaMod
  1305. * \sa SDL_SetTextureBlendMode
  1306. * \sa SDL_SetTextureColorMod
  1307. */
  1308. extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer,
  1309. SDL_Texture * texture,
  1310. const SDL_Rect * srcrect,
  1311. const SDL_Rect * dstrect);
  1312. /**
  1313. * Copy a portion of the texture to the current rendering, with optional
  1314. * rotation and flipping.
  1315. *
  1316. * Copy a portion of the texture to the current rendering target, optionally
  1317. * rotating it by angle around the given center and also flipping it
  1318. * top-bottom and/or left-right.
  1319. *
  1320. * The texture is blended with the destination based on its blend mode set
  1321. * with SDL_SetTextureBlendMode().
  1322. *
  1323. * The texture color is affected based on its color modulation set by
  1324. * SDL_SetTextureColorMod().
  1325. *
  1326. * The texture alpha is affected based on its alpha modulation set by
  1327. * SDL_SetTextureAlphaMod().
  1328. *
  1329. * \param renderer the rendering context
  1330. * \param texture the source texture
  1331. * \param srcrect the source SDL_Rect structure or NULL for the entire texture
  1332. * \param dstrect the destination SDL_Rect structure or NULL for the entire
  1333. * rendering target
  1334. * \param angle an angle in degrees that indicates the rotation that will be
  1335. * applied to dstrect, rotating it in a clockwise direction
  1336. * \param center a pointer to a point indicating the point around which
  1337. * dstrect will be rotated (if NULL, rotation will be done
  1338. * around `dstrect.w / 2`, `dstrect.h / 2`)
  1339. * \param flip a SDL_RendererFlip value stating which flipping actions should
  1340. * be performed on the texture
  1341. * \returns 0 on success or a negative error code on failure; call
  1342. * SDL_GetError() for more information.
  1343. *
  1344. * \since This function is available since SDL 2.0.0.
  1345. *
  1346. * \sa SDL_RenderCopy
  1347. * \sa SDL_SetTextureAlphaMod
  1348. * \sa SDL_SetTextureBlendMode
  1349. * \sa SDL_SetTextureColorMod
  1350. */
  1351. extern DECLSPEC int SDLCALL SDL_RenderCopyEx(SDL_Renderer * renderer,
  1352. SDL_Texture * texture,
  1353. const SDL_Rect * srcrect,
  1354. const SDL_Rect * dstrect,
  1355. const double angle,
  1356. const SDL_Point *center,
  1357. const SDL_RendererFlip flip);
  1358. /**
  1359. * Draw a point on the current rendering target at subpixel precision.
  1360. *
  1361. * \param renderer The renderer which should draw a point.
  1362. * \param x The x coordinate of the point.
  1363. * \param y The y coordinate of the point.
  1364. * \return 0 on success, or -1 on error
  1365. *
  1366. * \since This function is available since SDL 2.0.10.
  1367. */
  1368. extern DECLSPEC int SDLCALL SDL_RenderDrawPointF(SDL_Renderer * renderer,
  1369. float x, float y);
  1370. /**
  1371. * Draw multiple points on the current rendering target at subpixel precision.
  1372. *
  1373. * \param renderer The renderer which should draw multiple points.
  1374. * \param points The points to draw
  1375. * \param count The number of points to draw
  1376. * \return 0 on success, or -1 on error
  1377. *
  1378. * \since This function is available since SDL 2.0.10.
  1379. */
  1380. extern DECLSPEC int SDLCALL SDL_RenderDrawPointsF(SDL_Renderer * renderer,
  1381. const SDL_FPoint * points,
  1382. int count);
  1383. /**
  1384. * Draw a line on the current rendering target at subpixel precision.
  1385. *
  1386. * \param renderer The renderer which should draw a line.
  1387. * \param x1 The x coordinate of the start point.
  1388. * \param y1 The y coordinate of the start point.
  1389. * \param x2 The x coordinate of the end point.
  1390. * \param y2 The y coordinate of the end point.
  1391. * \return 0 on success, or -1 on error
  1392. *
  1393. * \since This function is available since SDL 2.0.10.
  1394. */
  1395. extern DECLSPEC int SDLCALL SDL_RenderDrawLineF(SDL_Renderer * renderer,
  1396. float x1, float y1, float x2, float y2);
  1397. /**
  1398. * Draw a series of connected lines on the current rendering target at
  1399. * subpixel precision.
  1400. *
  1401. * \param renderer The renderer which should draw multiple lines.
  1402. * \param points The points along the lines
  1403. * \param count The number of points, drawing count-1 lines
  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_RenderDrawLinesF(SDL_Renderer * renderer,
  1409. const SDL_FPoint * points,
  1410. int count);
  1411. /**
  1412. * Draw a rectangle on the current rendering target at subpixel precision.
  1413. *
  1414. * \param renderer The renderer which should draw a rectangle.
  1415. * \param rect A pointer to the destination rectangle, or NULL to outline the
  1416. * entire rendering target.
  1417. * \return 0 on success, or -1 on error
  1418. *
  1419. * \since This function is available since SDL 2.0.10.
  1420. */
  1421. extern DECLSPEC int SDLCALL SDL_RenderDrawRectF(SDL_Renderer * renderer,
  1422. const SDL_FRect * rect);
  1423. /**
  1424. * Draw some number of rectangles on the current rendering target at subpixel
  1425. * precision.
  1426. *
  1427. * \param renderer The renderer which should draw multiple rectangles.
  1428. * \param rects A pointer to an array of destination rectangles.
  1429. * \param count The number of rectangles.
  1430. * \return 0 on success, or -1 on error
  1431. *
  1432. * \since This function is available since SDL 2.0.10.
  1433. */
  1434. extern DECLSPEC int SDLCALL SDL_RenderDrawRectsF(SDL_Renderer * renderer,
  1435. const SDL_FRect * rects,
  1436. int count);
  1437. /**
  1438. * Fill a rectangle on the current rendering target with the drawing color at
  1439. * subpixel precision.
  1440. *
  1441. * \param renderer The renderer which should fill a rectangle.
  1442. * \param rect A pointer to the destination rectangle, or NULL for the entire
  1443. * rendering target.
  1444. * \return 0 on success, or -1 on error
  1445. *
  1446. * \since This function is available since SDL 2.0.10.
  1447. */
  1448. extern DECLSPEC int SDLCALL SDL_RenderFillRectF(SDL_Renderer * renderer,
  1449. const SDL_FRect * rect);
  1450. /**
  1451. * Fill some number of rectangles on the current rendering target with the
  1452. * drawing color at subpixel precision.
  1453. *
  1454. * \param renderer The renderer which should fill multiple rectangles.
  1455. * \param rects A pointer to an array of destination rectangles.
  1456. * \param count The number of rectangles.
  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_RenderFillRectsF(SDL_Renderer * renderer,
  1462. const SDL_FRect * rects,
  1463. int count);
  1464. /**
  1465. * Copy a portion of the texture to the current rendering target at subpixel
  1466. * precision.
  1467. *
  1468. * \param renderer The renderer which should copy parts of a texture.
  1469. * \param texture The source texture.
  1470. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1471. * texture.
  1472. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1473. * entire rendering target.
  1474. * \return 0 on success, or -1 on error
  1475. *
  1476. * \since This function is available since SDL 2.0.10.
  1477. */
  1478. extern DECLSPEC int SDLCALL SDL_RenderCopyF(SDL_Renderer * renderer,
  1479. SDL_Texture * texture,
  1480. const SDL_Rect * srcrect,
  1481. const SDL_FRect * dstrect);
  1482. /**
  1483. * Copy a portion of the source texture to the current rendering target, with
  1484. * rotation and flipping, at subpixel precision.
  1485. *
  1486. * \param renderer The renderer which should copy parts of a texture.
  1487. * \param texture The source texture.
  1488. * \param srcrect A pointer to the source rectangle, or NULL for the entire
  1489. * texture.
  1490. * \param dstrect A pointer to the destination rectangle, or NULL for the
  1491. * entire rendering target.
  1492. * \param angle An angle in degrees that indicates the rotation that will be
  1493. * applied to dstrect, rotating it in a clockwise direction
  1494. * \param center A pointer to a point indicating the point around which
  1495. * dstrect will be rotated (if NULL, rotation will be done
  1496. * around dstrect.w/2, dstrect.h/2).
  1497. * \param flip An SDL_RendererFlip value stating which flipping actions should
  1498. * be performed on the texture
  1499. * \return 0 on success, or -1 on error
  1500. *
  1501. * \since This function is available since SDL 2.0.10.
  1502. */
  1503. extern DECLSPEC int SDLCALL SDL_RenderCopyExF(SDL_Renderer * renderer,
  1504. SDL_Texture * texture,
  1505. const SDL_Rect * srcrect,
  1506. const SDL_FRect * dstrect,
  1507. const double angle,
  1508. const SDL_FPoint *center,
  1509. const SDL_RendererFlip flip);
  1510. /**
  1511. * Render a list of triangles, optionally using a texture and indices into the
  1512. * vertex array Color and alpha modulation is done per vertex
  1513. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1514. *
  1515. * \param texture (optional) The SDL texture to use.
  1516. * \param vertices Vertices.
  1517. * \param num_vertices Number of vertices.
  1518. * \param indices (optional) An array of integer indices into the 'vertices'
  1519. * array, if NULL all vertices will be rendered in sequential
  1520. * order.
  1521. * \param num_indices Number of indices.
  1522. * \return 0 on success, or -1 if the operation is not supported
  1523. *
  1524. * \since This function is available since SDL 2.0.18.
  1525. *
  1526. * \sa SDL_RenderGeometryRaw
  1527. * \sa SDL_Vertex
  1528. */
  1529. extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
  1530. SDL_Texture *texture,
  1531. const SDL_Vertex *vertices, int num_vertices,
  1532. const int *indices, int num_indices);
  1533. /**
  1534. * Render a list of triangles, optionally using a texture and indices into the
  1535. * vertex arrays Color and alpha modulation is done per vertex
  1536. * (SDL_SetTextureColorMod and SDL_SetTextureAlphaMod are ignored).
  1537. *
  1538. * \param texture (optional) The SDL texture to use.
  1539. * \param xy Vertex positions
  1540. * \param xy_stride Byte size to move from one element to the next element
  1541. * \param color Vertex colors (as SDL_Color)
  1542. * \param color_stride Byte size to move from one element to the next element
  1543. * \param uv Vertex normalized texture coordinates
  1544. * \param uv_stride Byte size to move from one element to the next element
  1545. * \param num_vertices Number of vertices.
  1546. * \param indices (optional) An array of indices into the 'vertices' arrays,
  1547. * if NULL all vertices will be rendered in sequential order.
  1548. * \param num_indices Number of indices.
  1549. * \param size_indices Index size: 1 (byte), 2 (short), 4 (int)
  1550. * \return 0 on success, or -1 if the operation is not supported
  1551. *
  1552. * \since This function is available since SDL 2.0.18.
  1553. *
  1554. * \sa SDL_RenderGeometry
  1555. * \sa SDL_Vertex
  1556. */
  1557. extern DECLSPEC int SDLCALL SDL_RenderGeometryRaw(SDL_Renderer *renderer,
  1558. SDL_Texture *texture,
  1559. const float *xy, int xy_stride,
  1560. const SDL_Color *color, int color_stride,
  1561. const float *uv, int uv_stride,
  1562. int num_vertices,
  1563. const void *indices, int num_indices, int size_indices);
  1564. /**
  1565. * Read pixels from the current rendering target to an array of pixels.
  1566. *
  1567. * **WARNING**: This is a very slow operation, and should not be used
  1568. * frequently.
  1569. *
  1570. * `pitch` specifies the number of bytes between rows in the destination
  1571. * `pixels` data. This allows you to write to a subrectangle or have padded
  1572. * rows in the destination. Generally, `pitch` should equal the number of
  1573. * pixels per row in the `pixels` data times the number of bytes per pixel,
  1574. * but it might contain additional padding (for example, 24bit RGB Windows
  1575. * Bitmap data pads all rows to multiples of 4 bytes).
  1576. *
  1577. * \param renderer the rendering context
  1578. * \param rect an SDL_Rect structure representing the area to read, or NULL
  1579. * for the entire render target
  1580. * \param format an SDL_PixelFormatEnum value of the desired format of the
  1581. * pixel data, or 0 to use the format of the rendering target
  1582. * \param pixels a pointer to the pixel data to copy into
  1583. * \param pitch the pitch of the `pixels` parameter
  1584. * \returns 0 on success or a negative error code on failure; call
  1585. * SDL_GetError() for more information.
  1586. *
  1587. * \since This function is available since SDL 2.0.0.
  1588. */
  1589. extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
  1590. const SDL_Rect * rect,
  1591. Uint32 format,
  1592. void *pixels, int pitch);
  1593. /**
  1594. * Update the screen with any rendering performed since the previous call.
  1595. *
  1596. * SDL's rendering functions operate on a backbuffer; that is, calling a
  1597. * rendering function such as SDL_RenderDrawLine() does not directly put a
  1598. * line on the screen, but rather updates the backbuffer. As such, you compose
  1599. * your entire scene and *present* the composed backbuffer to the screen as a
  1600. * complete picture.
  1601. *
  1602. * Therefore, when using SDL's rendering API, one does all drawing intended
  1603. * for the frame, and then calls this function once per frame to present the
  1604. * final drawing to the user.
  1605. *
  1606. * The backbuffer should be considered invalidated after each present; do not
  1607. * assume that previous contents will exist between frames. You are strongly
  1608. * encouraged to call SDL_RenderClear() to initialize the backbuffer before
  1609. * starting each new frame's drawing, even if you plan to overwrite every
  1610. * pixel.
  1611. *
  1612. * \param renderer the rendering context
  1613. *
  1614. * \since This function is available since SDL 2.0.0.
  1615. *
  1616. * \sa SDL_RenderClear
  1617. * \sa SDL_RenderDrawLine
  1618. * \sa SDL_RenderDrawLines
  1619. * \sa SDL_RenderDrawPoint
  1620. * \sa SDL_RenderDrawPoints
  1621. * \sa SDL_RenderDrawRect
  1622. * \sa SDL_RenderDrawRects
  1623. * \sa SDL_RenderFillRect
  1624. * \sa SDL_RenderFillRects
  1625. * \sa SDL_SetRenderDrawBlendMode
  1626. * \sa SDL_SetRenderDrawColor
  1627. */
  1628. extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer);
  1629. /**
  1630. * Destroy the specified texture.
  1631. *
  1632. * Passing NULL or an otherwise invalid texture will set the SDL error message
  1633. * to "Invalid texture".
  1634. *
  1635. * \param texture the texture to destroy
  1636. *
  1637. * \since This function is available since SDL 2.0.0.
  1638. *
  1639. * \sa SDL_CreateTexture
  1640. * \sa SDL_CreateTextureFromSurface
  1641. */
  1642. extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture);
  1643. /**
  1644. * Destroy the rendering context for a window and free associated textures.
  1645. *
  1646. * \param renderer the rendering context
  1647. *
  1648. * \since This function is available since SDL 2.0.0.
  1649. *
  1650. * \sa SDL_CreateRenderer
  1651. */
  1652. extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer);
  1653. /**
  1654. * Force the rendering context to flush any pending commands to the underlying
  1655. * rendering API.
  1656. *
  1657. * You do not need to (and in fact, shouldn't) call this function unless you
  1658. * are planning to call into OpenGL/Direct3D/Metal/whatever directly in
  1659. * addition to using an SDL_Renderer.
  1660. *
  1661. * This is for a very-specific case: if you are using SDL's render API, you
  1662. * asked for a specific renderer backend (OpenGL, Direct3D, etc), you set
  1663. * SDL_HINT_RENDER_BATCHING to "1", and you plan to make OpenGL/D3D/whatever
  1664. * calls in addition to SDL render API calls. If all of this applies, you
  1665. * should call SDL_RenderFlush() between calls to SDL's render API and the
  1666. * low-level API you're using in cooperation.
  1667. *
  1668. * In all other cases, you can ignore this function. This is only here to get
  1669. * maximum performance out of a specific situation. In all other cases, SDL
  1670. * will do the right thing, perhaps at a performance loss.
  1671. *
  1672. * This function is first available in SDL 2.0.10, and is not needed in 2.0.9
  1673. * and earlier, as earlier versions did not queue rendering commands at all,
  1674. * instead flushing them to the OS immediately.
  1675. *
  1676. * \param renderer the rendering context
  1677. * \returns 0 on success or a negative error code on failure; call
  1678. * SDL_GetError() for more information.
  1679. *
  1680. * \since This function is available since SDL 2.0.10.
  1681. */
  1682. extern DECLSPEC int SDLCALL SDL_RenderFlush(SDL_Renderer * renderer);
  1683. /**
  1684. * Bind an OpenGL/ES/ES2 texture to the current context.
  1685. *
  1686. * This is for use with OpenGL instructions when rendering OpenGL primitives
  1687. * directly.
  1688. *
  1689. * If not NULL, `texw` and `texh` will be filled with the width and height
  1690. * values suitable for the provided texture. In most cases, both will be 1.0,
  1691. * however, on systems that support the GL_ARB_texture_rectangle extension,
  1692. * these values will actually be the pixel width and height used to create the
  1693. * texture, so this factor needs to be taken into account when providing
  1694. * texture coordinates to OpenGL.
  1695. *
  1696. * You need a renderer to create an SDL_Texture, therefore you can only use
  1697. * this function with an implicit OpenGL context from SDL_CreateRenderer(),
  1698. * not with your own OpenGL context. If you need control over your OpenGL
  1699. * context, you need to write your own texture-loading methods.
  1700. *
  1701. * Also note that SDL may upload RGB textures as BGR (or vice-versa), and
  1702. * re-order the color channels in the shaders phase, so the uploaded texture
  1703. * may have swapped color channels.
  1704. *
  1705. * \param texture the texture to bind to the current OpenGL/ES/ES2 context
  1706. * \param texw a pointer to a float value which will be filled with the
  1707. * texture width or NULL if you don't need that value
  1708. * \param texh a pointer to a float value which will be filled with the
  1709. * texture height or NULL if you don't need that value
  1710. * \returns 0 on success, or -1 if the operation is not supported; call
  1711. * SDL_GetError() for more information.
  1712. *
  1713. * \since This function is available since SDL 2.0.0.
  1714. *
  1715. * \sa SDL_GL_MakeCurrent
  1716. * \sa SDL_GL_UnbindTexture
  1717. */
  1718. extern DECLSPEC int SDLCALL SDL_GL_BindTexture(SDL_Texture *texture, float *texw, float *texh);
  1719. /**
  1720. * Unbind an OpenGL/ES/ES2 texture from the current context.
  1721. *
  1722. * See SDL_GL_BindTexture() for examples on how to use these functions
  1723. *
  1724. * \param texture the texture to unbind from the current OpenGL/ES/ES2 context
  1725. * \returns 0 on success, or -1 if the operation is not supported
  1726. *
  1727. * \since This function is available since SDL 2.0.0.
  1728. *
  1729. * \sa SDL_GL_BindTexture
  1730. * \sa SDL_GL_MakeCurrent
  1731. */
  1732. extern DECLSPEC int SDLCALL SDL_GL_UnbindTexture(SDL_Texture *texture);
  1733. /**
  1734. * Get the CAMetalLayer associated with the given Metal renderer.
  1735. *
  1736. * This function returns `void *`, so SDL doesn't have to include Metal's
  1737. * headers, but it can be safely cast to a `CAMetalLayer *`.
  1738. *
  1739. * \param renderer The renderer to query
  1740. * \returns a `CAMetalLayer *` on success, or NULL if the renderer isn't a
  1741. * Metal renderer
  1742. *
  1743. * \since This function is available since SDL 2.0.8.
  1744. *
  1745. * \sa SDL_RenderGetMetalCommandEncoder
  1746. */
  1747. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalLayer(SDL_Renderer * renderer);
  1748. /**
  1749. * Get the Metal command encoder for the current frame
  1750. *
  1751. * This function returns `void *`, so SDL doesn't have to include Metal's
  1752. * headers, but it can be safely cast to an `id<MTLRenderCommandEncoder>`.
  1753. *
  1754. * Note that as of SDL 2.0.18, this will return NULL if Metal refuses to give
  1755. * SDL a drawable to render to, which might happen if the window is
  1756. * hidden/minimized/offscreen. This doesn't apply to command encoders for
  1757. * render targets, just the window's backbacker. Check your return values!
  1758. *
  1759. * \param renderer The renderer to query
  1760. * \returns an `id<MTLRenderCommandEncoder>` on success, or NULL if the
  1761. * renderer isn't a Metal renderer or there was an error.
  1762. *
  1763. * \since This function is available since SDL 2.0.8.
  1764. *
  1765. * \sa SDL_RenderGetMetalLayer
  1766. */
  1767. extern DECLSPEC void *SDLCALL SDL_RenderGetMetalCommandEncoder(SDL_Renderer * renderer);
  1768. /**
  1769. * Toggle VSync of the given renderer.
  1770. *
  1771. * \param renderer The renderer to toggle
  1772. * \param vsync 1 for on, 0 for off. All other values are reserved
  1773. * \returns a 0 int on success, or non-zero on failure
  1774. *
  1775. * \since This function is available since SDL 2.0.18.
  1776. */
  1777. extern DECLSPEC int SDLCALL SDL_RenderSetVSync(SDL_Renderer* renderer, int vsync);
  1778. /* Ends C function definitions when using C++ */
  1779. #ifdef __cplusplus
  1780. }
  1781. #endif
  1782. #include "close_code.h"
  1783. #endif /* SDL_render_h_ */
  1784. /* vi: set ts=4 sw=4 expandtab: */