SDL_render.h 62 KB

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