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