Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials
IVideoDriver.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2010 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 
5 #ifndef __IRR_I_VIDEO_DRIVER_H_INCLUDED__
6 #define __IRR_I_VIDEO_DRIVER_H_INCLUDED__
7 
8 #include "rect.h"
9 #include "SColor.h"
10 #include "ITexture.h"
11 #include "irrArray.h"
12 #include "matrix4.h"
13 #include "plane3d.h"
14 #include "dimension2d.h"
15 #include "position2d.h"
16 #include "SMaterial.h"
17 #include "IMeshBuffer.h"
18 #include "triangle3d.h"
19 #include "EDriverTypes.h"
20 #include "EDriverFeatures.h"
21 #include "SExposedVideoData.h"
22 
23 namespace irr
24 {
25 namespace io
26 {
27  class IAttributes;
28  class IReadFile;
29  class IWriteFile;
30 } // end namespace io
31 namespace scene
32 {
33  class IMeshBuffer;
34  class IMeshManipulator;
35 } // end namespace scene
36 
37 namespace video
38 {
39  struct S3DVertex;
40  struct S3DVertex2TCoords;
41  struct S3DVertexTangents;
42  struct SLight;
43  class IImageLoader;
44  class IImageWriter;
45  class IMaterialRenderer;
46  class IGPUProgrammingServices;
47 
50  {
52  ETS_VIEW = 0,
65 #if _IRR_MATERIAL_MAX_TEXTURES_>4
66 
67  ETS_TEXTURE_4,
68 #if _IRR_MATERIAL_MAX_TEXTURES_>5
69 
70  ETS_TEXTURE_5,
71 #if _IRR_MATERIAL_MAX_TEXTURES_>6
72 
73  ETS_TEXTURE_6,
74 #if _IRR_MATERIAL_MAX_TEXTURES_>7
75 
76  ETS_TEXTURE_7,
77 #endif
78 #endif
79 #endif
80 #endif
81 
83  };
84 
86 
90  {
96  ELR_RTTS = 4,
99  };
100 
102 
104  {
127  };
128 
131  {
135  };
136 
137  const c8* const FogTypeNames[] =
138  {
139  "FogExp",
140  "FogLinear",
141  "FogExp2",
142  0
143  };
144 
146  {
150 
153 
156 
158  bool Enabled;
159 
162 
164  void apply(SMaterial& material)
165  {
166  if (Enabled)
167  {
168  for (u32 i=0; i<32; ++i)
169  {
170  const u32 num=(1<<i);
171  if (EnableFlags & num)
172  {
173  switch (num)
174  {
175  case EMF_WIREFRAME: material.Wireframe = Material.Wireframe; break;
176  case EMF_POINTCLOUD: material.PointCloud = Material.PointCloud; break;
178  case EMF_LIGHTING: material.Lighting = Material.Lighting; break;
179  case EMF_ZBUFFER: material.ZBuffer = Material.ZBuffer; break;
180  case EMF_ZWRITE_ENABLE: material.ZWriteEnable = Material.ZWriteEnable; break;
183  case EMF_FOG_ENABLE: material.FogEnable = Material.FogEnable; break;
185  case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break;
186  case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break;
190  case EMF_TEXTURE_WRAP:
193  break;
194  }
195  }
196  }
197  }
198  }
199 
200  };
201 
203  {
205  E_COLOR_PLANE colorMask=ECP_ALL,
206  E_BLEND_FACTOR blendFuncSrc=EBF_ONE,
208  bool blendEnable=false) :
209  RenderTexture(texture),
211  BlendFuncSrc(blendFuncSrc), BlendFuncDst(blendFuncDst),
212  BlendEnable(blendEnable) {}
214  E_COLOR_PLANE colorMask=ECP_ALL,
215  E_BLEND_FACTOR blendFuncSrc=EBF_ONE,
217  bool blendEnable=false) :
218  RenderTexture(0),
219  TargetType(target), ColorMask(colorMask),
220  BlendFuncSrc(blendFuncSrc), BlendFuncDst(blendFuncDst),
221  BlendEnable(blendEnable) {}
228  };
229 
231 
238  class IVideoDriver : public virtual IReferenceCounted
239  {
240  public:
241 
243 
260  virtual bool beginScene(bool backBuffer=true, bool zBuffer=true,
261  SColor color=SColor(255,0,0,0),
262  const SExposedVideoData& videoData=SExposedVideoData(),
263  core::rect<s32>* sourceRect=0) =0;
264 
266 
269  virtual bool endScene() =0;
270 
272 
275  virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const =0;
276 
278 
282  virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
283 
285 
288  virtual bool checkDriverReset() =0;
289 
291 
294  virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) =0;
295 
297 
299  virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const =0;
300 
302 
303  virtual u32 getImageLoaderCount() const = 0;
304 
306 
309  virtual IImageLoader* getImageLoader(u32 n) = 0;
310 
312 
313  virtual u32 getImageWriterCount() const = 0;
314 
316 
319  virtual IImageWriter* getImageWriter(u32 n) = 0;
320 
322 
324  virtual void setMaterial(const SMaterial& material) =0;
325 
327 
336  virtual ITexture* getTexture(const io::path& filename) = 0;
337 
339 
348  virtual ITexture* getTexture(io::IReadFile* file) =0;
349 
351 
357  virtual ITexture* getTextureByIndex(u32 index) =0;
358 
360 
361  virtual u32 getTextureCount() const = 0;
362 
364 
366  virtual void renameTexture(ITexture* texture, const io::path& newName) = 0;
367 
369 
378  virtual ITexture* addTexture(const core::dimension2d<u32>& size,
379  const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
380 
382 
392  virtual ITexture* addTexture(const io::path& name, IImage* image, void* mipmapData=0) = 0;
393 
395 
405  const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
406 
408 
415  virtual void removeTexture(ITexture* texture) =0;
416 
418 
424  virtual void removeAllTextures() =0;
425 
427  virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb) =0;
428 
430  virtual void removeAllHardwareBuffers() =0;
431 
433 
448  virtual void makeColorKeyTexture(video::ITexture* texture,
449  video::SColor color,
450  bool zeroTexels = false) const =0;
451 
453 
464  virtual void makeColorKeyTexture(video::ITexture* texture,
465  core::position2d<s32> colorKeyPixelPos,
466  bool zeroTexels = false) const =0;
467 
469 
476  virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const =0;
477 
479 
510  virtual bool setRenderTarget(video::ITexture* texture,
511  bool clearBackBuffer=true, bool clearZBuffer=true,
512  SColor color=video::SColor(0,0,0,0)) =0;
513 
515 
526  virtual bool setRenderTarget(E_RENDER_TARGET target, bool clearTarget=true,
527  bool clearZBuffer=true,
528  SColor color=video::SColor(0,0,0,0)) =0;
529 
531  virtual bool setRenderTarget(const core::array<video::IRenderTarget>& texture,
532  bool clearBackBuffer=true, bool clearZBuffer=true,
533  SColor color=video::SColor(0,0,0,0)) =0;
534 
536 
539  virtual void setViewPort(const core::rect<s32>& area) =0;
540 
542 
543  virtual const core::rect<s32>& getViewPort() const =0;
544 
546 
560  virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
561  const void* indexList, u32 primCount,
564  E_INDEX_TYPE iType=EIT_16BIT) =0;
565 
567 
586  virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
587  const void* indexList, u32 primCount,
590  E_INDEX_TYPE iType=EIT_16BIT) =0;
591 
593 
601  void drawIndexedTriangleList(const S3DVertex* vertices,
602  u32 vertexCount, const u16* indexList, u32 triangleCount)
603  {
604  drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT);
605  }
606 
608 
617  u32 vertexCount, const u16* indexList, u32 triangleCount)
618  {
619  drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT);
620  }
621 
623 
632  u32 vertexCount, const u16* indexList, u32 triangleCount)
633  {
634  drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT);
635  }
636 
638 
646  void drawIndexedTriangleFan(const S3DVertex* vertices,
647  u32 vertexCount, const u16* indexList, u32 triangleCount)
648  {
649  drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
650  }
651 
653 
662  u32 vertexCount, const u16* indexList, u32 triangleCount)
663  {
664  drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
665  }
666 
668 
677  u32 vertexCount, const u16* indexList, u32 triangleCount)
678  {
679  drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
680  }
681 
683 
697  virtual void draw3DLine(const core::vector3df& start,
698  const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0;
699 
701 
714  virtual void draw3DTriangle(const core::triangle3df& triangle,
715  SColor color = SColor(255,255,255,255)) =0;
716 
718 
729  virtual void draw3DBox(const core::aabbox3d<f32>& box,
730  SColor color = SColor(255,255,255,255)) =0;
731 
733 
736  virtual void draw2DImage(const video::ITexture* texture,
737  const core::position2d<s32>& destPos) =0;
738 
740 
755  virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
756  const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
757  SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0;
758 
760 
779  virtual void draw2DImageBatch(const video::ITexture* texture,
780  const core::position2d<s32>& pos,
781  const core::array<core::rect<s32> >& sourceRects,
782  const core::array<s32>& indices,
783  s32 kerningWidth=0,
784  const core::rect<s32>* clipRect=0,
785  SColor color=SColor(255,255,255,255),
786  bool useAlphaChannelOfTexture=false) =0;
787 
789 
804  virtual void draw2DImageBatch(const video::ITexture* texture,
805  const core::array<core::position2d<s32> >& positions,
806  const core::array<core::rect<s32> >& sourceRects,
807  const core::rect<s32>* clipRect=0,
808  SColor color=SColor(255,255,255,255),
809  bool useAlphaChannelOfTexture=false) =0;
810 
812 
821  virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
822  const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
823  const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0;
824 
826 
833  virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
834  const core::rect<s32>* clip =0) =0;
835 
837 
853  virtual void draw2DRectangle(const core::rect<s32>& pos,
854  SColor colorLeftUp, SColor colorRightUp,
855  SColor colorLeftDown, SColor colorRightDown,
856  const core::rect<s32>* clip =0) =0;
857 
859 
862  virtual void draw2DRectangleOutline(const core::recti& pos,
863  SColor color=SColor(255,255,255,255)) =0;
864 
866 
871  virtual void draw2DLine(const core::position2d<s32>& start,
872  const core::position2d<s32>& end,
873  SColor color=SColor(255,255,255,255)) =0;
874 
876 
879  virtual void drawPixel(u32 x, u32 y, const SColor& color) =0;
880 
882 
894  virtual void draw2DPolygon(core::position2d<s32> center,
895  f32 radius,
896  video::SColor color=SColor(100,255,255,255),
897  s32 vertexCount=10) =0;
898 
900 
911  virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true) =0;
912 
914 
933  virtual void drawStencilShadow(bool clearStencilBuffer=false,
934  video::SColor leftUpEdge = video::SColor(255,0,0,0),
935  video::SColor rightUpEdge = video::SColor(255,0,0,0),
936  video::SColor leftDownEdge = video::SColor(255,0,0,0),
937  video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0;
938 
940 
941  virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0;
942 
944 
960  virtual void setFog(SColor color=SColor(0,255,255,255),
961  E_FOG_TYPE fogType=EFT_FOG_LINEAR,
962  f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
963  bool pixelFog=false, bool rangeFog=false) =0;
964 
966  virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
967  f32& start, f32& end, f32& density,
968  bool& pixelFog, bool& rangeFog) = 0;
969 
971 
972  virtual ECOLOR_FORMAT getColorFormat() const =0;
973 
975 
976  virtual const core::dimension2d<u32>& getScreenSize() const =0;
977 
979 
983  virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const =0;
984 
986 
991  virtual s32 getFPS() const =0;
992 
994 
998  virtual u32 getPrimitiveCountDrawn( u32 mode =0 ) const =0;
999 
1001  virtual void deleteAllDynamicLights() =0;
1002 
1006  virtual s32 addDynamicLight(const SLight& light) =0;
1007 
1009 
1010  virtual u32 getMaximalDynamicLightAmount() const =0;
1011 
1013 
1014  virtual u32 getDynamicLightCount() const =0;
1015 
1017 
1020  virtual const SLight& getDynamicLight(u32 idx) const =0;
1021 
1025  virtual void turnLightOn(s32 lightIndex, bool turnOn) =0;
1026 
1028 
1030  virtual const wchar_t* getName() const =0;
1031 
1033 
1039  virtual void addExternalImageLoader(IImageLoader* loader) =0;
1040 
1042 
1048  virtual void addExternalImageWriter(IImageWriter* writer) =0;
1049 
1051 
1054  virtual u32 getMaximalPrimitiveCount() const =0;
1055 
1057 
1066  virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled=true) =0;
1067 
1069 
1072  virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0;
1073 
1075 
1083  virtual IImage* createImageFromFile(const io::path& filename) = 0;
1084 
1086 
1093  virtual IImage* createImageFromFile(io::IReadFile* file) =0;
1094 
1096 
1103  virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) = 0;
1104 
1106 
1114  virtual bool writeImageToFile(IImage* image, io::IWriteFile* file, u32 param =0) =0;
1115 
1117 
1131  virtual IImage* createImageFromData(ECOLOR_FORMAT format,
1132  const core::dimension2d<u32>& size, void *data,
1133  bool ownForeignMemory=false,
1134  bool deleteMemory = true) =0;
1135 
1137 
1143  virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) =0;
1144 
1146 
1152  virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0;
1153 
1155 
1162  virtual IImage* createImage(IImage* imageToCopy,
1163  const core::position2d<s32>& pos,
1164  const core::dimension2d<u32>& size) =0;
1165 
1167 
1174  virtual IImage* createImage(ITexture* texture,
1175  const core::position2d<s32>& pos,
1176  const core::dimension2d<u32>& size) =0;
1177 
1179 
1181  virtual void OnResize(const core::dimension2d<u32>& size) =0;
1182 
1184 
1204  virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name =0) =0;
1205 
1207 
1211  virtual IMaterialRenderer* getMaterialRenderer(u32 idx) =0;
1212 
1214 
1215  virtual u32 getMaterialRendererCount() const =0;
1216 
1218 
1227  virtual const c8* getMaterialRendererName(u32 idx) const =0;
1228 
1230 
1235  virtual void setMaterialRendererName(s32 idx, const c8* name) =0;
1236 
1238 
1245  virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material) =0;
1246 
1248 
1254  virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) =0;
1255 
1257 
1260  virtual const SExposedVideoData& getExposedVideoData() =0;
1261 
1263 
1264  virtual E_DRIVER_TYPE getDriverType() const =0;
1265 
1267 
1271 
1274 
1276 
1282  virtual void clearZBuffer() =0;
1283 
1285 
1286  virtual IImage* createScreenShot() =0;
1287 
1289 
1293  virtual video::ITexture* findTexture(const io::path& filename) = 0;
1294 
1296 
1304  virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) =0;
1305 
1307 
1313  virtual void enableClipPlane(u32 index, bool enable) =0;
1314 
1316 
1317  virtual void setMinHardwareBufferVertexCount(u32 count) =0;
1318 
1320 
1324  virtual SOverrideMaterial& getOverrideMaterial() =0;
1325 
1327 
1340  virtual SMaterial& getMaterial2D() =0;
1341 
1343 
1345  virtual void enableMaterial2D(bool enable=true) =0;
1346 
1348  virtual core::stringc getVendorInfo() =0;
1349 
1351 
1354  virtual void setAmbientLight(const SColorf& color) =0;
1355 
1357 
1360  virtual void setAllowZWriteOnTransparent(bool flag) =0;
1361 
1363  virtual core::dimension2du getMaxTextureSize() const =0;
1364  };
1365 
1366 } // end namespace video
1367 } // end namespace irr
1368 
1369 
1370 #endif
1371 

The Irrlicht Engine
The Irrlicht Engine Documentation © 2003-2010 by Nikolaus Gebhardt. Generated on Tue Jun 5 2012 17:57:13 by Doxygen (1.8.1)