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
5 #ifndef __C_VIDEO_NULL_H_INCLUDED__
\r
6 #define __C_VIDEO_NULL_H_INCLUDED__
\r
8 #include "IVideoDriver.h"
\r
9 #include "IFileSystem.h"
\r
10 #include "IImagePresenter.h"
\r
11 #include "IGPUProgrammingServices.h"
\r
12 #include "irrArray.h"
\r
13 #include "irrString.h"
\r
15 #include "IAttributes.h"
\r
17 #include "IMeshBuffer.h"
\r
18 #include "IMeshSceneNode.h"
\r
19 #include "CFPSCounter.h"
\r
20 #include "S3DVertex.h"
\r
21 #include "SVertexIndex.h"
\r
23 #include "SExposedVideoData.h"
\r
26 #pragma warning( disable: 4996)
\r
35 } // end namespace io
\r
41 class CNullDriver : public IVideoDriver, public IGPUProgrammingServices
\r
46 CNullDriver(io::IFileSystem* io, const core::dimension2d<u32>& screenSize);
\r
49 virtual ~CNullDriver();
\r
51 virtual bool beginScene(u16 clearFlag, SColor clearColor = SColor(255,0,0,0), f32 clearDepth = 1.f, u8 clearStencil = 0,
\r
52 const SExposedVideoData& videoData = SExposedVideoData(), core::rect<s32>* sourceRect = 0) _IRR_OVERRIDE_;
\r
54 virtual bool endScene() _IRR_OVERRIDE_;
\r
56 //! Disable a feature of the driver.
\r
57 virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) _IRR_OVERRIDE_;
\r
59 //! queries the features of the driver, returns true if feature is available
\r
60 virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const _IRR_OVERRIDE_;
\r
62 //! Get attributes of the actual video driver
\r
63 virtual const io::IAttributes& getDriverAttributes() const _IRR_OVERRIDE_;
\r
65 //! sets transformation
\r
66 virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) _IRR_OVERRIDE_;
\r
68 //! Retrieve the number of image loaders
\r
69 virtual u32 getImageLoaderCount() const _IRR_OVERRIDE_;
\r
71 //! Retrieve the given image loader
\r
72 virtual IImageLoader* getImageLoader(u32 n) _IRR_OVERRIDE_;
\r
74 //! Retrieve the number of image writers
\r
75 virtual u32 getImageWriterCount() const _IRR_OVERRIDE_;
\r
77 //! Retrieve the given image writer
\r
78 virtual IImageWriter* getImageWriter(u32 n) _IRR_OVERRIDE_;
\r
81 virtual void setMaterial(const SMaterial& material) _IRR_OVERRIDE_;
\r
84 virtual ITexture* getTexture(const io::path& filename) _IRR_OVERRIDE_;
\r
87 virtual ITexture* getTexture(io::IReadFile* file) _IRR_OVERRIDE_;
\r
89 //! Returns a texture by index
\r
90 virtual ITexture* getTextureByIndex(u32 index) _IRR_OVERRIDE_;
\r
92 //! Returns amount of textures currently loaded
\r
93 virtual u32 getTextureCount() const _IRR_OVERRIDE_;
\r
95 //! Renames a texture
\r
96 virtual void renameTexture(ITexture* texture, const io::path& newName) _IRR_OVERRIDE_;
\r
98 virtual ITexture* addTexture(const core::dimension2d<u32>& size, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) _IRR_OVERRIDE_;
\r
100 virtual ITexture* addTexture(const io::path& name, IImage* image) _IRR_OVERRIDE_;
\r
102 virtual ITexture* addTextureCubemap(const io::path& name, IImage* imagePosX, IImage* imageNegX, IImage* imagePosY,
\r
103 IImage* imageNegY, IImage* imagePosZ, IImage* imageNegZ) _IRR_OVERRIDE_;
\r
105 virtual ITexture* addTextureCubemap(const irr::u32 sideLen, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) _IRR_OVERRIDE_;
\r
107 virtual bool setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),
\r
108 f32 clearDepth = 1.f, u8 clearStencil = 0) _IRR_OVERRIDE_;
\r
110 virtual bool setRenderTarget(ITexture* texture, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),
\r
111 f32 clearDepth = 1.f, u8 clearStencil = 0) _IRR_OVERRIDE_;
\r
113 //! sets a viewport
\r
114 virtual void setViewPort(const core::rect<s32>& area) _IRR_OVERRIDE_;
\r
116 //! gets the area of the current viewport
\r
117 virtual const core::rect<s32>& getViewPort() const _IRR_OVERRIDE_;
\r
119 //! draws a vertex primitive list
\r
120 virtual void drawVertexPrimitiveList(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) _IRR_OVERRIDE_;
\r
125 //! draws a vertex primitive list in 2d
\r
126 virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
\r
127 const void* indexList, u32 primitiveCount,
\r
128 E_VERTEX_TYPE vType=EVT_STANDARD, scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
\r
129 E_INDEX_TYPE iType=EIT_16BIT) _IRR_OVERRIDE_;
\r
131 //! Draws a 3d line.
\r
132 virtual void draw3DLine(const core::vector3df& start,
\r
133 const core::vector3df& end, SColor color = SColor(255,255,255,255)) _IRR_OVERRIDE_;
\r
135 //! Draws a 3d triangle.
\r
136 virtual void draw3DTriangle(const core::triangle3df& triangle,
\r
137 SColor color = SColor(255,255,255,255)) _IRR_OVERRIDE_;
\r
139 //! Draws a 3d axis aligned box.
\r
140 virtual void draw3DBox(const core::aabbox3d<f32>& box,
\r
141 SColor color = SColor(255,255,255,255)) _IRR_OVERRIDE_;
\r
143 //! draws an 2d image
\r
144 virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos, bool useAlphaChannelOfTexture) _IRR_OVERRIDE_;
\r
146 //! draws a set of 2d images, using a color and the alpha
\r
147 /** channel of the texture if desired. The images are drawn
\r
148 beginning at pos and concatenated in one line. All drawings
\r
149 are clipped against clipRect (if != 0).
\r
150 The subtextures are defined by the array of sourceRects
\r
151 and are chosen by the indices given.
\r
152 \param texture: Texture to be drawn.
\r
153 \param pos: Upper left 2d destination position where the image will be drawn.
\r
154 \param sourceRects: Source rectangles of the image.
\r
155 \param indices: List of indices which choose the actual rectangle used each time.
\r
156 \param kerningWidth: offset on position
\r
157 \param clipRect: Pointer to rectangle on the screen where the image is clipped to.
\r
158 This pointer can be 0. Then the image is not clipped.
\r
159 \param color: Color with which the image is colored.
\r
160 Note that the alpha component is used: If alpha is other than 255, the image will be transparent.
\r
161 \param useAlphaChannelOfTexture: If true, the alpha channel of the texture is
\r
162 used to draw the image. */
\r
163 virtual void draw2DImageBatch(const video::ITexture* texture,
\r
164 const core::position2d<s32>& pos,
\r
165 const core::array<core::rect<s32> >& sourceRects,
\r
166 const core::array<s32>& indices,
\r
167 s32 kerningWidth = 0,
\r
168 const core::rect<s32>* clipRect = 0,
\r
169 SColor color=SColor(255,255,255,255),
\r
170 bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;
\r
172 //! Draws a set of 2d images, using a color and the alpha channel of the texture.
\r
173 /** All drawings are clipped against clipRect (if != 0).
\r
174 The subtextures are defined by the array of sourceRects and are
\r
175 positioned using the array of positions.
\r
176 \param texture Texture to be drawn.
\r
177 \param pos Array of upper left 2d destinations where the images
\r
179 \param sourceRects Source rectangles of the image.
\r
180 \param clipRect Pointer to rectangle on the screen where the
\r
181 images are clipped to.
\r
182 If this pointer is 0 then the image is not clipped.
\r
183 \param color Color with which the image is drawn.
\r
184 Note that the alpha component is used. If alpha is other than
\r
185 255, the image will be transparent.
\r
186 \param useAlphaChannelOfTexture: If true, the alpha channel of
\r
187 the texture is used to draw the image. */
\r
188 virtual void draw2DImageBatch(const video::ITexture* texture,
\r
189 const core::array<core::position2d<s32> >& positions,
\r
190 const core::array<core::rect<s32> >& sourceRects,
\r
191 const core::rect<s32>* clipRect=0,
\r
192 SColor color=SColor(255,255,255,255),
\r
193 bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;
\r
195 //! 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
196 virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
\r
197 const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
\r
198 SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;
\r
200 //! Draws a part of the texture into the rectangle.
\r
201 virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
\r
202 const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
\r
203 const video::SColor* const colors=0, bool useAlphaChannelOfTexture=false) _IRR_OVERRIDE_;
\r
205 //! Draws a 2d rectangle
\r
206 virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos, const core::rect<s32>* clip = 0) _IRR_OVERRIDE_;
\r
208 //! Draws a 2d rectangle with a gradient.
\r
209 virtual void draw2DRectangle(const core::rect<s32>& pos,
\r
210 SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
\r
211 const core::rect<s32>* clip = 0) _IRR_OVERRIDE_;
\r
213 //! Draws the outline of a 2d rectangle
\r
214 virtual void draw2DRectangleOutline(const core::recti& pos, SColor color=SColor(255,255,255,255)) _IRR_OVERRIDE_;
\r
216 //! Draws a 2d line.
\r
217 virtual void draw2DLine(const core::position2d<s32>& start,
\r
218 const core::position2d<s32>& end,
\r
219 SColor color=SColor(255,255,255,255)) _IRR_OVERRIDE_;
\r
222 virtual void drawPixel(u32 x, u32 y, const SColor & color) _IRR_OVERRIDE_;
\r
224 //! Draws a non filled concyclic reqular 2d polygon.
\r
225 virtual void draw2DPolygon(core::position2d<s32> center,
\r
226 f32 radius, video::SColor Color, s32 vertexCount) _IRR_OVERRIDE_;
\r
228 virtual void setFog(SColor color=SColor(0,255,255,255),
\r
229 E_FOG_TYPE fogType=EFT_FOG_LINEAR,
\r
230 f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
\r
231 bool pixelFog=false, bool rangeFog=false) _IRR_OVERRIDE_;
\r
233 virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
\r
234 f32& start, f32& end, f32& density,
\r
235 bool& pixelFog, bool& rangeFog) _IRR_OVERRIDE_;
\r
237 //! get color format of the current color buffer
\r
238 virtual ECOLOR_FORMAT getColorFormat() const _IRR_OVERRIDE_;
\r
240 //! get screen size
\r
241 virtual const core::dimension2d<u32>& getScreenSize() const _IRR_OVERRIDE_;
\r
243 //! get current render target
\r
244 IRenderTarget* getCurrentRenderTarget() const;
\r
246 //! get render target size
\r
247 virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const _IRR_OVERRIDE_;
\r
249 // get current frames per second value
\r
250 virtual s32 getFPS() const _IRR_OVERRIDE_;
\r
252 //! returns amount of primitives (mostly triangles) were drawn in the last frame.
\r
253 //! very useful method for statistics.
\r
254 virtual u32 getPrimitiveCountDrawn( u32 param = 0 ) const _IRR_OVERRIDE_;
\r
256 //! deletes all dynamic lights there are
\r
257 virtual void deleteAllDynamicLights() _IRR_OVERRIDE_;
\r
259 //! adds a dynamic light, returning an index to the light
\r
260 //! \param light: the light data to use to create the light
\r
261 //! \return An index to the light, or -1 if an error occurs
\r
262 virtual s32 addDynamicLight(const SLight& light) _IRR_OVERRIDE_;
\r
264 //! Turns a dynamic light on or off
\r
265 //! \param lightIndex: the index returned by addDynamicLight
\r
266 //! \param turnOn: true to turn the light on, false to turn it off
\r
267 virtual void turnLightOn(s32 lightIndex, bool turnOn) _IRR_OVERRIDE_;
\r
269 //! returns the maximal amount of dynamic lights the device can handle
\r
270 virtual u32 getMaximalDynamicLightAmount() const _IRR_OVERRIDE_;
\r
272 //! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
\r
273 //! driver, it would return "Direct3D8.1".
\r
274 virtual const wchar_t* getName() const _IRR_OVERRIDE_;
\r
276 //! Sets the dynamic ambient light color. The default color is
\r
277 //! (0,0,0,0) which means it is dark.
\r
278 //! \param color: New color of the ambient light.
\r
279 virtual void setAmbientLight(const SColorf& color) _IRR_OVERRIDE_;
\r
281 //! Get the global ambient light currently used by the driver
\r
282 virtual const SColorf& getAmbientLight() const _IRR_OVERRIDE_;
\r
284 //! Adds an external image loader to the engine.
\r
285 virtual void addExternalImageLoader(IImageLoader* loader) _IRR_OVERRIDE_;
\r
287 //! Adds an external image writer to the engine.
\r
288 virtual void addExternalImageWriter(IImageWriter* writer) _IRR_OVERRIDE_;
\r
290 //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
\r
291 //! this: First, draw all geometry. Then use this method, to draw the shadow
\r
292 //! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
\r
293 virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles,
\r
294 bool zfail=true, u32 debugDataVisible=0) _IRR_OVERRIDE_;
\r
296 //! Fills the stencil shadow with color. After the shadow volume has been drawn
\r
297 //! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
\r
298 //! to draw the color of the shadow.
\r
299 virtual void drawStencilShadow(bool clearStencilBuffer=false,
\r
300 video::SColor leftUpEdge = video::SColor(0,0,0,0),
\r
301 video::SColor rightUpEdge = video::SColor(0,0,0,0),
\r
302 video::SColor leftDownEdge = video::SColor(0,0,0,0),
\r
303 video::SColor rightDownEdge = video::SColor(0,0,0,0)) _IRR_OVERRIDE_;
\r
305 //! Returns current amount of dynamic lights set
\r
306 //! \return Current amount of dynamic lights set
\r
307 virtual u32 getDynamicLightCount() const _IRR_OVERRIDE_;
\r
309 //! Returns light data which was previously set with IVideDriver::addDynamicLight().
\r
310 //! \param idx: Zero based index of the light. Must be greater than 0 and smaller
\r
311 //! than IVideoDriver()::getDynamicLightCount.
\r
312 //! \return Light data.
\r
313 virtual const SLight& getDynamicLight(u32 idx) const _IRR_OVERRIDE_;
\r
315 //! Removes a texture from the texture cache and deletes it, freeing lot of
\r
317 virtual void removeTexture(ITexture* texture) _IRR_OVERRIDE_;
\r
319 //! Removes all texture from the texture cache and deletes them, freeing lot of
\r
321 virtual void removeAllTextures() _IRR_OVERRIDE_;
\r
323 //! Creates a render target texture.
\r
324 virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
\r
325 const io::path& name, const ECOLOR_FORMAT format = ECF_UNKNOWN) _IRR_OVERRIDE_;
\r
327 //! Creates a render target texture for a cubemap
\r
328 ITexture* addRenderTargetTextureCubemap(const irr::u32 sideLen,
\r
329 const io::path& name, const ECOLOR_FORMAT format) _IRR_OVERRIDE_;
\r
331 //! Creates an 1bit alpha channel of the texture based of an color key.
\r
332 virtual void makeColorKeyTexture(video::ITexture* texture, video::SColor color, bool zeroTexels) const _IRR_OVERRIDE_;
\r
334 //! Creates an 1bit alpha channel of the texture based of an color key position.
\r
335 virtual void makeColorKeyTexture(video::ITexture* texture, core::position2d<s32> colorKeyPixelPos,
\r
336 bool zeroTexels) const _IRR_OVERRIDE_;
\r
338 //! Creates a normal map from a height map texture.
\r
339 //! \param amplitude: Constant value by which the height information is multiplied.
\r
340 virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const _IRR_OVERRIDE_;
\r
342 //! Returns the maximum amount of primitives (mostly vertices) which
\r
343 //! the device is able to render with one drawIndexedTriangleList
\r
345 virtual u32 getMaximalPrimitiveCount() const _IRR_OVERRIDE_;
\r
347 //! Enables or disables a texture creation flag.
\r
348 virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled) _IRR_OVERRIDE_;
\r
350 //! Returns if a texture creation flag is enabled or disabled.
\r
351 virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const _IRR_OVERRIDE_;
\r
353 virtual core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) _IRR_OVERRIDE_;
\r
355 virtual core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) _IRR_OVERRIDE_;
\r
357 //! Creates a software image from a byte array.
\r
358 /** \param useForeignMemory: If true, the image will use the data pointer
\r
359 directly and own it from now on, which means it will also try to delete [] the
\r
360 data when the image will be destructed. If false, the memory will by copied. */
\r
361 virtual IImage* createImageFromData(ECOLOR_FORMAT format,
\r
362 const core::dimension2d<u32>& size, void *data, bool ownForeignMemory = false,
\r
363 bool deleteMemory = true) _IRR_OVERRIDE_;
\r
365 //! Creates an empty software image.
\r
366 virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) _IRR_OVERRIDE_;
\r
368 //! Creates a software image from another image.
\r
369 virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) _IRR_OVERRIDE_;
\r
371 //! Creates a software image from part of another image.
\r
372 virtual IImage* createImage(IImage* imageToCopy,
\r
373 const core::position2d<s32>& pos,
\r
374 const core::dimension2d<u32>& size) _IRR_OVERRIDE_;
\r
376 //! Creates a software image from part of a texture.
\r
377 virtual IImage* createImage(ITexture* texture,
\r
378 const core::position2d<s32>& pos,
\r
379 const core::dimension2d<u32>& size) _IRR_OVERRIDE_;
\r
381 //! Draws a mesh buffer
\r
382 virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) _IRR_OVERRIDE_;
\r
384 //! Draws the normals of a mesh buffer
\r
385 virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f,
\r
386 SColor color=0xffffffff) _IRR_OVERRIDE_;
\r
388 //! Check if the driver supports creating textures with the given color format
\r
389 virtual bool queryTextureFormat(ECOLOR_FORMAT format) const _IRR_OVERRIDE_
\r
395 struct SHWBufferLink
\r
397 SHWBufferLink(const scene::IMeshBuffer *_MeshBuffer)
\r
398 :MeshBuffer(_MeshBuffer),
\r
399 ChangedID_Vertex(0),ChangedID_Index(0),LastUsed(0),
\r
400 Mapped_Vertex(scene::EHM_NEVER),Mapped_Index(scene::EHM_NEVER)
\r
403 MeshBuffer->grab();
\r
406 virtual ~SHWBufferLink()
\r
409 MeshBuffer->drop();
\r
412 const scene::IMeshBuffer *MeshBuffer;
\r
413 u32 ChangedID_Vertex;
\r
414 u32 ChangedID_Index;
\r
416 scene::E_HARDWARE_MAPPING Mapped_Vertex;
\r
417 scene::E_HARDWARE_MAPPING Mapped_Index;
\r
420 //! Gets hardware buffer link from a meshbuffer (may create or update buffer)
\r
421 virtual SHWBufferLink *getBufferLink(const scene::IMeshBuffer* mb);
\r
423 //! updates hardware buffer if needed (only some drivers can)
\r
424 virtual bool updateHardwareBuffer(SHWBufferLink *HWBuffer) {return false;}
\r
426 //! Draw hardware buffer (only some drivers can)
\r
427 virtual void drawHardwareBuffer(SHWBufferLink *HWBuffer) {}
\r
429 //! Delete hardware buffer
\r
430 virtual void deleteHardwareBuffer(SHWBufferLink *HWBuffer);
\r
432 //! Create hardware buffer from mesh (only some drivers can)
\r
433 virtual SHWBufferLink *createHardwareBuffer(const scene::IMeshBuffer* mb) {return 0;}
\r
436 //! Remove hardware buffer
\r
437 virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb) _IRR_OVERRIDE_;
\r
439 //! Remove all hardware buffers
\r
440 virtual void removeAllHardwareBuffers() _IRR_OVERRIDE_;
\r
442 //! Update all hardware buffers, remove unused ones
\r
443 virtual void updateAllHardwareBuffers();
\r
445 //! is vbo recommended on this mesh?
\r
446 virtual bool isHardwareBufferRecommend(const scene::IMeshBuffer* mb);
\r
448 //! Create occlusion query.
\r
449 /** Use node for identification and mesh for occlusion test. */
\r
450 virtual void addOcclusionQuery(scene::ISceneNode* node,
\r
451 const scene::IMesh* mesh=0) _IRR_OVERRIDE_;
\r
453 //! Remove occlusion query.
\r
454 virtual void removeOcclusionQuery(scene::ISceneNode* node) _IRR_OVERRIDE_;
\r
456 //! Remove all occlusion queries.
\r
457 virtual void removeAllOcclusionQueries() _IRR_OVERRIDE_;
\r
459 //! Run occlusion query. Draws mesh stored in query.
\r
460 /** If the mesh shall not be rendered visible, use
\r
461 overrideMaterial to disable the color and depth buffer. */
\r
462 virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false) _IRR_OVERRIDE_;
\r
464 //! Run all occlusion queries. Draws all meshes stored in queries.
\r
465 /** If the meshes shall not be rendered visible, use
\r
466 overrideMaterial to disable the color and depth buffer. */
\r
467 virtual void runAllOcclusionQueries(bool visible=false) _IRR_OVERRIDE_;
\r
469 //! Update occlusion query. Retrieves results from GPU.
\r
470 /** If the query shall not block, set the flag to false.
\r
471 Update might not occur in this case, though */
\r
472 virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true) _IRR_OVERRIDE_;
\r
474 //! Update all occlusion queries. Retrieves results from GPU.
\r
475 /** If the query shall not block, set the flag to false.
\r
476 Update might not occur in this case, though */
\r
477 virtual void updateAllOcclusionQueries(bool block=true) _IRR_OVERRIDE_;
\r
479 //! Return query result.
\r
480 /** Return value is the number of visible pixels/fragments.
\r
481 The value is a safe approximation, i.e. can be larger than the
\r
482 actual value of pixels. */
\r
483 virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const _IRR_OVERRIDE_;
\r
485 //! Create render target.
\r
486 virtual IRenderTarget* addRenderTarget() _IRR_OVERRIDE_;
\r
488 //! Remove render target.
\r
489 virtual void removeRenderTarget(IRenderTarget* renderTarget) _IRR_OVERRIDE_;
\r
491 //! Remove all render targets.
\r
492 virtual void removeAllRenderTargets() _IRR_OVERRIDE_;
\r
494 //! Only used by the engine internally.
\r
495 /** Used to notify the driver that the window was resized. */
\r
496 virtual void OnResize(const core::dimension2d<u32>& size) _IRR_OVERRIDE_;
\r
498 //! Adds a new material renderer to the video device.
\r
499 virtual s32 addMaterialRenderer(IMaterialRenderer* renderer,
\r
500 const char* name = 0) _IRR_OVERRIDE_;
\r
502 //! Returns driver and operating system specific data about the IVideoDriver.
\r
503 virtual const SExposedVideoData& getExposedVideoData() _IRR_OVERRIDE_;
\r
505 //! Returns type of video driver
\r
506 virtual E_DRIVER_TYPE getDriverType() const _IRR_OVERRIDE_;
\r
508 //! Returns the transformation set by setTransform
\r
509 virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const _IRR_OVERRIDE_;
\r
511 //! Returns pointer to the IGPUProgrammingServices interface.
\r
512 virtual IGPUProgrammingServices* getGPUProgrammingServices() _IRR_OVERRIDE_;
\r
514 //! Adds a new material renderer to the VideoDriver, using pixel and/or
\r
515 //! vertex shaders to render geometry.
\r
516 virtual s32 addShaderMaterial(const c8* vertexShaderProgram = 0,
\r
517 const c8* pixelShaderProgram = 0,
\r
518 IShaderConstantSetCallBack* callback = 0,
\r
519 E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
\r
520 s32 userData=0) _IRR_OVERRIDE_;
\r
522 //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
\r
523 //! programs from files.
\r
524 virtual s32 addShaderMaterialFromFiles(io::IReadFile* vertexShaderProgram = 0,
\r
525 io::IReadFile* pixelShaderProgram = 0,
\r
526 IShaderConstantSetCallBack* callback = 0,
\r
527 E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
\r
528 s32 userData=0) _IRR_OVERRIDE_;
\r
530 //! Like IGPUProgrammingServices::addShaderMaterial(), but tries to load the
\r
531 //! programs from files.
\r
532 virtual s32 addShaderMaterialFromFiles(const io::path& vertexShaderProgramFileName,
\r
533 const io::path& pixelShaderProgramFileName,
\r
534 IShaderConstantSetCallBack* callback = 0,
\r
535 E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
\r
536 s32 userData=0) _IRR_OVERRIDE_;
\r
538 //! Returns pointer to material renderer or null
\r
539 virtual IMaterialRenderer* getMaterialRenderer(u32 idx) const _IRR_OVERRIDE_;
\r
541 //! Returns amount of currently available material renderers.
\r
542 virtual u32 getMaterialRendererCount() const _IRR_OVERRIDE_;
\r
544 //! Returns name of the material renderer
\r
545 virtual const char* getMaterialRendererName(u32 idx) const _IRR_OVERRIDE_;
\r
547 //! Adds a new material renderer to the VideoDriver, based on a high level shading
\r
548 //! language. Currently only HLSL in D3D9 is supported.
\r
549 virtual s32 addHighLevelShaderMaterial(
\r
550 const c8* vertexShaderProgram,
\r
551 const c8* vertexShaderEntryPointName = 0,
\r
552 E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
\r
553 const c8* pixelShaderProgram = 0,
\r
554 const c8* pixelShaderEntryPointName = 0,
\r
555 E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
\r
556 const c8* geometryShaderProgram = 0,
\r
557 const c8* geometryShaderEntryPointName = "main",
\r
558 E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
\r
559 scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
\r
560 scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
\r
561 u32 verticesOut = 0,
\r
562 IShaderConstantSetCallBack* callback = 0,
\r
563 E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
\r
564 s32 userData = 0) _IRR_OVERRIDE_;
\r
566 //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
\r
567 //! but tries to load the programs from files.
\r
568 virtual s32 addHighLevelShaderMaterialFromFiles(
\r
569 const io::path& vertexShaderProgramFile,
\r
570 const c8* vertexShaderEntryPointName = "main",
\r
571 E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
\r
572 const io::path& pixelShaderProgramFile = "",
\r
573 const c8* pixelShaderEntryPointName = "main",
\r
574 E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
\r
575 const io::path& geometryShaderProgramFileName="",
\r
576 const c8* geometryShaderEntryPointName = "main",
\r
577 E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
\r
578 scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
\r
579 scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
\r
580 u32 verticesOut = 0,
\r
581 IShaderConstantSetCallBack* callback = 0,
\r
582 E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
\r
583 s32 userData = 0) _IRR_OVERRIDE_;
\r
585 //! Like IGPUProgrammingServices::addShaderMaterial() (look there for a detailed description),
\r
586 //! but tries to load the programs from files.
\r
587 virtual s32 addHighLevelShaderMaterialFromFiles(
\r
588 io::IReadFile* vertexShaderProgram,
\r
589 const c8* vertexShaderEntryPointName = "main",
\r
590 E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
\r
591 io::IReadFile* pixelShaderProgram = 0,
\r
592 const c8* pixelShaderEntryPointName = "main",
\r
593 E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
\r
594 io::IReadFile* geometryShaderProgram= 0,
\r
595 const c8* geometryShaderEntryPointName = "main",
\r
596 E_GEOMETRY_SHADER_TYPE gsCompileTarget = EGST_GS_4_0,
\r
597 scene::E_PRIMITIVE_TYPE inType = scene::EPT_TRIANGLES,
\r
598 scene::E_PRIMITIVE_TYPE outType = scene::EPT_TRIANGLE_STRIP,
\r
599 u32 verticesOut = 0,
\r
600 IShaderConstantSetCallBack* callback = 0,
\r
601 E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
\r
602 s32 userData = 0) _IRR_OVERRIDE_;
\r
604 //! Returns a pointer to the mesh manipulator.
\r
605 virtual scene::IMeshManipulator* getMeshManipulator() _IRR_OVERRIDE_;
\r
607 virtual void clearBuffers(u16 flag, SColor color = SColor(255,0,0,0), f32 depth = 1.f, u8 stencil = 0) _IRR_OVERRIDE_;
\r
609 //! Returns an image created from the last rendered frame.
\r
610 virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) _IRR_OVERRIDE_;
\r
612 //! Writes the provided image to disk file
\r
613 virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) _IRR_OVERRIDE_;
\r
615 //! Writes the provided image to a file.
\r
616 virtual bool writeImageToFile(IImage* image, io::IWriteFile * file, u32 param = 0) _IRR_OVERRIDE_;
\r
618 //! Sets the name of a material renderer.
\r
619 virtual void setMaterialRendererName(s32 idx, const char* name) _IRR_OVERRIDE_;
\r
621 //! Swap the material renderers used for certain id's
\r
622 virtual void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames) _IRR_OVERRIDE_;
\r
624 //! Creates material attributes list from a material, usable for serialization and more.
\r
625 virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material,
\r
626 io::SAttributeReadWriteOptions* options=0) _IRR_OVERRIDE_;
\r
628 //! Fills an SMaterial structure from attributes.
\r
629 virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) _IRR_OVERRIDE_;
\r
631 //! looks if the image is already loaded
\r
632 virtual video::ITexture* findTexture(const io::path& filename) _IRR_OVERRIDE_;
\r
634 //! Set/unset a clipping plane.
\r
635 //! There are at least 6 clipping planes available for the user to set at will.
\r
636 //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
\r
637 //! \param plane: The plane itself.
\r
638 //! \param enable: If true, enable the clipping plane else disable it.
\r
639 virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) _IRR_OVERRIDE_;
\r
641 //! Enable/disable a clipping plane.
\r
642 //! There are at least 6 clipping planes available for the user to set at will.
\r
643 //! \param index: The plane index. Must be between 0 and MaxUserClipPlanes.
\r
644 //! \param enable: If true, enable the clipping plane else disable it.
\r
645 virtual void enableClipPlane(u32 index, bool enable) _IRR_OVERRIDE_;
\r
647 //! Returns the graphics card vendor name.
\r
648 virtual core::stringc getVendorInfo() _IRR_OVERRIDE_ {return "Not available on this driver.";}
\r
650 //! Set the minimum number of vertices for which a hw buffer will be created
\r
651 /** \param count Number of vertices to set as minimum. */
\r
652 virtual void setMinHardwareBufferVertexCount(u32 count) _IRR_OVERRIDE_;
\r
654 //! Get the global Material, which might override local materials.
\r
655 /** Depending on the enable flags, values from this Material
\r
656 are used to override those of local materials of some
\r
657 meshbuffer being rendered. */
\r
658 virtual SOverrideMaterial& getOverrideMaterial() _IRR_OVERRIDE_;
\r
660 //! Get the 2d override material for altering its values
\r
661 virtual SMaterial& getMaterial2D() _IRR_OVERRIDE_;
\r
663 //! Enable the 2d override material
\r
664 virtual void enableMaterial2D(bool enable=true) _IRR_OVERRIDE_;
\r
666 //! Only used by the engine internally.
\r
667 virtual void setAllowZWriteOnTransparent(bool flag) _IRR_OVERRIDE_
\r
668 { AllowZWriteOnTransparent=flag; }
\r
670 //! Returns the maximum texture size supported.
\r
671 virtual core::dimension2du getMaxTextureSize() const _IRR_OVERRIDE_;
\r
673 //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass
\r
674 virtual bool needsTransparentRenderPass(const irr::video::SMaterial& material) const _IRR_OVERRIDE_;
\r
676 //! Color conversion convenience function
\r
677 /** Convert an image (as array of pixels) from source to destination
\r
678 array, thereby converting the color format. The pixel size is
\r
679 determined by the color formats.
\r
680 \param sP Pointer to source
\r
681 \param sF Color format of source
\r
682 \param sN Number of pixels to convert, both array must be large enough
\r
683 \param dP Pointer to destination
\r
684 \param dF Color format of destination
\r
686 virtual void convertColor(const void* sP, ECOLOR_FORMAT sF, s32 sN,
\r
687 void* dP, ECOLOR_FORMAT dF) const _IRR_OVERRIDE_;
\r
689 //! deprecated method
\r
690 virtual ITexture* createRenderTargetTexture(const core::dimension2d<u32>& size,
\r
693 virtual bool checkDriverReset() _IRR_OVERRIDE_ {return false;}
\r
696 //! deletes all textures
\r
697 void deleteAllTextures();
\r
699 //! opens the file and loads it into the surface
\r
700 ITexture* loadTextureFromFile(io::IReadFile* file, const io::path& hashName = "");
\r
702 //! adds a surface, not loaded or created by the Irrlicht Engine
\r
703 void addTexture(ITexture* surface);
\r
705 virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image);
\r
707 virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image);
\r
709 //! checks triangle count and print warning if wrong
\r
710 bool checkPrimitiveCount(u32 prmcnt) const;
\r
712 bool checkImage(const core::array<IImage*>& image) const;
\r
714 // adds a material renderer and drops it afterwards. To be used for internal creation
\r
715 s32 addAndDropMaterialRenderer(IMaterialRenderer* m);
\r
717 //! deletes all material renderers
\r
718 void deleteMaterialRenders();
\r
720 // prints renderer version
\r
721 void printVersion();
\r
723 //! normal map lookup 32 bit version
\r
724 inline f32 nml32(int x, int y, int pitch, int height, s32 *p) const
\r
734 return (f32)(((p[(y * pitch) + x])>>16) & 0xff);
\r
737 //! normal map lookup 16 bit version
\r
738 inline f32 nml16(int x, int y, int pitch, int height, s16 *p) const
\r
749 return (f32) getAverage ( p[(y * pitch) + x] );
\r
752 inline bool getWriteZBuffer(const SMaterial& material) const
\r
754 switch ( material.ZWriteEnable )
\r
756 case video::EZW_OFF:
\r
758 case video::EZW_AUTO:
\r
759 return AllowZWriteOnTransparent || ! needsTransparentRenderPass(material);
\r
760 case video::EZW_ON:
\r
763 return true; // never should get here, but some compilers don't know and complain
\r
768 video::ITexture* Surface;
\r
770 bool operator < (const SSurface& other) const
\r
772 return Surface->getName() < other.Surface->getName();
\r
776 struct SMaterialRenderer
\r
778 core::stringc Name;
\r
779 IMaterialRenderer* Renderer;
\r
782 struct SDummyTexture : public ITexture
\r
784 SDummyTexture(const io::path& name, E_TEXTURE_TYPE type) : ITexture(name, type) {};
\r
786 void setSize(const core::dimension2d<u32>& size) { Size = OriginalSize = size; }
\r
788 virtual 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) _IRR_OVERRIDE_ { return 0; }
\r
789 virtual void unlock()_IRR_OVERRIDE_ {}
\r
790 virtual void regenerateMipMapLevels(void* data = 0, u32 layer = 0) _IRR_OVERRIDE_ {}
\r
792 core::array<SSurface> Textures;
\r
796 SOccQuery(scene::ISceneNode* node, const scene::IMesh* mesh=0) : Node(node), Mesh(mesh), PID(0), Result(0xffffffff), Run(0xffffffff)
\r
804 SOccQuery(const SOccQuery& other) : Node(other.Node), Mesh(other.Mesh), PID(other.PID), Result(other.Result), Run(other.Run)
\r
820 SOccQuery& operator=(const SOccQuery& other)
\r
825 Result=other.Result;
\r
834 bool operator==(const SOccQuery& other) const
\r
836 return other.Node==Node;
\r
839 scene::ISceneNode* Node;
\r
840 const scene::IMesh* Mesh;
\r
849 core::array<SOccQuery> OcclusionQueries;
\r
851 core::array<IRenderTarget*> RenderTargets;
\r
853 // Shared objects used with simplified IVideoDriver::setRenderTarget method with ITexture* param.
\r
854 IRenderTarget* SharedRenderTarget;
\r
855 core::array<ITexture*> SharedDepthTextures;
\r
857 IRenderTarget* CurrentRenderTarget;
\r
858 core::dimension2d<u32> CurrentRenderTargetSize;
\r
860 core::array<video::IImageLoader*> SurfaceLoader;
\r
861 core::array<video::IImageWriter*> SurfaceWriter;
\r
862 core::array<SLight> Lights;
\r
863 core::array<SMaterialRenderer> MaterialRenderers;
\r
865 //core::array<SHWBufferLink*> HWBufferLinks;
\r
866 core::map< const scene::IMeshBuffer* , SHWBufferLink* > HWBufferMap;
\r
868 io::IFileSystem* FileSystem;
\r
870 //! mesh manipulator
\r
871 scene::IMeshManipulator* MeshManipulator;
\r
873 core::rect<s32> ViewPort;
\r
874 core::dimension2d<u32> ScreenSize;
\r
875 core::matrix4 TransformationMatrix;
\r
877 CFPSCounter FPSCounter;
\r
879 u32 PrimitivesDrawn;
\r
880 u32 MinVertexCountForVBO;
\r
882 u32 TextureCreationFlags;
\r
888 SExposedVideoData ExposedData;
\r
890 io::IAttributes* DriverAttributes;
\r
892 SOverrideMaterial OverrideMaterial;
\r
893 SMaterial OverrideMaterial2D;
\r
894 SMaterial InitMaterial2D;
\r
895 bool OverrideMaterial2DEnabled;
\r
897 E_FOG_TYPE FogType;
\r
900 bool AllowZWriteOnTransparent;
\r
902 bool FeatureEnabled[video::EVDF_COUNT];
\r
904 SColorf AmbientLight;
\r
907 } // end namespace video
\r
908 } // end namespace irr
\r