aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/include/IVideoDriver.h
diff options
context:
space:
mode:
authorDavid Walter Seikel2016-03-28 22:28:34 +1000
committerDavid Walter Seikel2016-03-28 22:28:34 +1000
commit7028cbe09c688437910a25623098762bf0fa592d (patch)
tree10b5af58277d9880380c2251f109325542c4e6eb /src/others/irrlicht-1.8.1/include/IVideoDriver.h
parentMove lemon to the src/others directory. (diff)
downloadSledjHamr-7028cbe09c688437910a25623098762bf0fa592d.zip
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.gz
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.bz2
SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.xz
Move Irrlicht to src/others.
Diffstat (limited to 'src/others/irrlicht-1.8.1/include/IVideoDriver.h')
-rw-r--r--src/others/irrlicht-1.8.1/include/IVideoDriver.h1471
1 files changed, 1471 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/include/IVideoDriver.h b/src/others/irrlicht-1.8.1/include/IVideoDriver.h
new file mode 100644
index 0000000..8af6607
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/include/IVideoDriver.h
@@ -0,0 +1,1471 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h
4
5#ifndef __IRR_I_VIDEO_DRIVER_H_INCLUDED__
6#define __IRR_I_VIDEO_DRIVER_H_INCLUDED__
7
8#include "rect.h"
9#include "SColor.h"
10#include "ITexture.h"
11#include "irrArray.h"
12#include "matrix4.h"
13#include "plane3d.h"
14#include "dimension2d.h"
15#include "position2d.h"
16#include "SMaterial.h"
17#include "IMeshBuffer.h"
18#include "triangle3d.h"
19#include "EDriverTypes.h"
20#include "EDriverFeatures.h"
21#include "SExposedVideoData.h"
22
23namespace irr
24{
25namespace io
26{
27 class IAttributes;
28 struct SAttributeReadWriteOptions;
29 class IReadFile;
30 class IWriteFile;
31} // end namespace io
32namespace scene
33{
34 class IMeshBuffer;
35 class IMesh;
36 class IMeshManipulator;
37 class ISceneNode;
38} // end namespace scene
39
40namespace video
41{
42 struct S3DVertex;
43 struct S3DVertex2TCoords;
44 struct S3DVertexTangents;
45 struct SLight;
46 class IImageLoader;
47 class IImageWriter;
48 class IMaterialRenderer;
49 class IGPUProgrammingServices;
50
51 //! enumeration for geometry transformation states
52 enum E_TRANSFORMATION_STATE
53 {
54 //! View transformation
55 ETS_VIEW = 0,
56 //! World transformation
57 ETS_WORLD,
58 //! Projection transformation
59 ETS_PROJECTION,
60 //! Texture transformation
61 ETS_TEXTURE_0,
62 //! Texture transformation
63 ETS_TEXTURE_1,
64 //! Texture transformation
65 ETS_TEXTURE_2,
66 //! Texture transformation
67 ETS_TEXTURE_3,
68#if _IRR_MATERIAL_MAX_TEXTURES_>4
69 //! Texture transformation
70 ETS_TEXTURE_4,
71#if _IRR_MATERIAL_MAX_TEXTURES_>5
72 //! Texture transformation
73 ETS_TEXTURE_5,
74#if _IRR_MATERIAL_MAX_TEXTURES_>6
75 //! Texture transformation
76 ETS_TEXTURE_6,
77#if _IRR_MATERIAL_MAX_TEXTURES_>7
78 //! Texture transformation
79 ETS_TEXTURE_7,
80#endif
81#endif
82#endif
83#endif
84 //! Not used
85 ETS_COUNT
86 };
87
88 //! enumeration for signaling resources which were lost after the last render cycle
89 /** These values can be signaled by the driver, telling the app that some resources
90 were lost and need to be recreated. Irrlicht will sometimes recreate the actual objects,
91 but the content needs to be recreated by the application. */
92 enum E_LOST_RESOURCE
93 {
94 //! The whole device/driver is lost
95 ELR_DEVICE = 1,
96 //! All texture are lost, rare problem
97 ELR_TEXTURES = 2,
98 //! The Render Target Textures are lost, typical problem for D3D
99 ELR_RTTS = 4,
100 //! The HW buffers are lost, will be recreated automatically, but might require some more time this frame
101 ELR_HW_BUFFERS = 8
102 };
103
104 //! Special render targets, which usually map to dedicated hardware
105 /** These render targets (besides 0 and 1) need not be supported by gfx cards */
106 enum E_RENDER_TARGET
107 {
108 //! Render target is the main color frame buffer
109 ERT_FRAME_BUFFER=0,
110 //! Render target is a render texture
111 ERT_RENDER_TEXTURE,
112 //! Multi-Render target textures
113 ERT_MULTI_RENDER_TEXTURES,
114 //! Render target is the main color frame buffer
115 ERT_STEREO_LEFT_BUFFER,
116 //! Render target is the right color buffer (left is the main buffer)
117 ERT_STEREO_RIGHT_BUFFER,
118 //! Render to both stereo buffers at once
119 ERT_STEREO_BOTH_BUFFERS,
120 //! Auxiliary buffer 0
121 ERT_AUX_BUFFER0,
122 //! Auxiliary buffer 1
123 ERT_AUX_BUFFER1,
124 //! Auxiliary buffer 2
125 ERT_AUX_BUFFER2,
126 //! Auxiliary buffer 3
127 ERT_AUX_BUFFER3,
128 //! Auxiliary buffer 4
129 ERT_AUX_BUFFER4
130 };
131
132 //! Enum for the types of fog distributions to choose from
133 enum E_FOG_TYPE
134 {
135 EFT_FOG_EXP=0,
136 EFT_FOG_LINEAR,
137 EFT_FOG_EXP2
138 };
139
140 const c8* const FogTypeNames[] =
141 {
142 "FogExp",
143 "FogLinear",
144 "FogExp2",
145 0
146 };
147
148 struct SOverrideMaterial
149 {
150 //! The Material values
151 SMaterial Material;
152 //! Which values are taken for override
153 /** OR'ed values from E_MATERIAL_FLAGS. */
154 u32 EnableFlags;
155 //! Set in which render passes the material override is active.
156 /** OR'ed values from E_SCENE_NODE_RENDER_PASS. */
157 u16 EnablePasses;
158 //! Global enable flag, overwritten by the SceneManager in each pass
159 /** The Scenemanager uses the EnablePass array and sets Enabled to
160 true if the Override material is enabled in the current pass. */
161 bool Enabled;
162
163 //! Default constructor
164 SOverrideMaterial() : EnableFlags(0), EnablePasses(0), Enabled(false) {}
165
166 //! Apply the enabled overrides
167 void apply(SMaterial& material)
168 {
169 if (Enabled)
170 {
171 for (u32 i=0; i<32; ++i)
172 {
173 const u32 num=(1<<i);
174 if (EnableFlags & num)
175 {
176 switch (num)
177 {
178 case EMF_WIREFRAME: material.Wireframe = Material.Wireframe; break;
179 case EMF_POINTCLOUD: material.PointCloud = Material.PointCloud; break;
180 case EMF_GOURAUD_SHADING: material.GouraudShading = Material.GouraudShading; break;
181 case EMF_LIGHTING: material.Lighting = Material.Lighting; break;
182 case EMF_ZBUFFER: material.ZBuffer = Material.ZBuffer; break;
183 case EMF_ZWRITE_ENABLE: material.ZWriteEnable = Material.ZWriteEnable; break;
184 case EMF_BACK_FACE_CULLING: material.BackfaceCulling = Material.BackfaceCulling; break;
185 case EMF_FRONT_FACE_CULLING: material.FrontfaceCulling = Material.FrontfaceCulling; break;
186 case EMF_BILINEAR_FILTER: material.TextureLayer[0].BilinearFilter = Material.TextureLayer[0].BilinearFilter; break;
187 case EMF_TRILINEAR_FILTER: material.TextureLayer[0].TrilinearFilter = Material.TextureLayer[0].TrilinearFilter; break;
188 case EMF_ANISOTROPIC_FILTER: material.TextureLayer[0].AnisotropicFilter = Material.TextureLayer[0].AnisotropicFilter; break;
189 case EMF_FOG_ENABLE: material.FogEnable = Material.FogEnable; break;
190 case EMF_NORMALIZE_NORMALS: material.NormalizeNormals = Material.NormalizeNormals; break;
191 case EMF_TEXTURE_WRAP:
192 material.TextureLayer[0].TextureWrapU = Material.TextureLayer[0].TextureWrapU;
193 material.TextureLayer[0].TextureWrapV = Material.TextureLayer[0].TextureWrapV;
194 break;
195 case EMF_ANTI_ALIASING: material.AntiAliasing = Material.AntiAliasing; break;
196 case EMF_COLOR_MASK: material.ColorMask = Material.ColorMask; break;
197 case EMF_COLOR_MATERIAL: material.ColorMaterial = Material.ColorMaterial; break;
198 case EMF_USE_MIP_MAPS: material.UseMipMaps = Material.UseMipMaps; break;
199 case EMF_BLEND_OPERATION: material.BlendOperation = Material.BlendOperation; break;
200 case EMF_POLYGON_OFFSET:
201 material.PolygonOffsetDirection = Material.PolygonOffsetDirection;
202 material.PolygonOffsetFactor = Material.PolygonOffsetFactor; break;
203 }
204 }
205 }
206 }
207 }
208
209 };
210
211 struct IRenderTarget
212 {
213 IRenderTarget(ITexture* texture,
214 E_COLOR_PLANE colorMask=ECP_ALL,
215 E_BLEND_FACTOR blendFuncSrc=EBF_ONE,
216 E_BLEND_FACTOR blendFuncDst=EBF_ONE_MINUS_SRC_ALPHA,
217 E_BLEND_OPERATION blendOp=EBO_NONE) :
218 RenderTexture(texture),
219 TargetType(ERT_RENDER_TEXTURE), ColorMask(colorMask),
220 BlendFuncSrc(blendFuncSrc), BlendFuncDst(blendFuncDst),
221 BlendOp(blendOp) {}
222 IRenderTarget(E_RENDER_TARGET target,
223 E_COLOR_PLANE colorMask=ECP_ALL,
224 E_BLEND_FACTOR blendFuncSrc=EBF_ONE,
225 E_BLEND_FACTOR blendFuncDst=EBF_ONE_MINUS_SRC_ALPHA,
226 E_BLEND_OPERATION blendOp=EBO_NONE) :
227 RenderTexture(0),
228 TargetType(target), ColorMask(colorMask),
229 BlendFuncSrc(blendFuncSrc), BlendFuncDst(blendFuncDst),
230 BlendOp(blendOp) {}
231 bool operator!=(const IRenderTarget& other) const
232 {
233 return ((RenderTexture != other.RenderTexture) ||
234 (TargetType != other.TargetType) ||
235 (ColorMask != other.ColorMask) ||
236 (BlendFuncSrc != other.BlendFuncSrc) ||
237 (BlendFuncDst != other.BlendFuncDst) ||
238 (BlendOp != other.BlendOp));
239 }
240 ITexture* RenderTexture;
241 E_RENDER_TARGET TargetType:8;
242 E_COLOR_PLANE ColorMask:8;
243 E_BLEND_FACTOR BlendFuncSrc:4;
244 E_BLEND_FACTOR BlendFuncDst:4;
245 E_BLEND_OPERATION BlendOp:4;
246 };
247
248 //! Interface to driver which is able to perform 2d and 3d graphics functions.
249 /** This interface is one of the most important interfaces of
250 the Irrlicht Engine: All rendering and texture manipulation is done with
251 this interface. You are able to use the Irrlicht Engine by only
252 invoking methods of this interface if you like to, although the
253 irr::scene::ISceneManager interface provides a lot of powerful classes
254 and methods to make the programmer's life easier.
255 */
256 class IVideoDriver : public virtual IReferenceCounted
257 {
258 public:
259
260 //! Applications must call this method before performing any rendering.
261 /** This method can clear the back- and the z-buffer.
262 \param backBuffer Specifies if the back buffer should be
263 cleared, which means that the screen is filled with the color
264 specified. If this parameter is false, the back buffer will
265 not be cleared and the color parameter is ignored.
266 \param zBuffer Specifies if the depth buffer (z buffer) should
267 be cleared. It is not nesesarry to do so if only 2d drawing is
268 used.
269 \param color The color used for back buffer clearing
270 \param videoData Handle of another window, if you want the
271 bitmap to be displayed on another window. If this is an empty
272 element, everything will be displayed in the default window.
273 Note: This feature is not fully implemented for all devices.
274 \param sourceRect Pointer to a rectangle defining the source
275 rectangle of the area to be presented. Set to null to present
276 everything. Note: not implemented in all devices.
277 \return False if failed. */
278 virtual bool beginScene(bool backBuffer=true, bool zBuffer=true,
279 SColor color=SColor(255,0,0,0),
280 const SExposedVideoData& videoData=SExposedVideoData(),
281 core::rect<s32>* sourceRect=0) =0;
282
283 //! Presents the rendered image to the screen.
284 /** Applications must call this method after performing any
285 rendering.
286 \return False if failed and true if succeeded. */
287 virtual bool endScene() =0;
288
289 //! Queries the features of the driver.
290 /** Returns true if a feature is available
291 \param feature Feature to query.
292 \return True if the feature is available, false if not. */
293 virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) const =0;
294
295 //! Disable a feature of the driver.
296 /** Can also be used to enable the features again. It is not
297 possible to enable unsupported features this way, though.
298 \param feature Feature to disable.
299 \param flag When true the feature is disabled, otherwise it is enabled. */
300 virtual void disableFeature(E_VIDEO_DRIVER_FEATURE feature, bool flag=true) =0;
301
302 //! Get attributes of the actual video driver
303 /** The following names can be queried for the given types:
304 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.
305 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.
306 MaxLights (int) Number of hardware lights supported in the fixed function pipieline of the driver, typically 6-8. Use light manager or deferred shading for more.
307 MaxAnisotropy (int) Number of anisotropy levels supported for filtering. At least 1, max is typically at 16 or 32.
308 MaxUserClipPlanes (int) Number of additional clip planes, which can be set by the user via dedicated driver methods.
309 MaxAuxBuffers (int) Special render buffers, which are currently not really usable inside Irrlicht. Only supported by OpenGL
310 MaxMultipleRenderTargets (int) Number of render targets which can be bound simultaneously. Rendering to MRTs is done via shaders.
311 MaxIndices (int) Number of indices which can be used in one render call (i.e. one mesh buffer).
312 MaxTextureSize (int) Dimension that a texture may have, both in width and height.
313 MaxGeometryVerticesOut (int) Number of vertices the geometry shader can output in one pass. Only OpenGL so far.
314 MaxTextureLODBias (float) Maximum value for LOD bias. Is usually at around 16, but can be lower on some systems.
315 Version (int) Version of the driver. Should be Major*100+Minor
316 ShaderLanguageVersion (int) Version of the high level shader language. Should be Major*100+Minor.
317 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
318 */
319 virtual const io::IAttributes& getDriverAttributes() const=0;
320
321 //! Check if the driver was recently reset.
322 /** For d3d devices you will need to recreate the RTTs if the
323 driver was reset. Should be queried right after beginScene().
324 */
325 virtual bool checkDriverReset() =0;
326
327 //! Sets transformation matrices.
328 /** \param state Transformation type to be set, e.g. view,
329 world, or projection.
330 \param mat Matrix describing the transformation. */
331 virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat) =0;
332
333 //! Returns the transformation set by setTransform
334 /** \param state Transformation type to query
335 \return Matrix describing the transformation. */
336 virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state) const =0;
337
338 //! Retrieve the number of image loaders
339 /** \return Number of image loaders */
340 virtual u32 getImageLoaderCount() const = 0;
341
342 //! Retrieve the given image loader
343 /** \param n The index of the loader to retrieve. This parameter is an 0-based
344 array index.
345 \return A pointer to the specified loader, 0 if the index is incorrect. */
346 virtual IImageLoader* getImageLoader(u32 n) = 0;
347
348 //! Retrieve the number of image writers
349 /** \return Number of image writers */
350 virtual u32 getImageWriterCount() const = 0;
351
352 //! Retrieve the given image writer
353 /** \param n The index of the writer to retrieve. This parameter is an 0-based
354 array index.
355 \return A pointer to the specified writer, 0 if the index is incorrect. */
356 virtual IImageWriter* getImageWriter(u32 n) = 0;
357
358 //! Sets a material.
359 /** All 3d drawing functions will draw geometry using this material thereafter.
360 \param material: Material to be used from now on. */
361 virtual void setMaterial(const SMaterial& material) =0;
362
363 //! Get access to a named texture.
364 /** Loads the texture from disk if it is not
365 already loaded and generates mipmap levels if desired.
366 Texture loading can be influenced using the
367 setTextureCreationFlag() method. The texture can be in several
368 imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD.
369 \param filename Filename of the texture to be loaded.
370 \return Pointer to the texture, or 0 if the texture
371 could not be loaded. This pointer should not be dropped. See
372 IReferenceCounted::drop() for more information. */
373 virtual ITexture* getTexture(const io::path& filename) = 0;
374
375 //! Get access to a named texture.
376 /** Loads the texture from disk if it is not
377 already loaded and generates mipmap levels if desired.
378 Texture loading can be influenced using the
379 setTextureCreationFlag() method. The texture can be in several
380 imageformats, such as BMP, JPG, TGA, PCX, PNG, and PSD.
381 \param file Pointer to an already opened file.
382 \return Pointer to the texture, or 0 if the texture
383 could not be loaded. This pointer should not be dropped. See
384 IReferenceCounted::drop() for more information. */
385 virtual ITexture* getTexture(io::IReadFile* file) =0;
386
387 //! Returns a texture by index
388 /** \param index: Index of the texture, must be smaller than
389 getTextureCount() Please note that this index might change when
390 adding or removing textures
391 \return Pointer to the texture, or 0 if the texture was not
392 set or index is out of bounds. This pointer should not be
393 dropped. See IReferenceCounted::drop() for more information. */
394 virtual ITexture* getTextureByIndex(u32 index) =0;
395
396 //! Returns amount of textures currently loaded
397 /** \return Amount of textures currently loaded */
398 virtual u32 getTextureCount() const = 0;
399
400 //! Renames a texture
401 /** \param texture Pointer to the texture to rename.
402 \param newName New name for the texture. This should be a unique name. */
403 virtual void renameTexture(ITexture* texture, const io::path& newName) = 0;
404
405 //! Creates an empty texture of specified size.
406 /** \param size: Size of the texture.
407 \param name A name for the texture. Later calls to
408 getTexture() with this name will return this texture
409 \param format Desired color format of the texture. Please note
410 that the driver may choose to create the texture in another
411 color format.
412 \return Pointer to the newly created texture. This pointer
413 should not be dropped. See IReferenceCounted::drop() for more
414 information. */
415 virtual ITexture* addTexture(const core::dimension2d<u32>& size,
416 const io::path& name, ECOLOR_FORMAT format = ECF_A8R8G8B8) = 0;
417
418 //! Creates a texture from an IImage.
419 /** \param name A name for the texture. Later calls of
420 getTexture() with this name will return this texture
421 \param image Image the texture is created from.
422 \param mipmapData Optional pointer to a set of images which
423 build up the whole mipmap set. Must be images of the same color
424 type as image. If this parameter is not given, the mipmaps are
425 derived from image.
426 \return Pointer to the newly created texture. This pointer
427 should not be dropped. See IReferenceCounted::drop() for more
428 information. */
429 virtual ITexture* addTexture(const io::path& name, IImage* image, void* mipmapData=0) = 0;
430
431 //! Adds a new render target texture to the texture cache.
432 /** \param size Size of the texture, in pixels. Width and
433 height should be a power of two (e.g. 64, 128, 256, 512, ...)
434 and it should not be bigger than the backbuffer, because it
435 shares the zbuffer with the screen buffer.
436 \param name An optional name for the RTT.
437 \param format The color format of the render target. Floating point formats are supported.
438 \return Pointer to the created texture or 0 if the texture
439 could not be created. This pointer should not be dropped. See
440 IReferenceCounted::drop() for more information. */
441 virtual ITexture* addRenderTargetTexture(const core::dimension2d<u32>& size,
442 const io::path& name = "rt", const ECOLOR_FORMAT format = ECF_UNKNOWN) =0;
443
444 //! Removes a texture from the texture cache and deletes it.
445 /** This method can free a lot of memory!
446 Please note that after calling this, the pointer to the
447 ITexture may no longer be valid, if it was not grabbed before
448 by other parts of the engine for storing it longer. So it is a
449 good idea to set all materials which are using this texture to
450 0 or another texture first.
451 \param texture Texture to delete from the engine cache. */
452 virtual void removeTexture(ITexture* texture) =0;
453
454 //! Removes all textures from the texture cache and deletes them.
455 /** This method can free a lot of memory!
456 Please note that after calling this, the pointer to the
457 ITexture may no longer be valid, if it was not grabbed before
458 by other parts of the engine for storing it longer. So it is a
459 good idea to set all materials which are using this texture to
460 0 or another texture first. */
461 virtual void removeAllTextures() =0;
462
463 //! Remove hardware buffer
464 virtual void removeHardwareBuffer(const scene::IMeshBuffer* mb) =0;
465
466 //! Remove all hardware buffers
467 virtual void removeAllHardwareBuffers() =0;
468
469 //! Create occlusion query.
470 /** Use node for identification and mesh for occlusion test. */
471 virtual void addOcclusionQuery(scene::ISceneNode* node,
472 const scene::IMesh* mesh=0) =0;
473
474 //! Remove occlusion query.
475 virtual void removeOcclusionQuery(scene::ISceneNode* node) =0;
476
477 //! Remove all occlusion queries.
478 virtual void removeAllOcclusionQueries() =0;
479
480 //! Run occlusion query. Draws mesh stored in query.
481 /** If the mesh shall not be rendered visible, use
482 overrideMaterial to disable the color and depth buffer. */
483 virtual void runOcclusionQuery(scene::ISceneNode* node, bool visible=false) =0;
484
485 //! Run all occlusion queries. Draws all meshes stored in queries.
486 /** If the meshes shall not be rendered visible, use
487 overrideMaterial to disable the color and depth buffer. */
488 virtual void runAllOcclusionQueries(bool visible=false) =0;
489
490 //! Update occlusion query. Retrieves results from GPU.
491 /** If the query shall not block, set the flag to false.
492 Update might not occur in this case, though */
493 virtual void updateOcclusionQuery(scene::ISceneNode* node, bool block=true) =0;
494
495 //! Update all occlusion queries. Retrieves results from GPU.
496 /** If the query shall not block, set the flag to false.
497 Update might not occur in this case, though */
498 virtual void updateAllOcclusionQueries(bool block=true) =0;
499
500 //! Return query result.
501 /** Return value is the number of visible pixels/fragments.
502 The value is a safe approximation, i.e. can be larger than the
503 actual value of pixels. */
504 virtual u32 getOcclusionQueryResult(scene::ISceneNode* node) const =0;
505
506 //! Sets a boolean alpha channel on the texture based on a color key.
507 /** This makes the texture fully transparent at the texels where
508 this color key can be found when using for example draw2DImage
509 with useAlphachannel==true. The alpha of other texels is not modified.
510 \param texture Texture whose alpha channel is modified.
511 \param color Color key color. Every texel with this color will
512 become fully transparent as described above. Please note that the
513 colors of a texture may be converted when loading it, so the
514 color values may not be exactly the same in the engine and for
515 example in picture edit programs. To avoid this problem, you
516 could use the makeColorKeyTexture method, which takes the
517 position of a pixel instead a color value.
518 \param zeroTexels \deprecated If set to true, then any texels that match
519 the color key will have their color, as well as their alpha, set to zero
520 (i.e. black). This behavior matches the legacy (buggy) behavior prior
521 to release 1.5 and is provided for backwards compatibility only.
522 This parameter may be removed by Irrlicht 1.9. */
523 virtual void makeColorKeyTexture(video::ITexture* texture,
524 video::SColor color,
525 bool zeroTexels = false) const =0;
526
527 //! Sets a boolean alpha channel on the texture based on the color at a position.
528 /** This makes the texture fully transparent at the texels where
529 the color key can be found when using for example draw2DImage
530 with useAlphachannel==true. The alpha of other texels is not modified.
531 \param texture Texture whose alpha channel is modified.
532 \param colorKeyPixelPos Position of a pixel with the color key
533 color. Every texel with this color will become fully transparent as
534 described above.
535 \param zeroTexels \deprecated If set to true, then any texels that match
536 the color key will have their color, as well as their alpha, set to zero
537 (i.e. black). This behavior matches the legacy (buggy) behavior prior
538 to release 1.5 and is provided for backwards compatibility only.
539 This parameter may be removed by Irrlicht 1.9. */
540 virtual void makeColorKeyTexture(video::ITexture* texture,
541 core::position2d<s32> colorKeyPixelPos,
542 bool zeroTexels = false) const =0;
543
544 //! Creates a normal map from a height map texture.
545 /** If the target texture has 32 bit, the height value is
546 stored in the alpha component of the texture as addition. This
547 value is used by the video::EMT_PARALLAX_MAP_SOLID material and
548 similar materials.
549 \param texture Texture whose alpha channel is modified.
550 \param amplitude Constant value by which the height
551 information is multiplied.*/
552 virtual void makeNormalMapTexture(video::ITexture* texture, f32 amplitude=1.0f) const =0;
553
554 //! Sets a new render target.
555 /** This will only work if the driver supports the
556 EVDF_RENDER_TO_TARGET feature, which can be queried with
557 queryFeature(). Usually, rendering to textures is done in this
558 way:
559 \code
560 // create render target
561 ITexture* target = driver->addRenderTargetTexture(core::dimension2d<u32>(128,128), "rtt1");
562
563 // ...
564
565 driver->setRenderTarget(target); // set render target
566 // .. draw stuff here
567 driver->setRenderTarget(0); // set previous render target
568 \endcode
569 Please note that you cannot render 3D or 2D geometry with a
570 render target as texture on it when you are rendering the scene
571 into this render target at the same time. It is usually only
572 possible to render into a texture between the
573 IVideoDriver::beginScene() and endScene() method calls.
574 \param texture New render target. Must be a texture created with
575 IVideoDriver::addRenderTargetTexture(). If set to 0, it sets
576 the previous render target which was set before the last
577 setRenderTarget() call.
578 \param clearBackBuffer Clears the backbuffer of the render
579 target with the color parameter
580 \param clearZBuffer Clears the zBuffer of the rendertarget.
581 Note that because the frame buffer may share the zbuffer with
582 the rendertarget, its zbuffer might be partially cleared too
583 by this.
584 \param color The background color for the render target.
585 \return True if sucessful and false if not. */
586 virtual bool setRenderTarget(video::ITexture* texture,
587 bool clearBackBuffer=true, bool clearZBuffer=true,
588 SColor color=video::SColor(0,0,0,0)) =0;
589
590 //! set or reset special render targets
591 /** This method enables access to special color buffers such as
592 stereoscopic buffers or auxiliary buffers.
593 \param target Enum value for the render target
594 \param clearTarget Clears the target buffer with the color
595 parameter
596 \param clearZBuffer Clears the zBuffer of the rendertarget.
597 Note that because the main frame buffer may share the zbuffer with
598 the rendertarget, its zbuffer might be partially cleared too
599 by this.
600 \param color The background color for the render target.
601 \return True if sucessful and false if not. */
602 virtual bool setRenderTarget(E_RENDER_TARGET target, bool clearTarget=true,
603 bool clearZBuffer=true,
604 SColor color=video::SColor(0,0,0,0)) =0;
605
606 //! Sets new multiple render targets.
607 virtual bool setRenderTarget(const core::array<video::IRenderTarget>& texture,
608 bool clearBackBuffer=true, bool clearZBuffer=true,
609 SColor color=video::SColor(0,0,0,0)) =0;
610
611 //! Sets a new viewport.
612 /** Every rendering operation is done into this new area.
613 \param area: Rectangle defining the new area of rendering
614 operations. */
615 virtual void setViewPort(const core::rect<s32>& area) =0;
616
617 //! Gets the area of the current viewport.
618 /** \return Rectangle of the current viewport. */
619 virtual const core::rect<s32>& getViewPort() const =0;
620
621 //! Draws a vertex primitive list
622 /** Note that, depending on the index type, some vertices might be not
623 accessible through the index list. The limit is at 65535 vertices for 16bit
624 indices. Please note that currently not all primitives are available for
625 all drivers, and some might be emulated via triangle renders.
626 \param vertices Pointer to array of vertices.
627 \param vertexCount Amount of vertices in the array.
628 \param indexList Pointer to array of indices. These define the vertices used
629 for each primitive. Depending on the pType, indices are interpreted as single
630 objects (for point like primitives), pairs (for lines), triplets (for
631 triangles), or quads.
632 \param primCount Amount of Primitives
633 \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
634 \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
635 \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
636 virtual void drawVertexPrimitiveList(const void* vertices, u32 vertexCount,
637 const void* indexList, u32 primCount,
638 E_VERTEX_TYPE vType=EVT_STANDARD,
639 scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
640 E_INDEX_TYPE iType=EIT_16BIT) =0;
641
642 //! Draws a vertex primitive list in 2d
643 /** Compared to the general (3d) version of this method, this
644 one sets up a 2d render mode, and uses only x and y of vectors.
645 Note that, depending on the index type, some vertices might be
646 not accessible through the index list. The limit is at 65535
647 vertices for 16bit indices. Please note that currently not all
648 primitives are available for all drivers, and some might be
649 emulated via triangle renders. This function is not available
650 for the sw drivers.
651 \param vertices Pointer to array of vertices.
652 \param vertexCount Amount of vertices in the array.
653 \param indexList Pointer to array of indices. These define the
654 vertices used for each primitive. Depending on the pType,
655 indices are interpreted as single objects (for point like
656 primitives), pairs (for lines), triplets (for triangles), or
657 quads.
658 \param primCount Amount of Primitives
659 \param vType Vertex type, e.g. video::EVT_STANDARD for S3DVertex.
660 \param pType Primitive type, e.g. scene::EPT_TRIANGLE_FAN for a triangle fan.
661 \param iType Index type, e.g. video::EIT_16BIT for 16bit indices. */
662 virtual void draw2DVertexPrimitiveList(const void* vertices, u32 vertexCount,
663 const void* indexList, u32 primCount,
664 E_VERTEX_TYPE vType=EVT_STANDARD,
665 scene::E_PRIMITIVE_TYPE pType=scene::EPT_TRIANGLES,
666 E_INDEX_TYPE iType=EIT_16BIT) =0;
667
668 //! Draws an indexed triangle list.
669 /** Note that there may be at maximum 65536 vertices, because
670 the index list is an array of 16 bit values each with a maximum
671 value of 65536. If there are more than 65536 vertices in the
672 list, results of this operation are not defined.
673 \param vertices Pointer to array of vertices.
674 \param vertexCount Amount of vertices in the array.
675 \param indexList Pointer to array of indices.
676 \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
677 void drawIndexedTriangleList(const S3DVertex* vertices,
678 u32 vertexCount, const u16* indexList, u32 triangleCount)
679 {
680 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES, EIT_16BIT);
681 }
682
683 //! Draws an indexed triangle list.
684 /** Note that there may be at maximum 65536 vertices, because
685 the index list is an array of 16 bit values each with a maximum
686 value of 65536. If there are more than 65536 vertices in the
687 list, results of this operation are not defined.
688 \param vertices Pointer to array of vertices.
689 \param vertexCount Amount of vertices in the array.
690 \param indexList Pointer to array of indices.
691 \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
692 void drawIndexedTriangleList(const S3DVertex2TCoords* vertices,
693 u32 vertexCount, const u16* indexList, u32 triangleCount)
694 {
695 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES, EIT_16BIT);
696 }
697
698 //! Draws an indexed triangle list.
699 /** Note that there may be at maximum 65536 vertices, because
700 the index list is an array of 16 bit values each with a maximum
701 value of 65536. If there are more than 65536 vertices in the
702 list, results of this operation are not defined.
703 \param vertices Pointer to array of vertices.
704 \param vertexCount Amount of vertices in the array.
705 \param indexList Pointer to array of indices.
706 \param triangleCount Amount of Triangles. Usually amount of indices / 3. */
707 void drawIndexedTriangleList(const S3DVertexTangents* vertices,
708 u32 vertexCount, const u16* indexList, u32 triangleCount)
709 {
710 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES, EIT_16BIT);
711 }
712
713 //! Draws an indexed triangle fan.
714 /** Note that there may be at maximum 65536 vertices, because
715 the index list is an array of 16 bit values each with a maximum
716 value of 65536. If there are more than 65536 vertices in the
717 list, results of this operation are not defined.
718 \param vertices Pointer to array of vertices.
719 \param vertexCount Amount of vertices in the array.
720 \param indexList Pointer to array of indices.
721 \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
722 void drawIndexedTriangleFan(const S3DVertex* vertices,
723 u32 vertexCount, const u16* indexList, u32 triangleCount)
724 {
725 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
726 }
727
728 //! Draws an indexed triangle fan.
729 /** Note that there may be at maximum 65536 vertices, because
730 the index list is an array of 16 bit values each with a maximum
731 value of 65536. If there are more than 65536 vertices in the
732 list, results of this operation are not defined.
733 \param vertices Pointer to array of vertices.
734 \param vertexCount Amount of vertices in the array.
735 \param indexList Pointer to array of indices.
736 \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
737 void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
738 u32 vertexCount, const u16* indexList, u32 triangleCount)
739 {
740 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
741 }
742
743 //! Draws an indexed triangle fan.
744 /** Note that there may be at maximum 65536 vertices, because
745 the index list is an array of 16 bit values each with a maximum
746 value of 65536. If there are more than 65536 vertices in the
747 list, results of this operation are not defined.
748 \param vertices Pointer to array of vertices.
749 \param vertexCount Amount of vertices in the array.
750 \param indexList Pointer to array of indices.
751 \param triangleCount Amount of Triangles. Usually amount of indices - 2. */
752 void drawIndexedTriangleFan(const S3DVertexTangents* vertices,
753 u32 vertexCount, const u16* indexList, u32 triangleCount)
754 {
755 drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLE_FAN, EIT_16BIT);
756 }
757
758 //! Draws a 3d line.
759 /** For some implementations, this method simply calls
760 drawVertexPrimitiveList for some triangles.
761 Note that the line is drawn using the current transformation
762 matrix and material. So if you need to draw the 3D line
763 independently of the current transformation, use
764 \code
765 driver->setMaterial(someMaterial);
766 driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
767 \endcode
768 for some properly set up material before drawing the line.
769 Some drivers support line thickness set in the material.
770 \param start Start of the 3d line.
771 \param end End of the 3d line.
772 \param color Color of the line. */
773 virtual void draw3DLine(const core::vector3df& start,
774 const core::vector3df& end, SColor color = SColor(255,255,255,255)) =0;
775
776 //! Draws a 3d triangle.
777 /** This method calls drawVertexPrimitiveList for some triangles.
778 This method works with all drivers because it simply calls
779 drawVertexPrimitiveList, but it is hence not very fast.
780 Note that the triangle is drawn using the current
781 transformation matrix and material. So if you need to draw it
782 independently of the current transformation, use
783 \code
784 driver->setMaterial(someMaterial);
785 driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
786 \endcode
787 for some properly set up material before drawing the triangle.
788 \param triangle The triangle to draw.
789 \param color Color of the line. */
790 virtual void draw3DTriangle(const core::triangle3df& triangle,
791 SColor color = SColor(255,255,255,255)) =0;
792
793 //! Draws a 3d axis aligned box.
794 /** This method simply calls draw3DLine for the edges of the
795 box. Note that the box is drawn using the current transformation
796 matrix and material. So if you need to draw it independently of
797 the current transformation, use
798 \code
799 driver->setMaterial(someMaterial);
800 driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
801 \endcode
802 for some properly set up material before drawing the box.
803 \param box The axis aligned box to draw
804 \param color Color to use while drawing the box. */
805 virtual void draw3DBox(const core::aabbox3d<f32>& box,
806 SColor color = SColor(255,255,255,255)) =0;
807
808 //! Draws a 2d image without any special effects
809 /** \param texture Pointer to texture to use.
810 \param destPos Upper left 2d destination position where the
811 image will be drawn. */
812 virtual void draw2DImage(const video::ITexture* texture,
813 const core::position2d<s32>& destPos) =0;
814
815 //! Draws a 2d image using a color
816 /** (if color is other than
817 Color(255,255,255,255)) and the alpha channel of the texture.
818 \param texture Texture to be drawn.
819 \param destPos Upper left 2d destination position where the
820 image will be drawn.
821 \param sourceRect Source rectangle in the image.
822 \param clipRect Pointer to rectangle on the screen where the
823 image is clipped to.
824 If this pointer is NULL the image is not clipped.
825 \param color Color with which the image is drawn. If the color
826 equals Color(255,255,255,255) it is ignored. Note that the
827 alpha component is used: If alpha is other than 255, the image
828 will be transparent.
829 \param useAlphaChannelOfTexture: If true, the alpha channel of
830 the texture is used to draw the image.*/
831 virtual void draw2DImage(const video::ITexture* texture, const core::position2d<s32>& destPos,
832 const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
833 SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false) =0;
834
835 //! Draws a set of 2d images, using a color and the alpha channel of the texture.
836 /** The images are drawn beginning at pos and concatenated in
837 one line. All drawings are clipped against clipRect (if != 0).
838 The subtextures are defined by the array of sourceRects and are
839 chosen by the indices given.
840 \param texture Texture to be drawn.
841 \param pos Upper left 2d destination position where the image
842 will be drawn.
843 \param sourceRects Source rectangles of the image.
844 \param indices List of indices which choose the actual
845 rectangle used each time.
846 \param kerningWidth Offset to Position on X
847 \param clipRect Pointer to rectangle on the screen where the
848 image is clipped to.
849 If this pointer is 0 then the image is not clipped.
850 \param color Color with which the image is drawn.
851 Note that the alpha component is used. If alpha is other than
852 255, the image will be transparent.
853 \param useAlphaChannelOfTexture: If true, the alpha channel of
854 the texture is used to draw the image. */
855 virtual void draw2DImageBatch(const video::ITexture* texture,
856 const core::position2d<s32>& pos,
857 const core::array<core::rect<s32> >& sourceRects,
858 const core::array<s32>& indices,
859 s32 kerningWidth=0,
860 const core::rect<s32>* clipRect=0,
861 SColor color=SColor(255,255,255,255),
862 bool useAlphaChannelOfTexture=false) =0;
863
864 //! Draws a set of 2d images, using a color and the alpha channel of the texture.
865 /** All drawings are clipped against clipRect (if != 0).
866 The subtextures are defined by the array of sourceRects and are
867 positioned using the array of positions.
868 \param texture Texture to be drawn.
869 \param positions Array of upper left 2d destinations where the
870 images will be drawn.
871 \param sourceRects Source rectangles of the image.
872 \param clipRect Pointer to rectangle on the screen where the
873 images are clipped to.
874 If this pointer is 0 then the image is not clipped.
875 \param color Color with which the image is drawn.
876 Note that the alpha component is used. If alpha is other than
877 255, the image will be transparent.
878 \param useAlphaChannelOfTexture: If true, the alpha channel of
879 the texture is used to draw the image. */
880 virtual void draw2DImageBatch(const video::ITexture* texture,
881 const core::array<core::position2d<s32> >& positions,
882 const core::array<core::rect<s32> >& sourceRects,
883 const core::rect<s32>* clipRect=0,
884 SColor color=SColor(255,255,255,255),
885 bool useAlphaChannelOfTexture=false) =0;
886
887 //! Draws a part of the texture into the rectangle. Note that colors must be an array of 4 colors if used.
888 /** Suggested and first implemented by zola.
889 \param texture The texture to draw from
890 \param destRect The rectangle to draw into
891 \param sourceRect The rectangle denoting a part of the texture
892 \param clipRect Clips the destination rectangle (may be 0)
893 \param colors Array of 4 colors denoting the color values of
894 the corners of the destRect
895 \param useAlphaChannelOfTexture True if alpha channel will be
896 blended. */
897 virtual void draw2DImage(const video::ITexture* texture, const core::rect<s32>& destRect,
898 const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect =0,
899 const video::SColor * const colors=0, bool useAlphaChannelOfTexture=false) =0;
900
901 //! Draws a 2d rectangle.
902 /** \param color Color of the rectangle to draw. The alpha
903 component will not be ignored and specifies how transparent the
904 rectangle will be.
905 \param pos Position of the rectangle.
906 \param clip Pointer to rectangle against which the rectangle
907 will be clipped. If the pointer is null, no clipping will be
908 performed. */
909 virtual void draw2DRectangle(SColor color, const core::rect<s32>& pos,
910 const core::rect<s32>* clip =0) =0;
911
912 //! Draws a 2d rectangle with a gradient.
913 /** \param colorLeftUp Color of the upper left corner to draw.
914 The alpha component will not be ignored and specifies how
915 transparent the rectangle will be.
916 \param colorRightUp Color of the upper right corner to draw.
917 The alpha component will not be ignored and specifies how
918 transparent the rectangle will be.
919 \param colorLeftDown Color of the lower left corner to draw.
920 The alpha component will not be ignored and specifies how
921 transparent the rectangle will be.
922 \param colorRightDown Color of the lower right corner to draw.
923 The alpha component will not be ignored and specifies how
924 transparent the rectangle will be.
925 \param pos Position of the rectangle.
926 \param clip Pointer to rectangle against which the rectangle
927 will be clipped. If the pointer is null, no clipping will be
928 performed. */
929 virtual void draw2DRectangle(const core::rect<s32>& pos,
930 SColor colorLeftUp, SColor colorRightUp,
931 SColor colorLeftDown, SColor colorRightDown,
932 const core::rect<s32>* clip =0) =0;
933
934 //! Draws the outline of a 2D rectangle.
935 /** \param pos Position of the rectangle.
936 \param color Color of the rectangle to draw. The alpha component
937 specifies how transparent the rectangle outline will be. */
938 virtual void draw2DRectangleOutline(const core::recti& pos,
939 SColor color=SColor(255,255,255,255)) =0;
940
941 //! Draws a 2d line. Both start and end will be included in coloring.
942 /** \param start Screen coordinates of the start of the line
943 in pixels.
944 \param end Screen coordinates of the start of the line in
945 pixels.
946 \param color Color of the line to draw. */
947 virtual void draw2DLine(const core::position2d<s32>& start,
948 const core::position2d<s32>& end,
949 SColor color=SColor(255,255,255,255)) =0;
950
951 //! Draws a pixel.
952 /** \param x The x-position of the pixel.
953 \param y The y-position of the pixel.
954 \param color Color of the pixel to draw. */
955 virtual void drawPixel(u32 x, u32 y, const SColor& color) =0;
956
957 //! Draws a non filled concyclic regular 2d polyon.
958 /** This method can be used to draw circles, but also
959 triangles, tetragons, pentagons, hexagons, heptagons, octagons,
960 enneagons, decagons, hendecagons, dodecagon, triskaidecagons,
961 etc. I think you'll got it now. And all this by simply
962 specifying the vertex count. Welcome to the wonders of
963 geometry.
964 \param center Position of center of circle (pixels).
965 \param radius Radius of circle in pixels.
966 \param color Color of the circle.
967 \param vertexCount Amount of vertices of the polygon. Specify 2
968 to draw a line, 3 to draw a triangle, 4 for tetragons and a lot
969 (>10) for nearly a circle. */
970 virtual void draw2DPolygon(core::position2d<s32> center,
971 f32 radius,
972 video::SColor color=SColor(100,255,255,255),
973 s32 vertexCount=10) =0;
974
975 //! Draws a shadow volume into the stencil buffer.
976 /** To draw a stencil shadow, do this: First, draw all geometry.
977 Then use this method, to draw the shadow volume. Then, use
978 IVideoDriver::drawStencilShadow() to visualize the shadow.
979 Please note that the code for the opengl version of the method
980 is based on free code sent in by Philipp Dortmann, lots of
981 thanks go to him!
982 \param triangles Array of 3d vectors, specifying the shadow
983 volume.
984 \param zfail If set to true, zfail method is used, otherwise
985 zpass.
986 \param debugDataVisible The debug data that is enabled for this
987 shadow node
988 */
989 virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true, u32 debugDataVisible=0) =0;
990
991 //! Fills the stencil shadow with color.
992 /** After the shadow volume has been drawn into the stencil
993 buffer using IVideoDriver::drawStencilShadowVolume(), use this
994 to draw the color of the shadow.
995 Please note that the code for the opengl version of the method
996 is based on free code sent in by Philipp Dortmann, lots of
997 thanks go to him!
998 \param clearStencilBuffer Set this to false, if you want to
999 draw every shadow with the same color, and only want to call
1000 drawStencilShadow() once after all shadow volumes have been
1001 drawn. Set this to true, if you want to paint every shadow with
1002 its own color.
1003 \param leftUpEdge Color of the shadow in the upper left corner
1004 of screen.
1005 \param rightUpEdge Color of the shadow in the upper right
1006 corner of screen.
1007 \param leftDownEdge Color of the shadow in the lower left
1008 corner of screen.
1009 \param rightDownEdge Color of the shadow in the lower right
1010 corner of screen. */
1011 virtual void drawStencilShadow(bool clearStencilBuffer=false,
1012 video::SColor leftUpEdge = video::SColor(255,0,0,0),
1013 video::SColor rightUpEdge = video::SColor(255,0,0,0),
1014 video::SColor leftDownEdge = video::SColor(255,0,0,0),
1015 video::SColor rightDownEdge = video::SColor(255,0,0,0)) =0;
1016
1017 //! Draws a mesh buffer
1018 /** \param mb Buffer to draw */
1019 virtual void drawMeshBuffer(const scene::IMeshBuffer* mb) =0;
1020
1021 //! Draws normals of a mesh buffer
1022 /** \param mb Buffer to draw the normals of
1023 \param length length scale factor of the normals
1024 \param color Color the normals are rendered with
1025 */
1026 virtual void drawMeshBufferNormals(const scene::IMeshBuffer* mb, f32 length=10.f, SColor color=0xffffffff) =0;
1027
1028 //! Sets the fog mode.
1029 /** These are global values attached to each 3d object rendered,
1030 which has the fog flag enabled in its material.
1031 \param color Color of the fog
1032 \param fogType Type of fog used
1033 \param start Only used in linear fog mode (linearFog=true).
1034 Specifies where fog starts.
1035 \param end Only used in linear fog mode (linearFog=true).
1036 Specifies where fog ends.
1037 \param density Only used in exponential fog mode
1038 (linearFog=false). Must be a value between 0 and 1.
1039 \param pixelFog Set this to false for vertex fog, and true if
1040 you want per-pixel fog.
1041 \param rangeFog Set this to true to enable range-based vertex
1042 fog. The distance from the viewer is used to compute the fog,
1043 not the z-coordinate. This is better, but slower. This might not
1044 be available with all drivers and fog settings. */
1045 virtual void setFog(SColor color=SColor(0,255,255,255),
1046 E_FOG_TYPE fogType=EFT_FOG_LINEAR,
1047 f32 start=50.0f, f32 end=100.0f, f32 density=0.01f,
1048 bool pixelFog=false, bool rangeFog=false) =0;
1049
1050 //! Gets the fog mode.
1051 virtual void getFog(SColor& color, E_FOG_TYPE& fogType,
1052 f32& start, f32& end, f32& density,
1053 bool& pixelFog, bool& rangeFog) = 0;
1054
1055 //! Get the current color format of the color buffer
1056 /** \return Color format of the color buffer. */
1057 virtual ECOLOR_FORMAT getColorFormat() const =0;
1058
1059 //! Get the size of the screen or render window.
1060 /** \return Size of screen or render window. */
1061 virtual const core::dimension2d<u32>& getScreenSize() const =0;
1062
1063 //! Get the size of the current render target
1064 /** This method will return the screen size if the driver
1065 doesn't support render to texture, or if the current render
1066 target is the screen.
1067 \return Size of render target or screen/window */
1068 virtual const core::dimension2d<u32>& getCurrentRenderTargetSize() const =0;
1069
1070 //! Returns current frames per second value.
1071 /** This value is updated approximately every 1.5 seconds and
1072 is only intended to provide a rough guide to the average frame
1073 rate. It is not suitable for use in performing timing
1074 calculations or framerate independent movement.
1075 \return Approximate amount of frames per second drawn. */
1076 virtual s32 getFPS() const =0;
1077
1078 //! Returns amount of primitives (mostly triangles) which were drawn in the last frame.
1079 /** Together with getFPS() very useful method for statistics.
1080 \param mode Defines if the primitives drawn are accumulated or
1081 counted per frame.
1082 \return Amount of primitives drawn in the last frame. */
1083 virtual u32 getPrimitiveCountDrawn( u32 mode =0 ) const =0;
1084
1085 //! Deletes all dynamic lights which were previously added with addDynamicLight().
1086 virtual void deleteAllDynamicLights() =0;
1087
1088 //! adds a dynamic light, returning an index to the light
1089 //! \param light: the light data to use to create the light
1090 //! \return An index to the light, or -1 if an error occurs
1091 virtual s32 addDynamicLight(const SLight& light) =0;
1092
1093 //! Returns the maximal amount of dynamic lights the device can handle
1094 /** \return Maximal amount of dynamic lights. */
1095 virtual u32 getMaximalDynamicLightAmount() const =0;
1096
1097 //! Returns amount of dynamic lights currently set
1098 /** \return Amount of dynamic lights currently set */
1099 virtual u32 getDynamicLightCount() const =0;
1100
1101 //! Returns light data which was previously set by IVideoDriver::addDynamicLight().
1102 /** \param idx Zero based index of the light. Must be 0 or
1103 greater and smaller than IVideoDriver::getDynamicLightCount.
1104 \return Light data. */
1105 virtual const SLight& getDynamicLight(u32 idx) const =0;
1106
1107 //! Turns a dynamic light on or off
1108 //! \param lightIndex: the index returned by addDynamicLight
1109 //! \param turnOn: true to turn the light on, false to turn it off
1110 virtual void turnLightOn(s32 lightIndex, bool turnOn) =0;
1111
1112 //! Gets name of this video driver.
1113 /** \return Returns the name of the video driver, e.g. in case
1114 of the Direct3D8 driver, it would return "Direct3D 8.1". */
1115 virtual const wchar_t* getName() const =0;
1116
1117 //! Adds an external image loader to the engine.
1118 /** This is useful if the Irrlicht Engine should be able to load
1119 textures of currently unsupported file formats (e.g. gif). The
1120 IImageLoader only needs to be implemented for loading this file
1121 format. A pointer to the implementation can be passed to the
1122 engine using this method.
1123 \param loader Pointer to the external loader created. */
1124 virtual void addExternalImageLoader(IImageLoader* loader) =0;
1125
1126 //! Adds an external image writer to the engine.
1127 /** This is useful if the Irrlicht Engine should be able to
1128 write textures of currently unsupported file formats (e.g
1129 .gif). The IImageWriter only needs to be implemented for
1130 writing this file format. A pointer to the implementation can
1131 be passed to the engine using this method.
1132 \param writer: Pointer to the external writer created. */
1133 virtual void addExternalImageWriter(IImageWriter* writer) =0;
1134
1135 //! Returns the maximum amount of primitives
1136 /** (mostly vertices) which the device is able to render with
1137 one drawVertexPrimitiveList call.
1138 \return Maximum amount of primitives. */
1139 virtual u32 getMaximalPrimitiveCount() const =0;
1140
1141 //! Enables or disables a texture creation flag.
1142 /** These flags define how textures should be created. By
1143 changing this value, you can influence for example the speed of
1144 rendering a lot. But please note that the video drivers take
1145 this value only as recommendation. It could happen that you
1146 enable the ETCF_ALWAYS_16_BIT mode, but the driver still creates
1147 32 bit textures.
1148 \param flag Texture creation flag.
1149 \param enabled Specifies if the given flag should be enabled or
1150 disabled. */
1151 virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled=true) =0;
1152
1153 //! Returns if a texture creation flag is enabled or disabled.
1154 /** You can change this value using setTextureCreationFlag().
1155 \param flag Texture creation flag.
1156 \return The current texture creation flag enabled mode. */
1157 virtual bool getTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag) const =0;
1158
1159 //! Creates a software image from a file.
1160 /** No hardware texture will be created for this image. This
1161 method is useful for example if you want to read a heightmap
1162 for a terrain renderer.
1163 \param filename Name of the file from which the image is
1164 created.
1165 \return The created image.
1166 If you no longer need the image, you should call IImage::drop().
1167 See IReferenceCounted::drop() for more information. */
1168 virtual IImage* createImageFromFile(const io::path& filename) = 0;
1169
1170 //! Creates a software image from a file.
1171 /** No hardware texture will be created for this image. This
1172 method is useful for example if you want to read a heightmap
1173 for a terrain renderer.
1174 \param file File from which the image is created.
1175 \return The created image.
1176 If you no longer need the image, you should call IImage::drop().
1177 See IReferenceCounted::drop() for more information. */
1178 virtual IImage* createImageFromFile(io::IReadFile* file) =0;
1179
1180 //! Writes the provided image to a file.
1181 /** Requires that there is a suitable image writer registered
1182 for writing the image.
1183 \param image Image to write.
1184 \param filename Name of the file to write.
1185 \param param Control parameter for the backend (e.g. compression
1186 level).
1187 \return True on successful write. */
1188 virtual bool writeImageToFile(IImage* image, const io::path& filename, u32 param = 0) = 0;
1189
1190 //! Writes the provided image to a file.
1191 /** Requires that there is a suitable image writer registered
1192 for writing the image.
1193 \param image Image to write.
1194 \param file An already open io::IWriteFile object. The name
1195 will be used to determine the appropriate image writer to use.
1196 \param param Control parameter for the backend (e.g. compression
1197 level).
1198 \return True on successful write. */
1199 virtual bool writeImageToFile(IImage* image, io::IWriteFile* file, u32 param =0) =0;
1200
1201 //! Creates a software image from a byte array.
1202 /** No hardware texture will be created for this image. This
1203 method is useful for example if you want to read a heightmap
1204 for a terrain renderer.
1205 \param format Desired color format of the texture
1206 \param size Desired size of the image
1207 \param data A byte array with pixel color information
1208 \param ownForeignMemory If true, the image will use the data
1209 pointer directly and own it afterwards. If false, the memory
1210 will by copied internally.
1211 \param deleteMemory Whether the memory is deallocated upon
1212 destruction.
1213 \return The created image.
1214 If you no longer need the image, you should call IImage::drop().
1215 See IReferenceCounted::drop() for more information. */
1216 virtual IImage* createImageFromData(ECOLOR_FORMAT format,
1217 const core::dimension2d<u32>& size, void *data,
1218 bool ownForeignMemory=false,
1219 bool deleteMemory = true) =0;
1220
1221 //! Creates an empty software image.
1222 /**
1223 \param format Desired color format of the image.
1224 \param size Size of the image to create.
1225 \return The created image.
1226 If you no longer need the image, you should call IImage::drop().
1227 See IReferenceCounted::drop() for more information. */
1228 virtual IImage* createImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size) =0;
1229
1230 //! Creates a software image by converting it to given format from another image.
1231 /** \deprecated Create an empty image and use copyTo(). This method may be removed by Irrlicht 1.9.
1232 \param format Desired color format of the image.
1233 \param imageToCopy Image to copy to the new image.
1234 \return The created image.
1235 If you no longer need the image, you should call IImage::drop().
1236 See IReferenceCounted::drop() for more information. */
1237 _IRR_DEPRECATED_ virtual IImage* createImage(ECOLOR_FORMAT format, IImage *imageToCopy) =0;
1238
1239 //! Creates a software image from a part of another image.
1240 /** \deprecated Create an empty image and use copyTo(). This method may be removed by Irrlicht 1.9.
1241 \param imageToCopy Image to copy to the new image in part.
1242 \param pos Position of rectangle to copy.
1243 \param size Extents of rectangle to copy.
1244 \return The created image.
1245 If you no longer need the image, you should call IImage::drop().
1246 See IReferenceCounted::drop() for more information. */
1247 _IRR_DEPRECATED_ virtual IImage* createImage(IImage* imageToCopy,
1248 const core::position2d<s32>& pos,
1249 const core::dimension2d<u32>& size) =0;
1250
1251 //! Creates a software image from a part of a texture.
1252 /**
1253 \param texture Texture to copy to the new image in part.
1254 \param pos Position of rectangle to copy.
1255 \param size Extents of rectangle to copy.
1256 \return The created image.
1257 If you no longer need the image, you should call IImage::drop().
1258 See IReferenceCounted::drop() for more information. */
1259 virtual IImage* createImage(ITexture* texture,
1260 const core::position2d<s32>& pos,
1261 const core::dimension2d<u32>& size) =0;
1262
1263 //! Event handler for resize events. Only used by the engine internally.
1264 /** Used to notify the driver that the window was resized.
1265 Usually, there is no need to call this method. */
1266 virtual void OnResize(const core::dimension2d<u32>& size) =0;
1267
1268 //! Adds a new material renderer to the video device.
1269 /** Use this method to extend the VideoDriver with new material
1270 types. To extend the engine using this method do the following:
1271 Derive a class from IMaterialRenderer and override the methods
1272 you need. For setting the right renderstates, you can try to
1273 get a pointer to the real rendering device using
1274 IVideoDriver::getExposedVideoData(). Add your class with
1275 IVideoDriver::addMaterialRenderer(). To use an object being
1276 displayed with your new material, set the MaterialType member of
1277 the SMaterial struct to the value returned by this method.
1278 If you simply want to create a new material using vertex and/or
1279 pixel shaders it would be easier to use the
1280 video::IGPUProgrammingServices interface which you can get
1281 using the getGPUProgrammingServices() method.
1282 \param renderer A pointer to the new renderer.
1283 \param name Optional name for the material renderer entry.
1284 \return The number of the material type which can be set in
1285 SMaterial::MaterialType to use the renderer. -1 is returned if
1286 an error occured. For example if you tried to add an material
1287 renderer to the software renderer or the null device, which do
1288 not accept material renderers. */
1289 virtual s32 addMaterialRenderer(IMaterialRenderer* renderer, const c8* name =0) =0;
1290
1291 //! Get access to a material renderer by index.
1292 /** \param idx Id of the material renderer. Can be a value of
1293 the E_MATERIAL_TYPE enum or a value which was returned by
1294 addMaterialRenderer().
1295 \return Pointer to material renderer or null if not existing. */
1296 virtual IMaterialRenderer* getMaterialRenderer(u32 idx) =0;
1297
1298 //! Get amount of currently available material renderers.
1299 /** \return Amount of currently available material renderers. */
1300 virtual u32 getMaterialRendererCount() const =0;
1301
1302 //! Get name of a material renderer
1303 /** This string can, e.g., be used to test if a specific
1304 renderer already has been registered/created, or use this
1305 string to store data about materials: This returned name will
1306 be also used when serializing materials.
1307 \param idx Id of the material renderer. Can be a value of the
1308 E_MATERIAL_TYPE enum or a value which was returned by
1309 addMaterialRenderer().
1310 \return String with the name of the renderer, or 0 if not
1311 exisiting */
1312 virtual const c8* getMaterialRendererName(u32 idx) const =0;
1313
1314 //! Sets the name of a material renderer.
1315 /** Will have no effect on built-in material renderers.
1316 \param idx: Id of the material renderer. Can be a value of the
1317 E_MATERIAL_TYPE enum or a value which was returned by
1318 addMaterialRenderer().
1319 \param name: New name of the material renderer. */
1320 virtual void setMaterialRendererName(s32 idx, const c8* name) =0;
1321
1322 //! Creates material attributes list from a material
1323 /** This method is useful for serialization and more.
1324 Please note that the video driver will use the material
1325 renderer names from getMaterialRendererName() to write out the
1326 material type name, so they should be set before.
1327 \param material The material to serialize.
1328 \param options Additional options which might influence the
1329 serialization.
1330 \return The io::IAttributes container holding the material
1331 properties. */
1332 virtual io::IAttributes* createAttributesFromMaterial(const video::SMaterial& material,
1333 io::SAttributeReadWriteOptions* options=0) =0;
1334
1335 //! Fills an SMaterial structure from attributes.
1336 /** Please note that for setting material types of the
1337 material, the video driver will need to query the material
1338 renderers for their names, so all non built-in materials must
1339 have been created before calling this method.
1340 \param outMaterial The material to set the properties for.
1341 \param attributes The attributes to read from. */
1342 virtual void fillMaterialStructureFromAttributes(video::SMaterial& outMaterial, io::IAttributes* attributes) =0;
1343
1344 //! Returns driver and operating system specific data about the IVideoDriver.
1345 /** This method should only be used if the engine should be
1346 extended without having to modify the source of the engine.
1347 \return Collection of device dependent pointers. */
1348 virtual const SExposedVideoData& getExposedVideoData() =0;
1349
1350 //! Get type of video driver
1351 /** \return Type of driver. */
1352 virtual E_DRIVER_TYPE getDriverType() const =0;
1353
1354 //! Gets the IGPUProgrammingServices interface.
1355 /** \return Pointer to the IGPUProgrammingServices. Returns 0
1356 if the video driver does not support this. For example the
1357 Software driver and the Null driver will always return 0. */
1358 virtual IGPUProgrammingServices* getGPUProgrammingServices() =0;
1359
1360 //! Returns a pointer to the mesh manipulator.
1361 virtual scene::IMeshManipulator* getMeshManipulator() =0;
1362
1363 //! Clears the ZBuffer.
1364 /** Note that you usually need not to call this method, as it
1365 is automatically done in IVideoDriver::beginScene() or
1366 IVideoDriver::setRenderTarget() if you enable zBuffer. But if
1367 you have to render some special things, you can clear the
1368 zbuffer during the rendering process with this method any time.
1369 */
1370 virtual void clearZBuffer() =0;
1371
1372 //! Make a screenshot of the last rendered frame.
1373 /** \return An image created from the last rendered frame. */
1374 virtual IImage* createScreenShot(video::ECOLOR_FORMAT format=video::ECF_UNKNOWN, video::E_RENDER_TARGET target=video::ERT_FRAME_BUFFER) =0;
1375
1376 //! Check if the image is already loaded.
1377 /** Works similar to getTexture(), but does not load the texture
1378 if it is not currently loaded.
1379 \param filename Name of the texture.
1380 \return Pointer to loaded texture, or 0 if not found. */
1381 virtual video::ITexture* findTexture(const io::path& filename) = 0;
1382
1383 //! Set or unset a clipping plane.
1384 /** There are at least 6 clipping planes available for the user
1385 to set at will.
1386 \param index The plane index. Must be between 0 and
1387 MaxUserClipPlanes.
1388 \param plane The plane itself.
1389 \param enable If true, enable the clipping plane else disable
1390 it.
1391 \return True if the clipping plane is usable. */
1392 virtual bool setClipPlane(u32 index, const core::plane3df& plane, bool enable=false) =0;
1393
1394 //! Enable or disable a clipping plane.
1395 /** There are at least 6 clipping planes available for the user
1396 to set at will.
1397 \param index The plane index. Must be between 0 and
1398 MaxUserClipPlanes.
1399 \param enable If true, enable the clipping plane else disable
1400 it. */
1401 virtual void enableClipPlane(u32 index, bool enable) =0;
1402
1403 //! Set the minimum number of vertices for which a hw buffer will be created
1404 /** \param count Number of vertices to set as minimum. */
1405 virtual void setMinHardwareBufferVertexCount(u32 count) =0;
1406
1407 //! Get the global Material, which might override local materials.
1408 /** Depending on the enable flags, values from this Material
1409 are used to override those of local materials of some
1410 meshbuffer being rendered.
1411 \return Reference to the Override Material. */
1412 virtual SOverrideMaterial& getOverrideMaterial() =0;
1413
1414 //! Get the 2d override material for altering its values
1415 /** The 2d override materual allows to alter certain render
1416 states of the 2d methods. Not all members of SMaterial are
1417 honored, especially not MaterialType and Textures. Moreover,
1418 the zbuffer is always ignored, and lighting is always off. All
1419 other flags can be changed, though some might have to effect
1420 in most cases.
1421 Please note that you have to enable/disable this effect with
1422 enableInitMaterial2D(). This effect is costly, as it increases
1423 the number of state changes considerably. Always reset the
1424 values when done.
1425 \return Material reference which should be altered to reflect
1426 the new settings.
1427 */
1428 virtual SMaterial& getMaterial2D() =0;
1429
1430 //! Enable the 2d override material
1431 /** \param enable Flag which tells whether the material shall be
1432 enabled or disabled. */
1433 virtual void enableMaterial2D(bool enable=true) =0;
1434
1435 //! Get the graphics card vendor name.
1436 virtual core::stringc getVendorInfo() =0;
1437
1438 //! Only used by the engine internally.
1439 /** The ambient color is set in the scene manager, see
1440 scene::ISceneManager::setAmbientLight().
1441 \param color New color of the ambient light. */
1442 virtual void setAmbientLight(const SColorf& color) =0;
1443
1444 //! Only used by the engine internally.
1445 /** Passes the global material flag AllowZWriteOnTransparent.
1446 Use the SceneManager attribute to set this value from your app.
1447 \param flag Default behavior is to disable ZWrite, i.e. false. */
1448 virtual void setAllowZWriteOnTransparent(bool flag) =0;
1449
1450 //! Get the maximum texture size supported.
1451 virtual core::dimension2du getMaxTextureSize() const =0;
1452
1453 //! Color conversion convenience function
1454 /** Convert an image (as array of pixels) from source to destination
1455 array, thereby converting the color format. The pixel size is
1456 determined by the color formats.
1457 \param sP Pointer to source
1458 \param sF Color format of source
1459 \param sN Number of pixels to convert, both array must be large enough
1460 \param dP Pointer to destination
1461 \param dF Color format of destination
1462 */
1463 virtual void convertColor(const void* sP, ECOLOR_FORMAT sF, s32 sN,
1464 void* dP, ECOLOR_FORMAT dF) const =0;
1465 };
1466
1467} // end namespace video
1468} // end namespace irr
1469
1470
1471#endif