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