]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CNullDriver.h
IVideoDriver::setMaterialRendererName now using u32 for index like other similar...
[irrlicht.git] / source / Irrlicht / CNullDriver.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_VIDEO_NULL_H_INCLUDED__\r
6 #define __C_VIDEO_NULL_H_INCLUDED__\r
7 \r
8 #include "IVideoDriver.h"\r
9 #include "IFileSystem.h"\r
10 #include "IGPUProgrammingServices.h"\r
11 #include "irrArray.h"\r
12 #include "irrString.h"\r
13 #include "IAttributes.h"\r
14 #include "IMesh.h"\r
15 #include "IMeshBuffer.h"\r
16 #include "IMeshSceneNode.h"\r
17 #include "CFPSCounter.h"\r
18 #include "S3DVertex.h"\r
19 #include "SVertexIndex.h"\r
20 #include "SExposedVideoData.h"\r
21 #include <list>\r
22 \r
23 namespace irr\r
24 {\r
25 namespace io\r
26 {\r
27         class IWriteFile;\r
28         class IReadFile;\r
29 } // end namespace io\r
30 namespace video\r
31 {\r
32         class IImageLoader;\r
33         class IImageWriter;\r
34 \r
35         class CNullDriver : public IVideoDriver, public IGPUProgrammingServices\r
36         {\r
37         public:\r
38 \r
39                 //! constructor\r
40                 CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize);\r
41 \r
42                 //! destructor\r
43                 virtual ~CNullDriver();\r
44 \r
45                 virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255,0,0,0), f32 clearDepth = 1.f, u8 clearStencil = 0,\r
46                         const SExposedVideoData& videoData = SExposedVideoData(), core::rect<s32>* sourceRect = 0) override;\r
47 \r
48                 bool endScene() override;\r
49 \r
50                 //! Disable a feature of the driver.\r
51                 void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) override;\r
52 \r
53                 //! queries the features of the driver, returns true if feature is available\r
54                 bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const override;\r
55 \r
56                 //! Get attributes of the actual video driver\r
57                 const io::IAttributes& getDriverAttributes() const override;\r
58 \r
59                 //! sets transformation\r
60                 void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) override;\r
61 \r
62                 //! Retrieve the number of image loaders\r
63                 u32 getImageLoaderCount() const override;\r
64 \r
65                 //! Retrieve the given image loader\r
66                 IImageLoader* getImageLoader(u32 n) override;\r
67 \r
68                 //! Retrieve the number of image writers\r
69                 u32 getImageWriterCount() const override;\r
70 \r
71                 //! Retrieve the given image writer\r
72                 IImageWriter* getImageWriter(u32 n) override;\r
73 \r
74                 //! sets a material\r
75                 void setMaterial(const SMaterial& material) override;\r
76 \r
77                 //! loads a Texture\r
78                 ITexture* getTexture(const io::path& filename) override;\r
79 \r
80                 //! loads a Texture\r
81                 ITexture* getTexture(io::IReadFile* file) override;\r
82 \r
83                 //! Returns a texture by index\r
84                 ITexture* getTextureByIndex(u32 index) override;\r
85 \r
86                 //! Returns amount of textures currently loaded\r
87                 u32 getTextureCount() const override;\r
88 \r
89                 //! Renames a texture\r
90                 void renameTexture(ITexture* texture, const io::path& newName) override;\r
91 \r
92                 ITexture* addTexture(const core::dimension2d<u32>& size, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) override;\r
93 \r
94                 ITexture* addTexture(const io::path& name, IImage* image) override;\r
95 \r
96                 virtual ITexture* addTextureCubemap(const io::path& name, IImage* imagePosX, IImage* imageNegX, IImage* imagePosY,\r
97                         IImage* imageNegY, IImage* imagePosZ, IImage* imageNegZ) override;\r
98 \r
99                 ITexture* addTextureCubemap(const irr::u32 sideLen, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) override;\r
100 \r
101                 virtual bool setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),\r
102                         f32 clearDepth = 1.f, u8 clearStencil = 0) override;\r
103 \r
104                 virtual bool setRenderTarget(ITexture* texture, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),\r
105                         f32 clearDepth = 1.f, u8 clearStencil = 0) override;\r
106 \r
107                 //! sets a viewport\r
108                 void setViewPort(const core::rect<s32>& area) override;\r
109 \r
110                 //! gets the area of the current viewport\r
111                 const core::rect<s32>& getViewPort() const override;\r
112 \r
113                 //! draws a vertex primitive list\r
114                 virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,\r
115                                 const void* indexList, u32 primitiveCount,\r
116                                 E_VERTEX_TYPE vType=EVT_STANDARD, scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,\r
117                                 E_INDEX_TYPE iType=EIT_16BIT) override;\r
118 \r
119                 //! draws a vertex primitive list in 2d\r
120                 virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,\r
121                                 const void* indexList, u32 primitiveCount,\r
122                                 E_VERTEX_TYPE vType=EVT_STANDARD, scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,\r
123                                 E_INDEX_TYPE iType=EIT_16BIT) override;\r
124 \r
125                 //! Draws a 3d line.\r
126                 virtual void draw3DLine(const core::vector3df& start,\r
127                         const core::vector3df& end, SColor color = SColor(255,255,255,255)) override;\r
128 \r
129                 //! Draws a 3d triangle.\r
130                 virtual void draw3DTriangle(const core::triangle3df& triangle,\r
131                         SColor color = SColor(255,255,255,255)) override;\r
132 \r
133                 //! Draws a 3d axis aligned box.\r
134                 virtual void draw3DBox(const core::aabbox3d<f32>& box,\r
135                         SColor color = SColor(255,255,255,255)) override;\r
136 \r
137                 //! draws an 2d image\r
138                 void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, bool useAlphaChannelOfTexture) override;\r
139 \r
140                 //! draws a set of 2d images, using a color and the alpha\r
141                 /** channel of the texture if desired. The images are drawn\r
142                 beginning at pos and concatenated in one line. All drawings\r
143                 are clipped against clipRect (if != 0).\r
144                 The subtextures are defined by the array of sourceRects\r
145                 and are chosen by the indices given.\r
146                 \param texture: Texture to be drawn.\r
147                 \param pos: Upper left 2d destination position where the image will be drawn.\r
148                 \param sourceRects: Source rectangles of the image.\r
149                 \param indices: List of indices which choose the actual rectangle used each time.\r
150                 \param kerningWidth: offset on position\r
151                 \param clipRect: Pointer to rectangle on the screen where the image is clipped to.\r
152                 This pointer can be 0. Then the image is not clipped.\r
153                 \param color: Color with which the image is colored.\r
154                 Note that the alpha component is used: If alpha is other than 255, the image will be transparent.\r
155                 \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is\r
156                 used to draw the image. */\r
157                 virtual void draw2DImageBatch(const video::ITexture* texture,\r
158                                 const core::position2d<s32>& pos,\r
159                                 const core::array<core::rect<s32> >& sourceRects,\r
160                                 const core::array<s32>& indices,\r
161                                 s32 kerningWidth = 0,\r
162                                 const core::rect<s32>* clipRect = 0,\r
163                                 SColor color=SColor(255,255,255,255),\r
164                                 bool useAlphaChannelOfTexture=false) override;\r
165 \r
166                 //! Draws a set of 2d images, using a color and the alpha channel of the texture.\r
167                 /** All drawings are clipped against clipRect (if != 0).\r
168                 The subtextures are defined by the array of sourceRects and are\r
169                 positioned using the array of positions.\r
170                 \param texture Texture to be drawn.\r
171                 \param pos Array of upper left 2d destinations where the images\r
172                 will be drawn.\r
173                 \param sourceRects Source rectangles of the image.\r
174                 \param clipRect Pointer to rectangle on the screen where the\r
175                 images are clipped to.\r
176                 If this pointer is 0 then the image is not clipped.\r
177                 \param color Color with which the image is drawn.\r
178                 Note that the alpha component is used. If alpha is other than\r
179                 255, the image will be transparent.\r
180                 \param useAlphaChannelOfTexture: If true, the alpha channel of\r
181                 the texture is used to draw the image. */\r
182                 virtual void draw2DImageBatch(const video::ITexture* texture,\r
183                                 const core::array<core::position2d<s32> >& positions,\r
184                                 const core::array<core::rect<s32> >& sourceRects,\r
185                                 const core::rect<s32>* clipRect=0,\r
186                                 SColor color=SColor(255,255,255,255),\r
187                                 bool useAlphaChannelOfTexture=false) override;\r
188 \r
189                 //! Draws a 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.\r
190                 virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,\r
191                         const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,\r
192                         SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) override;\r
193 \r
194                 //! Draws a part of the texture into the rectangle.\r
195                 virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,\r
196                         const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,\r
197                         const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false) override;\r
198 \r
199                 //! Draws a 2d rectangle\r
200                 void draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip = 0) override;\r
201 \r
202                 //! Draws a 2d rectangle with a gradient.\r
203                 virtual void draw2DRectangle(const core::rect<s32>& pos,\r
204                         SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,\r
205                         const core::rect<s32>* clip = 0) override;\r
206 \r
207                 //! Draws the outline of a 2d rectangle\r
208                 void draw2DRectangleOutline(const core::recti& pos, SColor color=SColor(255,255,255,255)) override;\r
209 \r
210                 //! Draws a 2d line.\r
211                 virtual void draw2DLine(const core::position2d<s32>& start,\r
212                                         const core::position2d<s32>& end,\r
213                                         SColor color=SColor(255,255,255,255)) override;\r
214 \r
215                 //! Draws a pixel\r
216                 void drawPixel(u32 x, u32 y, const SColor & color) override;\r
217 \r
218                 //! Draws a non filled concyclic reqular 2d polygon.\r
219                 virtual void draw2DPolygon(core::position2d<s32> center,\r
220                         f32 radius, video::SColor Color, s32 vertexCount) override;\r
221 \r
222                 virtual void setFog(SColor color=SColor(0,255,255,255),\r
223                                 E_FOG_TYPE fogType=EFT_FOG_LINEAR,\r
224                                 f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,\r
225                                 bool pixelFog=false, bool rangeFog=false) override;\r
226 \r
227                 virtual void getFog(SColor& color, E_FOG_TYPE& fogType,\r
228                                 f32& start, f32& end, f32& density,\r
229                                 bool& pixelFog, bool& rangeFog) override;\r
230 \r
231                 //! get color format of the current color buffer\r
232                 ECOLOR_FORMAT getColorFormat() const override;\r
233 \r
234                 //! get screen size\r
235                 const core::dimension2d<u32>& getScreenSize() const override;\r
236 \r
237                 //! get current render target\r
238                 IRenderTarget* getCurrentRenderTarget() const;\r
239 \r
240                 //! get render target size\r
241                 const core::dimension2d<u32>& getCurrentRenderTargetSize() const override;\r
242 \r
243                 // get current frames per second value\r
244                 s32 getFPS() const override;\r
245 \r
246                 //! returns amount of primitives (mostly triangles) were drawn in the last frame.\r
247                 //! very useful method for statistics.\r
248                 u32 getPrimitiveCountDrawn( u32 param = 0 ) const override;\r
249 \r
250                 //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8\r
251                 //! driver, it would return "Direct3D8.1".\r
252                 const wchar_t* getName() const override;\r
253 \r
254                 //! Sets the dynamic ambient light color. The default color is\r
255                 //! (0,0,0,0) which means it is dark.\r
256                 //! \param color: New color of the ambient light.\r
257                 void setAmbientLight(const SColorf& color) override;\r
258 \r
259                 //! Get the global ambient light currently used by the driver\r
260                 const SColorf& getAmbientLight() const override;\r
261 \r
262                 //! Adds an external image loader to the engine.\r
263                 void addExternalImageLoader(IImageLoader* loader) override;\r
264 \r
265                 //! Adds an external image writer to the engine.\r
266                 void addExternalImageWriter(IImageWriter* writer) override;\r
267 \r
268                 //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do\r
269                 //! this: First, draw all geometry. Then use this method, to draw the shadow\r
270                 //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.\r
271                 virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles,\r
272                         bool zfail=true, u32 debugDataVisible=0) override;\r
273 \r
274                 //! Fills the stencil shadow with color. After the shadow volume has been drawn\r
275                 //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this\r
276                 //! to draw the color of the shadow.\r
277                 virtual void drawStencilShadow(bool clearStencilBuffer=false,\r
278                         video::SColor leftUpEdge = video::SColor(0,0,0,0),\r
279                         video::SColor rightUpEdge = video::SColor(0,0,0,0),\r
280                         video::SColor leftDownEdge = video::SColor(0,0,0,0),\r
281                         video::SColor rightDownEdge = video::SColor(0,0,0,0)) override;\r
282 \r
283 \r
284                 //! Removes a texture from the texture cache and deletes it, freeing lot of\r
285                 //! memory.\r
286                 void removeTexture(ITexture* texture) override;\r
287 \r
288                 //! Removes all texture from the texture cache and deletes them, freeing lot of\r
289                 //! memory.\r
290                 void removeAllTextures() override;\r
291 \r
292                 //! Creates a render target texture.\r
293                 virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,\r
294                         const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN) override;\r
295 \r
296                 //! Creates a render target texture for a cubemap\r
297                 ITexture* addRenderTargetTextureCubemap(const irr::u32 sideLen,\r
298                                 const io::path& name, const ECOLOR_FORMAT format) override;\r
299 \r
300                 //! Creates an 1bit alpha channel of the texture based of an color key.\r
301                 void makeColorKeyTexture(video::ITexture* texture, video::SColor color, bool zeroTexels) const override;\r
302 \r
303                 //! Creates an 1bit alpha channel of the texture based of an color key position.\r
304                 virtual void makeColorKeyTexture(video::ITexture* texture, core::position2d<s32> colorKeyPixelPos,\r
305                         bool zeroTexels) const override;\r
306 \r
307                 //! Returns the maximum amount of primitives (mostly vertices) which\r
308                 //! the device is able to render with one drawIndexedTriangleList\r
309                 //! call.\r
310                 u32 getMaximalPrimitiveCount() const override;\r
311 \r
312                 //! Enables or disables a texture creation flag.\r
313                 void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) override;\r
314 \r
315                 //! Returns if a texture creation flag is enabled or disabled.\r
316                 bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const override;\r
317 \r
318                 core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) override;\r
319 \r
320                 core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) override;\r
321 \r
322                 //! Creates a software image from a byte array.\r
323                 /** \param useForeignMemory: If true, the image will use the data pointer\r
324                 directly and own it from now on, which means it will also try to delete [] the\r
325                 data when the image will be destructed. If false, the memory will by copied. */\r
326                 virtual IImage* createImageFromData(ECOLOR_FORMAT format,\r
327                         const core::dimension2d<u32>& size, void *data, bool ownForeignMemory = false,\r
328                         bool deleteMemory = true) override;\r
329 \r
330                 //! Creates an empty software image.\r
331                 IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) override;\r
332 \r
333                 //! Creates a software image from another image.\r
334                 IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) override;\r
335 \r
336                 //! Creates a software image from part of another image.\r
337                 virtual IImage* createImage(IImage* imageToCopy,\r
338                                 const core::position2d<s32>& pos,\r
339                                 const core::dimension2d<u32>& size) override;\r
340 \r
341                 //! Creates a software image from part of a texture.\r
342                 virtual IImage* createImage(ITexture* texture,\r
343                                 const core::position2d<s32>& pos,\r
344                                 const core::dimension2d<u32>& size) override;\r
345 \r
346                 //! Draws a mesh buffer\r
347                 void drawMeshBuffer(const scene::IMeshBuffer* mb) override;\r
348 \r
349                 //! Draws the normals of a mesh buffer\r
350                 virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f,\r
351                         SColor color=0xffffffff) override;\r
352 \r
353                 //! Check if the driver supports creating textures with the given color format\r
354                 bool queryTextureFormat(ECOLOR_FORMAT format) const override\r
355                 {\r
356                         return false;\r
357                 }\r
358 \r
359         protected:\r
360                 struct SHWBufferLink\r
361                 {\r
362                         SHWBufferLink(const scene::IMeshBuffer *_MeshBuffer)\r
363                                 :MeshBuffer(_MeshBuffer),\r
364                                 ChangedID_Vertex(0),ChangedID_Index(0),\r
365                                 Mapped_Vertex(scene::EHM_NEVER),Mapped_Index(scene::EHM_NEVER)\r
366                         {\r
367                                 if (MeshBuffer) {\r
368                                         MeshBuffer->grab();\r
369                                         MeshBuffer->setHWBuffer(reinterpret_cast<void*>(this));\r
370                                 }\r
371                         }\r
372 \r
373                         virtual ~SHWBufferLink()\r
374                         {\r
375                                 if (MeshBuffer) {\r
376                                         MeshBuffer->setHWBuffer(NULL);\r
377                                         MeshBuffer->drop();\r
378                                 }\r
379                         }\r
380 \r
381                         const scene::IMeshBuffer *MeshBuffer;\r
382                         u32 ChangedID_Vertex;\r
383                         u32 ChangedID_Index;\r
384                         scene::E_HARDWARE_MAPPING Mapped_Vertex;\r
385                         scene::E_HARDWARE_MAPPING Mapped_Index;\r
386                         std::list<SHWBufferLink*>::iterator listPosition;\r
387                 };\r
388 \r
389                 //! Gets hardware buffer link from a meshbuffer (may create or update buffer)\r
390                 virtual SHWBufferLink *getBufferLink(const scene::IMeshBuffer* mb);\r
391 \r
392                 //! updates hardware buffer if needed  (only some drivers can)\r
393                 virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer) {return false;}\r
394 \r
395                 //! Draw hardware buffer (only some drivers can)\r
396                 virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer) {}\r
397 \r
398                 //! Delete hardware buffer\r
399                 virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer);\r
400 \r
401                 //! Create hardware buffer from mesh (only some drivers can)\r
402                 virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb) {return 0;}\r
403 \r
404         public:\r
405                 //! Remove hardware buffer\r
406                 void removeHardwareBuffer(const scene::IMeshBuffer* mb) override;\r
407 \r
408                 //! Remove all hardware buffers\r
409                 void removeAllHardwareBuffers() override;\r
410 \r
411                 //! Update all hardware buffers, remove unused ones\r
412                 virtual void updateAllHardwareBuffers();\r
413 \r
414                 //! is vbo recommended on this mesh?\r
415                 virtual bool isHardwareBufferRecommend(const scene::IMeshBuffer* mb);\r
416 \r
417                 //! Create occlusion query.\r
418                 /** Use node for identification and mesh for occlusion test. */\r
419                 virtual void addOcclusionQuery(scene::ISceneNode* node,\r
420                                 const scene::IMesh* mesh=0) override;\r
421 \r
422                 //! Remove occlusion query.\r
423                 void removeOcclusionQuery(scene::ISceneNode* node) override;\r
424 \r
425                 //! Remove all occlusion queries.\r
426                 void removeAllOcclusionQueries() override;\r
427 \r
428                 //! Run occlusion query. Draws mesh stored in query.\r
429                 /** If the mesh shall not be rendered visible, use\r
430                 overrideMaterial to disable the color and depth buffer. */\r
431                 void runOcclusionQuery(scene::ISceneNode* node, bool visible=false) override;\r
432 \r
433                 //! Run all occlusion queries. Draws all meshes stored in queries.\r
434                 /** If the meshes shall not be rendered visible, use\r
435                 overrideMaterial to disable the color and depth buffer. */\r
436                 void runAllOcclusionQueries(bool visible=false) override;\r
437 \r
438                 //! Update occlusion query. Retrieves results from GPU.\r
439                 /** If the query shall not block, set the flag to false.\r
440                 Update might not occur in this case, though */\r
441                 void updateOcclusionQuery(scene::ISceneNode* node, bool block=true) override;\r
442 \r
443                 //! Update all occlusion queries. Retrieves results from GPU.\r
444                 /** If the query shall not block, set the flag to false.\r
445                 Update might not occur in this case, though */\r
446                 void updateAllOcclusionQueries(bool block=true) override;\r
447 \r
448                 //! Return query result.\r
449                 /** Return value is the number of visible pixels/fragments.\r
450                 The value is a safe approximation, i.e. can be larger than the\r
451                 actual value of pixels. */\r
452                 u32 getOcclusionQueryResult(scene::ISceneNode* node) const override;\r
453 \r
454                 //! Create render target.\r
455                 IRenderTarget* addRenderTarget() override;\r
456 \r
457                 //! Remove render target.\r
458                 void removeRenderTarget(IRenderTarget* renderTarget) override;\r
459 \r
460                 //! Remove all render targets.\r
461                 void removeAllRenderTargets() override;\r
462 \r
463                 //! Only used by the engine internally.\r
464                 /** Used to notify the driver that the window was resized. */\r
465                 void OnResize(const core::dimension2d<u32>& size) override;\r
466 \r
467                 //! Adds a new material renderer to the video device.\r
468                 virtual s32 addMaterialRenderer(IMaterialRenderer* renderer,\r
469                                 const char* name = 0) override;\r
470 \r
471                 //! Returns driver and operating system specific data about the IVideoDriver.\r
472                 const SExposedVideoData& getExposedVideoData() override;\r
473 \r
474                 //! Returns type of video driver\r
475                 E_DRIVER_TYPE getDriverType() const override;\r
476 \r
477                 //! Returns the transformation set by setTransform\r
478                 const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const override;\r
479 \r
480                 //! Returns pointer to the IGPUProgrammingServices interface.\r
481                 IGPUProgrammingServices* getGPUProgrammingServices() override;\r
482 \r
483                 //! Adds a new material renderer to the VideoDriver, using pixel and/or\r
484                 //! vertex shaders to render geometry.\r
485                 virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0,\r
486                         const c8* pixelShaderProgram = 0,\r
487                         IShaderConstantSetCallBack* callback = 0,\r
488                         E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,\r
489                         s32 userData=0) override;\r
490 \r
491                 //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the\r
492                 //! programs from files.\r
493                 virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram = 0,\r
494                         io::IReadFile* pixelShaderProgram = 0,\r
495                         IShaderConstantSetCallBack* callback = 0,\r
496                         E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,\r
497                         s32 userData=0) override;\r
498 \r
499                 //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the\r
500                 //! programs from files.\r
501                 virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,\r
502                         const io::path& pixelShaderProgramFileName,\r
503                         IShaderConstantSetCallBack* callback = 0,\r
504                         E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,\r
505                         s32 userData=0) override;\r
506 \r
507                 //! Returns pointer to material renderer or null\r
508                 IMaterialRenderer* getMaterialRenderer(u32 idx) const override;\r
509 \r
510                 //! Returns amount of currently available material renderers.\r
511                 u32 getMaterialRendererCount() const override;\r
512 \r
513                 //! Returns name of the material renderer\r
514                 const char* getMaterialRendererName(u32 idx) const override;\r
515 \r
516                 //! Adds a new material renderer to the VideoDriver, based on a high level shading\r
517                 //! language. Currently only HLSL in D3D9 is supported.\r
518                 virtual s32 addHighLevelShaderMaterial(\r
519                         const c8* vertexShaderProgram,\r
520                         const c8* vertexShaderEntryPointName = 0,\r
521                         E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,\r
522                         const c8* pixelShaderProgram = 0,\r
523                         const c8* pixelShaderEntryPointName = 0,\r
524                         E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,\r
525                         const c8* geometryShaderProgram = 0,\r
526                         const c8* geometryShaderEntryPointName = "main",\r
527                         E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,\r
528                         scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,\r
529                         scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,\r
530                         u32 verticesOut = 0,\r
531                         IShaderConstantSetCallBack* callback = 0,\r
532                         E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,\r
533                         s32 userData = 0) override;\r
534 \r
535                 //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),\r
536                 //! but tries to load the programs from files.\r
537                 virtual s32 addHighLevelShaderMaterialFromFiles(\r
538                         const io::path& vertexShaderProgramFile,\r
539                         const c8* vertexShaderEntryPointName = "main",\r
540                         E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,\r
541                         const io::path& pixelShaderProgramFile = "",\r
542                         const c8* pixelShaderEntryPointName = "main",\r
543                         E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,\r
544                         const io::path& geometryShaderProgramFileName="",\r
545                         const c8* geometryShaderEntryPointName = "main",\r
546                         E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,\r
547                         scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,\r
548                         scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,\r
549                         u32 verticesOut = 0,\r
550                         IShaderConstantSetCallBack* callback = 0,\r
551                         E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,\r
552                         s32 userData = 0) override;\r
553 \r
554                 //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),\r
555                 //! but tries to load the programs from files.\r
556                 virtual s32 addHighLevelShaderMaterialFromFiles(\r
557                         io::IReadFile* vertexShaderProgram,\r
558                         const c8* vertexShaderEntryPointName = "main",\r
559                         E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,\r
560                         io::IReadFile* pixelShaderProgram = 0,\r
561                         const c8* pixelShaderEntryPointName = "main",\r
562                         E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,\r
563                         io::IReadFile* geometryShaderProgram= 0,\r
564                         const c8* geometryShaderEntryPointName = "main",\r
565                         E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,\r
566                         scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,\r
567                         scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,\r
568                         u32 verticesOut = 0,\r
569                         IShaderConstantSetCallBack* callback = 0,\r
570                         E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,\r
571                         s32 userData = 0) override;\r
572 \r
573                 //! Returns a pointer to the mesh manipulator.\r
574                 scene::IMeshManipulator* getMeshManipulator() override;\r
575 \r
576                 void clearBuffers(u16 flag, SColor color = SColor(255,0,0,0), f32 depth = 1.f, u8 stencil = 0) override;\r
577 \r
578                 //! Returns an image created from the last rendered frame.\r
579                 IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) override;\r
580 \r
581                 //! Writes the provided image to disk file\r
582                 bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) override;\r
583 \r
584                 //! Writes the provided image to a file.\r
585                 bool writeImageToFile(IImage* image, io::IWriteFile * file, u32 param = 0) override;\r
586 \r
587                 //! Sets the name of a material renderer.\r
588                 void setMaterialRendererName(u32 idx, const char* name) override;\r
589 \r
590                 //! Swap the material renderers used for certain id's\r
591                 void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames) override;\r
592 \r
593                 //! looks if the image is already loaded\r
594                 video::ITexture* findTexture(const io::path& filename) override;\r
595 \r
596                 //! Set/unset a clipping plane.\r
597                 //! There are at least 6 clipping planes available for the user to set at will.\r
598                 //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.\r
599                 //! \param plane: The plane itself.\r
600                 //! \param enable: If true, enable the clipping plane else disable it.\r
601                 bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) override;\r
602 \r
603                 //! Enable/disable a clipping plane.\r
604                 //! There are at least 6 clipping planes available for the user to set at will.\r
605                 //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.\r
606                 //! \param enable: If true, enable the clipping plane else disable it.\r
607                 void enableClipPlane(u32 index, bool enable) override;\r
608 \r
609                 //! Returns the graphics card vendor name.\r
610                 core::stringc getVendorInfo() override {return "Not available on this driver.";}\r
611 \r
612                 //! Set the minimum number of vertices for which a hw buffer will be created\r
613                 /** \param count Number of vertices to set as minimum. */\r
614                 void setMinHardwareBufferVertexCount(u32 count) override;\r
615 \r
616                 //! Get the global Material, which might override local materials.\r
617                 /** Depending on the enable flags, values from this Material\r
618                 are used to override those of local materials of some\r
619                 meshbuffer being rendered. */\r
620                 SOverrideMaterial& getOverrideMaterial() override;\r
621 \r
622                 //! Get the 2d override material for altering its values\r
623                 SMaterial& getMaterial2D() override;\r
624 \r
625                 //! Enable the 2d override material\r
626                 void enableMaterial2D(bool enable=true) override;\r
627 \r
628                 //! Only used by the engine internally.\r
629                 void setAllowZWriteOnTransparent(bool flag) override\r
630                 { AllowZWriteOnTransparent=flag; }\r
631 \r
632                 //! Returns the maximum texture size supported.\r
633                 core::dimension2du getMaxTextureSize() const override;\r
634 \r
635                 //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass\r
636                 bool needsTransparentRenderPass(const irr::video::SMaterial& material) const override;\r
637 \r
638                 //! Color conversion convenience function\r
639                 /** Convert an image (as array of pixels) from source to destination\r
640                 array, thereby converting the color format. The pixel size is\r
641                 determined by the color formats.\r
642                 \param sP Pointer to source\r
643                 \param sF Color format of source\r
644                 \param sN Number of pixels to convert, both array must be large enough\r
645                 \param dP Pointer to destination\r
646                 \param dF Color format of destination\r
647                 */\r
648                 virtual void convertColor(const void* sP, ECOLOR_FORMAT sF, s32 sN,\r
649                                 void* dP, ECOLOR_FORMAT dF) const override;\r
650 \r
651                 //! deprecated method\r
652                 virtual ITexture* createRenderTargetTexture(const core::dimension2d<u32>& size,\r
653                                 const c8* name=0);\r
654 \r
655                 bool checkDriverReset() override {return false;}\r
656         protected:\r
657 \r
658                 //! deletes all textures\r
659                 void deleteAllTextures();\r
660 \r
661                 //! opens the file and loads it into the surface\r
662                 ITexture* loadTextureFromFile(io::IReadFile* file, const io::path& hashName = "");\r
663 \r
664                 //! adds a surface, not loaded or created by the Irrlicht Engine\r
665                 void addTexture(ITexture* surface);\r
666                 \r
667                 virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image);\r
668 \r
669                 virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image);\r
670 \r
671                 //! checks triangle count and print warning if wrong\r
672                 bool checkPrimitiveCount(u32 prmcnt) const;\r
673 \r
674                 bool checkImage(const core::array<IImage*>& image) const;\r
675 \r
676                 // adds a material renderer and drops it afterwards. To be used for internal creation\r
677                 s32 addAndDropMaterialRenderer(IMaterialRenderer* m);\r
678 \r
679                 //! deletes all material renderers\r
680                 void deleteMaterialRenders();\r
681 \r
682                 // prints renderer version\r
683                 void printVersion();\r
684 \r
685                 inline bool getWriteZBuffer(const SMaterial& material) const\r
686                 {\r
687                         switch ( material.ZWriteEnable )\r
688                         {\r
689                                 case video::EZW_OFF:\r
690                                         return false;\r
691                                 case video::EZW_AUTO:\r
692                                         return AllowZWriteOnTransparent || ! needsTransparentRenderPass(material);\r
693                                 case video::EZW_ON:\r
694                                         return true;\r
695                         }\r
696                         return true; // never should get here, but some compilers don't know and complain\r
697                 }\r
698 \r
699                 struct SSurface\r
700                 {\r
701                         video::ITexture* Surface;\r
702 \r
703                         bool operator < (const SSurface& other) const\r
704                         {\r
705                                 return Surface->getName() < other.Surface->getName();\r
706                         }\r
707                 };\r
708 \r
709                 struct SMaterialRenderer\r
710                 {\r
711                         core::stringc Name;\r
712                         IMaterialRenderer* Renderer;\r
713                 };\r
714 \r
715                 struct SDummyTexture : public ITexture\r
716                 {\r
717                         SDummyTexture(const io::path& name, E_TEXTURE_TYPE type) : ITexture(name, type) {};\r
718 \r
719                         void setSize(const core::dimension2d<u32>& size) { Size = OriginalSize = size; }\r
720 \r
721                         void* lock(E_TEXTURE_LOCK_MODE mode = ETLM_READ_WRITE, u32 mipmapLevel=0, u32 layer = 0, E_TEXTURE_LOCK_FLAGS lockFlags = ETLF_FLIP_Y_UP_RTT) override { return 0; }\r
722                         void unlock()override {}\r
723                         void regenerateMipMapLevels(void* data = 0, u32 layer = 0) override {}\r
724                 };\r
725                 core::array<SSurface> Textures;\r
726 \r
727                 struct SOccQuery\r
728                 {\r
729                         SOccQuery(scene::ISceneNode* node, const scene::IMesh* mesh=0) : Node(node), Mesh(mesh), PID(0), Result(0xffffffff), Run(0xffffffff)\r
730                         {\r
731                                 if (Node)\r
732                                         Node->grab();\r
733                                 if (Mesh)\r
734                                         Mesh->grab();\r
735                         }\r
736 \r
737                         SOccQuery(const SOccQuery& other) : Node(other.Node), Mesh(other.Mesh), PID(other.PID), Result(other.Result), Run(other.Run)\r
738                         {\r
739                                 if (Node)\r
740                                         Node->grab();\r
741                                 if (Mesh)\r
742                                         Mesh->grab();\r
743                         }\r
744 \r
745                         ~SOccQuery()\r
746                         {\r
747                                 if (Node)\r
748                                         Node->drop();\r
749                                 if (Mesh)\r
750                                         Mesh->drop();\r
751                         }\r
752 \r
753                         SOccQuery& operator=(const SOccQuery& other)\r
754                         {\r
755                                 Node=other.Node;\r
756                                 Mesh=other.Mesh;\r
757                                 PID=other.PID;\r
758                                 Result=other.Result;\r
759                                 Run=other.Run;\r
760                                 if (Node)\r
761                                         Node->grab();\r
762                                 if (Mesh)\r
763                                         Mesh->grab();\r
764                                 return *this;\r
765                         }\r
766 \r
767                         bool operator==(const SOccQuery& other) const\r
768                         {\r
769                                 return other.Node==Node;\r
770                         }\r
771 \r
772                         scene::ISceneNode* Node;\r
773                         const scene::IMesh* Mesh;\r
774                         union\r
775                         {\r
776                                 void* PID;\r
777                                 unsigned int UID;\r
778                         };\r
779                         u32 Result;\r
780                         u32 Run;\r
781                 };\r
782                 core::array<SOccQuery> OcclusionQueries;\r
783 \r
784                 core::array<IRenderTarget*> RenderTargets;\r
785 \r
786                 // Shared objects used with simplified IVideoDriver::setRenderTarget method with ITexture* param.\r
787                 IRenderTarget* SharedRenderTarget;\r
788                 core::array<ITexture*> SharedDepthTextures;\r
789 \r
790                 IRenderTarget* CurrentRenderTarget;\r
791                 core::dimension2d<u32> CurrentRenderTargetSize;\r
792 \r
793                 core::array<video::IImageLoader*> SurfaceLoader;\r
794                 core::array<video::IImageWriter*> SurfaceWriter;\r
795                 core::array<SMaterialRenderer> MaterialRenderers;\r
796 \r
797                 std::list<SHWBufferLink*> HWBufferList;\r
798 \r
799                 io::IFileSystem* FileSystem;\r
800 \r
801                 //! mesh manipulator\r
802                 scene::IMeshManipulator* MeshManipulator;\r
803 \r
804                 core::rect<s32> ViewPort;\r
805                 core::dimension2d<u32> ScreenSize;\r
806                 core::matrix4 TransformationMatrix;\r
807 \r
808                 CFPSCounter FPSCounter;\r
809 \r
810                 u32 PrimitivesDrawn;\r
811                 u32 MinVertexCountForVBO;\r
812 \r
813                 u32 TextureCreationFlags;\r
814 \r
815                 f32 FogStart;\r
816                 f32 FogEnd;\r
817                 f32 FogDensity;\r
818                 SColor FogColor;\r
819                 SExposedVideoData ExposedData;\r
820 \r
821                 io::IAttributes* DriverAttributes;\r
822 \r
823                 SOverrideMaterial OverrideMaterial;\r
824                 SMaterial OverrideMaterial2D;\r
825                 SMaterial InitMaterial2D;\r
826                 bool OverrideMaterial2DEnabled;\r
827 \r
828                 E_FOG_TYPE FogType;\r
829                 bool PixelFog;\r
830                 bool RangeFog;\r
831                 bool AllowZWriteOnTransparent;\r
832 \r
833                 bool FeatureEnabled[video::EVDF_COUNT];\r
834 \r
835                 SColorf AmbientLight;\r
836         };\r
837 \r
838 } // end namespace video\r
839 } // end namespace irr\r
840 \r
841 \r
842 #endif\r