IVideoDriver.h 70 KB

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