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
47 class IMaterialRenderer;
\r
48 class IGPUProgrammingServices;
\r
49 class IRenderTarget;
\r
51 //! enumeration for geometry transformation states
\r
52 enum E_TRANSFORMATION_STATE
\r
54 //! View transformation
\r
56 //! World transformation
\r
58 //! Projection transformation
\r
60 //! Texture transformation
\r
62 //! Texture transformation
\r
64 //! Texture transformation
\r
66 //! Texture transformation
\r
68 #if _IRR_MATERIAL_MAX_TEXTURES_>4
\r
69 //! Texture transformation
\r
71 #if _IRR_MATERIAL_MAX_TEXTURES_>5
\r
72 //! Texture transformation
\r
74 #if _IRR_MATERIAL_MAX_TEXTURES_>6
\r
75 //! Texture transformation
\r
77 #if _IRR_MATERIAL_MAX_TEXTURES_>7
\r
78 //! Texture transformation
\r
84 //! Only used internally
\r
85 ETS_COUNT = ETS_TEXTURE_0 + _IRR_MATERIAL_MAX_TEXTURES_
\r
88 //! Special render targets, which usually map to dedicated hardware
\r
89 /** These render targets (besides 0 and 1) need not be supported by gfx cards */
\r
90 enum E_RENDER_TARGET
\r
92 //! Render target is the main color frame buffer
\r
94 //! Render target is a render texture
\r
96 //! Multi-Render target textures
\r
97 ERT_MULTI_RENDER_TEXTURES,
\r
98 //! Render target is the main color frame buffer
\r
99 ERT_STEREO_LEFT_BUFFER,
\r
100 //! Render target is the right color buffer (left is the main buffer)
\r
101 ERT_STEREO_RIGHT_BUFFER,
\r
102 //! Render to both stereo buffers at once
\r
103 ERT_STEREO_BOTH_BUFFERS,
\r
104 //! Auxiliary buffer 0
\r
106 //! Auxiliary buffer 1
\r
108 //! Auxiliary buffer 2
\r
110 //! Auxiliary buffer 3
\r
112 //! Auxiliary buffer 4
\r
116 //! Enum for the flags of clear buffer
\r
117 enum E_CLEAR_BUFFER_FLAG
\r
123 ECBF_ALL = ECBF_COLOR|ECBF_DEPTH|ECBF_STENCIL
\r
126 //! Enum for the types of fog distributions to choose from
\r
134 const c8* const FogTypeNames[] =
\r
142 //! Interface to driver which is able to perform 2d and 3d graphics functions.
\r
143 /** This interface is one of the most important interfaces of
\r
144 the Irrlicht Engine: All rendering and texture manipulation is done with
\r
145 this interface. You are able to use the Irrlicht Engine by only
\r
146 invoking methods of this interface if you like to, although the
\r
147 irr::scene::ISceneManager interface provides a lot of powerful classes
\r
148 and methods to make the programmer's life easier.
\r
150 class IVideoDriver : public virtual IReferenceCounted
\r
154 //! Applications must call this method before performing any rendering.
\r
155 /** This method can clear the back- and the z-buffer.
\r
156 \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags.
\r
157 \param clearColor The clear color for the color buffer.
\r
158 \param clearDepth The clear value for the depth buffer.
\r
159 \param clearStencil The clear value for the stencil buffer.
\r
160 \param videoData Handle of another window, if you want the
\r
161 bitmap to be displayed on another window. If this is an empty
\r
162 element, everything will be displayed in the default window.
\r
163 Note: This feature is not fully implemented for all devices.
\r
164 \param sourceRect Pointer to a rectangle defining the source
\r
165 rectangle of the area to be presented. Set to null to present
\r
166 everything. Note: not implemented in all devices.
\r
167 \return False if failed. */
\r
168 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
169 const SExposedVideoData& videoData=SExposedVideoData(), core::rect<s32>* sourceRect = 0) = 0;
\r
171 //! Alternative beginScene implementation. Can't clear stencil buffer, but otherwise identical to other beginScene
\r
172 bool beginScene(bool backBuffer, bool zBuffer, SColor color = SColor(255,0,0,0),
\r
173 const SExposedVideoData& videoData = SExposedVideoData(), core::rect<s32>* sourceRect = 0)
\r
178 flag |= ECBF_COLOR;
\r
181 flag |= ECBF_DEPTH;
\r
183 return beginScene(flag, color, 1.f, 0, videoData, sourceRect);
\r
186 //! Presents the rendered image to the screen.
\r
187 /** Applications must call this method after performing any
\r
189 \return False if failed and true if succeeded. */
\r
190 virtual bool endScene() = 0;
\r
192 //! Queries the features of the driver.
\r
193 /** Returns true if a feature is available
\r
194 \param feature Feature to query.
\r
195 \return True if the feature is available, false if not. */
\r
196 virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const =0;
\r
198 //! Disable a feature of the driver.
\r
199 /** Can also be used to enable the features again. It is not
\r
200 possible to enable unsupported features this way, though.
\r
201 \param feature Feature to disable.
\r
202 \param flag When true the feature is disabled, otherwise it is enabled. */
\r
203 virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
\r
205 //! Get attributes of the actual video driver
\r
206 /** The following names can be queried for the given types:
\r
207 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
208 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
209 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
210 MaxAnisotropy (int) Number of anisotropy levels supported for filtering. At least 1, max is typically at 16 or 32.
\r
211 MaxUserClipPlanes (int) Number of additional clip planes, which can be set by the user via dedicated driver methods.
\r
212 MaxAuxBuffers (int) Special render buffers, which are currently not really usable inside Irrlicht. Only supported by OpenGL
\r
213 MaxMultipleRenderTargets (int) Number of render targets which can be bound simultaneously. Rendering to MRTs is done via shaders.
\r
214 MaxIndices (int) Number of indices which can be used in one render call (i.e. one mesh buffer).
\r
215 MaxTextureSize (int) Dimension that a texture may have, both in width and height.
\r
216 MaxGeometryVerticesOut (int) Number of vertices the geometry shader can output in one pass. Only OpenGL so far.
\r
217 MaxTextureLODBias (float) Maximum value for LOD bias. Is usually at around 16, but can be lower on some systems.
\r
218 Version (int) Version of the driver. Should be Major*100+Minor
\r
219 ShaderLanguageVersion (int) Version of the high level shader language. Should be Major*100+Minor.
\r
220 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
222 virtual const io::IAttributes& getDriverAttributes() const=0;
\r
224 //! Check if the driver was recently reset.
\r
225 /** For d3d devices you will need to recreate the RTTs if the
\r
226 driver was reset. Should be queried right after beginScene().
\r
228 virtual bool checkDriverReset() =0;
\r
230 //! Sets transformation matrices.
\r
231 /** \param state Transformation type to be set, e.g. view,
\r
232 world, or projection.
\r
233 \param mat Matrix describing the transformation. */
\r
234 virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) =0;
\r
236 //! Returns the transformation set by setTransform
\r
237 /** \param state Transformation type to query
\r
238 \return Matrix describing the transformation. */
\r
239 virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const =0;
\r
241 //! Retrieve the number of image loaders
\r
242 /** \return Number of image loaders */
\r
243 virtual u32 getImageLoaderCount() const = 0;
\r
245 //! Retrieve the given image loader
\r
246 /** \param n The index of the loader to retrieve. This parameter is an 0-based
\r
248 \return A pointer to the specified loader, 0 if the index is incorrect. */
\r
249 virtual IImageLoader* getImageLoader(u32 n) = 0;
\r
251 //! Retrieve the number of image writers
\r
252 /** \return Number of image writers */
\r
253 virtual u32 getImageWriterCount() const = 0;
\r
255 //! Retrieve the given image writer
\r
256 /** \param n The index of the writer to retrieve. This parameter is an 0-based
\r
258 \return A pointer to the specified writer, 0 if the index is incorrect. */
\r
259 virtual IImageWriter* getImageWriter(u32 n) = 0;
\r
261 //! Sets a material.
\r
262 /** All 3d drawing functions will draw geometry using this material thereafter.
\r
263 \param material: Material to be used from now on. */
\r
264 virtual void setMaterial(const SMaterial& material) =0;
\r
266 //! Get access to a named texture.
\r
267 /** Loads the texture from disk if it is not
\r
268 already loaded and generates mipmap levels if desired.
\r
269 Texture loading can be influenced using the
\r
270 setTextureCreationFlag() method. The texture can be in several
\r
271 imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD.
\r
272 \param filename Filename of the texture to be loaded.
\r
273 \return Pointer to the texture, or 0 if the texture
\r
274 could not be loaded. This pointer should not be dropped. See
\r
275 IReferenceCounted::drop() for more information. */
\r
276 virtual ITexture* getTexture(const io::path& filename) = 0;
\r
278 //! Get access to a named texture.
\r
279 /** Loads the texture from disk if it is not
\r
280 already loaded and generates mipmap levels if desired.
\r
281 Texture loading can be influenced using the
\r
282 setTextureCreationFlag() method. The texture can be in several
\r
283 imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD.
\r
284 \param file Pointer to an already opened file.
\r
285 \return Pointer to the texture, or 0 if the texture
\r
286 could not be loaded. This pointer should not be dropped. See
\r
287 IReferenceCounted::drop() for more information. */
\r
288 virtual ITexture* getTexture(io::IReadFile* file) =0;
\r
290 //! Returns a texture by index
\r
291 /** \param index: Index of the texture, must be smaller than
\r
292 getTextureCount() Please note that this index might change when
\r
293 adding or removing textures
\r
294 \return Pointer to the texture, or 0 if the texture was not
\r
295 set or index is out of bounds. This pointer should not be
\r
296 dropped. See IReferenceCounted::drop() for more information. */
\r
297 virtual ITexture* getTextureByIndex(u32 index) =0;
\r
299 //! Returns amount of textures currently loaded
\r
300 /** \return Amount of textures currently loaded */
\r
301 virtual u32 getTextureCount() const = 0;
\r
303 //! Renames a texture
\r
304 /** \param texture Pointer to the texture to rename.
\r
305 \param newName New name for the texture. This should be a unique name. */
\r
306 virtual void renameTexture(ITexture* texture, const io::path& newName) = 0;
\r
308 //! Creates an empty texture of specified size.
\r
309 /** \param size: Size of the texture.
\r
310 \param name A name for the texture. Later calls to
\r
311 getTexture() with this name will return this texture.
\r
312 The name can _not_ be empty.
\r
313 \param format Desired color format of the texture. Please note
\r
314 that the driver may choose to create the texture in another
\r
316 \return Pointer to the newly created texture. This pointer
\r
317 should not be dropped. See IReferenceCounted::drop() for more
\r
319 virtual ITexture* addTexture(const core::dimension2d<u32>& size,
\r
320 const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
\r
322 //! Creates a texture from an IImage.
\r
323 /** \param name A name for the texture. Later calls of
\r
324 getTexture() with this name will return this texture.
\r
325 The name can _not_ be empty.
\r
326 \param image Image the texture is created from.
\r
327 \param mipmapData Optional pointer to a mipmaps data.
\r
328 If this parameter is not given, the mipmaps are derived from image.
\r
329 \return Pointer to the newly created texture. This pointer
\r
330 should not be dropped. See IReferenceCounted::drop() for more
\r
332 _IRR_DEPRECATED_ ITexture* addTexture(const io::path& name, IImage* image, void* mipmapData)
\r
335 image->setMipMapsData(mipmapData, false, true);
\r
337 return addTexture(name, image);
\r
340 //! Creates a texture from an IImage.
\r
341 /** \param name A name for the texture. Later calls of
\r
342 getTexture() with this name will return this texture.
\r
343 The name can _not_ be empty.
\r
344 \param image Image the texture is created from.
\r
345 \return Pointer to the newly created texture. This pointer
\r
346 should not be dropped. See IReferenceCounted::drop() for more
\r
348 virtual ITexture* addTexture(const io::path& name, IImage* image) = 0;
\r
350 //! Creates a cubemap texture from loaded IImages.
\r
351 /** \param name A name for the texture. Later calls of getTexture() with this name will return this texture.
\r
352 The name can _not_ be empty.
\r
353 \param imagePosX Image (positive X) the texture is created from.
\r
354 \param imageNegX Image (negative X) the texture is created from.
\r
355 \param imagePosY Image (positive Y) the texture is created from.
\r
356 \param imageNegY Image (negative Y) the texture is created from.
\r
357 \param imagePosZ Image (positive Z) the texture is created from.
\r
358 \param imageNegZ Image (negative Z) the texture is created from.
\r
359 \return Pointer to the newly created texture. This pointer should not be dropped. See IReferenceCounted::drop() for more information. */
\r
360 virtual ITexture* addTextureCubemap(const io::path& name, IImage* imagePosX, IImage* imageNegX, IImage* imagePosY,
\r
361 IImage* imageNegY, IImage* imagePosZ, IImage* imageNegZ) = 0;
\r
363 //! Creates an empty cubemap texture of specified size.
\r
364 /** \param sideLen diameter of one side of the cube
\r
365 \param name A name for the texture. Later calls of
\r
366 getTexture() with this name will return this texture.
\r
367 The name can _not_ be empty.
\r
368 \param format Desired color format of the texture. Please note
\r
369 that the driver may choose to create the texture in another
\r
371 \return Pointer to the newly created texture. */
\r
372 virtual ITexture* addTextureCubemap(const irr::u32 sideLen, const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
\r
374 //! Adds a new render target texture to the texture cache.
\r
375 /** \param size Size of the texture, in pixels. Width and
\r
376 height should be a power of two (e.g. 64, 128, 256, 512, ...)
\r
377 and it should not be bigger than the backbuffer, because it
\r
378 shares the zbuffer with the screen buffer.
\r
379 \param name A name for the texture. Later calls of getTexture() with this name will return this texture.
\r
380 The name can _not_ be empty.
\r
381 \param format The color format of the render target. Floating point formats are supported.
\r
382 \return Pointer to the created texture or 0 if the texture
\r
383 could not be created. This pointer should not be dropped. See
\r
384 IReferenceCounted::drop() for more information.
\r
385 You may want to remove it from driver texture cache with removeTexture if you no longer need it.
\r
387 virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
\r
388 const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
\r
390 //! Adds a new render target texture with 6 sides for a cubemap map to the texture cache.
\r
391 /** NOTE: Only supported on D3D9 so far.
\r
392 \param sideLen Length of one cubemap side.
\r
393 \param name A name for the texture. Later calls of getTexture() with this name will return this texture.
\r
394 The name can _not_ be empty.
\r
395 \param format The color format of the render target. Floating point formats are supported.
\r
396 \return Pointer to the created texture or 0 if the texture
\r
397 could not be created. This pointer should not be dropped. See
\r
398 IReferenceCounted::drop() for more information. */
\r
399 virtual ITexture* addRenderTargetTextureCubemap(const irr::u32 sideLen,
\r
400 const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
\r
402 //! Removes a texture from the texture cache and deletes it.
\r
403 /** This method can free a lot of memory!
\r
404 Please note that after calling this, the pointer to the
\r
405 ITexture may no longer be valid, if it was not grabbed before
\r
406 by other parts of the engine for storing it longer. So it is a
\r
407 good idea to set all materials which are using this texture to
\r
408 0 or another texture first.
\r
409 \param texture Texture to delete from the engine cache. */
\r
410 virtual void removeTexture(ITexture* texture) =0;
\r
412 //! Removes all textures from the texture cache and deletes them.
\r
413 /** This method can free a lot of memory!
\r
414 Please note that after calling this, the pointer to the
\r
415 ITexture may no longer be valid, if it was not grabbed before
\r
416 by other parts of the engine for storing it longer. So it is a
\r
417 good idea to set all materials which are using this texture to
\r
418 0 or another texture first. */
\r
419 virtual void removeAllTextures() =0;
\r
421 //! Remove hardware buffer
\r
422 virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb) =0;
\r
424 //! Remove all hardware buffers
\r
425 virtual void removeAllHardwareBuffers() =0;
\r
427 //! Create occlusion query.
\r
428 /** Use node for identification and mesh for occlusion test. */
\r
429 virtual void addOcclusionQuery(scene::ISceneNode* node,
\r
430 const scene::IMesh* mesh=0) =0;
\r
432 //! Remove occlusion query.
\r
433 virtual void removeOcclusionQuery(scene::ISceneNode* node) =0;
\r
435 //! Remove all occlusion queries.
\r
436 virtual void removeAllOcclusionQueries() =0;
\r
438 //! Run occlusion query. Draws mesh stored in query.
\r
439 /** If the mesh shall not be rendered visible, use
\r
440 overrideMaterial to disable the color and depth buffer. */
\r
441 virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false) =0;
\r
443 //! Run all occlusion queries. Draws all meshes stored in queries.
\r
444 /** If the meshes shall not be rendered visible, use
\r
445 overrideMaterial to disable the color and depth buffer. */
\r
446 virtual void runAllOcclusionQueries(bool visible=false) =0;
\r
448 //! Update occlusion query. Retrieves results from GPU.
\r
449 /** If the query shall not block, set the flag to false.
\r
450 Update might not occur in this case, though */
\r
451 virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true) =0;
\r
453 //! Update all occlusion queries. Retrieves results from GPU.
\r
454 /** If the query shall not block, set the flag to false.
\r
455 Update might not occur in this case, though */
\r
456 virtual void updateAllOcclusionQueries(bool block=true) =0;
\r
458 //! Return query result.
\r
459 /** Return value is the number of visible pixels/fragments.
\r
460 The value is a safe approximation, i.e. can be larger than the
\r
461 actual value of pixels. */
\r
462 virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const =0;
\r
464 //! Create render target.
\r
465 virtual IRenderTarget* addRenderTarget() = 0;
\r
467 //! Remove render target.
\r
468 virtual void removeRenderTarget(IRenderTarget* renderTarget) = 0;
\r
470 //! Remove all render targets.
\r
471 virtual void removeAllRenderTargets() = 0;
\r
473 //! Sets a boolean alpha channel on the texture based on a color key.
\r
474 /** This makes the texture fully transparent at the texels where
\r
475 this color key can be found when using for example draw2DImage
\r
476 with useAlphachannel==true. The alpha of other texels is not modified.
\r
477 \param texture Texture whose alpha channel is modified.
\r
478 \param color Color key color. Every texel with this color will
\r
479 become fully transparent as described above. Please note that the
\r
480 colors of a texture may be converted when loading it, so the
\r
481 color values may not be exactly the same in the engine and for
\r
482 example in picture edit programs. To avoid this problem, you
\r
483 could use the makeColorKeyTexture method, which takes the
\r
484 position of a pixel instead a color value.
\r
485 \param zeroTexels (deprecated) If set to true, then any texels that match
\r
486 the color key will have their color, as well as their alpha, set to zero
\r
487 (i.e. black). This behavior matches the legacy (buggy) behavior prior
\r
488 to release 1.5 and is provided for backwards compatibility only.
\r
489 This parameter may be removed by Irrlicht 1.9. */
\r
490 virtual void makeColorKeyTexture(video::ITexture* texture,
\r
491 video::SColor color,
\r
492 bool zeroTexels = false) const =0;
\r
494 //! Sets a boolean alpha channel on the texture based on the color at a position.
\r
495 /** This makes the texture fully transparent at the texels where
\r
496 the color key can be found when using for example draw2DImage
\r
497 with useAlphachannel==true. The alpha of other texels is not modified.
\r
498 \param texture Texture whose alpha channel is modified.
\r
499 \param colorKeyPixelPos Position of a pixel with the color key
\r
500 color. Every texel with this color will become fully transparent as
\r
502 \param zeroTexels (deprecated) If set to true, then any texels that match
\r
503 the color key will have their color, as well as their alpha, set to zero
\r
504 (i.e. black). This behavior matches the legacy (buggy) behavior prior
\r
505 to release 1.5 and is provided for backwards compatibility only.
\r
506 This parameter may be removed by Irrlicht 1.9. */
\r
507 virtual void makeColorKeyTexture(video::ITexture* texture,
\r
508 core::position2d<s32> colorKeyPixelPos,
\r
509 bool zeroTexels = false) const =0;
\r
511 //! Set a render target.
\r
512 /** This will only work if the driver supports the
\r
513 EVDF_RENDER_TO_TARGET feature, which can be queried with
\r
514 queryFeature(). Please note that you cannot render 3D or 2D
\r
515 geometry with a render target as texture on it when you are rendering
\r
516 the scene into this render target at the same time. It is usually only
\r
517 possible to render into a texture between the
\r
518 IVideoDriver::beginScene() and endScene() method calls. If you need the
\r
519 best performance use this method instead of setRenderTarget.
\r
520 \param target Render target object. If set to nullptr, it makes the
\r
521 window the current render target.
\r
522 \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags.
\r
523 \param clearColor The clear color for the color buffer.
\r
524 \param clearDepth The clear value for the depth buffer.
\r
525 \param clearStencil The clear value for the stencil buffer.
\r
526 \return True if successful and false if not. */
\r
527 virtual bool setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SColor clearColor = SColor(255,0,0,0),
\r
528 f32 clearDepth = 1.f, u8 clearStencil = 0) = 0;
\r
530 //! Sets a new render target.
\r
531 /** This will only work if the driver supports the
\r
532 EVDF_RENDER_TO_TARGET feature, which can be queried with
\r
533 queryFeature(). Usually, rendering to textures is done in this
\r
536 // create render target
\r
537 ITexture* target = driver->addRenderTargetTexture(core::dimension2d<u32>(128,128), "rtt1");
\r
541 driver->setRenderTarget(target); // set render target
\r
542 // .. draw stuff here
\r
543 driver->setRenderTarget(0); // set previous render target
\r
545 Please note that you cannot render 3D or 2D geometry with a
\r
546 render target as texture on it when you are rendering the scene
\r
547 into this render target at the same time. It is usually only
\r
548 possible to render into a texture between the
\r
549 IVideoDriver::beginScene() and endScene() method calls.
\r
550 \param texture New render target. Must be a texture created with
\r
551 IVideoDriver::addRenderTargetTexture(). If set to nullptr, it makes
\r
552 the window the current render target.
\r
553 \param clearFlag A combination of the E_CLEAR_BUFFER_FLAG bit-flags.
\r
554 \param clearColor The clear color for the color buffer.
\r
555 \param clearDepth The clear value for the depth buffer.
\r
556 \param clearStencil The clear value for the stencil buffer.
\r
557 \return True if successful and false if not. */
\r
558 virtual bool setRenderTarget(ITexture* texture, u16 clearFlag=ECBF_COLOR|ECBF_DEPTH, SColor clearColor = SColor(255,0,0,0),
\r
559 f32 clearDepth = 1.f, u8 clearStencil = 0) = 0;
\r
561 //! Sets a new render target.
\r
562 //! Prefer to use the setRenderTarget function taking flags as parameter as this one can't clear the stencil buffer.
\r
563 //! It's still offered for backward compatibility.
\r
564 bool setRenderTarget(ITexture* texture, bool clearBackBuffer, bool clearZBuffer, SColor color = SColor(255,0,0,0))
\r
568 if (clearBackBuffer)
\r
569 flag |= ECBF_COLOR;
\r
572 flag |= ECBF_DEPTH;
\r
574 return setRenderTarget(texture, flag, color);
\r
577 //! Sets a new viewport.
\r
578 /** Every rendering operation is done into this new area.
\r
579 \param area: Rectangle defining the new area of rendering
\r
581 virtual void setViewPort(const core::rect<s32>& area) =0;
\r
583 //! Gets the area of the current viewport.
\r
584 /** \return Rectangle of the current viewport. */
\r
585 virtual const core::rect<s32>& getViewPort() const =0;
\r
587 //! Draws a vertex primitive list
\r
588 /** Note that, depending on the index type, some vertices might be not
\r
589 accessible through the index list. The limit is at 65535 vertices for 16bit
\r
590 indices. Please note that currently not all primitives are available for
\r
591 all drivers, and some might be emulated via triangle renders.
\r
592 \param vertices Pointer to array of vertices.
\r
593 \param vertexCount Amount of vertices in the array.
\r
594 \param indexList Pointer to array of indices. These define the vertices used
\r
595 for each primitive. Depending on the pType, indices are interpreted as single
\r
596 objects (for point like primitives), pairs (for lines), triplets (for
\r
597 triangles), or quads.
\r
598 \param primCount Amount of Primitives
\r
599 \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
\r
600 \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
\r
601 \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
\r
602 virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
\r
603 const void* indexList, u32 primCount,
\r
604 E_VERTEX_TYPE vType=EVT_STANDARD,
\r
605 scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
\r
606 E_INDEX_TYPE iType=EIT_16BIT) =0;
\r
608 //! Draws a vertex primitive list in 2d
\r
609 /** Compared to the general (3d) version of this method, this
\r
610 one sets up a 2d render mode, and uses only x and y of vectors.
\r
611 Note that, depending on the index type, some vertices might be
\r
612 not accessible through the index list. The limit is at 65535
\r
613 vertices for 16bit indices. Please note that currently not all
\r
614 primitives are available for all drivers, and some might be
\r
615 emulated via triangle renders. This function is not available
\r
616 for the sw drivers.
\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. These define the
\r
620 vertices used for each primitive. Depending on the pType,
\r
621 indices are interpreted as single objects (for point like
\r
622 primitives), pairs (for lines), triplets (for triangles), or
\r
624 \param primCount Amount of Primitives
\r
625 \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
\r
626 \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
\r
627 \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
\r
628 virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
\r
629 const void* indexList, u32 primCount,
\r
630 E_VERTEX_TYPE vType=EVT_STANDARD,
\r
631 scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
\r
632 E_INDEX_TYPE iType=EIT_16BIT) =0;
\r
634 //! Draws an indexed triangle list.
\r
635 /** Note that there may be at maximum 65536 vertices, because
\r
636 the index list is an array of 16 bit values each with a maximum
\r
637 value of 65536. If there are more than 65536 vertices in the
\r
638 list, results of this operation are not defined.
\r
639 \param vertices Pointer to array of vertices.
\r
640 \param vertexCount Amount of vertices in the array.
\r
641 \param indexList Pointer to array of indices.
\r
642 \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
\r
643 void drawIndexedTriangleList(const S3DVertex* vertices,
\r
644 u32 vertexCount, const u16* indexList, u32 triangleCount)
\r
646 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT);
\r
649 //! Draws an indexed triangle list.
\r
650 /** Note that there may be at maximum 65536 vertices, because
\r
651 the index list is an array of 16 bit values each with a maximum
\r
652 value of 65536. If there are more than 65536 vertices in the
\r
653 list, results of this operation are not defined.
\r
654 \param vertices Pointer to array of vertices.
\r
655 \param vertexCount Amount of vertices in the array.
\r
656 \param indexList Pointer to array of indices.
\r
657 \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
\r
658 void drawIndexedTriangleList(const S3DVertex2TCoords* vertices,
\r
659 u32 vertexCount, const u16* indexList, u32 triangleCount)
\r
661 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT);
\r
664 //! Draws an indexed triangle list.
\r
665 /** Note that there may be at maximum 65536 vertices, because
\r
666 the index list is an array of 16 bit values each with a maximum
\r
667 value of 65536. If there are more than 65536 vertices in the
\r
668 list, results of this operation are not defined.
\r
669 \param vertices Pointer to array of vertices.
\r
670 \param vertexCount Amount of vertices in the array.
\r
671 \param indexList Pointer to array of indices.
\r
672 \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
\r
673 void drawIndexedTriangleList(const S3DVertexTangents* vertices,
\r
674 u32 vertexCount, const u16* indexList, u32 triangleCount)
\r
676 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT);
\r
679 //! Draws an indexed triangle fan.
\r
680 /** Note that there may be at maximum 65536 vertices, because
\r
681 the index list is an array of 16 bit values each with a maximum
\r
682 value of 65536. If there are more than 65536 vertices in the
\r
683 list, results of this operation are not defined.
\r
684 \param vertices Pointer to array of vertices.
\r
685 \param vertexCount Amount of vertices in the array.
\r
686 \param indexList Pointer to array of indices.
\r
687 \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
\r
688 void drawIndexedTriangleFan(const S3DVertex* vertices,
\r
689 u32 vertexCount, const u16* indexList, u32 triangleCount)
\r
691 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
\r
694 //! Draws an indexed triangle fan.
\r
695 /** Note that there may be at maximum 65536 vertices, because
\r
696 the index list is an array of 16 bit values each with a maximum
\r
697 value of 65536. If there are more than 65536 vertices in the
\r
698 list, results of this operation are not defined.
\r
699 \param vertices Pointer to array of vertices.
\r
700 \param vertexCount Amount of vertices in the array.
\r
701 \param indexList Pointer to array of indices.
\r
702 \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
\r
703 void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
\r
704 u32 vertexCount, const u16* indexList, u32 triangleCount)
\r
706 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
\r
709 //! Draws an indexed triangle fan.
\r
710 /** Note that there may be at maximum 65536 vertices, because
\r
711 the index list is an array of 16 bit values each with a maximum
\r
712 value of 65536. If there are more than 65536 vertices in the
\r
713 list, results of this operation are not defined.
\r
714 \param vertices Pointer to array of vertices.
\r
715 \param vertexCount Amount of vertices in the array.
\r
716 \param indexList Pointer to array of indices.
\r
717 \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
\r
718 void drawIndexedTriangleFan(const S3DVertexTangents* vertices,
\r
719 u32 vertexCount, const u16* indexList, u32 triangleCount)
\r
721 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
\r
724 //! Draws a 3d line.
\r
725 /** For some implementations, this method simply calls
\r
726 drawVertexPrimitiveList for some triangles.
\r
727 Note that the line is drawn using the current transformation
\r
728 matrix and material. So if you need to draw the 3D line
\r
729 independently of the current transformation, use
\r
731 driver->setMaterial(someMaterial);
\r
732 driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
\r
734 for some properly set up material before drawing the line.
\r
735 Some drivers support line thickness set in the material.
\r
736 \param start Start of the 3d line.
\r
737 \param end End of the 3d line.
\r
738 \param color Color of the line. */
\r
739 virtual void draw3DLine(const core::vector3df& start,
\r
740 const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0;
\r
742 //! Draws a 3d triangle.
\r
743 /** This method calls drawVertexPrimitiveList for some triangles.
\r
744 This method works with all drivers because it simply calls
\r
745 drawVertexPrimitiveList, but it is hence not very fast.
\r
746 Note that the triangle is drawn using the current
\r
747 transformation matrix and material. So if you need to draw it
\r
748 independently of the current transformation, use
\r
750 driver->setMaterial(someMaterial);
\r
751 driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
\r
753 for some properly set up material before drawing the triangle.
\r
754 \param triangle The triangle to draw.
\r
755 \param color Color of the line. */
\r
756 virtual void draw3DTriangle(const core::triangle3df& triangle,
\r
757 SColor color = SColor(255,255,255,255)) =0;
\r
759 //! Draws a 3d axis aligned box.
\r
760 /** This method simply calls draw3DLine for the edges of the
\r
761 box. Note that the box is drawn using the current transformation
\r
762 matrix and material. So if you need to draw it independently of
\r
763 the current transformation, use
\r
765 driver->setMaterial(someMaterial);
\r
766 driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
\r
768 for some properly set up material before drawing the box.
\r
769 \param box The axis aligned box to draw
\r
770 \param color Color to use while drawing the box. */
\r
771 virtual void draw3DBox(const core::aabbox3d<f32>& box,
\r
772 SColor color = SColor(255,255,255,255)) =0;
\r
774 //! Draws a 2d image without any special effects
\r
775 /** \param texture Pointer to texture to use.
\r
776 \param destPos Upper left 2d destination position where the
\r
777 image will be drawn.
\r
778 \param useAlphaChannelOfTexture: If true, the alpha channel of
\r
779 the texture is used to draw the image.*/
\r
780 virtual void draw2DImage(const video::ITexture* texture,
\r
781 const core::position2d<s32>& destPos, bool useAlphaChannelOfTexture=false) =0;
\r
783 //! Draws a 2d image using a color
\r
784 /** (if color is other than
\r
785 Color(255,255,255,255)) and the alpha channel of the texture.
\r
786 \param texture Texture to be drawn.
\r
787 \param destPos Upper left 2d destination position where the
\r
788 image will be drawn.
\r
789 \param sourceRect Source rectangle in the image.
\r
790 \param clipRect Pointer to rectangle on the screen where the
\r
791 image is clipped to.
\r
792 If this pointer is NULL the image is not clipped.
\r
793 \param color Color with which the image is drawn. If the color
\r
794 equals Color(255,255,255,255) it is ignored. Note that the
\r
795 alpha component is used: If alpha is other than 255, the image
\r
796 will be transparent.
\r
797 \param useAlphaChannelOfTexture: If true, the alpha channel of
\r
798 the texture is used to draw the image.*/
\r
799 virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
\r
800 const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
\r
801 SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0;
\r
803 //! Draws a set of 2d images, using a color and the alpha channel of the texture.
\r
804 /** The images are drawn beginning at pos and concatenated in
\r
805 one line. All drawings are clipped against clipRect (if != 0).
\r
806 The subtextures are defined by the array of sourceRects and are
\r
807 chosen by the indices given.
\r
808 \param texture Texture to be drawn.
\r
809 \param pos Upper left 2d destination position where the image
\r
811 \param sourceRects Source rectangles of the image.
\r
812 \param indices List of indices which choose the actual
\r
813 rectangle used each time.
\r
814 \param kerningWidth Offset to Position on X
\r
815 \param clipRect Pointer to rectangle on the screen where the
\r
816 image is clipped to.
\r
817 If this pointer is 0 then the image is not clipped.
\r
818 \param color Color with which the image is drawn.
\r
819 Note that the alpha component is used. If alpha is other than
\r
820 255, the image will be transparent.
\r
821 \param useAlphaChannelOfTexture: If true, the alpha channel of
\r
822 the texture is used to draw the image. */
\r
823 virtual void draw2DImageBatch(const video::ITexture* texture,
\r
824 const core::position2d<s32>& pos,
\r
825 const core::array<core::rect<s32> >& sourceRects,
\r
826 const core::array<s32>& indices,
\r
827 s32 kerningWidth=0,
\r
828 const core::rect<s32>* clipRect=0,
\r
829 SColor color=SColor(255,255,255,255),
\r
830 bool useAlphaChannelOfTexture=false) =0;
\r
832 //! Draws a set of 2d images, using a color and the alpha channel of the texture.
\r
833 /** All drawings are clipped against clipRect (if != 0).
\r
834 The subtextures are defined by the array of sourceRects and are
\r
835 positioned using the array of positions.
\r
836 \param texture Texture to be drawn.
\r
837 \param positions Array of upper left 2d destinations where the
\r
838 images will be drawn.
\r
839 \param sourceRects Source rectangles of the image.
\r
840 \param clipRect Pointer to rectangle on the screen where the
\r
841 images are clipped to.
\r
842 If this pointer is 0 then the image is not clipped.
\r
843 \param color Color with which the image is drawn.
\r
844 Note that the alpha component is used. If alpha is other than
\r
845 255, the image will be transparent.
\r
846 \param useAlphaChannelOfTexture: If true, the alpha channel of
\r
847 the texture is used to draw the image. */
\r
848 virtual void draw2DImageBatch(const video::ITexture* texture,
\r
849 const core::array<core::position2d<s32> >& positions,
\r
850 const core::array<core::rect<s32> >& sourceRects,
\r
851 const core::rect<s32>* clipRect=0,
\r
852 SColor color=SColor(255,255,255,255),
\r
853 bool useAlphaChannelOfTexture=false) =0;
\r
855 //! Draws a part of the texture into the rectangle. Note that colors must be an array of 4 colors if used.
\r
856 /** Suggested and first implemented by zola.
\r
857 \param texture The texture to draw from
\r
858 \param destRect The rectangle to draw into
\r
859 \param sourceRect The rectangle denoting a part of the texture
\r
860 \param clipRect Clips the destination rectangle (may be 0)
\r
861 \param colors Array of 4 colors denoting the color values of
\r
862 the corners of the destRect
\r
863 \param useAlphaChannelOfTexture True if alpha channel will be
\r
865 virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
\r
866 const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
\r
867 const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0;
\r
869 //! Draws a 2d rectangle.
\r
870 /** \param color Color of the rectangle to draw. The alpha
\r
871 component will not be ignored and specifies how transparent the
\r
873 \param pos Position of the rectangle.
\r
874 \param clip Pointer to rectangle against which the rectangle
\r
875 will be clipped. If the pointer is null, no clipping will be
\r
877 virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
\r
878 const core::rect<s32>* clip =0) =0;
\r
880 //! Draws a 2d rectangle with a gradient.
\r
881 /** \param colorLeftUp Color of the upper left corner to draw.
\r
882 The alpha component will not be ignored and specifies how
\r
883 transparent the rectangle will be.
\r
884 \param colorRightUp Color of the upper right corner to draw.
\r
885 The alpha component will not be ignored and specifies how
\r
886 transparent the rectangle will be.
\r
887 \param colorLeftDown Color of the lower left corner to draw.
\r
888 The alpha component will not be ignored and specifies how
\r
889 transparent the rectangle will be.
\r
890 \param colorRightDown Color of the lower right corner to draw.
\r
891 The alpha component will not be ignored and specifies how
\r
892 transparent the rectangle will be.
\r
893 \param pos Position of the rectangle.
\r
894 \param clip Pointer to rectangle against which the rectangle
\r
895 will be clipped. If the pointer is null, no clipping will be
\r
897 virtual void draw2DRectangle(const core::rect<s32>& pos,
\r
898 SColor colorLeftUp, SColor colorRightUp,
\r
899 SColor colorLeftDown, SColor colorRightDown,
\r
900 const core::rect<s32>* clip =0) =0;
\r
902 //! Draws the outline of a 2D rectangle.
\r
903 /** \param pos Position of the rectangle.
\r
904 \param color Color of the rectangle to draw. The alpha component
\r
905 specifies how transparent the rectangle outline will be. */
\r
906 virtual void draw2DRectangleOutline(const core::recti& pos,
\r
907 SColor color=SColor(255,255,255,255)) =0;
\r
909 //! Draws a 2d line.
\r
910 /** In theory both start and end will be included in coloring.
\r
911 BUG: Currently d3d ignores the last pixel
\r
912 (it uses the so called "diamond exit rule" for drawing lines).
\r
913 \param start Screen coordinates of the start of the line
\r
915 \param end Screen coordinates of the start of the line in
\r
917 \param color Color of the line to draw. */
\r
918 virtual void draw2DLine(const core::position2d<s32>& start,
\r
919 const core::position2d<s32>& end,
\r
920 SColor color=SColor(255,255,255,255)) =0;
\r
923 /** \param x The x-position of the pixel.
\r
924 \param y The y-position of the pixel.
\r
925 \param color Color of the pixel to draw. */
\r
926 virtual void drawPixel(u32 x, u32 y, const SColor& color) =0;
\r
928 //! Draws a non filled concyclic regular 2d polygon.
\r
929 /** This method can be used to draw circles, but also
\r
930 triangles, tetragons, pentagons, hexagons, heptagons, octagons,
\r
931 enneagons, decagons, hendecagons, dodecagon, triskaidecagons,
\r
932 etc. I think you'll got it now. And all this by simply
\r
933 specifying the vertex count. Welcome to the wonders of
\r
935 \param center Position of center of circle (pixels).
\r
936 \param radius Radius of circle in pixels.
\r
937 \param color Color of the circle.
\r
938 \param vertexCount Amount of vertices of the polygon. Specify 2
\r
939 to draw a line, 3 to draw a triangle, 4 for tetragons and a lot
\r
940 (>10) for nearly a circle. */
\r
941 virtual void draw2DPolygon(core::position2d<s32> center,
\r
943 video::SColor color=SColor(100,255,255,255),
\r
944 s32 vertexCount=10) =0;
\r
946 //! Draws a shadow volume into the stencil buffer.
\r
947 /** To draw a stencil shadow, do this: First, draw all geometry.
\r
948 Then use this method, to draw the shadow volume. Then, use
\r
949 IVideoDriver::drawStencilShadow() to visualize the shadow.
\r
950 Please note that the code for the opengl version of the method
\r
951 is based on free code sent in by Philipp Dortmann, lots of
\r
953 \param triangles Array of 3d vectors, specifying the shadow
\r
955 \param zfail If set to true, zfail method is used, otherwise
\r
957 \param debugDataVisible The debug data that is enabled for this
\r
960 virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true, u32 debugDataVisible=0) =0;
\r
962 //! Fills the stencil shadow with color.
\r
963 /** After the shadow volume has been drawn into the stencil
\r
964 buffer using IVideoDriver::drawStencilShadowVolume(), use this
\r
965 to draw the color of the shadow.
\r
966 Please note that the code for the opengl version of the method
\r
967 is based on free code sent in by Philipp Dortmann, lots of
\r
969 \param clearStencilBuffer Set this to false, if you want to
\r
970 draw every shadow with the same color, and only want to call
\r
971 drawStencilShadow() once after all shadow volumes have been
\r
972 drawn. Set this to true, if you want to paint every shadow with
\r
974 \param leftUpEdge Color of the shadow in the upper left corner
\r
976 \param rightUpEdge Color of the shadow in the upper right
\r
978 \param leftDownEdge Color of the shadow in the lower left
\r
980 \param rightDownEdge Color of the shadow in the lower right
\r
981 corner of screen. */
\r
982 virtual void drawStencilShadow(bool clearStencilBuffer=false,
\r
983 video::SColor leftUpEdge = video::SColor(255,0,0,0),
\r
984 video::SColor rightUpEdge = video::SColor(255,0,0,0),
\r
985 video::SColor leftDownEdge = video::SColor(255,0,0,0),
\r
986 video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0;
\r
988 //! Draws a mesh buffer
\r
989 /** \param mb Buffer to draw */
\r
990 virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0;
\r
992 //! Draws normals of a mesh buffer
\r
993 /** \param mb Buffer to draw the normals of
\r
994 \param length length scale factor of the normals
\r
995 \param color Color the normals are rendered with
\r
997 virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f, SColor color=0xffffffff) =0;
\r
999 //! Sets the fog mode.
\r
1000 /** These are global values attached to each 3d object rendered,
\r
1001 which has the fog flag enabled in its material.
\r
1002 \param color Color of the fog
\r
1003 \param fogType Type of fog used
\r
1004 \param start Only used in linear fog mode (linearFog=true).
\r
1005 Specifies where fog starts.
\r
1006 \param end Only used in linear fog mode (linearFog=true).
\r
1007 Specifies where fog ends.
\r
1008 \param density Only used in exponential fog mode
\r
1009 (linearFog=false). Must be a value between 0 and 1.
\r
1010 \param pixelFog Set this to false for vertex fog, and true if
\r
1011 you want per-pixel fog.
\r
1012 \param rangeFog Set this to true to enable range-based vertex
\r
1013 fog. The distance from the viewer is used to compute the fog,
\r
1014 not the z-coordinate. This is better, but slower. This might not
\r
1015 be available with all drivers and fog settings. */
\r
1016 virtual void setFog(SColor color=SColor(0,255,255,255),
\r
1017 E_FOG_TYPE fogType=EFT_FOG_LINEAR,
\r
1018 f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
\r
1019 bool pixelFog=false, bool rangeFog=false) =0;
\r
1021 //! Gets the fog mode.
\r
1022 virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
\r
1023 f32& start, f32& end, f32& density,
\r
1024 bool& pixelFog, bool& rangeFog) = 0;
\r
1026 //! Get the current color format of the color buffer
\r
1027 /** \return Color format of the color buffer. */
\r
1028 virtual ECOLOR_FORMAT getColorFormat() const =0;
\r
1030 //! Get the size of the screen or render window.
\r
1031 /** \return Size of screen or render window. */
\r
1032 virtual const core::dimension2d<u32>& getScreenSize() const =0;
\r
1034 //! Get the size of the current render target
\r
1035 /** This method will return the screen size if the driver
\r
1036 doesn't support render to texture, or if the current render
\r
1037 target is the screen.
\r
1038 \return Size of render target or screen/window */
\r
1039 virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const =0;
\r
1041 //! Returns current frames per second value.
\r
1042 /** This value is updated approximately every 1.5 seconds and
\r
1043 is only intended to provide a rough guide to the average frame
\r
1044 rate. It is not suitable for use in performing timing
\r
1045 calculations or framerate independent movement.
\r
1046 \return Approximate amount of frames per second drawn. */
\r
1047 virtual s32 getFPS() const =0;
\r
1049 //! Returns amount of primitives (mostly triangles) which were drawn in the last frame.
\r
1050 /** Together with getFPS() very useful method for statistics.
\r
1051 \param mode Defines if the primitives drawn are accumulated or
\r
1052 counted per frame.
\r
1053 \return Amount of primitives drawn in the last frame. */
\r
1054 virtual u32 getPrimitiveCountDrawn( u32 mode =0 ) const =0;
\r
1056 //! Deletes all dynamic lights which were previously added with addDynamicLight().
\r
1057 virtual void deleteAllDynamicLights() =0;
\r
1059 //! adds a dynamic light, returning an index to the light
\r
1060 //! \param light: the light data to use to create the light
\r
1061 //! \return An index to the light, or -1 if an error occurs
\r
1062 virtual s32 addDynamicLight(const SLight& light) =0;
\r
1064 //! Returns the maximal amount of dynamic lights the device can handle
\r
1065 /** \return Maximal amount of dynamic lights. */
\r
1066 virtual u32 getMaximalDynamicLightAmount() const =0;
\r
1068 //! Returns amount of dynamic lights currently set
\r
1069 /** \return Amount of dynamic lights currently set */
\r
1070 virtual u32 getDynamicLightCount() const =0;
\r
1072 //! Returns light data which was previously set by IVideoDriver::addDynamicLight().
\r
1073 /** \param idx Zero based index of the light. Must be 0 or
\r
1074 greater and smaller than IVideoDriver::getDynamicLightCount.
\r
1075 \return Light data. */
\r
1076 virtual const SLight& getDynamicLight(u32 idx) const =0;
\r
1078 //! Turns a dynamic light on or off
\r
1079 //! \param lightIndex: the index returned by addDynamicLight
\r
1080 //! \param turnOn: true to turn the light on, false to turn it off
\r
1081 virtual void turnLightOn(s32 lightIndex, bool turnOn) =0;
\r
1083 //! Gets name of this video driver.
\r
1084 /** \return Returns the name of the video driver, e.g. in case
\r
1085 of the Direct3D8 driver, it would return "Direct3D 8.1". */
\r
1086 virtual const wchar_t* getName() const =0;
\r
1088 //! Adds an external image loader to the engine.
\r
1089 /** This is useful if the Irrlicht Engine should be able to load
\r
1090 textures of currently unsupported file formats (e.g. gif). The
\r
1091 IImageLoader only needs to be implemented for loading this file
\r
1092 format. A pointer to the implementation can be passed to the
\r
1093 engine using this method.
\r
1094 \param loader Pointer to the external loader created. */
\r
1095 virtual void addExternalImageLoader(IImageLoader* loader) =0;
\r
1097 //! Adds an external image writer to the engine.
\r
1098 /** This is useful if the Irrlicht Engine should be able to
\r
1099 write textures of currently unsupported file formats (e.g
\r
1100 .gif). The IImageWriter only needs to be implemented for
\r
1101 writing this file format. A pointer to the implementation can
\r
1102 be passed to the engine using this method.
\r
1103 \param writer: Pointer to the external writer created. */
\r
1104 virtual void addExternalImageWriter(IImageWriter* writer) =0;
\r
1106 //! Returns the maximum amount of primitives
\r
1107 /** (mostly vertices) which the device is able to render with
\r
1108 one drawVertexPrimitiveList call.
\r
1109 \return Maximum amount of primitives. */
\r
1110 virtual u32 getMaximalPrimitiveCount() const =0;
\r
1112 //! Enables or disables a texture creation flag.
\r
1113 /** These flags define how textures should be created. By
\r
1114 changing this value, you can influence for example the speed of
\r
1115 rendering a lot. But please note that the video drivers take
\r
1116 this value only as recommendation. It could happen that you
\r
1117 enable the ETCF_ALWAYS_16_BIT mode, but the driver still creates
\r
1119 \param flag Texture creation flag.
\r
1120 \param enabled Specifies if the given flag should be enabled or
\r
1122 virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled=true) =0;
\r
1124 //! Returns if a texture creation flag is enabled or disabled.
\r
1125 /** You can change this value using setTextureCreationFlag().
\r
1126 \param flag Texture creation flag.
\r
1127 \return The current texture creation flag enabled mode. */
\r
1128 virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0;
\r
1130 //! Creates a software images from a file.
\r
1131 /** No hardware texture will be created for those images. This
\r
1132 method is useful for example if you want to read a heightmap
\r
1133 for a terrain renderer.
\r
1134 \param filename Name of the file from which the images are created.
\r
1135 \param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
\r
1136 \return The array of created images.
\r
1137 If you no longer need those images, you should call IImage::drop() on each of them.
\r
1138 See IReferenceCounted::drop() for more information. */
\r
1139 virtual core::array<IImage*> createImagesFromFile(const io::path& filename, E_TEXTURE_TYPE* type = 0) = 0;
\r
1141 //! Creates a software images from a file.
\r
1142 /** No hardware texture will be created for those images. This
\r
1143 method is useful for example if you want to read a heightmap
\r
1144 for a terrain renderer.
\r
1145 \param file File from which the image is created.
\r
1146 \param type Pointer to E_TEXTURE_TYPE where a recommended type of the texture will be stored.
\r
1147 \return The array of created images.
\r
1148 If you no longer need those images, you should call IImage::drop() on each of them.
\r
1149 See IReferenceCounted::drop() for more information. */
\r
1150 virtual core::array<IImage*> createImagesFromFile(io::IReadFile* file, E_TEXTURE_TYPE* type = 0) = 0;
\r
1152 //! Creates a software image from a file.
\r
1153 /** No hardware texture will be created for this image. This
\r
1154 method is useful for example if you want to read a heightmap
\r
1155 for a terrain renderer.
\r
1156 \param filename Name of the file from which the image is
\r
1158 \return The created image.
\r
1159 If you no longer need the image, you should call IImage::drop().
\r
1160 See IReferenceCounted::drop() for more information. */
\r
1161 IImage* createImageFromFile(const io::path& filename)
\r
1163 core::array<IImage*> imageArray = createImagesFromFile(filename);
\r
1165 for (u32 i = 1; i < imageArray.size(); ++i)
\r
1166 imageArray[i]->drop();
\r
1168 return (imageArray.size() > 0) ? imageArray[0] : 0;
\r
1171 //! Creates a software image from a file.
\r
1172 /** No hardware texture will be created for this image. This
\r
1173 method is useful for example if you want to read a heightmap
\r
1174 for a terrain renderer.
\r
1175 \param file File from which the image is created.
\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 IImage* createImageFromFile(io::IReadFile* file)
\r
1181 core::array<IImage*> imageArray = createImagesFromFile(file);
\r
1183 for (u32 i = 1; i < imageArray.size(); ++i)
\r
1184 imageArray[i]->drop();
\r
1186 return (imageArray.size() > 0) ? imageArray[0] : 0;
\r
1189 //! Writes the provided image to a file.
\r
1190 /** Requires that there is a suitable image writer registered
\r
1191 for writing the image.
\r
1192 \param image Image to write.
\r
1193 \param filename Name of the file to write.
\r
1194 \param param Control parameter for the backend (e.g. compression
\r
1196 \return True on successful write. */
\r
1197 virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) = 0;
\r
1199 //! Writes the provided image to a file.
\r
1200 /** Requires that there is a suitable image writer registered
\r
1201 for writing the image.
\r
1202 \param image Image to write.
\r
1203 \param file An already open io::IWriteFile object. The name
\r
1204 will be used to determine the appropriate image writer to use.
\r
1205 \param param Control parameter for the backend (e.g. compression
\r
1207 \return True on successful write. */
\r
1208 virtual bool writeImageToFile(IImage* image, io::IWriteFile* file, u32 param =0) =0;
\r
1210 //! Creates a software image from a byte array.
\r
1211 /** No hardware texture will be created for this image. This
\r
1212 method is useful for example if you want to read a heightmap
\r
1213 for a terrain renderer.
\r
1214 \param format Desired color format of the texture
\r
1215 \param size Desired size of the image
\r
1216 \param data A byte array with pixel color information
\r
1217 \param ownForeignMemory If true, the image will use the data
\r
1218 pointer directly and own it afterward. If false, the memory
\r
1219 will by copied internally.
\r
1220 WARNING: Setting this to 'true' will not work across dll boundaries.
\r
1221 So unless you link Irrlicht statically you should keep this to 'false'.
\r
1222 The parameter is mainly for internal usage.
\r
1223 \param deleteMemory Whether the memory is deallocated upon
\r
1225 \return The created image.
\r
1226 If you no longer need the image, you should call IImage::drop().
\r
1227 See IReferenceCounted::drop() for more information. */
\r
1228 virtual IImage* createImageFromData(ECOLOR_FORMAT format,
\r
1229 const core::dimension2d<u32>& size, void *data, bool ownForeignMemory = false,
\r
1230 bool deleteMemory = true) = 0;
\r
1232 //! Creates an empty software image.
\r
1234 \param format Desired color format of the image.
\r
1235 \param size Size of the image to create.
\r
1236 \return The created image.
\r
1237 If you no longer need the image, you should call IImage::drop().
\r
1238 See IReferenceCounted::drop() for more information. */
\r
1239 virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) =0;
\r
1241 //! Creates a software image by converting it to given format from another image.
\r
1242 /** \deprecated Create an empty image and use copyTo(). This method may be removed by Irrlicht 1.9.
\r
1243 \param format Desired color format of the image.
\r
1244 \param imageToCopy Image to copy to the new image.
\r
1245 \return The created image.
\r
1246 If you no longer need the image, you should call IImage::drop().
\r
1247 See IReferenceCounted::drop() for more information. */
\r
1248 _IRR_DEPRECATED_ virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0;
\r
1250 //! Creates a software image from a part of another image.
\r
1251 /** \deprecated Create an empty image and use copyTo(). This method may be removed by Irrlicht 1.9.
\r
1252 \param imageToCopy Image to copy to the new image in part.
\r
1253 \param pos Position of rectangle to copy.
\r
1254 \param size Extents of rectangle to copy.
\r
1255 \return The created image.
\r
1256 If you no longer need the image, you should call IImage::drop().
\r
1257 See IReferenceCounted::drop() for more information. */
\r
1258 _IRR_DEPRECATED_ virtual IImage* createImage(IImage* imageToCopy,
\r
1259 const core::position2d<s32>& pos,
\r
1260 const core::dimension2d<u32>& size) =0;
\r
1262 //! Creates a software image from a part of a texture.
\r
1264 \param texture Texture to copy to the new image in part.
\r
1265 \param pos Position of rectangle to copy.
\r
1266 \param size Extents of rectangle to copy.
\r
1267 \return The created image.
\r
1268 If you no longer need the image, you should call IImage::drop().
\r
1269 See IReferenceCounted::drop() for more information. */
\r
1270 virtual IImage* createImage(ITexture* texture,
\r
1271 const core::position2d<s32>& pos,
\r
1272 const core::dimension2d<u32>& size) =0;
\r
1274 //! Event handler for resize events. Only used by the engine internally.
\r
1275 /** Used to notify the driver that the window was resized.
\r
1276 Usually, there is no need to call this method. */
\r
1277 virtual void OnResize(const core::dimension2d<u32>& size) =0;
\r
1279 //! Adds a new material renderer to the video device.
\r
1280 /** Use this method to extend the VideoDriver with new material
\r
1281 types. To extend the engine using this method do the following:
\r
1282 Derive a class from IMaterialRenderer and override the methods
\r
1283 you need. For setting the right renderstates, you can try to
\r
1284 get a pointer to the real rendering device using
\r
1285 IVideoDriver::getExposedVideoData(). Add your class with
\r
1286 IVideoDriver::addMaterialRenderer(). To use an object being
\r
1287 displayed with your new material, set the MaterialType member of
\r
1288 the SMaterial struct to the value returned by this method.
\r
1289 If you simply want to create a new material using vertex and/or
\r
1290 pixel shaders it would be easier to use the
\r
1291 video::IGPUProgrammingServices interface which you can get
\r
1292 using the getGPUProgrammingServices() method.
\r
1293 \param renderer A pointer to the new renderer.
\r
1294 \param name Optional name for the material renderer entry.
\r
1295 \return The number of the material type which can be set in
\r
1296 SMaterial::MaterialType to use the renderer. -1 is returned if
\r
1297 an error occurred. For example if you tried to add an material
\r
1298 renderer to the software renderer or the null device, which do
\r
1299 not accept material renderers. */
\r
1300 virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name =0) =0;
\r
1302 //! Get access to a material renderer by index.
\r
1303 /** \param idx Id of the material renderer. Can be a value of
\r
1304 the E_MATERIAL_TYPE enum or a value which was returned by
\r
1305 addMaterialRenderer().
\r
1306 \return Pointer to material renderer or null if not existing. */
\r
1307 virtual IMaterialRenderer* getMaterialRenderer(u32 idx) const = 0;
\r
1309 //! Get amount of currently available material renderers.
\r
1310 /** \return Amount of currently available material renderers. */
\r
1311 virtual u32 getMaterialRendererCount() const =0;
\r
1313 //! Get name of a material renderer
\r
1314 /** This string can, e.g., be used to test if a specific
\r
1315 renderer already has been registered/created, or use this
\r
1316 string to store data about materials: This returned name will
\r
1317 be also used when serializing materials.
\r
1318 \param idx Id of the material renderer. Can be a value of the
\r
1319 E_MATERIAL_TYPE enum or a value which was returned by
\r
1320 addMaterialRenderer().
\r
1321 \return String with the name of the renderer, or 0 if not
\r
1323 virtual const c8* getMaterialRendererName(u32 idx) const =0;
\r
1325 //! Sets the name of a material renderer.
\r
1326 /** Will have no effect on built-in material renderers.
\r
1327 \param idx: Id of the material renderer. Can be a value of the
\r
1328 E_MATERIAL_TYPE enum or a value which was returned by
\r
1329 addMaterialRenderer().
\r
1330 \param name: New name of the material renderer. */
\r
1331 virtual void setMaterialRendererName(s32 idx, const c8* name) =0;
\r
1333 //! Swap the material renderers used for certain id's
\r
1334 /** Swap the IMaterialRenderers responsible for rendering specific
\r
1335 material-id's. This means every SMaterial using a MaterialType
\r
1336 with one of the indices involved here will now render differently.
\r
1337 \param idx1 First material index to swap. It must already exist or nothing happens.
\r
1338 \param idx2 Second material index to swap. It must already exist or nothing happens.
\r
1339 \param swapNames When true the renderer names also swap
\r
1340 When false the names will stay at the original index */
\r
1341 virtual void swapMaterialRenderers(u32 idx1, u32 idx2, bool swapNames=true) = 0;
\r
1343 //! Returns driver and operating system specific data about the IVideoDriver.
\r
1344 /** This method should only be used if the engine should be
\r
1345 extended without having to modify the source of the engine.
\r
1346 \return Collection of device dependent pointers. */
\r
1347 virtual const SExposedVideoData& getExposedVideoData() =0;
\r
1349 //! Get type of video driver
\r
1350 /** \return Type of driver. */
\r
1351 virtual E_DRIVER_TYPE getDriverType() const =0;
\r
1353 //! Gets the IGPUProgrammingServices interface.
\r
1354 /** \return Pointer to the IGPUProgrammingServices. Returns 0
\r
1355 if the video driver does not support this. For example the
\r
1356 Software driver and the Null driver will always return 0. */
\r
1357 virtual IGPUProgrammingServices* getGPUProgrammingServices() =0;
\r
1359 //! Returns a pointer to the mesh manipulator.
\r
1360 virtual scene::IMeshManipulator* getMeshManipulator() =0;
\r
1362 //! Clear the color, depth and/or stencil buffers.
\r
1363 virtual void clearBuffers(u16 flag, SColor color = SColor(255,0,0,0), f32 depth = 1.f, u8 stencil = 0) = 0;
\r
1365 //! Clear the color, depth and/or stencil buffers.
\r
1366 _IRR_DEPRECATED_ void clearBuffers(bool backBuffer, bool depthBuffer, bool stencilBuffer, SColor color)
\r
1371 flag |= ECBF_COLOR;
\r
1374 flag |= ECBF_DEPTH;
\r
1376 if (stencilBuffer)
\r
1377 flag |= ECBF_STENCIL;
\r
1379 clearBuffers(flag, color);
\r
1382 //! Clears the ZBuffer.
\r
1383 /** Note that you usually need not to call this method, as it
\r
1384 is automatically done in IVideoDriver::beginScene() or
\r
1385 IVideoDriver::setRenderTarget() if you enable zBuffer. But if
\r
1386 you have to render some special things, you can clear the
\r
1387 zbuffer during the rendering process with this method any time.
\r
1389 void clearZBuffer()
\r
1391 clearBuffers(ECBF_DEPTH, SColor(255,0,0,0), 1.f, 0);
\r
1394 //! Make a screenshot of the last rendered frame.
\r
1395 /** \return An image created from the last rendered frame. */
\r
1396 virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) =0;
\r
1398 //! Check if the image is already loaded.
\r
1399 /** Works similar to getTexture(), but does not load the texture
\r
1400 if it is not currently loaded.
\r
1401 \param filename Name of the texture.
\r
1402 \return Pointer to loaded texture, or 0 if not found. */
\r
1403 virtual video::ITexture* findTexture(const io::path& filename) = 0;
\r
1405 //! Set or unset a clipping plane.
\r
1406 /** There are at least 6 clipping planes available for the user
\r
1408 \param index The plane index. Must be between 0 and
\r
1409 MaxUserClipPlanes.
\r
1410 \param plane The plane itself.
\r
1411 \param enable If true, enable the clipping plane else disable
\r
1413 \return True if the clipping plane is usable. */
\r
1414 virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) =0;
\r
1416 //! Enable or disable a clipping plane.
\r
1417 /** There are at least 6 clipping planes available for the user
\r
1419 \param index The plane index. Must be between 0 and
\r
1420 MaxUserClipPlanes.
\r
1421 \param enable If true, enable the clipping plane else disable
\r
1423 virtual void enableClipPlane(u32 index, bool enable) =0;
\r
1425 //! Set the minimum number of vertices for which a hw buffer will be created
\r
1426 /** \param count Number of vertices to set as minimum. */
\r
1427 virtual void setMinHardwareBufferVertexCount(u32 count) =0;
\r
1429 //! Get the global Material, which might override local materials.
\r
1430 /** Depending on the enable flags, values from this Material
\r
1431 are used to override those of local materials of some
\r
1432 meshbuffer being rendered.
\r
1433 \return Reference to the Override Material. */
\r
1434 virtual SOverrideMaterial& getOverrideMaterial() =0;
\r
1436 //! Get the 2d override material for altering its values
\r
1437 /** The 2d override material allows to alter certain render
\r
1438 states of the 2d methods. Not all members of SMaterial are
\r
1439 honored, especially not MaterialType and Textures. Moreover,
\r
1440 the zbuffer is always ignored, and lighting is always off. All
\r
1441 other flags can be changed, though some might have to effect
\r
1443 Please note that you have to enable/disable this effect with
\r
1444 enableMaterial2D(). This effect is costly, as it increases
\r
1445 the number of state changes considerably. Always reset the
\r
1447 \return Material reference which should be altered to reflect
\r
1450 virtual SMaterial& getMaterial2D() =0;
\r
1452 //! Enable the 2d override material
\r
1453 /** \param enable Flag which tells whether the material shall be
\r
1454 enabled or disabled. */
\r
1455 virtual void enableMaterial2D(bool enable=true) =0;
\r
1457 //! Get the graphics card vendor name.
\r
1458 virtual core::stringc getVendorInfo() =0;
\r
1460 //! Only used by the engine internally.
\r
1461 /** The ambient color is set in the scene manager, see
\r
1462 scene::ISceneManager::setAmbientLight().
\r
1463 \param color New color of the ambient light. */
\r
1464 virtual void setAmbientLight(const SColorf& color) =0;
\r
1466 //! Get the global ambient light currently used by the driver
\r
1467 virtual const SColorf& getAmbientLight() const = 0;
\r
1469 //! Only used by the engine internally.
\r
1470 /** Passes the global material flag AllowZWriteOnTransparent.
\r
1471 Use the SceneManager attribute to set this value from your app.
\r
1472 \param flag Default behavior is to disable ZWrite, i.e. false. */
\r
1473 virtual void setAllowZWriteOnTransparent(bool flag) =0;
\r
1475 //! Get the maximum texture size supported.
\r
1476 virtual core::dimension2du getMaxTextureSize() const =0;
\r
1478 //! Color conversion convenience function
\r
1479 /** Convert an image (as array of pixels) from source to destination
\r
1480 array, thereby converting the color format. The pixel size is
\r
1481 determined by the color formats.
\r
1482 \param sP Pointer to source
\r
1483 \param sF Color format of source
\r
1484 \param sN Number of pixels to convert, both array must be large enough
\r
1485 \param dP Pointer to destination
\r
1486 \param dF Color format of destination
\r
1488 virtual void convertColor(const void* sP, ECOLOR_FORMAT sF, s32 sN,
\r
1489 void* dP, ECOLOR_FORMAT dF) const =0;
\r
1491 //! Check if the driver supports creating textures with the given color format
\r
1492 /** \return True if the format is available, false if not. */
\r
1493 virtual bool queryTextureFormat(ECOLOR_FORMAT format) const = 0;
\r
1495 //! Used by some SceneNodes to check if a material should be rendered in the transparent render pass
\r
1496 virtual bool needsTransparentRenderPass(const irr::video::SMaterial& material) const = 0;
\r
1499 } // end namespace video
\r
1500 } // end namespace irr
\r