Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members | Tutorials

# IVideoDriver.h

Go to the documentation of this file.

    00001 // Copyright (C) 2002-2009 Nikolaus Gebhardt
    00002 // This file is part of the "Irrlicht Engine".
    00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
    00004
    00005 #ifndef __IRR_I_VIDEO_DRIVER_H_INCLUDED__
    00006 #define __IRR_I_VIDEO_DRIVER_H_INCLUDED__
    00007
    00008 #include "rect.h"
    00009 #include "SColor.h"
    00010 #include "ITexture.h"
    00011 #include "irrArray.h"
    00012 #include "matrix4.h"
    00013 #include "plane3d.h"
    00014 #include "dimension2d.h"
    00015 #include "position2d.h"
    00016 #include "SMaterial.h"
    00017 #include "IMeshBuffer.h"
    00018 #include "triangle3d.h"
    00019 #include "EDriverTypes.h"
    00020 #include "EDriverFeatures.h"
    00021
    00022 namespace irr
    00023 {
    00024 namespace io
    00025 {
    00026         class IAttributes;
    00027         class IReadFile;
    00028         class IWriteFile;
    00029 } // end namespace io
    00030 namespace scene
    00031 {
    00032         class IMeshBuffer;
    00033         class IMeshManipulator;
    00034 } // end namespace scene
    00035
    00036 namespace video
    00037 {
    00038         struct S3DVertex;
    00039         struct S3DVertex2TCoords;
    00040         struct S3DVertexTangents;
    00041         struct SLight;
    00042         struct SExposedVideoData;
    00043         class IImageLoader;
    00044         class IImageWriter;
    00045         class IMaterialRenderer;
    00046         class IGPUProgrammingServices;
    00047
    00049         enum E_TRANSFORMATION_STATE
    00050         {
    00052                 ETS_VIEW = 0,
    00054                 ETS_WORLD,
    00056                 ETS_PROJECTION,
    00058                 ETS_TEXTURE_0,
    00060                 ETS_TEXTURE_1,
    00062                 ETS_TEXTURE_2,
    00064                 ETS_TEXTURE_3,
    00065 #if _IRR_MATERIAL_MAX_TEXTURES_>4
    00067                 ETS_TEXTURE_4,
    00068 #if _IRR_MATERIAL_MAX_TEXTURES_>5
    00070                 ETS_TEXTURE_5,
    00071 #if _IRR_MATERIAL_MAX_TEXTURES_>6
    00073                 ETS_TEXTURE_6,
    00074 #if _IRR_MATERIAL_MAX_TEXTURES_>7
    00076                 ETS_TEXTURE_7,
    00077 #endif
    00078 #endif
    00079 #endif
    00080 #endif
    00082                 ETS_COUNT
    00083         };
    00084
    00086
    00089         enum E_LOST_RESSOURCE
    00090         {
    00092                 ELR_DEVICE = 1,
    00094                 ELR_TEXTURES = 2,
    00096                 ELR_RTTS = 4,
    00098                 ELR_HW_BUFFERS = 8
    00099         };
    00100
    00102
    00103         enum E_RENDER_TARGET
    00104         {
    00106                 ERT_FRAME_BUFFER=0,
    00108                 ERT_STEREO_LEFT_BUFFER=0,
    00110                 ERT_RENDER_TEXTURE,
    00112                 ERT_STEREO_RIGHT_BUFFER,
    00114                 ERT_STEREO_BOTH_BUFFERS,
    00116                 ERT_AUX_BUFFER0,
    00118                 ERT_AUX_BUFFER1,
    00120                 ERT_AUX_BUFFER2,
    00122                 ERT_AUX_BUFFER3,
    00124                 ERT_AUX_BUFFER4
    00125         };
    00126
    00128         enum E_FOG_TYPE
    00129         {
    00130                 EFT_FOG_EXP=0,
    00131                 EFT_FOG_LINEAR,
    00132                 EFT_FOG_EXP2
    00133         };
    00134
    00135         struct SOverrideMaterial
    00136         {
    00138                 SMaterial Material;
    00140
    00141                 u32 EnableFlags;
    00143
    00144                 u16 EnablePasses;
    00146
    00148                 bool Enabled;
    00149
    00151                 SOverrideMaterial() : EnableFlags(0), EnablePasses(0), Enabled(false) {}
    00152
    00154                 void apply(SMaterial& material)
    00155                 {
    00156                         if (Enabled)
    00157                         {
    00158                                 for (u32 i=0; i<32; ++i)
    00159                                 {
    00160                                         const u32 num=(1<<i);
    00161                                         if (EnableFlags & num)
    00162                                         {
    00163                                                 switch (num)
    00164                                                 {
    00165                                                 case EMF_WIREFRAME: material.Wireframe = Material.Wireframe; break;
    00166                                                 case EMF_POINTCLOUD: material.PointCloud = Material.PointCloud; break;
    00167                                                 case EMF_GOURAUD_SHADING: material.GouraudShading = Material.GouraudShading; break;
    00168                                                 case EMF_LIGHTING: material.Lighting = Material.Lighting; break;
    00169                                                 case EMF_ZBUFFER: material.ZBuffer = Material.ZBuffer; break;
    00170                                                 case EMF_ZWRITE_ENABLE: material.ZWriteEnable = Material.ZWriteEnable; break;
    00171                                                 case EMF_BACK_FACE_CULLING: material.BackfaceCulling = Material.BackfaceCulling; break;
    00172                                                 case EMF_FRONT_FACE_CULLING: material.FrontfaceCulling = Material.FrontfaceCulling; break;
    00173                                                 case EMF_FOG_ENABLE: material.FogEnable = Material.FogEnable; break;
    00174                                                 case EMF_NORMALIZE_NORMALS: material.NormalizeNormals = Material.NormalizeNormals; break;
    00175                                                 case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break;
    00176                                                 case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break;
    00177                                                 case EMF_BILINEAR_FILTER: material.TextureLayer[0].BilinearFilter = Material.TextureLayer[0].BilinearFilter; break;
    00178                                                 case EMF_TRILINEAR_FILTER: material.TextureLayer[0].TrilinearFilter = Material.TextureLayer[0].TrilinearFilter; break;
    00179                                                 case EMF_ANISOTROPIC_FILTER: material.TextureLayer[0].AnisotropicFilter = Material.TextureLayer[0].AnisotropicFilter; break;
    00180                                                 case EMF_TEXTURE_WRAP: material.TextureLayer[0].TextureWrap = Material.TextureLayer[0].TextureWrap; break;
    00181                                                 }
    00182                                         }
    00183                                 }
    00184                         }
    00185                 }
    00186
    00187         };
    00188
    00190
    00197         class IVideoDriver : public virtual IReferenceCounted
    00198         {
    00199         public:
    00200
    00202
    00219                 virtual bool beginScene(bool backBuffer=true, bool zBuffer=true,
    00220                                 SColor color=SColor(255,0,0,0),
    00221                                 void* windowId=0,
    00222                                 core::rect<s32>* sourceRect=0) =0;
    00223
    00225
    00228                 virtual bool endScene() =0;
    00229
    00231
    00234                 virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const =0;
    00235
    00237
    00241                 virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
    00242
    00244
    00247                 virtual bool checkDriverReset() =0;
    00248
    00250
    00253                 virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) =0;
    00254
    00256
    00258                 virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const =0;
    00259
    00261
    00262                 virtual u32 getImageLoaderCount() const = 0;
    00263
    00265
    00268                 virtual IImageLoader* getImageLoader(u32 n) = 0;
    00269
    00271
    00272                 virtual u32 getImageWriterCount() const = 0;
    00273
    00275
    00278                 virtual IImageWriter* getImageWriter(u32 n) = 0;
    00279
    00281
    00283                 virtual void setMaterial(const SMaterial& material) =0;
    00284
    00286
    00295                 virtual ITexture* getTexture(const io::path& filename) = 0;
    00296
    00298
    00307                 virtual ITexture* getTexture(io::IReadFile* file) =0;
    00308
    00310
    00316                 virtual ITexture* getTextureByIndex(u32 index) =0;
    00317
    00319
    00320                 virtual u32 getTextureCount() const = 0;
    00321
    00323
    00325                 virtual void renameTexture(ITexture* texture, const io::path& newName) = 0;
    00326
    00328
    00337                 virtual ITexture* addTexture(const core::dimension2d<u32>& size,
    00338                         const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
    00339
    00341
    00347                 virtual ITexture* addTexture(const io::path& name, IImage* image) = 0;
    00348
    00350
    00359                 virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
    00360                                 const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
    00361
    00363
    00370                 virtual void removeTexture(ITexture* texture) =0;
    00371
    00373
    00379                 virtual void removeAllTextures() =0;
    00380
    00382                 virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb) =0;
    00383
    00385                 virtual void removeAllHardwareBuffers() =0;
    00386
    00388
    00403                 virtual void makeColorKeyTexture(video::ITexture* texture,
    00404                                                 video::SColor color,
    00405                                                 bool zeroTexels = false) const =0;
    00406
    00408
    00419                 virtual void makeColorKeyTexture(video::ITexture* texture,
    00420                                 core::position2d<s32> colorKeyPixelPos,
    00421                                 bool zeroTexels = false) const =0;
    00422
    00424
    00431                 virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const =0;
    00432
    00434
    00465                 virtual bool setRenderTarget(video::ITexture* texture,
    00466                         bool clearBackBuffer=true, bool clearZBuffer=true,
    00467                         SColor color=video::SColor(0,0,0,0)) =0;
    00468
    00470
    00481                 virtual bool setRenderTarget(E_RENDER_TARGET target, bool clearTarget=true,
    00482                                         bool clearZBuffer=true,
    00483                                         SColor color=video::SColor(0,0,0,0)) =0;
    00484
    00486
    00489                 virtual void setViewPort(const core::rect<s32>& area) =0;
    00490
    00492
    00493                 virtual const core::rect<s32>& getViewPort() const =0;
    00494
    00496
    00510                 virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
    00511                                 const void* indexList, u32 primCount,
    00512                                 E_VERTEX_TYPE vType=EVT_STANDARD,
    00513                                 scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
    00514                                 E_INDEX_TYPE iType=EIT_16BIT) =0;
    00515
    00517
    00536                 virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
    00537                                 const void* indexList, u32 primCount,
    00538                                 E_VERTEX_TYPE vType=EVT_STANDARD,
    00539                                 scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
    00540                                 E_INDEX_TYPE iType=EIT_16BIT) =0;
    00541
    00543
    00551                 virtual void drawIndexedTriangleList(const S3DVertex* vertices,
    00552                         u32 vertexCount, const u16* indexList, u32 triangleCount) =0;
    00553
    00555
    00563                 virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices,
    00564                         u32 vertexCount, const u16* indexList, u32 triangleCount) =0;
    00565
    00567
    00575                 virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices,
    00576                         u32 vertexCount, const u16* indexList, u32 triangleCount) =0;
    00577
    00579
    00587                 virtual void drawIndexedTriangleFan(const S3DVertex* vertices,
    00588                         u32 vertexCount, const u16* indexList, u32 triangleCount) =0;
    00589
    00591
    00599                 virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
    00600                         u32 vertexCount, const u16* indexList, u32 triangleCount) =0;
    00601
    00603
    00617                 virtual void draw3DLine(const core::vector3df& start,
    00618                         const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0;
    00619
    00621
    00634                 virtual void draw3DTriangle(const core::triangle3df& triangle,
    00635                         SColor color = SColor(255,255,255,255)) =0;
    00636
    00638
    00649                 virtual void draw3DBox(const core::aabbox3d<f32>& box,
    00650                         SColor color = SColor(255,255,255,255)) =0;
    00651
    00653
    00656                 virtual void draw2DImage(const video::ITexture* texture,
    00657                         const core::position2d<s32>& destPos) =0;
    00658
    00660
    00675                 virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
    00676                         const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
    00677                         SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0;
    00678
    00680
    00699                 virtual void draw2DImageBatch(const video::ITexture* texture,
    00700                                 const core::position2d<s32>& pos,
    00701                                 const core::array<core::rect<s32> >& sourceRects,
    00702                                 const core::array<s32>& indices,
    00703                                 s32 kerningWidth=0,
    00704                                 const core::rect<s32>* clipRect=0,
    00705                                 SColor color=SColor(255,255,255,255),
    00706                                 bool useAlphaChannelOfTexture=false) =0;
    00707
    00709
    00724                 virtual void draw2DImageBatch(const video::ITexture* texture,
    00725                                 const core::array<core::position2d<s32> >& positions,
    00726                                 const core::array<core::rect<s32> >& sourceRects,
    00727                                 const core::rect<s32>* clipRect=0,
    00728                                 SColor color=SColor(255,255,255,255),
    00729                                 bool useAlphaChannelOfTexture=false) =0;
    00730
    00732
    00741                 virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
    00742                         const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
    00743                         const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0;
    00744
    00746
    00753                 virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
    00754                         const core::rect<s32>* clip =0) =0;
    00755
    00757
    00773                 virtual void draw2DRectangle(const core::rect<s32>& pos,
    00774                                 SColor colorLeftUp, SColor colorRightUp,
    00775                                 SColor colorLeftDown, SColor colorRightDown,
    00776                                 const core::rect<s32>* clip =0) =0;
    00777
    00779
    00782                 virtual void draw2DRectangleOutline(const core::recti& pos,
    00783                                 SColor color=SColor(255,255,255,255)) =0;
    00784
    00786
    00791                 virtual void draw2DLine(const core::position2d<s32>& start,
    00792                                         const core::position2d<s32>& end,
    00793                                         SColor color=SColor(255,255,255,255)) =0;
    00794
    00796
    00799                 virtual void drawPixel(u32 x, u32 y, const SColor& color) =0;
    00800
    00802
    00814                 virtual void draw2DPolygon(core::position2d<s32> center,
    00815                                 f32 radius,
    00816                                 video::SColor color=SColor(100,255,255,255),
    00817                                 s32 vertexCount=10) =0;
    00818
    00820
    00831                 virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true) =0;
    00832
    00834
    00853                 virtual void drawStencilShadow(bool clearStencilBuffer=false,
    00854                         video::SColor leftUpEdge = video::SColor(255,0,0,0),
    00855                         video::SColor rightUpEdge = video::SColor(255,0,0,0),
    00856                         video::SColor leftDownEdge = video::SColor(255,0,0,0),
    00857                         video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0;
    00858
    00860
    00861                 virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0;
    00862
    00864
    00880                 virtual void setFog(SColor color=SColor(0,255,255,255),
    00881                                 E_FOG_TYPE fogType=EFT_FOG_LINEAR,
    00882                                 f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
    00883                                 bool pixelFog=false, bool rangeFog=false) =0;
    00884
    00886
    00887                 virtual ECOLOR_FORMAT getColorFormat() const =0;
    00888
    00890
    00891                 virtual const core::dimension2d<u32>& getScreenSize() const =0;
    00892
    00894
    00898                 virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const =0;
    00899
    00901
    00906                 virtual s32 getFPS() const =0;
    00907
    00909
    00913                 virtual u32 getPrimitiveCountDrawn( u32 mode =0 ) const =0;
    00914
    00916                 virtual void deleteAllDynamicLights() =0;
    00917
    00921                 virtual s32 addDynamicLight(const SLight& light) =0;
    00922
    00924
    00925                 virtual u32 getMaximalDynamicLightAmount() const =0;
    00926
    00928
    00929                 virtual u32 getDynamicLightCount() const =0;
    00930
    00932
    00935                 virtual const SLight& getDynamicLight(u32 idx) const =0;
    00936
    00940                 virtual void turnLightOn(s32 lightIndex, bool turnOn) =0;
    00941
    00943
    00945                 virtual const wchar_t* getName() const =0;
    00946
    00948
    00954                 virtual void addExternalImageLoader(IImageLoader* loader) =0;
    00955
    00957
    00963                 virtual void addExternalImageWriter(IImageWriter* writer) =0;
    00964
    00966
    00969                 virtual u32 getMaximalPrimitiveCount() const =0;
    00970
    00972
    00981                 virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled=true) =0;
    00982
    00984
    00987                 virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0;
    00988
    00990
    00998                 virtual IImage* createImageFromFile(const io::path& filename) = 0;
    00999
    01001
    01008                 virtual IImage* createImageFromFile(io::IReadFile* file) =0;
    01009
    01011
    01018                 virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) = 0;
    01019
    01021
    01029                 virtual bool writeImageToFile(IImage* image, io::IWriteFile* file, u32 param =0) =0;
    01030
    01032
    01046                 virtual IImage* createImageFromData(ECOLOR_FORMAT format,
    01047                         const core::dimension2d<u32>& size, void *data,
    01048                         bool ownForeignMemory=false,
    01049                         bool deleteMemory = true) =0;
    01050
    01052
    01058                 virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) =0;
    01059
    01061
    01067                 virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0;
    01068
    01070
    01077                 virtual IImage* createImage(IImage* imageToCopy,
    01078                                 const core::position2d<s32>& pos,
    01079                                 const core::dimension2d<u32>& size) =0;
    01080
    01082
    01089                 virtual IImage* createImage(ITexture* texture,
    01090                                 const core::position2d<s32>& pos,
    01091                                 const core::dimension2d<u32>& size) =0;
    01092
    01094
    01096                 virtual void OnResize(const core::dimension2d<u32>& size) =0;
    01097
    01099
    01119                 virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name =0) =0;
    01120
    01122
    01126                 virtual IMaterialRenderer* getMaterialRenderer(u32 idx) =0;
    01127
    01129
    01130                 virtual u32 getMaterialRendererCount() const =0;
    01131
    01133
    01142                 virtual const c8* getMaterialRendererName(u32 idx) const =0;
    01143
    01145
    01150                 virtual void setMaterialRendererName(s32 idx, const c8* name) =0;
    01151
    01153
    01160                 virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material) =0;
    01161
    01163
    01169                 virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) =0;
    01170
    01172
    01175                 virtual const SExposedVideoData& getExposedVideoData() =0;
    01176
    01178
    01179                 virtual E_DRIVER_TYPE getDriverType() const =0;
    01180
    01182
    01185                 virtual IGPUProgrammingServices* getGPUProgrammingServices() =0;
    01186
    01188                 virtual scene::IMeshManipulator* getMeshManipulator() =0;
    01189
    01191
    01197                 virtual void clearZBuffer() =0;
    01198
    01200
    01201                 virtual IImage* createScreenShot() =0;
    01202
    01204
    01208                 virtual video::ITexture* findTexture(const io::path& filename) = 0;
    01209
    01211
    01219                 virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) =0;
    01220
    01222
    01228                 virtual void enableClipPlane(u32 index, bool enable) =0;
    01229
    01231
    01232                 virtual void setMinHardwareBufferVertexCount(u32 count) =0;
    01233
    01235
    01239                 virtual SOverrideMaterial& getOverrideMaterial() =0;
    01240
    01242                 virtual core::stringc getVendorInfo() =0;
    01243
    01245
    01248                 virtual void setAmbientLight(const SColorf& color) =0;
    01249
    01251
    01254                 virtual void setAllowZWriteOnTransparent(bool flag) =0;
    01255         };
    01256
    01257 } // end namespace video
    01258 } // end namespace irr
    01259
    01260
    01261 #endif
    01262

| The Irrlicht Engine Documentation © 2003-2009 by Nikolaus Gebhardt. Generated on Sun Jan 10 09:24:04 2010 by Doxygen (1.5.6)