IVideoDriver.h 71 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #ifndef IRR_I_VIDEO_DRIVER_H_INCLUDED
  5. #define IRR_I_VIDEO_DRIVER_H_INCLUDED
  6. #include "rect.h"
  7. #include "SColor.h"
  8. #include "ITexture.h"
  9. #include "irrArray.h"
  10. #include "matrix4.h"
  11. #include "plane3d.h"
  12. #include "dimension2d.h"
  13. #include "position2d.h"
  14. #include "triangle3d.h"
  15. #include "EDriverTypes.h"
  16. #include "EDriverFeatures.h"
  17. #include "EPrimitiveTypes.h"
  18. #include "SExposedVideoData.h"
  19. #include "S3DVertex.h"
  20. #include "SVertexIndex.h"
  21. namespace irr
  22. {
  23. namespace io
  24. {
  25. class IAttributes;
  26. struct SAttributeReadWriteOptions;
  27. class IReadFile;
  28. class IWriteFile;
  29. } // end namespace io
  30. namespace scene
  31. {
  32. class IMeshBuffer;
  33. class IMesh;
  34. class IMeshManipulator;
  35. class ISceneNode;
  36. } // end namespace scene
  37. namespace video
  38. {
  39. struct S3DVertex;
  40. struct S3DVertex2TCoords;
  41. struct S3DVertexTangents;
  42. struct SLight;
  43. struct SOverrideMaterial;
  44. class SMaterial;
  45. class IImageLoader;
  46. class IImageWriter;
  47. class IMaterialRenderer;
  48. class IGPUProgrammingServices;
  49. class IRenderTarget;
  50. //! enumeration for geometry transformation states
  51. enum E_TRANSFORMATION_STATE
  52. {
  53. //! View transformation
  54. ETS_VIEW = 0,
  55. //! World transformation
  56. ETS_WORLD,
  57. //! Projection transformation
  58. ETS_PROJECTION,
  59. //! Texture transformation
  60. ETS_TEXTURE_0,
  61. //! Texture transformation
  62. ETS_TEXTURE_1,
  63. //! Texture transformation
  64. ETS_TEXTURE_2,
  65. //! Texture transformation
  66. ETS_TEXTURE_3,
  67. #if _IRR_MATERIAL_MAX_TEXTURES_>4
  68. //! Texture transformation
  69. ETS_TEXTURE_4,
  70. #if _IRR_MATERIAL_MAX_TEXTURES_>5
  71. //! Texture transformation
  72. ETS_TEXTURE_5,
  73. #if _IRR_MATERIAL_MAX_TEXTURES_>6
  74. //! Texture transformation
  75. ETS_TEXTURE_6,
  76. #if _IRR_MATERIAL_MAX_TEXTURES_>7
  77. //! Texture transformation
  78. ETS_TEXTURE_7,
  79. #endif
  80. #endif
  81. #endif
  82. #endif
  83. //! Only used internally
  84. ETS_COUNT = ETS_TEXTURE_0 + _IRR_MATERIAL_MAX_TEXTURES_
  85. };
  86. //! Special render targets, which usually map to dedicated hardware
  87. /** These render targets (besides 0 and 1) need not be supported by gfx cards */
  88. enum E_RENDER_TARGET
  89. {
  90. //! Render target is the main color frame buffer
  91. ERT_FRAME_BUFFER=0,
  92. //! Render target is a render texture
  93. ERT_RENDER_TEXTURE,
  94. //! Multi-Render target textures
  95. ERT_MULTI_RENDER_TEXTURES,
  96. //! Render target is the main color frame buffer
  97. ERT_STEREO_LEFT_BUFFER,
  98. //! Render target is the right color buffer (left is the main buffer)
  99. ERT_STEREO_RIGHT_BUFFER,
  100. //! Render to both stereo buffers at once
  101. ERT_STEREO_BOTH_BUFFERS,
  102. //! Auxiliary buffer 0
  103. ERT_AUX_BUFFER0,
  104. //! Auxiliary buffer 1
  105. ERT_AUX_BUFFER1,
  106. //! Auxiliary buffer 2
  107. ERT_AUX_BUFFER2,
  108. //! Auxiliary buffer 3
  109. ERT_AUX_BUFFER3,
  110. //! Auxiliary buffer 4
  111. ERT_AUX_BUFFER4
  112. };
  113. //! Enum for the flags of clear buffer
  114. enum E_CLEAR_BUFFER_FLAG
  115. {
  116. ECBF_NONE = 0,
  117. ECBF_COLOR = 1,
  118. ECBF_DEPTH = 2,
  119. ECBF_STENCIL = 4,
  120. ECBF_ALL = ECBF_COLOR|ECBF_DEPTH|ECBF_STENCIL
  121. };
  122. //! Enum for the types of fog distributions to choose from
  123. enum E_FOG_TYPE
  124. {
  125. EFT_FOG_EXP=0,
  126. EFT_FOG_LINEAR,
  127. EFT_FOG_EXP2
  128. };
  129. const c8* const FogTypeNames[] =
  130. {
  131. "FogExp",
  132. "FogLinear",
  133. "FogExp2",
  134. 0
  135. };
  136. //! Interface to driver which is able to perform 2d and 3d graphics functions.
  137. /** This interface is one of the most important interfaces of
  138. the Irrlicht Engine: All rendering and texture manipulation is done with
  139. this interface. You are able to use the Irrlicht Engine by only
  140. invoking methods of this interface if you like to, although the
  141. irr::scene::ISceneManager interface provides a lot of powerful classes
  142. and methods to make the programmer's life easier.
  143. */
  144. class IVideoDriver : public virtual IReferenceCounted
  145. {
  146. public:
  147. //! Applications must call this method before performing any rendering.
  148. /** This method can clear the back- and the z-buffer.
  149. \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags.
  150. \param clearColor The clear color for the color buffer.
  151. \param clearDepth The clear value for the depth buffer.
  152. \param clearStencil The clear value for the stencil buffer.
  153. \param videoData Handle of another window, if you want the
  154. bitmap to be displayed on another window. If this is an empty
  155. element, everything will be displayed in the default window.
  156. Note: This feature is not fully implemented for all devices.
  157. \param sourceRect Pointer to a rectangle defining the source
  158. rectangle of the area to be presented. Set to null to present
  159. everything. Note: not implemented in all devices.
  160. \return False if failed. */
  161. virtual bool beginScene(u16 clearFlag=(u16)(ECBF_COLOR|ECBF_DEPTH), SColor clearColor = SColor(255,0,0,0), f32 clearDepth = 1.f, u8 clearStencil = 0,
  162. const SExposedVideoData& videoData=SExposedVideoData(), core::rect<s32>* sourceRect = 0) = 0;
  163. //! Alternative beginScene implementation. Can't clear stencil buffer, but otherwise identical to other beginScene
  164. bool beginScene(bool backBuffer, bool zBuffer, SColor color = SColor(255,0,0,0),
  165. const SExposedVideoData& videoData = SExposedVideoData(), core::rect<s32>* sourceRect = 0)
  166. {
  167. u16 flag = 0;
  168. if (backBuffer)
  169. flag |= ECBF_COLOR;
  170. if (zBuffer)
  171. flag |= ECBF_DEPTH;
  172. return beginScene(flag, color, 1.f, 0, videoData, sourceRect);
  173. }
  174. //! Presents the rendered image to the screen.
  175. /** Applications must call this method after performing any
  176. rendering.
  177. \return False if failed and true if succeeded. */
  178. virtual bool endScene() = 0;
  179. //! Queries the features of the driver.
  180. /** Returns true if a feature is available
  181. \param feature Feature to query.
  182. \return True if the feature is available, false if not. */
  183. virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const =0;
  184. //! Disable a feature of the driver.
  185. /** Can also be used to enable the features again. It is not
  186. possible to enable unsupported features this way, though.
  187. \param feature Feature to disable.
  188. \param flag When true the feature is disabled, otherwise it is enabled. */
  189. virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
  190. //! Get attributes of the actual video driver
  191. /** The following names can be queried for the given types:
  192. MaxTextures (int) The maximum number of simultaneous textures supported by the driver. This can be less than the supported number of textures of the driver. Use _IRR_MATERIAL_MAX_TEXTURES_ to adapt the number.
  193. MaxSupportedTextures (int) The maximum number of simultaneous textures supported by the fixed function pipeline of the (hw) driver. The actual supported number of textures supported by the engine can be lower.
  194. MaxLights (int) Number of hardware lights supported in the fixed function pipeline of the driver, typically 6-8. Use light manager or deferred shading for more.
  195. MaxAnisotropy (int) Number of anisotropy levels supported for filtering. At least 1, max is typically at 16 or 32.
  196. MaxUserClipPlanes (int) Number of additional clip planes, which can be set by the user via dedicated driver methods.
  197. MaxAuxBuffers (int) Special render buffers, which are currently not really usable inside Irrlicht. Only supported by OpenGL
  198. MaxMultipleRenderTargets (int) Number of render targets which can be bound simultaneously. Rendering to MRTs is done via shaders.
  199. MaxIndices (int) Number of indices which can be used in one render call (i.e. one mesh buffer).
  200. MaxTextureSize (int) Dimension that a texture may have, both in width and height.
  201. MaxGeometryVerticesOut (int) Number of vertices the geometry shader can output in one pass. Only OpenGL so far.
  202. MaxTextureLODBias (float) Maximum value for LOD bias. Is usually at around 16, but can be lower on some systems.
  203. Version (int) Version of the driver. Should be Major*100+Minor
  204. ShaderLanguageVersion (int) Version of the high level shader language. Should be Major*100+Minor.
  205. AntiAlias (int) Number of Samples the driver uses for each pixel. 0 and 1 means anti aliasing is off, typical values are 2,4,8,16,32
  206. */
  207. virtual const io::IAttributes& getDriverAttributes() const=0;
  208. //! Check if the driver was recently reset.
  209. /** For d3d devices you will need to recreate the RTTs if the
  210. driver was reset. Should be queried right after beginScene().
  211. */
  212. virtual bool checkDriverReset() =0;
  213. //! Sets transformation matrices.
  214. /** \param state Transformation type to be set, e.g. view,
  215. world, or projection.
  216. \param mat Matrix describing the transformation. */
  217. virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) =0;
  218. //! Returns the transformation set by setTransform
  219. /** \param state Transformation type to query
  220. \return Matrix describing the transformation. */
  221. virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const =0;
  222. //! Retrieve the number of image loaders
  223. /** \return Number of image loaders */
  224. virtual u32 getImageLoaderCount() const = 0;
  225. //! Retrieve the given image loader
  226. /** \param n The index of the loader to retrieve. This parameter is an 0-based
  227. array index.
  228. \return A pointer to the specified loader, 0 if the index is incorrect. */
  229. virtual IImageLoader* getImageLoader(u32 n) = 0;
  230. //! Retrieve the number of image writers
  231. /** \return Number of image writers */
  232. virtual u32 getImageWriterCount() const = 0;
  233. //! Retrieve the given image writer
  234. /** \param n The index of the writer to retrieve. This parameter is an 0-based
  235. array index.
  236. \return A pointer to the specified writer, 0 if the index is incorrect. */
  237. virtual IImageWriter* getImageWriter(u32 n) = 0;
  238. //! Sets a material.
  239. /** All 3d drawing functions will draw geometry using this material thereafter.
  240. \param material: Material to be used from now on. */
  241. virtual void setMaterial(const SMaterial& material) =0;
  242. //! Get access to a named texture.
  243. /** Loads the texture from disk if it is not
  244. already loaded and generates mipmap levels if desired.
  245. Texture loading can be influenced using the
  246. setTextureCreationFlag() method. The texture can be in several
  247. imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD.
  248. \param filename Filename of the texture to be loaded.
  249. \return Pointer to the texture, or 0 if the texture
  250. could not be loaded. This pointer should not be dropped. See
  251. IReferenceCounted::drop() for more information. */
  252. virtual ITexture* getTexture(const io::path& filename) = 0;
  253. //! Get access to a named texture.
  254. /** Loads the texture from disk if it is not
  255. already loaded and generates mipmap levels if desired.
  256. Texture loading can be influenced using the
  257. setTextureCreationFlag() method. The texture can be in several
  258. imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD.
  259. \param file Pointer to an already opened file.
  260. \return Pointer to the texture, or 0 if the texture
  261. could not be loaded. This pointer should not be dropped. See
  262. IReferenceCounted::drop() for more information. */
  263. virtual ITexture* getTexture(io::IReadFile* file) =0;
  264. //! Returns a texture by index
  265. /** \param index: Index of the texture, must be smaller than
  266. getTextureCount() Please note that this index might change when
  267. adding or removing textures
  268. \return Pointer to the texture, or 0 if the texture was not
  269. set or index is out of bounds. This pointer should not be
  270. dropped. See IReferenceCounted::drop() for more information. */
  271. virtual ITexture* getTextureByIndex(u32 index) =0;
  272. //! Returns amount of textures currently loaded
  273. /** \return Amount of textures currently loaded */
  274. virtual u32 getTextureCount() const = 0;
  275. //! Renames a texture
  276. /** \param texture Pointer to the texture to rename.
  277. \param newName New name for the texture. This should be a unique name. */
  278. virtual void renameTexture(ITexture* texture, const io::path& newName) = 0;
  279. //! Creates an empty texture of specified size.
  280. /** \param size: Size of the texture.
  281. \param name A name for the texture. Later calls to
  282. getTexture() with this name will return this texture.
  283. The name can _not_ be empty.
  284. \param format Desired color format of the texture. Please note
  285. that the driver may choose to create the texture in another
  286. color format.
  287. \return Pointer to the newly created texture. This pointer
  288. should not be dropped. See IReferenceCounted::drop() for more
  289. information. */
  290. virtual ITexture* addTexture(const core::dimension2d<u32>& size,
  291. const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
  292. //! Creates a texture from an IImage.
  293. /** \param name A name for the texture. Later calls of
  294. getTexture() with this name will return this texture.
  295. The name can _not_ be empty.
  296. \param image Image the texture is created from.
  297. \param mipmapData Optional pointer to a mipmaps data.
  298. If this parameter is not given, the mipmaps are derived from image.
  299. \return Pointer to the newly created texture. This pointer
  300. should not be dropped. See IReferenceCounted::drop() for more
  301. information. */
  302. IRR_DEPRECATED ITexture* addTexture(const io::path& name, IImage* image, void* mipmapData)
  303. {
  304. if (image)
  305. image->setMipMapsData(mipmapData, false, true);
  306. return addTexture(name, image);
  307. }
  308. //! Creates a texture from an IImage.
  309. /** \param name A name for the texture. Later calls of
  310. getTexture() with this name will return this texture.
  311. The name can _not_ be empty.
  312. \param image Image the texture is created from.
  313. \return Pointer to the newly created texture. This pointer
  314. should not be dropped. See IReferenceCounted::drop() for more
  315. information. */
  316. virtual ITexture* addTexture(const io::path& name, IImage* image) = 0;
  317. //! Creates a cubemap texture from loaded IImages.
  318. /** \param name A name for the texture. Later calls of getTexture() with this name will return this texture.
  319. The name can _not_ be empty.
  320. \param imagePosX Image (positive X) the texture is created from.
  321. \param imageNegX Image (negative X) the texture is created from.
  322. \param imagePosY Image (positive Y) the texture is created from.
  323. \param imageNegY Image (negative Y) the texture is created from.
  324. \param imagePosZ Image (positive Z) the texture is created from.
  325. \param imageNegZ Image (negative Z) the texture is created from.
  326. \return Pointer to the newly created texture. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
  327. virtual ITexture* addTextureCubemap(const io::path& name, IImage* imagePosX, IImage* imageNegX, IImage* imagePosY,
  328. IImage* imageNegY, IImage* imagePosZ, IImage* imageNegZ) = 0;
  329. //! Creates an empty cubemap texture of specified size.
  330. /** \param sideLen diameter of one side of the cube
  331. \param name A name for the texture. Later calls of
  332. getTexture() with this name will return this texture.
  333. The name can _not_ be empty.
  334. \param format Desired color format of the texture. Please note
  335. that the driver may choose to create the texture in another
  336. color format.
  337. \return Pointer to the newly created texture. */
  338. virtual ITexture* addTextureCubemap(const irr::u32 sideLen, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
  339. //! Adds a new render target texture to the texture cache.
  340. /** \param size Size of the texture, in pixels. Width and
  341. height should be a power of two (e.g. 64, 128, 256, 512, ...)
  342. and it should not be bigger than the backbuffer, because it
  343. shares the zbuffer with the screen buffer.
  344. \param name A name for the texture. Later calls of getTexture() with this name will return this texture.
  345. The name can _not_ be empty.
  346. \param format The color format of the render target. Floating point formats are supported.
  347. \return Pointer to the created texture or 0 if the texture
  348. could not be created. This pointer should not be dropped. See
  349. IReferenceCounted::drop() for more information.
  350. You may want to remove it from driver texture cache with removeTexture if you no longer need it.
  351. */
  352. virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
  353. const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
  354. //! Adds a new render target texture with 6 sides for a cubemap map to the texture cache.
  355. /** \param sideLen Length of one cubemap side.
  356. \param name A name for the texture. Later calls of getTexture() with this name will return this texture.
  357. The name can _not_ be empty.
  358. \param format The color format of the render target. Floating point formats are supported.
  359. \return Pointer to the created texture or 0 if the texture
  360. could not be created. This pointer should not be dropped. See
  361. IReferenceCounted::drop() for more information. */
  362. virtual ITexture* addRenderTargetTextureCubemap(const irr::u32 sideLen,
  363. const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
  364. //! Removes a texture from the texture cache and deletes it.
  365. /** This method can free a lot of memory!
  366. Please note that after calling this, the pointer to the
  367. ITexture may no longer be valid, if it was not grabbed before
  368. by other parts of the engine for storing it longer. So it is a
  369. good idea to set all materials which are using this texture to
  370. 0 or another texture first.
  371. \param texture Texture to delete from the engine cache. */
  372. virtual void removeTexture(ITexture* texture) =0;
  373. //! Removes all textures from the texture cache and deletes them.
  374. /** This method can free a lot of memory!
  375. Please note that after calling this, the pointer to the
  376. ITexture may no longer be valid, if it was not grabbed before
  377. by other parts of the engine for storing it longer. So it is a
  378. good idea to set all materials which are using this texture to
  379. 0 or another texture first. */
  380. virtual void removeAllTextures() =0;
  381. //! Remove hardware buffer
  382. virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb) =0;
  383. //! Remove all hardware buffers
  384. virtual void removeAllHardwareBuffers() =0;
  385. //! Create occlusion query.
  386. /** Use node for identification and mesh for occlusion test. */
  387. virtual void addOcclusionQuery(scene::ISceneNode* node,
  388. const scene::IMesh* mesh=0) =0;
  389. //! Remove occlusion query.
  390. virtual void removeOcclusionQuery(scene::ISceneNode* node) =0;
  391. //! Remove all occlusion queries.
  392. virtual void removeAllOcclusionQueries() =0;
  393. //! Run occlusion query. Draws mesh stored in query.
  394. /** If the mesh shall not be rendered visible, use
  395. overrideMaterial to disable the color and depth buffer. */
  396. virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false) =0;
  397. //! Run all occlusion queries. Draws all meshes stored in queries.
  398. /** If the meshes shall not be rendered visible, use
  399. overrideMaterial to disable the color and depth buffer. */
  400. virtual void runAllOcclusionQueries(bool visible=false) =0;
  401. //! Update occlusion query. Retrieves results from GPU.
  402. /** If the query shall not block, set the flag to false.
  403. Update might not occur in this case, though */
  404. virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true) =0;
  405. //! Update all occlusion queries. Retrieves results from GPU.
  406. /** If the query shall not block, set the flag to false.
  407. Update might not occur in this case, though */
  408. virtual void updateAllOcclusionQueries(bool block=true) =0;
  409. //! Return query result.
  410. /** Return value is the number of visible pixels/fragments.
  411. The value is a safe approximation, i.e. can be larger than the
  412. actual value of pixels. */
  413. virtual u32 getOcclusionQueryResult(const scene::ISceneNode* node) const =0;
  414. //! Create render target.
  415. virtual IRenderTarget* addRenderTarget() = 0;
  416. //! Remove render target.
  417. virtual void removeRenderTarget(IRenderTarget* renderTarget) = 0;
  418. //! Remove all render targets.
  419. virtual void removeAllRenderTargets() = 0;
  420. //! Sets a boolean alpha channel on the texture based on a color key.
  421. /** This makes the texture fully transparent at the texels where
  422. this color key can be found when using for example draw2DImage
  423. with useAlphachannel==true. The alpha of other texels is not modified.
  424. \param texture Texture whose alpha channel is modified.
  425. \param color Color key color. Every texel with this color will
  426. become fully transparent as described above. Please note that the
  427. colors of a texture may be converted when loading it, so the
  428. color values may not be exactly the same in the engine and for
  429. example in picture edit programs. To avoid this problem, you
  430. could use the makeColorKeyTexture method, which takes the
  431. position of a pixel instead a color value.
  432. \param zeroTexels (deprecated) If set to true, then any texels that match
  433. the color key will have their color, as well as their alpha, set to zero
  434. (i.e. black). This behavior matches the legacy (buggy) behavior prior
  435. to release 1.5 and is provided for backwards compatibility only.
  436. This parameter may be removed by Irrlicht 1.9. */
  437. virtual void makeColorKeyTexture(video::ITexture* texture,
  438. video::SColor color,
  439. bool zeroTexels = false) const =0;
  440. //! Sets a boolean alpha channel on the texture based on the color at a position.
  441. /** This makes the texture fully transparent at the texels where
  442. the color key can be found when using for example draw2DImage
  443. with useAlphachannel==true. The alpha of other texels is not modified.
  444. \param texture Texture whose alpha channel is modified.
  445. \param colorKeyPixelPos Position of a pixel with the color key
  446. color. Every texel with this color will become fully transparent as
  447. described above.
  448. \param zeroTexels (deprecated) If set to true, then any texels that match
  449. the color key will have their color, as well as their alpha, set to zero
  450. (i.e. black). This behavior matches the legacy (buggy) behavior prior
  451. to release 1.5 and is provided for backwards compatibility only.
  452. This parameter may be removed by Irrlicht 1.9. */
  453. virtual void makeColorKeyTexture(video::ITexture* texture,
  454. core::position2d<s32> colorKeyPixelPos,
  455. bool zeroTexels = false) const =0;
  456. //! Creates a normal map from a height map texture.
  457. /** As input is considered to be a height map the texture is read like:
  458. - For a 32-bit texture only the red channel is regarded
  459. - For a 16-bit texture the rgb-values are averaged.
  460. Output channels red/green for X/Y and blue for up (Z).
  461. For a 32-bit texture we store additionally the height value in the
  462. alpha channel. This value is used by the video::EMT_PARALLAX_MAP_SOLID
  463. material and similar materials.
  464. On the borders the texture is considered to repeat.
  465. \param texture Height map texture which is converted to a normal map.
  466. \param amplitude Constant value by which the height
  467. information is multiplied.*/
  468. virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const =0;
  469. //! Set a render target.
  470. /** This will only work if the driver supports the
  471. EVDF_RENDER_TO_TARGET feature, which can be queried with
  472. queryFeature(). Please note that you cannot render 3D or 2D
  473. geometry with a render target as texture on it when you are rendering
  474. the scene into this render target at the same time. It is usually only
  475. possible to render into a texture between the
  476. IVideoDriver::beginScene() and endScene() method calls. If you need the
  477. best performance use this method instead of setRenderTarget.
  478. \param target Render target object.
  479. \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags.
  480. \param clearColor The clear color for the color buffer.
  481. \param clearDepth The clear value for the depth buffer.
  482. \param clearStencil The clear value for the stencil buffer.
  483. \return True if successful and false if not. */
  484. virtual bool setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),
  485. f32 clearDepth = 1.f, u8 clearStencil = 0) = 0;
  486. //! Sets a new render target.
  487. /** This will only work if the driver supports the
  488. EVDF_RENDER_TO_TARGET feature, which can be queried with
  489. queryFeature(). Usually, rendering to textures is done in this
  490. way:
  491. \code
  492. // create render target
  493. ITexture* target = driver->addRenderTargetTexture(core::dimension2d<u32>(128,128), "rtt1");
  494. // ...
  495. driver->setRenderTarget(target); // set render target
  496. // .. draw stuff here
  497. driver->setRenderTarget(0); // set previous render target
  498. \endcode
  499. Please note that you cannot render 3D or 2D geometry with a
  500. render target as texture on it when you are rendering the scene
  501. into this render target at the same time. It is usually only
  502. possible to render into a texture between the
  503. IVideoDriver::beginScene() and endScene() method calls.
  504. \param texture New render target. Must be a texture created with
  505. IVideoDriver::addRenderTargetTexture(). If set to 0, it sets
  506. the previous render target which was set before the last
  507. setRenderTarget() call.
  508. \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags.
  509. \param clearColor The clear color for the color buffer.
  510. \param clearDepth The clear value for the depth buffer.
  511. \param clearStencil The clear value for the stencil buffer.
  512. \return True if successful and false if not. */
  513. virtual bool setRenderTarget(ITexture* texture, u16 clearFlag=ECBF_COLOR|ECBF_DEPTH, SColor clearColor = SColor(255,0,0,0),
  514. f32 clearDepth = 1.f, u8 clearStencil = 0) = 0;
  515. //! Sets a new render target.
  516. //! Prefer to use the setRenderTarget function taking flags as parameter as this one can't clear the stencil buffer.
  517. //! It's still offered for backward compatibility.
  518. bool setRenderTarget(ITexture* texture, bool clearBackBuffer, bool clearZBuffer, SColor color = SColor(255,0,0,0))
  519. {
  520. u16 flag = 0;
  521. if (clearBackBuffer)
  522. flag |= ECBF_COLOR;
  523. if (clearZBuffer)
  524. flag |= ECBF_DEPTH;
  525. return setRenderTarget(texture, flag, color);
  526. }
  527. //! Sets a new viewport.
  528. /** Every rendering operation is done into this new area.
  529. \param area: Rectangle defining the new area of rendering
  530. operations. */
  531. virtual void setViewPort(const core::rect<s32>& area) =0;
  532. //! Gets the area of the current viewport.
  533. /** \return Rectangle of the current viewport. */
  534. virtual const core::rect<s32>& getViewPort() const =0;
  535. //! Draws a vertex primitive list
  536. /** Note that, depending on the index type, some vertices might be not
  537. accessible through the index list. The limit is at 65535 vertices for 16bit
  538. indices. Please note that currently not all primitives are available for
  539. all drivers, and some might be emulated via triangle renders.
  540. \param vertices Pointer to array of vertices.
  541. \param vertexCount Amount of vertices in the array.
  542. \param indexList Pointer to array of indices. These define the vertices used
  543. for each primitive. Depending on the pType, indices are interpreted as single
  544. objects (for point like primitives), pairs (for lines), triplets (for
  545. triangles), or quads.
  546. \param primCount Amount of Primitives
  547. \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
  548. \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
  549. \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
  550. virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
  551. const void* indexList, u32 primCount,
  552. E_VERTEX_TYPE vType=EVT_STANDARD,
  553. scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
  554. E_INDEX_TYPE iType=EIT_16BIT) =0;
  555. //! Draws a vertex primitive list in 2d
  556. /** Compared to the general (3d) version of this method, this
  557. one sets up a 2d render mode, and uses only x and y of vectors.
  558. Note that, depending on the index type, some vertices might be
  559. not accessible through the index list. The limit is at 65535
  560. vertices for 16bit indices. Please note that currently not all
  561. primitives are available for all drivers, and some might be
  562. emulated via triangle renders. This function is not available
  563. for the sw drivers.
  564. \param vertices Pointer to array of vertices.
  565. \param vertexCount Amount of vertices in the array.
  566. \param indexList Pointer to array of indices. These define the
  567. vertices used for each primitive. Depending on the pType,
  568. indices are interpreted as single objects (for point like
  569. primitives), pairs (for lines), triplets (for triangles), or
  570. quads.
  571. \param primCount Amount of Primitives
  572. \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
  573. \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
  574. \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
  575. virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
  576. const void* indexList, u32 primCount,
  577. E_VERTEX_TYPE vType=EVT_STANDARD,
  578. scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
  579. E_INDEX_TYPE iType=EIT_16BIT) =0;
  580. //! Draws an indexed triangle list.
  581. /** Note that there may be at maximum 65536 vertices, because
  582. the index list is an array of 16 bit values each with a maximum
  583. value of 65536. If there are more than 65536 vertices in the
  584. list, results of this operation are not defined.
  585. \param vertices Pointer to array of vertices.
  586. \param vertexCount Amount of vertices in the array.
  587. \param indexList Pointer to array of indices.
  588. \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
  589. void drawIndexedTriangleList(const S3DVertex* vertices,
  590. u32 vertexCount, const u16* indexList, u32 triangleCount)
  591. {
  592. drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT);
  593. }
  594. //! Draws an indexed triangle list.
  595. /** Note that there may be at maximum 65536 vertices, because
  596. the index list is an array of 16 bit values each with a maximum
  597. value of 65536. If there are more than 65536 vertices in the
  598. list, results of this operation are not defined.
  599. \param vertices Pointer to array of vertices.
  600. \param vertexCount Amount of vertices in the array.
  601. \param indexList Pointer to array of indices.
  602. \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
  603. void drawIndexedTriangleList(const S3DVertex2TCoords* vertices,
  604. u32 vertexCount, const u16* indexList, u32 triangleCount)
  605. {
  606. drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT);
  607. }
  608. //! Draws an indexed triangle list.
  609. /** Note that there may be at maximum 65536 vertices, because
  610. the index list is an array of 16 bit values each with a maximum
  611. value of 65536. If there are more than 65536 vertices in the
  612. list, results of this operation are not defined.
  613. \param vertices Pointer to array of vertices.
  614. \param vertexCount Amount of vertices in the array.
  615. \param indexList Pointer to array of indices.
  616. \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
  617. void drawIndexedTriangleList(const S3DVertexTangents* vertices,
  618. u32 vertexCount, const u16* indexList, u32 triangleCount)
  619. {
  620. drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT);
  621. }
  622. //! Draws an indexed triangle fan.
  623. /** Note that there may be at maximum 65536 vertices, because
  624. the index list is an array of 16 bit values each with a maximum
  625. value of 65536. If there are more than 65536 vertices in the
  626. list, results of this operation are not defined.
  627. \param vertices Pointer to array of vertices.
  628. \param vertexCount Amount of vertices in the array.
  629. \param indexList Pointer to array of indices.
  630. \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
  631. void drawIndexedTriangleFan(const S3DVertex* vertices,
  632. u32 vertexCount, const u16* indexList, u32 triangleCount)
  633. {
  634. drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
  635. }
  636. //! Draws an indexed triangle fan.
  637. /** Note that there may be at maximum 65536 vertices, because
  638. the index list is an array of 16 bit values each with a maximum
  639. value of 65536. If there are more than 65536 vertices in the
  640. list, results of this operation are not defined.
  641. \param vertices Pointer to array of vertices.
  642. \param vertexCount Amount of vertices in the array.
  643. \param indexList Pointer to array of indices.
  644. \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
  645. void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
  646. u32 vertexCount, const u16* indexList, u32 triangleCount)
  647. {
  648. drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
  649. }
  650. //! Draws an indexed triangle fan.
  651. /** Note that there may be at maximum 65536 vertices, because
  652. the index list is an array of 16 bit values each with a maximum
  653. value of 65536. If there are more than 65536 vertices in the
  654. list, results of this operation are not defined.
  655. \param vertices Pointer to array of vertices.
  656. \param vertexCount Amount of vertices in the array.
  657. \param indexList Pointer to array of indices.
  658. \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
  659. void drawIndexedTriangleFan(const S3DVertexTangents* vertices,
  660. u32 vertexCount, const u16* indexList, u32 triangleCount)
  661. {
  662. drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
  663. }
  664. //! Draws a 3d line.
  665. /** For some implementations, this method simply calls
  666. drawVertexPrimitiveList for some triangles.
  667. Note that the line is drawn using the current transformation
  668. matrix and material. So if you need to draw the 3D line
  669. independently of the current transformation, use
  670. \code
  671. driver->setMaterial(someMaterial);
  672. driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
  673. \endcode
  674. for some properly set up material before drawing the line.
  675. Some drivers support line thickness set in the material.
  676. \param start Start of the 3d line.
  677. \param end End of the 3d line.
  678. \param color Color of the line. */
  679. virtual void draw3DLine(const core::vector3df& start,
  680. const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0;
  681. //! Draws a 3d triangle.
  682. /** This method calls drawVertexPrimitiveList for some triangles.
  683. This method works with all drivers because it simply calls
  684. drawVertexPrimitiveList, but it is hence not very fast.
  685. Note that the triangle is drawn using the current
  686. transformation matrix and material. So if you need to draw it
  687. independently of the current transformation, use
  688. \code
  689. driver->setMaterial(someMaterial);
  690. driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
  691. \endcode
  692. for some properly set up material before drawing the triangle.
  693. \param triangle The triangle to draw.
  694. \param color Color of the line. */
  695. virtual void draw3DTriangle(const core::triangle3df& triangle,
  696. SColor color = SColor(255,255,255,255)) =0;
  697. //! Draws a 3d axis aligned box.
  698. /** This method simply calls draw3DLine for the edges of the
  699. box. Note that the box is drawn using the current transformation
  700. matrix and material. So if you need to draw it independently of
  701. the current transformation, use
  702. \code
  703. driver->setMaterial(someMaterial);
  704. driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
  705. \endcode
  706. for some properly set up material before drawing the box.
  707. \param box The axis aligned box to draw
  708. \param color Color to use while drawing the box. */
  709. virtual void draw3DBox(const core::aabbox3d<f32>& box,
  710. SColor color = SColor(255,255,255,255)) =0;
  711. //! Draws a 2d image without any special effects
  712. /** \param texture Pointer to texture to use.
  713. \param destPos Upper left 2d destination position where the
  714. image will be drawn.
  715. \param useAlphaChannelOfTexture: If true, the alpha channel of
  716. the texture is used to draw the image.*/
  717. virtual void draw2DImage(const video::ITexture* texture,
  718. const core::position2d<s32>& destPos, bool useAlphaChannelOfTexture=false) =0;
  719. //! Draws a 2d image using a color
  720. /** (if color is other than
  721. Color(255,255,255,255)) and the alpha channel of the texture.
  722. \param texture Texture to be drawn.
  723. \param destPos Upper left 2d destination position where the
  724. image will be drawn.
  725. \param sourceRect Source rectangle in the texture (based on it's OriginalSize)
  726. \param clipRect Pointer to rectangle on the screen where the
  727. image is clipped to.
  728. If this pointer is NULL the image is not clipped.
  729. \param color Color with which the image is drawn. If the color
  730. equals Color(255,255,255,255) it is ignored. Note that the
  731. alpha component is used: If alpha is other than 255, the image
  732. will be transparent.
  733. \param useAlphaChannelOfTexture: If true, the alpha channel of
  734. the texture is used to draw the image.*/
  735. virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
  736. const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
  737. SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0;
  738. //! Draws a set of 2d images, using a color and the alpha channel of the texture.
  739. /** The images are drawn beginning at pos and concatenated in
  740. one line. All drawings are clipped against clipRect (if != 0).
  741. The subtextures are defined by the array of sourceRects and are
  742. chosen by the indices given.
  743. \param texture Texture to be drawn.
  744. \param pos Upper left 2d destination position where the image
  745. will be drawn.
  746. \param sourceRects Source rectangles of the texture (based on it's OriginalSize)
  747. \param indices List of indices which choose the actual
  748. rectangle used each time.
  749. \param kerningWidth Offset to Position on X
  750. \param clipRect Pointer to rectangle on the screen where the
  751. image is clipped to.
  752. If this pointer is 0 then the image is not clipped.
  753. \param color Color with which the image is drawn.
  754. Note that the alpha component is used. If alpha is other than
  755. 255, the image will be transparent.
  756. \param useAlphaChannelOfTexture: If true, the alpha channel of
  757. the texture is used to draw the image. */
  758. virtual void draw2DImageBatch(const video::ITexture* texture,
  759. const core::position2d<s32>& pos,
  760. const core::array<core::rect<s32> >& sourceRects,
  761. const core::array<s32>& indices,
  762. s32 kerningWidth=0,
  763. const core::rect<s32>* clipRect=0,
  764. SColor color=SColor(255,255,255,255),
  765. bool useAlphaChannelOfTexture=false) =0;
  766. //! Draws a set of 2d images, using a color and the alpha channel of the texture.
  767. /** All drawings are clipped against clipRect (if != 0).
  768. The subtextures are defined by the array of sourceRects and are
  769. positioned using the array of positions.
  770. \param texture Texture to be drawn.
  771. \param positions Array of upper left 2d destinations where the
  772. images will be drawn.
  773. \param sourceRects Source rectangles of the texture (based on it's OriginalSize)
  774. \param clipRect Pointer to rectangle on the screen where the
  775. images are clipped to.
  776. If this pointer is 0 then the image is not clipped.
  777. \param color Color with which the image is drawn.
  778. Note that the alpha component is used. If alpha is other than
  779. 255, the image will be transparent.
  780. \param useAlphaChannelOfTexture: If true, the alpha channel of
  781. the texture is used to draw the image. */
  782. virtual void draw2DImageBatch(const video::ITexture* texture,
  783. const core::array<core::position2d<s32> >& positions,
  784. const core::array<core::rect<s32> >& sourceRects,
  785. const core::rect<s32>* clipRect=0,
  786. SColor color=SColor(255,255,255,255),
  787. bool useAlphaChannelOfTexture=false) =0;
  788. //! Draws a part of the texture into the rectangle. Note that colors must be an array of 4 colors if used.
  789. /** Suggested and first implemented by zola.
  790. \param texture The texture to draw from
  791. \param destRect The rectangle to draw into
  792. \param sourceRect The rectangle denoting a part of the texture (based on it's OriginalSize)
  793. \param clipRect Clips the destination rectangle (may be 0)
  794. \param colors Array of 4 colors denoting the color values of
  795. the corners of the destRect
  796. \param useAlphaChannelOfTexture True if alpha channel will be
  797. blended. */
  798. virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
  799. const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
  800. const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0;
  801. //! Draws a 2d rectangle.
  802. /** \param color Color of the rectangle to draw. The alpha
  803. component will not be ignored and specifies how transparent the
  804. rectangle will be.
  805. \param pos Position of the rectangle.
  806. \param clip Pointer to rectangle against which the rectangle
  807. will be clipped. If the pointer is null, no clipping will be
  808. performed. */
  809. virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
  810. const core::rect<s32>* clip =0) =0;
  811. //! Draws a 2d rectangle with a gradient.
  812. /** \param colorLeftUp Color of the upper left corner to draw.
  813. The alpha component will not be ignored and specifies how
  814. transparent the rectangle will be.
  815. \param colorRightUp Color of the upper right corner to draw.
  816. The alpha component will not be ignored and specifies how
  817. transparent the rectangle will be.
  818. \param colorLeftDown Color of the lower left corner to draw.
  819. The alpha component will not be ignored and specifies how
  820. transparent the rectangle will be.
  821. \param colorRightDown Color of the lower right corner to draw.
  822. The alpha component will not be ignored and specifies how
  823. transparent the rectangle will be.
  824. \param pos Position of the rectangle.
  825. \param clip Pointer to rectangle against which the rectangle
  826. will be clipped. If the pointer is null, no clipping will be
  827. performed. */
  828. virtual void draw2DRectangle(const core::rect<s32>& pos,
  829. SColor colorLeftUp, SColor colorRightUp,
  830. SColor colorLeftDown, SColor colorRightDown,
  831. const core::rect<s32>* clip =0) =0;
  832. //! Draws the outline of a 2D rectangle.
  833. /** \param pos Position of the rectangle.
  834. \param color Color of the rectangle to draw. The alpha component
  835. specifies how transparent the rectangle outline will be. */
  836. virtual void draw2DRectangleOutline(const core::recti& pos,
  837. SColor color=SColor(255,255,255,255)) =0;
  838. //! Draws a 2d line.
  839. /** In theory both start and end will be included in coloring.
  840. BUG: Currently hardware drivers (d3d/opengl) ignore the last pixel
  841. (they use the so called "diamond exit rule" for drawing lines).
  842. \param start Screen coordinates of the start of the line
  843. in pixels.
  844. \param end Screen coordinates of the start of the line in
  845. pixels.
  846. \param color Color of the line to draw. */
  847. virtual void draw2DLine(const core::position2d<s32>& start,
  848. const core::position2d<s32>& end,
  849. SColor color=SColor(255,255,255,255)) =0;
  850. //! Draws a pixel.
  851. /** \param x The x-position of the pixel.
  852. \param y The y-position of the pixel.
  853. \param color Color of the pixel to draw. */
  854. virtual void drawPixel(u32 x, u32 y, const SColor& color) =0;
  855. //! Draws a non filled concyclic regular 2d polygon.
  856. /** This method can be used to draw circles, but also
  857. triangles, tetragons, pentagons, hexagons, heptagons, octagons,
  858. enneagons, decagons, hendecagons, dodecagon, triskaidecagons,
  859. etc. I think you'll got it now. And all this by simply
  860. specifying the vertex count. Welcome to the wonders of
  861. geometry.
  862. \param center Position of center of circle (pixels).
  863. \param radius Radius of circle in pixels.
  864. \param color Color of the circle.
  865. \param vertexCount Amount of vertices of the polygon. Specify 2
  866. to draw a line, 3 to draw a triangle, 4 for tetragons and a lot
  867. (>10) for nearly a circle. */
  868. virtual void draw2DPolygon(core::position2d<s32> center,
  869. f32 radius,
  870. video::SColor color=SColor(100,255,255,255),
  871. s32 vertexCount=10) =0;
  872. //! Draws a shadow volume into the stencil buffer.
  873. /** To draw a stencil shadow, do this: First, draw all geometry.
  874. Then use this method, to draw the shadow volume. Then, use
  875. IVideoDriver::drawStencilShadow() to visualize the shadow.
  876. Please note that the code for the opengl version of the method
  877. is based on free code sent in by Philipp Dortmann, lots of
  878. thanks go to him!
  879. \param triangles Array of 3d vectors, specifying the shadow
  880. volume.
  881. \param zfail If set to true, zfail method is used, otherwise
  882. zpass.
  883. \param debugDataVisible The debug data that is enabled for this
  884. shadow node
  885. */
  886. virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true, u32 debugDataVisible=0) =0;
  887. //! Fills the stencil shadow with color.
  888. /** After the shadow volume has been drawn into the stencil
  889. buffer using IVideoDriver::drawStencilShadowVolume(), use this
  890. to draw the color of the shadow.
  891. Please note that the code for the opengl version of the method
  892. is based on free code sent in by Philipp Dortmann, lots of
  893. thanks go to him!
  894. \param clearStencilBuffer Set this to false, if you want to
  895. draw every shadow with the same color, and only want to call
  896. drawStencilShadow() once after all shadow volumes have been
  897. drawn. Set this to true, if you want to paint every shadow with
  898. its own color.
  899. \param leftUpEdge Color of the shadow in the upper left corner
  900. of screen.
  901. \param rightUpEdge Color of the shadow in the upper right
  902. corner of screen.
  903. \param leftDownEdge Color of the shadow in the lower left
  904. corner of screen.
  905. \param rightDownEdge Color of the shadow in the lower right
  906. corner of screen. */
  907. virtual void drawStencilShadow(bool clearStencilBuffer=false,
  908. video::SColor leftUpEdge = video::SColor(255,0,0,0),
  909. video::SColor rightUpEdge = video::SColor(255,0,0,0),
  910. video::SColor leftDownEdge = video::SColor(255,0,0,0),
  911. video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0;
  912. //! Draws a mesh buffer
  913. /** \param mb Buffer to draw */
  914. virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0;
  915. //! Draws normals of a mesh buffer
  916. /** \param mb Buffer to draw the normals of
  917. \param length length scale factor of the normals
  918. \param color Color the normals are rendered with
  919. */
  920. virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f, SColor color=0xffffffff) =0;
  921. //! Sets the fog mode.
  922. /** These are global values attached to each 3d object rendered,
  923. which has the fog flag enabled in its material.
  924. \param color Color of the fog
  925. \param fogType Type of fog used
  926. \param start Only used in linear fog mode (linearFog=true).
  927. Specifies where fog starts.
  928. \param end Only used in linear fog mode (linearFog=true).
  929. Specifies where fog ends.
  930. \param density Only used in exponential fog mode
  931. (linearFog=false). Must be a value between 0 and 1.
  932. \param pixelFog Set this to false for vertex fog, and true if
  933. you want per-pixel fog.
  934. \param rangeFog Set this to true to enable range-based vertex
  935. fog. The distance from the viewer is used to compute the fog,
  936. not the z-coordinate. This is better, but slower. This might not
  937. be available with all drivers and fog settings. */
  938. virtual void setFog(SColor color=SColor(0,255,255,255),
  939. E_FOG_TYPE fogType=EFT_FOG_LINEAR,
  940. f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
  941. bool pixelFog=false, bool rangeFog=false) =0;
  942. //! Gets the fog mode.
  943. virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
  944. f32& start, f32& end, f32& density,
  945. bool& pixelFog, bool& rangeFog) = 0;
  946. //! Get the current color format of the color buffer
  947. /** \return Color format of the color buffer. */
  948. virtual ECOLOR_FORMAT getColorFormat() const =0;
  949. //! Get the size of the screen or render window.
  950. /** \return Size of screen or render window. */
  951. virtual const core::dimension2d<u32>& getScreenSize() const =0;
  952. //! Get the size of the current render target
  953. /** This method will return the screen size if the driver
  954. doesn't support render to texture, or if the current render
  955. target is the screen.
  956. \return Size of render target or screen/window */
  957. virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const =0;
  958. //! Returns current frames per second value.
  959. /** This value is updated approximately every 1.5 seconds and
  960. is only intended to provide a rough guide to the average frame
  961. rate. It is not suitable for use in performing timing
  962. calculations or framerate independent movement.
  963. \return Approximate amount of frames per second drawn. */
  964. virtual s32 getFPS() const =0;
  965. //! Returns amount of primitives (mostly triangles) which were drawn in the last frame.
  966. /** Together with getFPS() very useful method for statistics.
  967. \param mode Defines if the primitives drawn are accumulated or
  968. counted per frame.
  969. \return Amount of primitives drawn in the last frame. */
  970. virtual u32 getPrimitiveCountDrawn( u32 mode =0 ) const =0;
  971. //! Deletes all dynamic lights which were previously added with addDynamicLight().
  972. virtual void deleteAllDynamicLights() =0;
  973. //! adds a dynamic light, returning an index to the light
  974. //! \param light: the light data to use to create the light
  975. //! \return An index to the light, or -1 if an error occurs
  976. virtual s32 addDynamicLight(const SLight& light) =0;
  977. //! Returns the maximal amount of dynamic lights the device can handle
  978. /** \return Maximal amount of dynamic lights. */
  979. virtual u32 getMaximalDynamicLightAmount() const =0;
  980. //! Returns amount of dynamic lights currently set
  981. /** \return Amount of dynamic lights currently set */
  982. virtual u32 getDynamicLightCount() const =0;
  983. //! Returns light data which was previously set by IVideoDriver::addDynamicLight().
  984. /** \param idx Zero based index of the light. Must be 0 or
  985. greater and smaller than IVideoDriver::getDynamicLightCount.
  986. \return Light data. */
  987. virtual const SLight& getDynamicLight(u32 idx) const =0;
  988. //! Turns a dynamic light on or off
  989. //! \param lightIndex: the index returned by addDynamicLight
  990. //! \param turnOn: true to turn the light on, false to turn it off
  991. virtual void turnLightOn(s32 lightIndex, bool turnOn) =0;
  992. //! Gets name of this video driver.
  993. /** \return Returns the name of the video driver, e.g. in case
  994. of the Direct3D8 driver, it would return "Direct3D 8.1". */
  995. virtual const wchar_t* getName() const =0;
  996. //! Adds an external image loader to the engine.
  997. /** This is useful if the Irrlicht Engine should be able to load
  998. textures of currently unsupported file formats (e.g. gif). The
  999. IImageLoader only needs to be implemented for loading this file
  1000. format. A pointer to the implementation can be passed to the
  1001. engine using this method.
  1002. \param loader Pointer to the external loader created. */
  1003. virtual void addExternalImageLoader(IImageLoader* loader) =0;
  1004. //! Adds an external image writer to the engine.
  1005. /** This is useful if the Irrlicht Engine should be able to
  1006. write textures of currently unsupported file formats (e.g
  1007. .gif). The IImageWriter only needs to be implemented for
  1008. writing this file format. A pointer to the implementation can
  1009. be passed to the engine using this method.
  1010. \param writer: Pointer to the external writer created. */
  1011. virtual void addExternalImageWriter(IImageWriter* writer) =0;
  1012. //! Returns the maximum amount of primitives
  1013. /** (mostly vertices) which the device is able to render with
  1014. one drawVertexPrimitiveList call.
  1015. \return Maximum amount of primitives. */
  1016. virtual u32 getMaximalPrimitiveCount() const =0;
  1017. //! Enables or disables a texture creation flag.
  1018. /** These flags define how textures should be created. By
  1019. changing this value, you can influence for example the speed of
  1020. rendering a lot. But please note that the video drivers take
  1021. this value only as recommendation. It could happen that you
  1022. enable the ETCF_ALWAYS_16_BIT mode, but the driver still creates
  1023. 32 bit textures.
  1024. \param flag Texture creation flag.
  1025. \param enabled Specifies if the given flag should be enabled or
  1026. disabled. */
  1027. virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled=true) =0;
  1028. //! Returns if a texture creation flag is enabled or disabled.
  1029. /** You can change this value using setTextureCreationFlag().
  1030. \param flag Texture creation flag.
  1031. \return The current texture creation flag enabled mode. */
  1032. virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0;
  1033. //! Creates a software images from a file.
  1034. /** No hardware texture will be created for those images. This
  1035. method is useful for example if you want to read a heightmap
  1036. for a terrain renderer.
  1037. \param filename Name of the file from which the images are created.
  1038. \param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
  1039. \return The array of created images.
  1040. If you no longer need those images, you should call IImage::drop() on each of them.
  1041. See IReferenceCounted::drop() for more information. */
  1042. virtual core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) = 0;
  1043. //! Creates a software images from a file.
  1044. /** No hardware texture will be created for those images. This
  1045. method is useful for example if you want to read a heightmap
  1046. for a terrain renderer.
  1047. \param file File from which the image is created.
  1048. \param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
  1049. \return The array of created images.
  1050. If you no longer need those images, you should call IImage::drop() on each of them.
  1051. See IReferenceCounted::drop() for more information. */
  1052. virtual core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) = 0;
  1053. //! Creates a software image from a file.
  1054. /** No hardware texture will be created for this image. This
  1055. method is useful for example if you want to read a heightmap
  1056. for a terrain renderer.
  1057. \param filename Name of the file from which the image is
  1058. created.
  1059. \return The created image.
  1060. If you no longer need the image, you should call IImage::drop().
  1061. See IReferenceCounted::drop() for more information. */
  1062. IImage* createImageFromFile(const io::path& filename)
  1063. {
  1064. core::array<IImage*> imageArray = createImagesFromFile(filename);
  1065. for (u32 i = 1; i < imageArray.size(); ++i)
  1066. imageArray[i]->drop();
  1067. return (imageArray.size() > 0) ? imageArray[0] : 0;
  1068. }
  1069. //! Creates a software image from a file.
  1070. /** No hardware texture will be created for this image. This
  1071. method is useful for example if you want to read a heightmap
  1072. for a terrain renderer.
  1073. \param file File from which the image is created.
  1074. \return The created image.
  1075. If you no longer need the image, you should call IImage::drop().
  1076. See IReferenceCounted::drop() for more information. */
  1077. IImage* createImageFromFile(io::IReadFile* file)
  1078. {
  1079. core::array<IImage*> imageArray = createImagesFromFile(file);
  1080. for (u32 i = 1; i < imageArray.size(); ++i)
  1081. imageArray[i]->drop();
  1082. return (imageArray.size() > 0) ? imageArray[0] : 0;
  1083. }
  1084. //! Writes the provided image to a file.
  1085. /** Requires that there is a suitable image writer registered
  1086. for writing the image.
  1087. \param image Image to write.
  1088. \param filename Name of the file to write.
  1089. \param param Control parameter for the backend. Meaning depends on format:
  1090. 0 is always some default
  1091. For jpg it's otherwise the quality level in range 1-100 (0=default is 75)
  1092. For png it's the compression level in range 1-10 (0=default is converted to Z_DEFAULT_COMPRESSION)
  1093. \return True on successful write. */
  1094. virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) = 0;
  1095. //! Writes the provided image to a file.
  1096. /** Requires that there is a suitable image writer registered
  1097. for writing the image.
  1098. \param image Image to write.
  1099. \param file An already open io::IWriteFile object. The name
  1100. will be used to determine the appropriate image writer to use.
  1101. \param param Control parameter for the backend. Meaning depends on format:
  1102. 0 is always some default
  1103. For jpg it's otherwise the quality level in range 1-100 (0=default is 75)
  1104. For png it's the compression level in range 1-10 (0=default is converted to Z_DEFAULT_COMPRESSION)
  1105. \return True on successful write. */
  1106. virtual bool writeImageToFile(IImage* image, io::IWriteFile* file, u32 param =0) =0;
  1107. //! Creates a software image from a byte array.
  1108. /** No hardware texture will be created for this image. This
  1109. method is useful for example if you want to read a heightmap
  1110. for a terrain renderer.
  1111. \param format Desired color format of the texture
  1112. \param size Desired size of the image
  1113. \param data A byte array with pixel color information
  1114. \param ownForeignMemory If true, the image will use the data
  1115. pointer directly and own it afterward. If false, the memory
  1116. will by copied internally.
  1117. WARNING: Setting this to 'true' will not work across dll boundaries.
  1118. So unless you link Irrlicht statically you should keep this to 'false'.
  1119. The parameter is mainly for internal usage.
  1120. \param deleteMemory Whether the memory is deallocated upon
  1121. destruction.
  1122. \return The created image.
  1123. If you no longer need the image, you should call IImage::drop().
  1124. See IReferenceCounted::drop() for more information. */
  1125. virtual IImage* createImageFromData(ECOLOR_FORMAT format,
  1126. const core::dimension2d<u32>& size, void *data, bool ownForeignMemory = false,
  1127. bool deleteMemory = true) = 0;
  1128. //! Creates an empty software image.
  1129. /**
  1130. \param format Desired color format of the image.
  1131. \param size Size of the image to create.
  1132. \return The created image.
  1133. If you no longer need the image, you should call IImage::drop().
  1134. See IReferenceCounted::drop() for more information. */
  1135. virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) =0;
  1136. //! Creates a software image by converting it to given format from another image.
  1137. /** \deprecated Create an empty image and use copyTo(). This method may be removed by Irrlicht 1.9.
  1138. \param format Desired color format of the image.
  1139. \param imageToCopy Image to copy to the new image.
  1140. \return The created image.
  1141. If you no longer need the image, you should call IImage::drop().
  1142. See IReferenceCounted::drop() for more information. */
  1143. IRR_DEPRECATED virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0;
  1144. //! Creates a software image from a part of another image.
  1145. /** \deprecated Create an empty image and use copyTo(). This method may be removed by Irrlicht 1.9.
  1146. \param imageToCopy Image to copy to the new image in part.
  1147. \param pos Position of rectangle to copy.
  1148. \param size Extents of rectangle to copy.
  1149. \return The created image.
  1150. If you no longer need the image, you should call IImage::drop().
  1151. See IReferenceCounted::drop() for more information. */
  1152. IRR_DEPRECATED virtual IImage* createImage(IImage* imageToCopy,
  1153. const core::position2d<s32>& pos,
  1154. const core::dimension2d<u32>& size) =0;
  1155. //! Creates a software image from a part of a texture.
  1156. /**
  1157. \param texture Texture to copy to the new image in part.
  1158. \param pos Position of rectangle to copy.
  1159. \param size Extents of rectangle to copy.
  1160. \return The created image.
  1161. If you no longer need the image, you should call IImage::drop().
  1162. See IReferenceCounted::drop() for more information. */
  1163. virtual IImage* createImage(ITexture* texture,
  1164. const core::position2d<s32>& pos,
  1165. const core::dimension2d<u32>& size) =0;
  1166. //! Event handler for resize events. Only used by the engine internally.
  1167. /** Used to notify the driver that the window was resized.
  1168. Usually, there is no need to call this method. */
  1169. virtual void OnResize(const core::dimension2d<u32>& size) =0;
  1170. //! Adds a new material renderer to the video device.
  1171. /** Use this method to extend the VideoDriver with new material
  1172. types. To extend the engine using this method do the following:
  1173. Derive a class from IMaterialRenderer and override the methods
  1174. you need. For setting the right renderstates, you can try to
  1175. get a pointer to the real rendering device using
  1176. IVideoDriver::getExposedVideoData(). Add your class with
  1177. IVideoDriver::addMaterialRenderer(). To use an object being
  1178. displayed with your new material, set the MaterialType member of
  1179. the SMaterial struct to the value returned by this method.
  1180. If you simply want to create a new material using vertex and/or
  1181. pixel shaders it would be easier to use the
  1182. video::IGPUProgrammingServices interface which you can get
  1183. using the getGPUProgrammingServices() method.
  1184. \param renderer A pointer to the new renderer.
  1185. \param name Optional name for the material renderer entry.
  1186. \return The number of the material type which can be set in
  1187. SMaterial::MaterialType to use the renderer. -1 is returned if
  1188. an error occurred. For example if you tried to add an material
  1189. renderer to the software renderer or the null device, which do
  1190. not accept material renderers. */
  1191. virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name =0) =0;
  1192. //! Get access to a material renderer by index.
  1193. /** \param idx Id of the material renderer. Can be a value of
  1194. the E_MATERIAL_TYPE enum or a value which was returned by
  1195. addMaterialRenderer().
  1196. \return Pointer to material renderer or null if not existing. */
  1197. virtual IMaterialRenderer* getMaterialRenderer(u32 idx) const = 0;
  1198. //! Get amount of currently available material renderers.
  1199. /** \return Amount of currently available material renderers. */
  1200. virtual u32 getMaterialRendererCount() const =0;
  1201. //! Get name of a material renderer
  1202. /** This string can, e.g., be used to test if a specific
  1203. renderer already has been registered/created, or use this
  1204. string to store data about materials: This returned name will
  1205. be also used when serializing materials.
  1206. \param idx Id of the material renderer. Can be a value of the
  1207. E_MATERIAL_TYPE enum or a value which was returned by
  1208. addMaterialRenderer().
  1209. \return String with the name of the renderer, or 0 if not
  1210. existing */
  1211. virtual const c8* getMaterialRendererName(u32 idx) const =0;
  1212. //! Sets the name of a material renderer.
  1213. /** Will have no effect on built-in material renderers.
  1214. \param idx: Id of the material renderer. Can be a value of the
  1215. E_MATERIAL_TYPE enum or a value which was returned by
  1216. addMaterialRenderer().
  1217. \param name: New name of the material renderer. */
  1218. virtual void setMaterialRendererName(u32 idx, const c8* name) =0;
  1219. //! Swap the material renderers used for certain id's
  1220. /** Swap the IMaterialRenderers responsible for rendering specific
  1221. material-id's. This means every SMaterial using a MaterialType
  1222. with one of the indices involved here will now render differently.
  1223. \param idx1 First material index to swap. It must already exist or nothing happens.
  1224. \param idx2 Second material index to swap. It must already exist or nothing happens.
  1225. \param swapNames When true the renderer names also swap
  1226. When false the names will stay at the original index */
  1227. virtual void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames=true) = 0;
  1228. //! Creates material attributes list from a material
  1229. /** This method is useful for serialization and more.
  1230. Please note that the video driver will use the material
  1231. renderer names from getMaterialRendererName() to write out the
  1232. material type name, so they should be set before.
  1233. \param material The material to serialize.
  1234. \param options Additional options which might influence the
  1235. serialization.
  1236. \return The io::IAttributes container holding the material
  1237. properties. */
  1238. virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material,
  1239. io::SAttributeReadWriteOptions* options=0) =0;
  1240. //! Fills an SMaterial structure from attributes.
  1241. /** Please note that for setting material types of the
  1242. material, the video driver will need to query the material
  1243. renderers for their names, so all non built-in materials must
  1244. have been created before calling this method.
  1245. \param outMaterial The material to set the properties for.
  1246. \param attributes The attributes to read from. */
  1247. virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) =0;
  1248. //! Returns driver and operating system specific data about the IVideoDriver.
  1249. /** This method should only be used if the engine should be
  1250. extended without having to modify the source of the engine.
  1251. \return Collection of device dependent pointers. */
  1252. virtual const SExposedVideoData& getExposedVideoData() =0;
  1253. //! Get type of video driver
  1254. /** \return Type of driver. */
  1255. virtual E_DRIVER_TYPE getDriverType() const =0;
  1256. //! Gets the IGPUProgrammingServices interface.
  1257. /** \return Pointer to the IGPUProgrammingServices. Returns 0
  1258. if the video driver does not support this. For example the
  1259. Software driver and the Null driver will always return 0. */
  1260. virtual IGPUProgrammingServices* getGPUProgrammingServices() =0;
  1261. //! Returns a pointer to the mesh manipulator.
  1262. virtual scene::IMeshManipulator* getMeshManipulator() =0;
  1263. //! Clear the color, depth and/or stencil buffers.
  1264. virtual void clearBuffers(u16 flag, SColor color = SColor(255,0,0,0), f32 depth = 1.f, u8 stencil = 0) = 0;
  1265. //! Clear the color, depth and/or stencil buffers.
  1266. IRR_DEPRECATED void clearBuffers(bool backBuffer, bool depthBuffer, bool stencilBuffer, SColor color)
  1267. {
  1268. u16 flag = 0;
  1269. if (backBuffer)
  1270. flag |= ECBF_COLOR;
  1271. if (depthBuffer)
  1272. flag |= ECBF_DEPTH;
  1273. if (stencilBuffer)
  1274. flag |= ECBF_STENCIL;
  1275. clearBuffers(flag, color);
  1276. }
  1277. //! Clears the ZBuffer.
  1278. /** Note that you usually need not to call this method, as it
  1279. is automatically done in IVideoDriver::beginScene() or
  1280. IVideoDriver::setRenderTarget() if you enable zBuffer. But if
  1281. you have to render some special things, you can clear the
  1282. zbuffer during the rendering process with this method any time.
  1283. */
  1284. void clearZBuffer()
  1285. {
  1286. clearBuffers(ECBF_DEPTH, SColor(255,0,0,0), 1.f, 0);
  1287. }
  1288. //! Make a screenshot of the last rendered frame.
  1289. /**
  1290. \param target All current drivers only support ERT_FRAME_BUFFER
  1291. \return An image created from the last rendered frame. */
  1292. virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) =0;
  1293. //! Check if the image is already loaded.
  1294. /** Works similar to getTexture(), but does not load the texture
  1295. if it is not currently loaded.
  1296. \param filename Name of the texture.
  1297. \return Pointer to loaded texture, or 0 if not found. */
  1298. virtual video::ITexture* findTexture(const io::path& filename) = 0;
  1299. //! Set or unset a clipping plane.
  1300. /** There are at least 6 clipping planes available for the user
  1301. to set at will.
  1302. \param index The plane index. Must be between 0 and
  1303. MaxUserClipPlanes.
  1304. \param plane The plane itself.
  1305. \param enable If true, enable the clipping plane else disable
  1306. it.
  1307. \return True if the clipping plane is usable. */
  1308. virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) =0;
  1309. //! Enable or disable a clipping plane.
  1310. /** There are at least 6 clipping planes available for the user
  1311. to set at will.
  1312. \param index The plane index. Must be between 0 and
  1313. MaxUserClipPlanes.
  1314. \param enable If true, enable the clipping plane else disable
  1315. it. */
  1316. virtual void enableClipPlane(u32 index, bool enable) =0;
  1317. //! Set the minimum number of vertices for which a hw buffer will be created
  1318. /** \param count Number of vertices to set as minimum. */
  1319. virtual void setMinHardwareBufferVertexCount(u32 count) =0;
  1320. //! Get the global Material, which might override local materials.
  1321. /** Depending on the enable flags, values from this Material
  1322. are used to override those of local materials of some
  1323. meshbuffer being rendered.
  1324. \return Reference to the Override Material. */
  1325. virtual SOverrideMaterial& getOverrideMaterial() =0;
  1326. //! Get the 2d override material for altering its values
  1327. /** The 2d override material allows to alter certain render
  1328. states of the 2d methods. Not all members of SMaterial are
  1329. honored, especially not MaterialType and Textures. Moreover,
  1330. the zbuffer is always ignored, and lighting is always off. All
  1331. other flags can be changed, though some might have to effect
  1332. in most cases.
  1333. Please note that you have to enable/disable this effect with
  1334. enableMaterial2D(). This effect is costly, as it increases
  1335. the number of state changes considerably. Always reset the
  1336. values when done.
  1337. \return Material reference which should be altered to reflect
  1338. the new settings.
  1339. */
  1340. virtual SMaterial& getMaterial2D() =0;
  1341. //! Enable the 2d override material
  1342. /** \param enable Flag which tells whether the material shall be
  1343. enabled or disabled. */
  1344. virtual void enableMaterial2D(bool enable=true) =0;
  1345. //! Get the graphics card vendor name.
  1346. virtual core::stringc getVendorInfo() =0;
  1347. //! Only used by the engine internally.
  1348. /** The ambient color is set in the scene manager, see
  1349. scene::ISceneManager::setAmbientLight().
  1350. \param color New color of the ambient light. */
  1351. virtual void setAmbientLight(const SColorf& color) =0;
  1352. //! Only used by the engine internally.
  1353. /** Passes the global material flag AllowZWriteOnTransparent.
  1354. Use the SceneManager attribute to set this value from your app.
  1355. \param flag Default behavior is to disable ZWrite, i.e. false. */
  1356. virtual void setAllowZWriteOnTransparent(bool flag) =0;
  1357. //! Get the maximum texture size supported.
  1358. virtual core::dimension2du getMaxTextureSize() const =0;
  1359. //! Color conversion convenience function
  1360. /** Convert an image (as array of pixels) from source to destination
  1361. array, thereby converting the color format. The pixel size is
  1362. determined by the color formats.
  1363. \param sP Pointer to source
  1364. \param sF Color format of source
  1365. \param sN Number of pixels to convert, both array must be large enough
  1366. \param dP Pointer to destination
  1367. \param dF Color format of destination
  1368. */
  1369. virtual void convertColor(const void* sP, ECOLOR_FORMAT sF, s32 sN,
  1370. void* dP, ECOLOR_FORMAT dF) const =0;
  1371. //! Check if the driver supports creating textures with the given color format
  1372. /** \return True if the format is available, false if not. */
  1373. virtual bool queryTextureFormat(ECOLOR_FORMAT format) const = 0;
  1374. //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass
  1375. virtual bool needsTransparentRenderPass(const irr::video::SMaterial& material) const = 0;
  1376. };
  1377. } // end namespace video
  1378. } // end namespace irr
  1379. #endif