SDL_render.h 62 KB

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