diff -r -uw -N irrlicht/include/EDriverTypes.h irrlicht_multipatch/include/EDriverTypes.h
--- irrlicht/include/EDriverTypes.h	2006-09-24 11:31:06.000000000 +0200
+++ irrlicht_multipatch/include/EDriverTypes.h	2006-11-30 17:22:12.000000000 +0100
@@ -42,6 +42,10 @@
 		//! Win2K, WinXP. Performs hardware accelerated rendering of 3D and 2D primitives.
 		EDT_DIRECT3D9,
 
+		//! Direct3D 9 multihead device, only available on Win32 platforms including Win95, Win98, WinNT,
+		//! Win2K, WinXP.
+		EDT_DIRECT3D9_MULTIHEAD,
+
 		//! OpenGL device, available on all Win32 platforms and on Linux.
 		//! Performs hardware accelerated rendering of 3D and 2D primitives.
 		EDT_OPENGL    
diff -r -uw -N irrlicht/include/IEventReceiver.h irrlicht_multipatch/include/IEventReceiver.h
--- irrlicht/include/IEventReceiver.h	2006-11-11 09:29:20.000000000 +0100
+++ irrlicht_multipatch/include/IEventReceiver.h	2006-12-01 13:16:06.000000000 +0100
@@ -116,6 +116,9 @@
 			//! In an editbox was pressed 'ENTER'
 			EGET_EDITBOX_ENTER,
 
+			//! In a edit box was press a key
+			EGET_EDITBOX_KEY_PRESS,
+
 			//! The tab was changed in an tab control
 			EGET_TAB_CHANGED,
 
@@ -123,7 +126,10 @@
 			EGET_MENU_ITEM_SELECTED,
 
 			//! The selection in a combo box has been changed
-			EGET_COMBO_BOX_CHANGED
+			EGET_COMBO_BOX_CHANGED,
+
+			//! The window has closed
+			EGET_WINDOW_CLOSED
 		};
 	} // end namespace gui
 
diff -r -uw -N irrlicht/include/IGUIContextMenu.h irrlicht_multipatch/include/IGUIContextMenu.h
--- irrlicht/include/IGUIContextMenu.h	2006-06-17 08:12:14.000000000 +0200
+++ irrlicht_multipatch/include/IGUIContextMenu.h	2006-11-30 12:36:04.000000000 +0100
@@ -38,7 +38,7 @@
 		 at this item. You can acess this submenu via getSubMenu().
 		 \return Returns the index of the new item */
 		virtual s32 addItem(const wchar_t* text, s32 commandId=-1, bool enabled=true,
-			bool hasSubMenu=false) = 0;
+			bool hasSubMenu=false, bool checked=false) = 0;
 
 		//! Adds a separator item to the menu
 		virtual void addSeparator() = 0;
@@ -61,6 +61,15 @@
 		 \param enabled: True if it is enabled, otherwise false. */
 		virtual void setItemEnabled(s32 idx, bool enabled) = 0;
 
+		//! Returns if a menu item is checked
+		/** \param idx: Zero based index of the menu item */
+		virtual bool isItemChecked(s32 idx) = 0;
+
+		//! Sets if the menu item should be checked.
+		/** \param idx: Zero based index of the menu item
+		 \param enabled: True if it is checked, otherwise false. */
+		virtual void setItemChecked(s32 idx, bool checked) = 0;
+
 		//! Removes a menu item
 		/** \param idx: Zero based index of the menu item */
 		virtual void removeItem(s32 idx) = 0;
diff -r -uw -N irrlicht/include/IMaterialRenderer.h irrlicht_multipatch/include/IMaterialRenderer.h
--- irrlicht/include/IMaterialRenderer.h	2006-06-21 08:16:08.000000000 +0200
+++ irrlicht_multipatch/include/IMaterialRenderer.h	2006-11-30 16:54:58.000000000 +0100
@@ -87,6 +87,14 @@
 	Fixed function pipeline materials should return 0 in most cases, parallax mapped
 	material will only return 0 when at least pixel shader 1.4 is available on that machine. */
 	virtual s32 getRenderCapability() { return 0; }
+
+	//!Sets a device adapter index number
+	virtual void setRenderDevice(s32 deviceIdx = 0)
+	{
+		deviceIndex = deviceIdx;
+	}
+protected:
+	u32 deviceIndex;
 };
 
 
diff -r -uw -N irrlicht/include/IMeshBuffer.h irrlicht_multipatch/include/IMeshBuffer.h
--- irrlicht/include/IMeshBuffer.h	2006-08-29 08:12:58.000000000 +0200
+++ irrlicht_multipatch/include/IMeshBuffer.h	2006-11-29 21:51:46.000000000 +0100
@@ -80,10 +80,10 @@
 		virtual s32 getVertexCount() const = 0;
 
 		//! returns pointer to Indices
-		virtual const u16* getIndices() const = 0;
+		virtual const u32* getIndices() const = 0;
 
 		//! returns pointer to Indices
-		virtual u16* getIndices() = 0;
+		virtual u32* getIndices() = 0;
 
 		//! returns amount of indices
 		virtual s32 getIndexCount() const = 0;
diff -r -uw -N irrlicht/include/ISceneManager.h irrlicht_multipatch/include/ISceneManager.h
--- irrlicht/include/ISceneManager.h	2006-11-11 09:31:16.000000000 +0100
+++ irrlicht_multipatch/include/ISceneManager.h	2006-12-03 16:20:12.000000000 +0100
@@ -777,6 +777,13 @@
 		virtual void registerNodeForRendering(ISceneNode* node,
 			E_SCENE_NODE_RENDER_PASS pass = ESNRP_AUTOMATIC) = 0;
 
+		//! Update effects of all the scene nodes.
+		/** This can only be invoked between
+		 IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that
+		 the scene is not only drawn when calling this, but also animated
+		 by existing scene node animators, culling of scene nodes is done, etc. */
+		virtual void updateEffects() = 0;
+
 		//! Draws all the scene nodes.
 		/** This can only be invoked between
 		 IVideoDriver::beginScene() and IVideoDriver::endScene(). Please note that
@@ -828,7 +835,7 @@
 		 If you no longer need the animator, you should call ISceneNodeAnimator::drop().
 		 See IUnknown::drop() for more information. */
 		virtual ISceneNodeAnimator* createTextureAnimator(const core::array<video::ITexture*>& textures,
-			s32 timePerFrame, bool loop=true) = 0;
+			s32 timePerFrame, bool loop=true, s32 layer=0) = 0;
 
 		//! Creates a scene node animator, which deletes the scene node after some time automatically.
 		/** \param timeMs: Time in milliseconds, after when the node will be deleted.
diff -r -uw -N irrlicht/include/ISceneNode.h irrlicht_multipatch/include/ISceneNode.h
--- irrlicht/include/ISceneNode.h	2006-10-15 08:48:52.000000000 +0200
+++ irrlicht_multipatch/include/ISceneNode.h	2006-12-03 16:30:56.000000000 +0100
@@ -66,6 +66,18 @@
 		}
 
 
+		//! This method is called just before the whole rendering process of the whole scene.
+		//! not calling their OnUpdateEffect-Method.
+		virtual void OnUpdateEffect()
+		{
+			if (IsVisible)
+			{
+				core::list<ISceneNode*>::Iterator it = Children.begin();
+				for (; it != Children.end(); ++it)
+					(*it)->OnUpdateEffect();
+			}
+		}
+
 		//! This method is called just before the rendering process of the whole scene.
 		//! Nodes may register themselves in the render pipeline during this call,
 		//! precalculate the geometry which should be renderered, and prevent their
diff -r -uw -N irrlicht/include/ITerrainSceneNode.h irrlicht_multipatch/include/ITerrainSceneNode.h
--- irrlicht/include/ITerrainSceneNode.h	2006-10-15 08:48:56.000000000 +0200
+++ irrlicht_multipatch/include/ITerrainSceneNode.h	2006-12-01 14:46:08.000000000 +0100
@@ -67,6 +67,9 @@
 		//! Returns pointer to the mesh
 		virtual IMesh* getMesh() = 0;
 
+		//!a helper function to destroy the meshbuffer.
+		virtual void destroyMeshBuffer(SMeshBufferLightMap& mb) = 0;
+
 		//! Gets the meshbuffer data based on a specified level of detail.
 		/** \param mb: A reference to an SMeshBuffer object
 		 \param LOD: the level of detail you want the indices from. */
diff -r -uw -N irrlicht/include/IVideoDriver.h irrlicht_multipatch/include/IVideoDriver.h
--- irrlicht/include/IVideoDriver.h	2006-11-25 13:46:54.000000000 +0100
+++ irrlicht_multipatch/include/IVideoDriver.h	2006-12-05 11:50:56.000000000 +0100
@@ -165,7 +165,7 @@
 		/** Returns true if a feature is available
 		\param feature: A feature to query.
 		\return Returns true if the feature is available, false if not. */
-		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature) = 0;
+		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1) = 0;
 
 		//! Sets the view, world or projection transformation.
 		/* \param state: Transformation type to be set. Can be view, world or projection.
@@ -360,7 +360,7 @@
 		\param triangleCount: amount of Triangles.
 		\param vType: Vertex type, e.g. EVT_STANDARD for S3DVertex.
 		\param pType: Primitive type, e.g. EPT_TRIANGLE_FAN for a triangle fan. */
-		virtual void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) = 0;
+		virtual void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType) = 0;
 
 		//! Draws an indexed triangle list.
 		/** Note that there may be at maximum 65536 vertices, because the
@@ -372,7 +372,7 @@
 		\param indexList: Pointer to array of indizes.
 		\param triangleCount: amount of Triangles. Usually amount of indizes / 3. */
 		virtual void drawIndexedTriangleList(const S3DVertex* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount) = 0;
+			s32 vertexCount, const u32* indexList, s32 triangleCount) = 0;
 
 		//! Draws an indexed triangle list.
 		/** Note that there may be at maximum 65536 vertices, because the
@@ -384,7 +384,7 @@
 		\param indexList: Pointer to array of indizes.
 		\param triangleCount: amount of Triangles. Usually amount of indizes / 3.*/
 		virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount) = 0;
+			s32 vertexCount, const u32* indexList, s32 triangleCount) = 0;
 
 		//! Draws an indexed triangle list.
 		/** Note that there may be at maximum 65536 vertices, because the
@@ -396,7 +396,7 @@
 		\param indexList: Pointer to array of indizes.
 		\param triangleCount: amount of Triangles. Usually amount of indizes / 3. */
 		virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount) = 0;
+			s32 vertexCount, const u32* indexList, s32 triangleCount) = 0;
 
 		//! Draws an indexed triangle fan.
 		/** Note that there may be at maximum 65536 vertices, because the
@@ -410,7 +410,7 @@
 		\param indexList: Pointer to array of indizes.
 		\param triangleCount: amount of Triangles. Usually amount of indizes - 2. */
 		virtual void drawIndexedTriangleFan(const S3DVertex* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount) = 0;
+			s32 vertexCount, const u32* indexList, s32 triangleCount) = 0;
 
 		//! Draws an indexed triangle fan.
 		/** Note that there may be at maximum 65536 vertices, because the
@@ -424,7 +424,7 @@
 		\param indexList: Pointer to array of indizes.
 		\param triangleCount: amount of Triangles. Usually amount of indizes - 2. */
 		virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount) = 0;
+			s32 vertexCount, const u32* indexList, s32 triangleCount) = 0;
 
 		//! Draws a 3d line.
 		/** For some implementations, this method simply calls drawIndexedTriangles with some
diff -r -uw -N irrlicht/include/SMeshBuffer.h irrlicht_multipatch/include/SMeshBuffer.h
--- irrlicht/include/SMeshBuffer.h	2006-08-29 08:12:58.000000000 +0200
+++ irrlicht_multipatch/include/SMeshBuffer.h	2006-11-29 21:55:30.000000000 +0100
@@ -57,13 +57,13 @@
 		}
 
 		//! returns pointer to Indices
-		virtual const u16* getIndices() const
+		virtual const u32* getIndices() const
 		{
 			return Indices.const_pointer();
 		}
 
 		//! returns pointer to Indices
-		virtual u16* getIndices()
+		virtual u32* getIndices()
 		{
 			return Indices.pointer();
 		}
@@ -107,7 +107,7 @@
 
 		video::SMaterial Material; //! material for this meshBuffer.
 		core::array<video::S3DVertex> Vertices; //! Array of vertices
-		core::array<u16> Indices; //! Array of the Indices.
+		core::array<u32> Indices; //! Array of the Indices.
 		core::aabbox3d<f32> BoundingBox;
 	};
 
diff -r -uw -N irrlicht/include/SMeshBufferLightMap.h irrlicht_multipatch/include/SMeshBufferLightMap.h
--- irrlicht/include/SMeshBufferLightMap.h	2006-08-29 08:12:58.000000000 +0200
+++ irrlicht_multipatch/include/SMeshBufferLightMap.h	2006-11-29 21:56:34.000000000 +0100
@@ -58,13 +58,13 @@
 		}
 
 		//! returns pointer to Indices
-		virtual const u16* getIndices() const
+		virtual const u32* getIndices() const
 		{
 			return Indices.const_pointer();
 		}
 
 		//! returns pointer to Indices
-		virtual u16* getIndices()
+		virtual u32* getIndices()
 		{
 			return Indices.pointer();
 		}
@@ -108,7 +108,7 @@
 
 		video::SMaterial Material; //! material for this meshBuffer.
 		core::array<video::S3DVertex2TCoords> Vertices; //! Array of vertices
-		core::array<u16> Indices; //! Array of the Indices.
+		core::array<u32> Indices; //! Array of the Indices.
 		core::aabbox3d<f32> BoundingBox;
 	};
 
diff -r -uw -N irrlicht/include/SMeshBufferTangents.h irrlicht_multipatch/include/SMeshBufferTangents.h
--- irrlicht/include/SMeshBufferTangents.h	2006-08-29 08:12:58.000000000 +0200
+++ irrlicht_multipatch/include/SMeshBufferTangents.h	2006-11-29 21:57:30.000000000 +0100
@@ -57,13 +57,13 @@
 		}
 
 		//! returns pointer to Indices
-		virtual const u16* getIndices() const
+		virtual const u32* getIndices() const
 		{
 			return Indices.const_pointer();
 		}
 
 		//! returns pointer to Indices
-		virtual u16* getIndices()
+		virtual u32* getIndices()
 		{
 			return Indices.pointer();
 		}
@@ -107,7 +107,7 @@
 
 		video::SMaterial Material; //! material for this meshBuffer.
 		core::array<video::S3DVertexTangents> Vertices; //! Array of vertices
-		core::array<u16> Indices; //! Array of the Indices.
+		core::array<u32> Indices; //! Array of the Indices.
 		core::aabbox3d<f32> BoundingBox;
 	};
 
diff -r -uw -N irrlicht/include/irrlicht.h irrlicht_multipatch/include/irrlicht.h
--- irrlicht/include/irrlicht.h	2006-11-18 08:23:12.000000000 +0100
+++ irrlicht_multipatch/include/irrlicht.h	2006-11-30 17:25:28.000000000 +0100
@@ -279,6 +279,8 @@
 		IEventReceiver* receiver = 0,
 		const c8* sdk_version_do_not_use = IRRLICHT_SDK_VERSION);
 
+	IRRLICHT_API s32 IRRCALLCONV getMultiHeadAdapterCountDX9();
+
 	//! Creates an Irrlicht device with the option to specify advanced parameters. 
 	/** Usually you should used createDevice() for creating an Irrlicht Engine device.
 	Use this function only if you wish to specify advanced parameters like a window
diff -r -uw -N irrlicht/include/matrix4.h irrlicht_multipatch/include/matrix4.h
--- irrlicht/include/matrix4.h	2006-11-12 10:40:22.000000000 +0100
+++ irrlicht_multipatch/include/matrix4.h	2006-12-04 16:51:49.000000000 +0100
@@ -147,6 +147,12 @@
 			//! Builds a left-handed perspective projection matrix.
 			void buildProjectionMatrixPerspectiveLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar);
 
+			//! Builds a right-handed perspective projection matrix.
+			void buildProjectionMatrixPerspectiveRH(f32 left, f32 right, f32 bottom, f32 top, f32 zNear, f32 zFar);
+
+			//! Builds a left-handed perspective projection matrix.
+			void buildProjectionMatrixPerspectiveLH(f32 left, f32 right, f32 bottom, f32 top, f32 zNear, f32 zFar);
+
 			//! Builds a left-handed orthogonal projection matrix.
 			void buildProjectionMatrixOrthoLH(f32 widthOfViewVolume, f32 heightOfViewVolume, f32 zNear, f32 zFar);
 
@@ -775,6 +781,55 @@
 	}
 
 
+	//! Builds a left-handed perspective projection matrix.
+	inline void matrix4::buildProjectionMatrixPerspectiveLH(f32 left, f32 right, f32 bottom, f32 top, f32 zNear, f32 zFar)
+	{
+		M[0] = 2*zNear/(right-left);
+		M[1] = 0;
+		M[2] = 0;
+		M[3] = 0;
+
+		M[4] = 0;
+		M[5] = 2*zNear/(top-bottom);
+		M[6] = 0;
+		M[7] = 0;
+
+		M[8] = (right+left)/(left-right);;
+		M[9] = (top+bottom)/(bottom-top);
+		M[10] = zFar/(zFar-zNear);
+		M[11] = 1;
+
+		M[12] = 0;
+		M[13] = 0;
+		M[14] = zNear*zFar/(zNear-zFar);
+		M[15] = 0;
+		
+	}
+
+	//! Builds a right-handed perspective projection matrix.
+	inline void matrix4::buildProjectionMatrixPerspectiveRH(f32 left, f32 right, f32 bottom, f32 top, f32 zNear, f32 zFar)
+	{
+		M[0] = 2*zNear/(right-left);
+		M[1] = 0;
+		M[2] = 0;
+		M[3] = 0;
+
+		M[4] = 0;
+		M[5] = 2*zNear/(top-bottom);
+		M[6] = 0;
+		M[7] = 0;
+
+		M[8] = (right+left)/(right-left);
+		M[9] = (top+bottom)/(top-bottom);
+		M[10] = zFar/(zNear-zFar);
+		M[11] = -1;
+
+		M[12] = 0;
+		M[13] = 0;
+		M[14] = zNear*zFar/(zNear-zFar);
+		M[15] = 0;
+	}
+
 	//! Builds a matrix that flattens geometry into a plane.
 	inline void matrix4::buildShadowMatrix(const core::vector3df& light, core::plane3df plane, f32 point)
 	{
diff -r -uw -N irrlicht/source/Irrlicht/C3DSMeshFileLoader.cpp irrlicht_multipatch/source/Irrlicht/C3DSMeshFileLoader.cpp
--- irrlicht/source/Irrlicht/C3DSMeshFileLoader.cpp	2006-11-12 10:40:20.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/C3DSMeshFileLoader.cpp	2006-11-29 23:49:34.000000000 +0100
@@ -1161,7 +1161,7 @@
 	group.faces = new s16[group.faceCount];
 	file->read(group.faces, sizeof(s16) * group.faceCount);
 #ifdef __BIG_ENDIAN__
-	for (int i=0;i<group.faceCount;i++) group.faces[i] = os::Byteswap::byteswap(group.faces[i]);
+	for (int i=0;i<group.faceCount;++i) group.faces[i] = os::Byteswap::byteswap(group.faces[i]);
 #endif
 	data.read += sizeof(s16) * group.faceCount;
 
@@ -1181,8 +1181,15 @@
 
 	// Indices are u16s.
 	// After every 3 Indices in the array, there follows an edge flag.
-	Indices = new u16[CountFaces * 4];
-	file->read(Indices, indexBufferByteSize);
+	u16 *l_indicies = new u16[CountFaces * 4];
+	file->read(l_indicies, indexBufferByteSize);
+
+	Indices = new u32[CountFaces * 4];
+
+	for (s32 idx = 0; idx < CountFaces*4; ++idx) 
+		Indices[idx] = l_indicies[idx];
+	delete []l_indicies;
+
 #ifdef __BIG_ENDIAN__
 	for (int i=0;i<CountFaces*4;++i) Indices[i] = os::Byteswap::byteswap(Indices[i]);
 #endif
diff -r -uw -N irrlicht/source/Irrlicht/C3DSMeshFileLoader.h irrlicht_multipatch/source/Irrlicht/C3DSMeshFileLoader.h
--- irrlicht/source/Irrlicht/C3DSMeshFileLoader.h	2006-07-15 08:41:48.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/C3DSMeshFileLoader.h	2006-11-29 22:27:46.000000000 +0100
@@ -155,7 +155,7 @@
 	video::IVideoDriver* Driver;
 
 	f32* Vertices;
-	u16* Indices;
+	u32* Indices;
 	core::array<u16> TempIndices;
 	f32* TCoords;
 	u16 CountVertices;
diff -r -uw -N irrlicht/source/Irrlicht/CAnimatedMeshB3d.h irrlicht_multipatch/source/Irrlicht/CAnimatedMeshB3d.h
--- irrlicht/source/Irrlicht/CAnimatedMeshB3d.h	2006-09-24 11:30:56.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CAnimatedMeshB3d.h	2006-11-29 22:33:56.000000000 +0100
@@ -139,12 +139,12 @@
 				return Vertices.size();
 			}
 
-			virtual const u16* getIndices() const
+			virtual const u32* getIndices() const
 			{
 				return Indices.const_pointer();
 			}
 
-			virtual u16* getIndices()
+			virtual u32* getIndices()
 			{
 				return Indices.pointer();
 			}
@@ -183,7 +183,7 @@
 
 			video::SMaterial Material;
 			core::array<video::S3DVertex2TCoords> Vertices;
-			core::array<u16> Indices;
+			core::array<u32> Indices;
 			core::aabbox3d<f32> BoundingBox;
 		};
 
diff -r -uw -N irrlicht/source/Irrlicht/CAnimatedMeshMD2.cpp irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMD2.cpp
--- irrlicht/source/Irrlicht/CAnimatedMeshMD2.cpp	2006-09-24 11:30:54.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMD2.cpp	2006-11-29 22:41:16.000000000 +0100
@@ -399,7 +399,7 @@
 
 
 //! returns pointer to Indices
-const u16* CAnimatedMeshMD2::getIndices() const
+const u32* CAnimatedMeshMD2::getIndices() const
 {
 	return Indices.const_pointer();
 }
@@ -407,7 +407,7 @@
 
 
 //! returns pointer to Indices
-u16* CAnimatedMeshMD2::getIndices()
+u32* CAnimatedMeshMD2::getIndices()
 {
 	return Indices.pointer();
 }
diff -r -uw -N irrlicht/source/Irrlicht/CAnimatedMeshMD2.h irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMD2.h
--- irrlicht/source/Irrlicht/CAnimatedMeshMD2.h	2006-08-29 08:13:00.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMD2.h	2006-11-29 22:40:34.000000000 +0100
@@ -60,10 +60,10 @@
 		virtual s32 getVertexCount() const;
 
 		//! returns pointer to Indices
-		virtual const u16* getIndices() const;
+		virtual const u32* getIndices() const;
 
 		//! returns pointer to Indices
-		virtual u16* getIndices();
+		virtual u32* getIndices();
 
 		//! returns amount of indices
 		virtual s32 getIndexCount() const;
@@ -112,7 +112,7 @@
 		//! calculates normals
 		void calculateNormals();
 
-		core::array<u16> Indices;
+		core::array<u32> Indices;
 		core::array<video::S3DVertex> *FrameList;
 		core::array<core::aabbox3d<f32> > BoxList;
 		u32 FrameCount;
diff -r -uw -N irrlicht/source/Irrlicht/CAnimatedMeshMS3D.cpp irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMS3D.cpp
--- irrlicht/source/Irrlicht/CAnimatedMeshMS3D.cpp	2006-11-18 08:23:12.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMS3D.cpp	2006-11-29 22:56:04.000000000 +0100
@@ -471,7 +471,7 @@
 		if (grp.MaterialIdx >= Buffers.size()) 
 			grp.MaterialIdx = 0; 
 
-		core::array<u16>& indices = Buffers[grp.MaterialIdx].Indices;
+		core::array<u32>& indices = Buffers[grp.MaterialIdx].Indices;
 
 		for (u32 k=0; k<grp.VertexIds.size(); ++k)
 			for (u32 l=0; l<3; ++l)
@@ -736,13 +736,13 @@
 } 
 
 //! returns pointer to Indices 
-const u16* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() const 
+const u32* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() const 
 { 
 	return Indices.const_pointer(); 
 } 
 
 //! returns pointer to Indices 
-u16* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() 
+u32* CAnimatedMeshMS3D::SMS3DMeshBuffer::getIndices() 
 { 
 	return Indices.pointer(); 
 } 
diff -r -uw -N irrlicht/source/Irrlicht/CAnimatedMeshMS3D.h irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMS3D.h
--- irrlicht/source/Irrlicht/CAnimatedMeshMS3D.h	2006-08-29 08:13:00.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CAnimatedMeshMS3D.h	2006-11-29 22:49:34.000000000 +0100
@@ -131,10 +131,10 @@
 			virtual s32 getVertexCount() const;
 
 			//! returns pointer to Indices 
-			virtual const u16* getIndices() const;
+			virtual const u32* getIndices() const;
 
 			//! returns pointer to Indices 
-			virtual u16* getIndices();
+			virtual u32* getIndices();
 
 			//! returns amount of indices 
 			virtual s32 getIndexCount() const;
@@ -150,7 +150,7 @@
 
 			video::SMaterial Material;                  //! material for this meshBuffer. 
 			core::array<video::S3DVertex> *Vertices;      //! Array of vertices 
-			core::array<u16> Indices;   //! Array of the Indices. 
+			core::array<u32> Indices;   //! Array of the Indices. 
 			core::aabbox3d<f32> *BoundingBox; 
 		}; 
 
@@ -161,7 +161,7 @@
 
 		core::array<video::S3DVertex> Vertices;
 		core::array<video::S3DVertex> AnimatedVertices;
-		core::array<u16> Indices;
+		core::array<u32> Indices;
 		
 		core::array<SJoint> Joints;
 		core::array<SGroup> Groups;
diff -r -uw -N irrlicht/source/Irrlicht/CBillboardSceneNode.h irrlicht_multipatch/source/Irrlicht/CBillboardSceneNode.h
--- irrlicht/source/Irrlicht/CBillboardSceneNode.h	2006-06-17 08:11:42.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CBillboardSceneNode.h	2006-11-29 23:20:36.000000000 +0100
@@ -61,7 +61,7 @@
 	video::SMaterial Material;
 
 	video::S3DVertex vertices[4];
-	u16 indices[6];
+	u32 indices[6];
 };
 
 
diff -r -uw -N irrlicht/source/Irrlicht/CCubeSceneNode.cpp irrlicht_multipatch/source/Irrlicht/CCubeSceneNode.cpp
--- irrlicht/source/Irrlicht/CCubeSceneNode.cpp	2006-08-29 08:13:00.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CCubeSceneNode.cpp	2006-11-29 23:22:12.000000000 +0100
@@ -22,7 +22,7 @@
 	setDebugName("CCubeSceneNode");
 	#endif
 
-	u16 u[36] = {   0,2,1,   0,3,2,   1,5,4,   1,2,5,   4,6,7,   4,5,6, 
+	u32 u[36] = {   0,2,1,   0,3,2,   1,5,4,   1,2,5,   4,6,7,   4,5,6, 
             7,3,0,   7,6,3,   9,5,2,   9,8,5,   0,11,10,   0,10,7};
 
 	Buffer.Indices.set_used(36);
diff -r -uw -N irrlicht/source/Irrlicht/CD3D8Driver.cpp irrlicht_multipatch/source/Irrlicht/CD3D8Driver.cpp
--- irrlicht/source/Irrlicht/CD3D8Driver.cpp	2006-11-01 08:01:48.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CD3D8Driver.cpp	2006-12-05 11:58:39.000000000 +0100
@@ -271,7 +271,7 @@
 	}
 
 	if (!StencilBuffer)
-		present.AutoDepthStencilFormat = D3DFMT_D24X8;
+		present.AutoDepthStencilFormat = D3DFMT_D16;
 
 	// create device
 
@@ -488,7 +488,7 @@
 
 
 //! queries the features of the driver, returns true if feature is available
-bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature)
+bool CD3D8Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice)
 {
 	switch (feature)
 	{
@@ -754,7 +754,7 @@
 
 
 //! draws a vertex primitive list
-void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
+void CD3D8Driver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
 {
 	if (!checkPrimitiveCount(primitiveCount))
 		return;
@@ -785,16 +785,16 @@
 		{
 		   case scene::EPT_POINTS:
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount,
-				 primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+				 primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 			  break;
 		   case scene::EPT_LINE_STRIP:
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
-				 primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+				 primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 			  break;
 		   case scene::EPT_LINE_LOOP:
 		   {
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
-				 primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+				 primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 			  u16 tmpIndices[] = {0, primitiveCount};
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
 				 1, tmpIndices, D3DFMT_INDEX16, vertices, stride);
@@ -802,19 +802,19 @@
 			  break;
 		   case scene::EPT_LINES:
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
-				 primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+				 primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 			  break;
 		   case scene::EPT_TRIANGLE_STRIP:
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount,
-				 primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+				 primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 			  break;
 		   case scene::EPT_TRIANGLE_FAN:
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount,
-				 primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+				 primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 			  break;
 		   case scene::EPT_TRIANGLES:
 			  pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount,
-				 primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+				 primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 			  break;
 		}
 	}
diff -r -uw -N irrlicht/source/Irrlicht/CD3D8Driver.h irrlicht_multipatch/source/Irrlicht/CD3D8Driver.h
--- irrlicht/source/Irrlicht/CD3D8Driver.h	2006-10-15 08:48:48.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D8Driver.h	2006-12-05 11:49:16.000000000 +0100
@@ -46,7 +46,7 @@
 		virtual bool endScene( s32 windowId, core::rect<s32>* sourceRect=0 );
 
 		//! queries the features of the driver, returns true if feature is available
-		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature);
+		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1);
 
 		//! sets transformation
 		virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
@@ -66,7 +66,7 @@
 		virtual const core::rect<s32>& getViewPort() const;
 
 		//! draws a vertex primitive list
-		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
+		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
 
 		//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
 		virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9Driver.cpp irrlicht_multipatch/source/Irrlicht/CD3D9Driver.cpp
--- irrlicht/source/Irrlicht/CD3D9Driver.cpp	2006-10-15 08:48:50.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9Driver.cpp	2006-12-05 11:50:24.000000000 +0100
@@ -48,19 +48,6 @@
 		LastTextureMipMapsAvailable[i] = false;
 	}
 
-	// create sphere map matrix
-
-	SphereMapMatrixD3D9._11 = 0.5f; SphereMapMatrixD3D9._12 = 0.0f;
-	SphereMapMatrixD3D9._13 = 0.0f; SphereMapMatrixD3D9._14 = 0.0f;
-	SphereMapMatrixD3D9._21 = 0.0f; SphereMapMatrixD3D9._22 =-0.5f;
-	SphereMapMatrixD3D9._23 = 0.0f; SphereMapMatrixD3D9._24 = 0.0f;
-	SphereMapMatrixD3D9._31 = 0.0f; SphereMapMatrixD3D9._32 = 0.0f;
-	SphereMapMatrixD3D9._33 = 1.0f; SphereMapMatrixD3D9._34 = 0.0f;
-	SphereMapMatrixD3D9._41 = 0.5f; SphereMapMatrixD3D9._42 = 0.5f;
-	SphereMapMatrixD3D9._43 = 0.0f; SphereMapMatrixD3D9._44 = 1.0f;
-
-	core::matrix4 mat;
-	UnitMatrixD3D9 = *(D3DMATRIX*)((void*)&mat);
 
 	// init direct 3d is done in the factory function
 
@@ -93,12 +80,15 @@
 {
 	// create D3D9 material renderers
 
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID_2_LAYER(pID3DDevice, this));
+	core::array<IDirect3DDevice9*> devices;
+	devices.push_back(pID3DDevice);
+
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID_2_LAYER(devices, this));
 
 	// add the same renderer for all lightmap types
 
-	CD3D9MaterialRenderer_LIGHTMAP* lmr = new CD3D9MaterialRenderer_LIGHTMAP(pID3DDevice, this);
+	CD3D9MaterialRenderer_LIGHTMAP* lmr = new CD3D9MaterialRenderer_LIGHTMAP(devices, this);
 	addMaterialRenderer(lmr); // for EMT_LIGHTMAP:
 	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD:
 	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2:
@@ -110,45 +100,47 @@
 
 	// add remaining fixed function pipeline material renderers
 
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_DETAIL_MAP(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SPHERE_MAP(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_REFLECTION_2_LAYER(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevice, this));
-	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevice, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_DETAIL_MAP(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SPHERE_MAP(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_REFLECTION_2_LAYER(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(devices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(devices, this));
 
 	// add normal map renderers
 
 	s32 tmp = 0;
 	video::IMaterialRenderer* renderer = 0;
 
-	renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp,
+	renderer = new CD3D9NormalMapRenderer(devices, this, tmp,
 		MaterialRenderers[EMT_SOLID].Renderer);
 	renderer->drop();
 
-	renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp,
+	renderer = new CD3D9NormalMapRenderer(devices, this, tmp,
 		MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer);
 	renderer->drop();
 
-	renderer = new CD3D9NormalMapRenderer(pID3DDevice, this, tmp,
+	renderer = new CD3D9NormalMapRenderer(devices, this, tmp,
 		MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer);
 	renderer->drop();
 
 	// add parallax map renderers
 
-	renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp,
+	renderer = new CD3D9ParallaxMapRenderer(devices, this, tmp,
 		MaterialRenderers[EMT_SOLID].Renderer);
 	renderer->drop();
 
-	renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp,
+	renderer = new CD3D9ParallaxMapRenderer(devices, this, tmp,
 		MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer);
 	renderer->drop();
 
-	renderer = new CD3D9ParallaxMapRenderer(pID3DDevice, this, tmp,
+	renderer = new CD3D9ParallaxMapRenderer(devices, this, tmp,
 		MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer);
 	renderer->drop();
+
+	devices.clear();
 }
 
 
@@ -282,17 +274,17 @@
 	// check stencil buffer compatibility
 	if (StencilBuffer)
 	{
-		present.AutoDepthStencilFormat = D3DFMT_D24S8;
+		present.AutoDepthStencilFormat = D3DFMT_D16;
 		if(FAILED(pID3D->CheckDeviceFormat(D3DADAPTER_DEFAULT, devtype,
 			present.BackBufferFormat, D3DUSAGE_DEPTHSTENCIL,
-			D3DRTYPE_SURFACE, D3DFMT_D24S8)))
+			D3DRTYPE_SURFACE, D3DFMT_D16)))
 		{
 			os::Printer::log("Device does not support stencilbuffer, disabling stencil buffer.", ELL_WARNING);
 			StencilBuffer = false;
 		}
 		else
 		if(FAILED(pID3D->CheckDepthStencilMatch(D3DADAPTER_DEFAULT, devtype,
-			present.BackBufferFormat, present.BackBufferFormat, D3DFMT_D24S8)))
+			present.BackBufferFormat, present.BackBufferFormat, D3DFMT_D16)))
 		{
 			os::Printer::log("Depth-stencil format is not compatible with display format, disabling stencil buffer.", ELL_WARNING);
 			StencilBuffer = false;
@@ -300,7 +292,7 @@
 	}
 
 	if (!StencilBuffer)
-		present.AutoDepthStencilFormat = D3DFMT_D24X8;
+		present.AutoDepthStencilFormat = D3DFMT_D16;
 
 	// create device
 
@@ -481,7 +473,7 @@
 
 
 //! queries the features of the driver, returns true if feature is available
-bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature)
+bool CD3D9Driver::queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice)
 {
 	switch (feature)
 	{
@@ -736,7 +728,7 @@
 
 
 //! draws a vertex primitive list
-void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
+void CD3D9Driver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
 {
 	if (!checkPrimitiveCount(primitiveCount))
 		return;
@@ -767,16 +759,16 @@
 		{
 			case scene::EPT_POINTS:
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount,
-					primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 				break;
 			case scene::EPT_LINE_STRIP:
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
-					primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 				break;
 			case scene::EPT_LINE_LOOP:
 			{
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
-					primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 				u16 tmpIndices[] = {0, primitiveCount};
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
 					1, tmpIndices, D3DFMT_INDEX16, vertices, stride);
@@ -784,19 +776,19 @@
 				break;
 			case scene::EPT_LINES:
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
-					primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 				break;
 			case scene::EPT_TRIANGLE_STRIP:
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount,
-					primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 				break;
 			case scene::EPT_TRIANGLE_FAN:
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount,
-					primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 				break;
 			case scene::EPT_TRIANGLES:
 				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount,
-					primitiveCount, indexList, D3DFMT_INDEX16, vertices, stride);
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
 				break;
 		}
 	}
@@ -1450,6 +1442,7 @@
 	if (CurrentRenderMode != ERM_2D || Transformation3DChanged)
 	{
 		core::matrix4 mat;
+		core::matrix4 mat1;
 		pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&mat));
 		pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&mat));
 		pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&mat));
@@ -1470,7 +1463,7 @@
 
 		pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
 		pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
-		pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 );
+		pID3DDevice->SetTransform( D3DTS_TEXTURE0, (D3DMATRIX*)((void*)&mat1) );
 
 		Transformation3DChanged = false;
 
@@ -1895,11 +1888,15 @@
 	E_MATERIAL_TYPE baseMaterial, s32 userData)
 {
 	s32 nr = -1;
+	core::array<IDirect3DDevice9*> dev;
+	dev.push_back(pID3DDevice);
+
 	CD3D9ShaderMaterialRenderer* r = new CD3D9ShaderMaterialRenderer(
-		pID3DDevice, this, nr, vertexShaderProgram, pixelShaderProgram,
+		dev, this, nr, vertexShaderProgram, pixelShaderProgram,
 		callback, getMaterialRenderer(baseMaterial), userData);
 
 	r->drop();
+	dev.clear();
 	return nr;
 }
 
@@ -1919,8 +1916,11 @@
 {
 	s32 nr = -1;
 
+	core::array<IDirect3DDevice9*> dev;
+	dev.push_back(pID3DDevice);
+
 	CD3D9HLSLMaterialRenderer* hlsl = new CD3D9HLSLMaterialRenderer(
-		pID3DDevice, this, nr,
+		dev, this, nr,
 		vertexShaderProgram,
 		vertexShaderEntryPointName,
 		vsCompileTarget,
@@ -1932,6 +1932,7 @@
 		userData);
 
 	hlsl->drop();
+	dev.clear();
 	return nr;
 }
 
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9Driver.h irrlicht_multipatch/source/Irrlicht/CD3D9Driver.h
--- irrlicht/source/Irrlicht/CD3D9Driver.h	2006-10-15 08:48:50.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9Driver.h	2006-12-05 11:50:44.000000000 +0100
@@ -38,7 +38,7 @@
 		virtual bool endScene( s32 windowId = 0, core::rect<s32>* sourceRect=0 );
 
 		//! queries the features of the driver, returns true if feature is available
-		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature);
+		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1);
 
 		//! sets transformation
 		virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
@@ -58,7 +58,7 @@
 		virtual const core::rect<s32>& getViewPort() const;
 
 		//! draws a vertex primitive list
-		virtual void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
+		virtual void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
 
 		//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
 		virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp irrlicht_multipatch/source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp
--- irrlicht/source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp	2006-06-17 08:11:42.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9HLSLMaterialRenderer.cpp	2006-12-08 15:55:52.000000000 +0100
@@ -23,7 +23,7 @@
 
 
 //! Public constructor
-CD3D9HLSLMaterialRenderer::CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev,
+	CD3D9HLSLMaterialRenderer::CD3D9HLSLMaterialRenderer(core::array<IDirect3DDevice9*> d3ddev,
 	video::IVideoDriver* driver, s32& outMaterialTypeNr, 
 	const c8* vertexShaderProgram,
 	const c8* vertexShaderEntryPointName,
@@ -34,10 +34,10 @@
 	IShaderConstantSetCallBack* callback, 
 	IMaterialRenderer* baseMaterial,
 	s32 userData)
-	: CD3D9ShaderMaterialRenderer(d3ddev, driver, callback, baseMaterial, userData),
-	VSConstantsTable(0), PSConstantsTable(0)
+	: CD3D9ShaderMaterialRenderer(d3ddev, driver, callback, baseMaterial, userData)
 {
 	outMaterialTypeNr = -1;
+	deviceIndex = 0;
 
 	// now create shaders
 
@@ -47,14 +47,16 @@
 		return;
 	}
 
+	for(u32 idx = 0; idx < d3ddev.size(); ++idx)
+	{
 	if (!createHLSLVertexShader(vertexShaderProgram, 
-		vertexShaderEntryPointName, VERTEX_SHADER_TYPE_NAMES[vsCompileTarget]))
+			vertexShaderEntryPointName, VERTEX_SHADER_TYPE_NAMES[vsCompileTarget], idx))
 		return;
 
 	if (!createHLSLPixelShader(pixelShaderProgram, 
-		pixelShaderEntryPointName, PIXEL_SHADER_TYPE_NAMES[psCompileTarget]))
+			pixelShaderEntryPointName, PIXEL_SHADER_TYPE_NAMES[psCompileTarget], idx))
 		return;
-
+	}
 	// register myself as new material
 	outMaterialTypeNr = Driver->addMaterialRenderer(this);
 }
@@ -62,17 +64,25 @@
 	//! Destructor
 CD3D9HLSLMaterialRenderer::~CD3D9HLSLMaterialRenderer()
 {
-	if (VSConstantsTable)
-		VSConstantsTable->Release();
+	u32 idx = 0;
+	for(idx = 0; idx < VSConstantsTables.size(); ++idx)
+		if (VSConstantsTables[idx])
+			VSConstantsTables[idx]->Release();
+
+	VSConstantsTables.clear();
+
+	for(idx = 0; idx < PSConstantsTables.size(); ++idx)
+		if (PSConstantsTables[idx])
+			PSConstantsTables[idx]->Release();
 
-	if (PSConstantsTable)
-		PSConstantsTable->Release();
+	PSConstantsTables.clear();
 }
 
 
 bool CD3D9HLSLMaterialRenderer::createHLSLVertexShader(const char* vertexShaderProgram,
 													   const char* shaderEntryPointName,
-													   const char* shaderTargetName)
+													   const char* shaderTargetName,
+													   u32 _deviceIndex)
 {
 	if (!vertexShaderProgram)
 		return true;
@@ -83,6 +93,7 @@
 	#ifdef _IRR_D3D_NO_SHADER_DEBUGGING
 
 		// compile without debug info
+		LPD3DXCONSTANTTABLE constTa;
 		
 		HRESULT h = stubD3DXCompileShader(
 			vertexShaderProgram,
@@ -94,10 +105,10 @@
 			0, // no flags 
 			&buffer,
 			&errors,
-			&VSConstantsTable);
-
+			&constTa);
+		VSConstantsTables.push_back(constTa);
 	#else
-
+		LPD3DXCONSTANTTABLE constTa;
 		// compile shader and emitt some debug informations to
 		// make it possible to debug the shader in visual studio
 
@@ -120,8 +131,9 @@
 			D3DXSHADER_DEBUG | D3DXSHADER_SKIPOPTIMIZATION,
 			&buffer,
 			&errors,
-			&VSConstantsTable);
+			&constTa);
 
+		VSConstantsTables.push_back(constTa);
 	#endif
 
 	if (FAILED(h))
@@ -140,8 +152,8 @@
 
 	if (buffer)
 	{
-		if (FAILED(pID3DDevice->CreateVertexShader((DWORD*)buffer->GetBufferPointer(),
-			&VertexShader)))
+		if (FAILED(pID3DDevices[_deviceIndex]->CreateVertexShader((DWORD*)buffer->GetBufferPointer(),
+			&VertexShaders[_deviceIndex])))
 		{
 			os::Printer::log("Could not create hlsl vertex shader.");
 			buffer->Release();
@@ -158,13 +170,15 @@
 
 bool CD3D9HLSLMaterialRenderer::createHLSLPixelShader(const char* pixelShaderProgram, 
 		const char* shaderEntryPointName,
-		const char* shaderTargetName)
+		const char* shaderTargetName,
+		u32 _deviceIndex)
 {
 	if (!pixelShaderProgram)
 		return true;
 
 	LPD3DXBUFFER buffer = 0;
 	LPD3DXBUFFER errors = 0;
+	LPD3DXCONSTANTTABLE constTab;
 	
 	HRESULT h = stubD3DXCompileShader(
 		pixelShaderProgram,
@@ -176,7 +190,9 @@
 		0, // no flags (D3DXSHADER_DEBUG)
 		&buffer,
 		&errors,
-		&PSConstantsTable);
+		&constTab);
+	
+	PSConstantsTables.push_back(constTab);
 
 	if (FAILED(h))
 	{
@@ -194,8 +210,8 @@
 
 	if (buffer)
 	{
-		if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)buffer->GetBufferPointer(),
-			&PixelShader)))
+		if (FAILED(pID3DDevices[_deviceIndex]->CreatePixelShader((DWORD*)buffer->GetBufferPointer(),
+			&PixelShaders[_deviceIndex])))
 		{
 			os::Printer::log("Could not create hlsl pixel shader.");
 			buffer->Release();
@@ -213,7 +229,7 @@
 bool CD3D9HLSLMaterialRenderer::setVariable(bool vertexShader, const c8* name, 
 											const f32* floats, int count)
 {
-	LPD3DXCONSTANTTABLE tbl = vertexShader ? VSConstantsTable : PSConstantsTable;
+	LPD3DXCONSTANTTABLE tbl = vertexShader ? VSConstantsTables[deviceIndex] : PSConstantsTables[deviceIndex];
 	if (!tbl)
 		return false;
 
@@ -231,7 +247,7 @@
 		return false;
 	}
 
-	HRESULT hr = tbl->SetFloatArray(pID3DDevice, hndl, floats, count);
+	HRESULT hr = tbl->SetFloatArray(pID3DDevices[deviceIndex], hndl, floats, count);
 	if (FAILED(hr))
 	{
 		os::Printer::log("Error setting float array for HLSL variable", ELL_WARNING);
@@ -243,8 +259,8 @@
 
 bool CD3D9HLSLMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
 {
-	if (VSConstantsTable)
-		VSConstantsTable->SetDefaults(pID3DDevice);
+	if (VSConstantsTables[deviceIndex])
+		VSConstantsTables[deviceIndex]->SetDefaults(pID3DDevices[deviceIndex]);
 
 	return CD3D9ShaderMaterialRenderer::OnRender(service, vtxtype);
 }
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9HLSLMaterialRenderer.h irrlicht_multipatch/source/Irrlicht/CD3D9HLSLMaterialRenderer.h
--- irrlicht/source/Irrlicht/CD3D9HLSLMaterialRenderer.h	2006-06-17 08:12:08.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9HLSLMaterialRenderer.h	2006-12-08 15:53:48.000000000 +0100
@@ -28,7 +28,7 @@
 public:
 
 	//! Public constructor
-	CD3D9HLSLMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, 
+	CD3D9HLSLMaterialRenderer(core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver, 
 		s32& outMaterialTypeNr, 
 		const c8* vertexShaderProgram,
 		const c8* vertexShaderEntryPointName,
@@ -57,16 +57,18 @@
 
 	bool createHLSLVertexShader(const char* vertexShaderProgram, 
 		const char* shaderEntryPointName,
-		const char* shaderTargetName);
+		const char* shaderTargetName,
+		u32 _deviceIndex);
 
 	bool createHLSLPixelShader(const char* pixelShaderProgram, 
 		const char* shaderEntryPointName,
-		const char* shaderTargetName);
+		const char* shaderTargetName,
+		u32 _deviceIndex);
 
 	void printHLSLVariables(LPD3DXCONSTANTTABLE table);
 	
-	LPD3DXCONSTANTTABLE VSConstantsTable;
-	LPD3DXCONSTANTTABLE PSConstantsTable;
+	core::array<LPD3DXCONSTANTTABLE> VSConstantsTables;
+	core::array<LPD3DXCONSTANTTABLE> PSConstantsTables;
 };
 
 
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9MDriver.cpp irrlicht_multipatch/source/Irrlicht/CD3D9MDriver.cpp
--- irrlicht/source/Irrlicht/CD3D9MDriver.cpp	1970-01-01 01:00:00.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CD3D9MDriver.cpp	2006-12-11 14:01:04.000000000 +0100
@@ -0,0 +1,2419 @@
+// Copyright (C) 2002-2006 Nikolaus Gebhardt
+// This file is part of the "Irrlicht Engine".
+// For conditions of distribution and use, see copyright notice in irrlicht.h
+
+#define _IRR_DONT_DO_MEMORY_DEBUGGING_HERE
+#include "CD3D9MDriver.h"
+#include "os.h"
+#include "S3DVertex.h"
+#include "CD3D9Texture.h"
+#include "CImage.h"
+#include <stdio.h>
+
+#include "IrrCompileConfig.h"
+#ifdef _IRR_WINDOWS_
+
+#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
+
+#include "CD3D9MaterialRenderer.h"
+#include "CD3D9ShaderMaterialRenderer.h"
+#include "CD3D9NormalMapRenderer.h"
+#include "CD3D9ParallaxMapRenderer.h"
+#include "CD3D9HLSLMaterialRenderer.h"
+
+namespace irr
+{
+namespace video
+{
+
+
+//! constructor
+CD3D9MDriver::CD3D9MDriver(const core::dimension2d<s32>& screenSize, HWND window,
+				bool fullscreen, bool stencilbuffer,
+				io::IFileSystem* io, bool pureSoftware)
+: CNullDriver(io, screenSize), D3DLibrary(0), CurrentRenderMode(ERM_NONE), pID3DDevice(0),
+ pID3D(0), Transformation3DChanged(0), StencilBuffer(stencilbuffer),
+ DeviceLost(false), Fullscreen(fullscreen), PrevRenderTarget(0), CurrentRendertargetSize(0,0)
+{
+	#ifdef _DEBUG
+	setDebugName("CD3D9MDriver");
+	#endif
+
+	printVersion();
+
+	for (s32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
+	{
+		CurrentTexture[i] = 0;
+		LastTextureMipMapsAvailable[i] = false;
+	}
+
+	// init direct 3d is done in the factory function
+
+	MaxLightDistance = sqrtf(FLT_MAX);
+
+	m_pSwapChain = NULL;
+	m_pBackBuffer = NULL;
+	m_curMode = NULL;
+	m_beginScene = false;
+	m_renderAdapter = 0;
+}
+
+
+
+//! destructor
+CD3D9MDriver::~CD3D9MDriver()
+{
+	u32 idx = 0;
+	deleteMaterialRenders();
+
+	for (s32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
+		if (CurrentTexture[i])
+			CurrentTexture[i]->drop();
+
+	for(idx = 0; Matricess.size(); ++idx)
+	{
+		if(Matricess[idx])
+			delete []Matricess[idx];
+	}
+	Matricess.clear();
+	// drop d3d9
+
+	for(idx = 1; idx < pID3DDevices.size(); ++idx)
+	{
+		if(pID3DDevices[idx])
+			pID3DDevices[idx]->Release();
+	}
+	pID3DDevices.clear();
+
+	for(idx = 0; idx < m_pPresentParams.size(); ++idx)
+	{
+		if(m_pPresentParams[idx] && m_pPresentParams[idx] != NULL)
+		{
+			delete[]m_pPresentParams[idx];
+		}
+	}
+	m_pPresentParams.clear();
+
+	if (pID3D)		
+		pID3D->Release();
+}
+
+
+
+void CD3D9MDriver::createMaterialRenderers()
+{
+	// create D3D9 material renderers
+
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SOLID_2_LAYER(pID3DDevices, this));
+
+	// add the same renderer for all lightmap types
+
+	CD3D9MaterialRenderer_LIGHTMAP* lmr = new CD3D9MaterialRenderer_LIGHTMAP(pID3DDevices, this);
+	addMaterialRenderer(lmr); // for EMT_LIGHTMAP:
+	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_ADD:
+	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M2:
+	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_M4:
+	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING:
+	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M2:
+	addMaterialRenderer(lmr); // for EMT_LIGHTMAP_LIGHTING_M4:
+	lmr->drop();
+
+	// add remaining fixed function pipeline material renderers
+
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_DETAIL_MAP(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_SPHERE_MAP(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_REFLECTION_2_LAYER(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(pID3DDevices, this));
+	addAndDropMaterialRenderer(new CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(pID3DDevices, this));
+
+	// add normal map renderers
+
+	s32 tmp = 0;
+	video::IMaterialRenderer* renderer = 0;
+
+	renderer = new CD3D9NormalMapRenderer(pID3DDevices, this, tmp,
+		MaterialRenderers[EMT_SOLID].Renderer);
+	renderer->drop();
+
+	renderer = new CD3D9NormalMapRenderer(pID3DDevices, this, tmp,
+		MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer);
+	renderer->drop();
+
+	renderer = new CD3D9NormalMapRenderer(pID3DDevices, this, tmp,
+		MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer);
+	renderer->drop();
+
+	// add parallax map renderers
+
+	renderer = new CD3D9ParallaxMapRenderer(pID3DDevices, this, tmp,
+		MaterialRenderers[EMT_SOLID].Renderer);
+	renderer->drop();
+
+	renderer = new CD3D9ParallaxMapRenderer(pID3DDevices, this, tmp,
+		MaterialRenderers[EMT_TRANSPARENT_ADD_COLOR].Renderer);
+	renderer->drop();
+
+	renderer = new CD3D9ParallaxMapRenderer(pID3DDevices, this, tmp,
+		MaterialRenderers[EMT_TRANSPARENT_VERTEX_ALPHA].Renderer);
+	renderer->drop();
+}
+
+bool CD3D9MDriver::findMultiHeadDevice()
+{
+	HRESULT hr;
+	UINT adapterCount = pID3D->GetAdapterCount();
+	bool result = false;
+	m_Device.iNumAdapters = 0;
+
+    for ( UINT i = 0; i < adapterCount; i++ )
+    {
+        // Get caps for HAL device
+		D3DCAPS9 caps;
+		hr = pID3D->GetDeviceCaps( i, D3DDEVTYPE_HAL, &caps );
+
+		// Look for multi-head adpater
+		if ( caps.NumberOfAdaptersInGroup > 1 )
+		{
+			// Get device name
+			D3DADAPTER_IDENTIFIER9 identifier;
+			hr = pID3D->GetAdapterIdentifier( i, 0, &identifier );
+
+			strcpy( m_Device.Adapters[m_Device.iNumAdapters].DeviceName, identifier.Description );
+			m_Device.Adapters[m_Device.iNumAdapters].AdapterID = i;
+			m_Device.Adapters[m_Device.iNumAdapters].Ordinal = caps.NumberOfAdaptersInGroup;
+			m_Device.Adapters[m_Device.iNumAdapters].iNumModes = 0;
+			m_Device.Adapters[m_Device.iNumAdapters].CurrMode = NULL;
+			m_Device.Adapters[m_Device.iNumAdapters].pDepthStencil = NULL;
+
+			m_Device.iNumAdapters++;
+			result = true;
+		}
+    }
+
+	return result;
+}
+
+//! build presents params for d3d device
+void CD3D9MDriver::buildPresentParams(const core::array<core::dimension2d<s32> >& screenSize, core::array<HWND> hwnd, u32 bits, bool vsync)
+{
+	u32 hwndCnt = 0;
+	for(u32 idx = 0; idx < m_Device.iNumAdapters; ++idx)
+	{	
+		m_pPresentParams.push_back(new D3DPRESENT_PARAMETERS[m_Device.Adapters[idx].Ordinal]);
+
+		D3DPRESENT_PARAMETERS *tmp = m_pPresentParams[m_pPresentParams.size()-1];
+
+		memset( tmp, 0, sizeof( D3DPRESENT_PARAMETERS ) * m_Device.Adapters[idx].Ordinal );
+
+		// Initialize presentation params
+		for ( UINT i = 0; i < m_Device.Adapters[idx].Ordinal ; i++ )
+		{
+			tmp[i].BackBufferWidth = screenSize[i].Width;
+			tmp[i].BackBufferHeight = screenSize[i].Height;
+			tmp[i].BackBufferFormat = D3DFMT_R5G6B5;
+			tmp[i].BackBufferCount = 1;
+			//m_pPresentParams[i].MultiSampleType = D3DMULTISAMPLE_NONE;	//???
+			//m_pPresentParams[i].MultiSampleQuality = 0;					//???
+			tmp[i].SwapEffect = D3DSWAPEFFECT_FLIP;
+			tmp[i].hDeviceWindow = hwnd[hwndCnt++];
+			tmp[i].Windowed = FALSE;
+			tmp[i].EnableAutoDepthStencil = true;
+			tmp[i].AutoDepthStencilFormat = D3DFMT_D24S8;
+			tmp[i].Flags = 0;
+			tmp[i].FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
+			tmp[i].PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+
+			if (vsync)
+				tmp[i].PresentationInterval = D3DPRESENT_INTERVAL_ONE;
+			
+			// request 32bit mode if user specified 32 bit, added by Thomas Stüfe
+			if ( bits == 32 ) 
+				tmp[i].BackBufferFormat = D3DFMT_A8R8G8B8;
+	        
+			// check stencil buffer compatibility
+			if (!StencilBuffer)
+			{
+				tmp[i].AutoDepthStencilFormat = D3DFMT_D16;
+			}
+		}
+	}
+}
+
+bool CD3D9MDriver::initDirect3DInterface()
+{
+	if (!pID3D)
+	{
+		D3DLibrary = LoadLibrary( "d3d9.dll" );
+
+		if (!D3DLibrary)
+		{
+			os::Printer::log("Error, could not load d3d9.dll.", ELL_ERROR);
+			return false;
+		}
+
+		typedef IDirect3D9 * (__stdcall *D3DCREATETYPE)(UINT);
+		D3DCREATETYPE d3dCreate = (D3DCREATETYPE) GetProcAddress(D3DLibrary, "Direct3DCreate9");
+
+		if (!d3dCreate)
+		{
+			os::Printer::log("Error, could not get proc adress of Direct3DCreate9.", ELL_ERROR);
+			return false;
+		}
+
+		//just like pID3D = Direct3DCreate9(D3D_SDK_VERSION);
+		pID3D = (*d3dCreate)(D3D_SDK_VERSION);
+		
+
+		if (!pID3D)
+		{
+			os::Printer::log("Error initializing D3D.", ELL_ERROR);
+			return false;
+		}
+	}
+	return true;
+}
+
+//! initialises the Direct3D API for multihead support
+bool CD3D9MDriver::initDriver(const core::array<core::dimension2d<s32> >& screenSize, core::array<HWND> hwnd,
+								u32 bits, bool fullScreen, bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias)
+{
+	HRESULT hr;
+	Fullscreen = fullScreen;
+	u32 idx = 0;
+
+	if(!initDirect3DInterface())
+		return false;
+
+	if(!findMultiHeadDevice())
+	{
+		os::Printer::log("No multihead adapters found! Try to start default adapter.", ELL_INFORMATION);
+		return false;
+	}
+
+	buildPresentParams(screenSize, hwnd, bits, vsync);
+
+
+	/*TODO enable anti aliasing*/
+	DWORD behaviorFlags = D3DCREATE_ADAPTERGROUP_DEVICE | 
+						  D3DCREATE_HARDWARE_VERTEXPROCESSING;
+
+	if (pureSoftware)
+	{
+		os::Printer::log("Was not able to create Direct3D9 software device with multimonitor mode.", ELL_ERROR);
+		return false;
+	}
+	else
+	{
+		core::array<HWND> hwnds;
+		for(idx = 0; idx < m_Device.iNumAdapters; ++idx)
+		{
+			for(u32 idy = 0; idy < m_Device.Adapters[idx].Ordinal; ++idy)
+			{
+				hwnds.push_back(hwnd[idy]);
+			}
+			hr = pID3D->CreateDevice(m_Device.Adapters[idx].AdapterID, D3DDEVTYPE_HAL,
+									hwnds[0], behaviorFlags, m_pPresentParams[idx], 
+									&pID3DDevice);
+
+			if(FAILED(hr))
+			{
+				os::Printer::log("Was not able to create Direct3D9 device with multimonitor support.", ELL_ERROR);
+				return false;
+			}
+			pID3DDevices.push_back(pID3DDevice);
+			m_pRenderTargets.push_back(LPDIRECT3DSURFACE9());//????
+			Materials.push_back(SMaterial());
+			LastMaterials.push_back(SMaterial());
+			ResetRenderStatess.push_back(false);
+			LastSetLights.push_back(-1);
+			LastVertexTypes.push_back((video::E_VERTEX_TYPE)-1);
+			Matricess.push_back(new core::matrix4[ETS_COUNT]);
+			hwnds.clear();
+		}
+	}
+	
+	bool devicesAvailable = true;
+	//now we check the created devices if there realy available
+	for(idx = 0; idx < pID3DDevices.size(); ++idx)
+	{
+		if (!pID3DDevices[idx])
+		{
+			os::Printer::log("Was not able to create DirectX9 device.", ELL_ERROR);
+			devicesAvailable = false;
+		}
+	}
+	if(!devicesAvailable)
+		return devicesAvailable;
+
+	reset();
+
+	for(idx = 0; idx < pID3DDevices.size(); ++idx)
+	{
+		Capss.push_back(_D3DCAPS9());
+		pID3DDevices[idx]->GetDeviceCaps(&Capss[Capss.size()-1]);
+		// disable stencilbuffer if necessary
+		if (StencilBuffer && 
+			(!(Capss[Capss.size()-1].StencilCaps & D3DSTENCILCAPS_DECRSAT) ||
+			!(Capss[Capss.size()-1].StencilCaps & D3DSTENCILCAPS_INCRSAT) ||
+			!(Capss[Capss.size()-1].StencilCaps & D3DSTENCILCAPS_KEEP)))
+		{
+			os::Printer::log("Device not able to use stencil buffer, disabling stencil buffer.", ELL_WARNING);
+			StencilBuffer = false;
+		}
+
+	}
+
+	// set exposed data
+	ExposedData.D3D9.D3D9 = pID3D;
+	ExposedData.D3D9.D3DDev9 = pID3DDevices[0];//we use here the first of the devices
+	ExposedData.D3D9.HWnd =  reinterpret_cast<s32>(hwnd[0]);
+
+	//pID3DDevice = pID3DDevices[0];
+
+	// create materials
+	createMaterialRenderers();
+
+	for(idx = 0; idx < pID3DDevices.size(); ++idx)
+	{
+		pID3DDevice = pID3DDevices[idx];
+		// set default vertex shader
+		setVertexShader(EVT_STANDARD);
+		// set fog mode
+		setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog);
+		ResetRenderStatess[idx] = true;
+
+		// enable antialiasing
+		if (antiAlias)
+			pID3DDevice->SetRenderState(D3DRS_MULTISAMPLEANTIALIAS, TRUE);
+
+		// set the renderstates
+		setRenderStates3DMode();
+
+		// set maximal anisotropy
+		pID3DDevice->SetSamplerState(0, D3DSAMP_MAXANISOTROPY, min(16, Capss[idx].MaxAnisotropy));
+		pID3DDevice->SetSamplerState(1, D3DSAMP_MAXANISOTROPY, min(16, Capss[idx].MaxAnisotropy));
+	}
+
+	pID3DDevice = pID3DDevices[0];
+	//setRenderStates3DMode();
+	// so far so good.
+	return true;
+
+}
+
+
+
+//! applications must call this method before performing any rendering. returns false if failed.
+bool CD3D9MDriver::beginScene(bool backBuffer, bool zBuffer, SColor color)
+{
+	CNullDriver::beginScene(backBuffer, zBuffer, color);
+	HRESULT hr;
+	u32 idx = 0;
+	
+	for(idx = 0; idx < pID3DDevices.size(); ++idx)
+	{
+		if(!pID3DDevices[idx])
+			return false;
+	
+
+		if (DeviceLost)
+		{
+			if(FAILED(hr = pID3DDevices[idx]->TestCooperativeLevel()))
+			{
+				if (hr == D3DERR_DEVICELOST)
+					return false;
+
+				if (hr == D3DERR_DEVICENOTRESET)
+					reset();
+				return false;
+			}
+		}
+	
+		BackBuffer = backBuffer;
+		ZBuffer = zBuffer;
+		Color = color;
+
+		if(m_pRenderTargets[idx] == NULL)
+		{
+			hr = pID3DDevices[idx]->GetRenderTarget( 0, &m_pRenderTargets[idx] );
+			if (FAILED(hr))
+			{
+				os::Printer::log("DirectX9 get render target failed.", ELL_WARNING);
+				return false;
+			}
+		}
+	
+		DWORD flags = 0;
+
+		if (backBuffer)
+			flags |= D3DCLEAR_TARGET;
+
+		if (zBuffer)
+			flags |= D3DCLEAR_ZBUFFER;
+
+		if (StencilBuffer)
+			flags |= D3DCLEAR_STENCIL;
+
+		hr = pID3DDevices[idx]->Clear( 0, NULL, flags, color.color, 1.0, 0);
+		if (FAILED(hr))
+			os::Printer::log("DIRECT3D9 clear failed.", ELL_WARNING);
+
+	}
+
+	pID3DDevice = pID3DDevices[0];
+
+	return true;
+}
+
+//! begins a part scene.
+bool CD3D9MDriver::beginPartScene()
+{
+	if (DeviceLost)
+		return false;
+
+	HRESULT hr = pID3DDevice->BeginScene();
+	if (FAILED(hr))
+	{
+		os::Printer::log("DirectX9 begin scene failed.", ELL_WARNING);
+		return false;
+	}
+	return true;
+}
+
+//! ends a part scene.
+bool CD3D9MDriver::endPartScene()
+{
+	if (DeviceLost)
+		return false;
+	HRESULT hr = pID3DDevice->EndScene();
+	if (FAILED(hr))
+	{
+		os::Printer::log("DirectX9 end scene failed.", ELL_WARNING);
+		return false;
+	}
+	return true;
+}
+
+
+//! applications must call this method after performing any rendering. returns false if failed.
+bool CD3D9MDriver::endScene( s32 windowId, core::rect<s32>* sourceRect )
+{
+	HRESULT hr;
+	if (DeviceLost)
+		return false;
+
+	CNullDriver::endScene();
+
+	for(u32 idx = 0; idx < pID3DDevices.size(); ++idx)
+	{
+		hr = pID3DDevices[idx]->SetRenderTarget( 0, m_pRenderTargets[idx] );
+		if(m_pRenderTargets[idx])
+		{
+			m_pRenderTargets[idx]->Release();
+			m_pRenderTargets[idx] = NULL;
+		}
+
+		RECT* srcRct = 0;
+		RECT sourceRectData;
+		if ( sourceRect )
+		{
+			srcRct = &sourceRectData;
+			sourceRectData.left = sourceRect->UpperLeftCorner.X;
+			sourceRectData.top = sourceRect->UpperLeftCorner.Y;
+			sourceRectData.right = sourceRect->LowerRightCorner.X;
+			sourceRectData.bottom = sourceRect->LowerRightCorner.Y;
+		}
+
+		hr = pID3DDevices[idx]->Present(srcRct, NULL, (HWND)windowId, NULL);
+		if (hr == D3DERR_DEVICELOST)
+		{
+			DeviceLost = true;
+			os::Printer::log("DirectX9 device lost.", ELL_WARNING);
+		}
+		else
+		if (FAILED(hr) && hr != D3DERR_INVALIDCALL)
+		{
+			os::Printer::log("DirectX9 present failed.", ELL_WARNING);
+			return false;
+		}
+	}
+	return true;
+
+	return true;
+}
+
+
+
+//! queries the features of the driver, returns true if feature is available
+bool CD3D9MDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice)
+{
+	if(renderDevice > -1)
+	{
+		switch (feature)
+		{
+		case EVDF_MULTITEXTURE:
+		case EVDF_BILINEAR_FILTER:
+			return true;
+		case EVDF_RENDER_TO_TARGET:
+			return Capss[renderDevice].NumSimultaneousRTs > 0;
+		case EVDF_HARDWARE_TL:
+			return (Capss[renderDevice].DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0;
+		case EVDF_MIP_MAP:
+			return (Capss[renderDevice].TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0;
+		case EVDF_STENCIL_BUFFER:
+			return StencilBuffer &&  Capss[renderDevice].StencilCaps;
+		case EVDF_VERTEX_SHADER_1_1:
+			return Capss[renderDevice].VertexShaderVersion >= D3DVS_VERSION(1,1);
+		case EVDF_VERTEX_SHADER_2_0:
+			return Capss[renderDevice].VertexShaderVersion >= D3DVS_VERSION(2,0);
+		case EVDF_VERTEX_SHADER_3_0:
+			return Capss[renderDevice].VertexShaderVersion >= D3DVS_VERSION(3,0);
+		case EVDF_PIXEL_SHADER_1_1:
+			return Capss[renderDevice].PixelShaderVersion >= D3DPS_VERSION(1,1);
+		case EVDF_PIXEL_SHADER_1_2:
+			return Capss[renderDevice].PixelShaderVersion >= D3DPS_VERSION(1,2);
+		case EVDF_PIXEL_SHADER_1_3:
+			return Capss[renderDevice].PixelShaderVersion >= D3DPS_VERSION(1,3);
+		case EVDF_PIXEL_SHADER_1_4:
+			return Capss[renderDevice].PixelShaderVersion >= D3DPS_VERSION(1,4);
+		case EVDF_PIXEL_SHADER_2_0:
+			return Capss[renderDevice].PixelShaderVersion >= D3DPS_VERSION(2,0);
+		case EVDF_PIXEL_SHADER_3_0:
+			return Capss[renderDevice].PixelShaderVersion >= D3DPS_VERSION(3,0);
+		case EVDF_HLSL:
+			return Capss[renderDevice].VertexShaderVersion >= D3DVS_VERSION(1,1);
+		case EVDF_TEXTURE_NPOT:
+			return (Capss[renderDevice].TextureCaps & D3DPTEXTURECAPS_POW2) == 0;
+		default:
+			return false;
+		};
+	}
+	bool result = true;
+	for(u32 idx = 0; idx < Capss.size(); ++idx)
+	{
+		switch (feature)
+		{
+		case EVDF_MULTITEXTURE:
+		case EVDF_BILINEAR_FILTER:
+			result = true;
+			break;
+		case EVDF_RENDER_TO_TARGET:
+			result = Capss[idx].NumSimultaneousRTs > 0;
+			break;
+		case EVDF_HARDWARE_TL:
+			result = (Capss[idx].DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) != 0;
+			break;
+		case EVDF_MIP_MAP:
+			result = (Capss[idx].TextureCaps & D3DPTEXTURECAPS_MIPMAP) != 0;
+			break;
+		case EVDF_STENCIL_BUFFER:
+			result = StencilBuffer &&  Capss[idx].StencilCaps;
+			break;
+		case EVDF_VERTEX_SHADER_1_1:
+			result = Capss[idx].VertexShaderVersion >= D3DVS_VERSION(1,1);
+			break;
+		case EVDF_VERTEX_SHADER_2_0:
+			result = Capss[idx].VertexShaderVersion >= D3DVS_VERSION(2,0);
+			break;
+		case EVDF_VERTEX_SHADER_3_0:
+			result = Capss[idx].VertexShaderVersion >= D3DVS_VERSION(3,0);
+			break;
+		case EVDF_PIXEL_SHADER_1_1:
+			result = Capss[idx].PixelShaderVersion >= D3DPS_VERSION(1,1);
+			break;
+		case EVDF_PIXEL_SHADER_1_2:
+			result = Capss[idx].PixelShaderVersion >= D3DPS_VERSION(1,2);
+			break;
+		case EVDF_PIXEL_SHADER_1_3:
+			result = Capss[idx].PixelShaderVersion >= D3DPS_VERSION(1,3);
+			break;
+		case EVDF_PIXEL_SHADER_1_4:
+			result = Capss[idx].PixelShaderVersion >= D3DPS_VERSION(1,4);
+			break;
+		case EVDF_PIXEL_SHADER_2_0:
+			result = Capss[idx].PixelShaderVersion >= D3DPS_VERSION(2,0);
+			break;
+		case EVDF_PIXEL_SHADER_3_0:
+			result = Capss[idx].PixelShaderVersion >= D3DPS_VERSION(3,0);
+			break;
+		case EVDF_HLSL:
+			result = Capss[idx].VertexShaderVersion >= D3DVS_VERSION(1,1);
+			break;
+		case EVDF_TEXTURE_NPOT:
+			result = (Capss[idx].TextureCaps & D3DPTEXTURECAPS_POW2) == 0;
+			break;
+		default:
+			result = false;
+		};
+		if(!result)
+			return result;
+	}
+	return result;
+}
+
+
+
+//! sets transformation
+void CD3D9MDriver::setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat)
+{
+	Transformation3DChanged = true;
+
+	switch(state)
+	{
+	case ETS_VIEW:
+		pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&mat));
+		break;
+	case ETS_WORLD:
+		pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&mat));
+		break;
+	case ETS_PROJECTION:
+		pID3DDevice->SetTransform( D3DTS_PROJECTION, (D3DMATRIX*)((void*)&mat));
+		break;
+	}
+
+	Matricess[m_renderAdapter][state] = mat;
+}
+
+
+
+//! sets the current Texture
+bool CD3D9MDriver::setTexture(s32 stage, video::ITexture* texture)
+{
+	if (CurrentTexture[stage] == texture)
+		return true;
+
+	if (texture && texture->getDriverType() != EDT_DIRECT3D9)
+	{
+		os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR);
+		return false;
+	}
+
+	if (CurrentTexture[stage])
+		CurrentTexture[stage]->drop();
+
+	CurrentTexture[stage] = texture;
+
+	if (!texture)
+		pID3DDevice->SetTexture(stage, 0);
+	else
+	{
+		pID3DDevice->SetTexture(stage, ((CD3D9Texture*)texture)->getDX9Texture(m_renderAdapter));
+		texture->grab();
+		pID3DDevice->SetTextureStageState( stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
+		pID3DDevice->SetTransform((D3DTRANSFORMSTATETYPE)(D3DTS_TEXTURE0+stage), (D3DMATRIX*)((void*)&texture->getTransformation()));
+	}
+	return true;
+}
+
+
+
+//! sets a material
+void CD3D9MDriver::setMaterial(const SMaterial& material)
+{
+	Materials[m_renderAdapter] = material;
+
+	for (s32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
+		setTexture(i, Materials[m_renderAdapter].Textures[i]);
+}
+
+
+
+//! returns a device dependent texture from a software surface (IImage)
+video::ITexture* CD3D9MDriver::createDeviceDependentTexture(IImage* surface, const char* name)
+{
+	return new CD3D9Texture(surface, this, pID3DDevices, TextureCreationFlags, name);
+}
+
+
+
+//! Enables or disables a texture creation flag.
+void CD3D9MDriver::setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled)
+{
+	if (flag == video::ETCF_CREATE_MIP_MAPS && !queryFeature(EVDF_MIP_MAP))
+		enabled = false;
+
+	CNullDriver::setTextureCreationFlag(flag, enabled);
+}
+
+
+
+//! sets a render target
+bool CD3D9MDriver::setRenderTarget(video::ITexture* texture,
+			bool clearBackBuffer, bool clearZBuffer,
+			SColor color)
+{
+	// check for right driver type
+
+	if (texture && texture->getDriverType() != EDT_DIRECT3D9)
+	{
+		os::Printer::log("Fatal Error: Tried to set a texture not owned by this driver.", ELL_ERROR);
+		return false;
+	}
+
+	// check for valid render target
+
+	CD3D9Texture* tex = (CD3D9Texture*)texture;
+
+	if (texture && !tex->isRenderTarget())
+	{
+		os::Printer::log("Fatal Error: Tried to set a non render target texture as render target.", ELL_ERROR);
+		return false;
+	}
+
+	if (texture && (tex->getSize().Width > ScreenSize.Width ||
+		tex->getSize().Height > ScreenSize.Height ))
+	{
+		os::Printer::log("Error: Tried to set a render target texture which is bigger than the screen.", ELL_ERROR);
+		return false;
+	}
+
+	// check if we should set the previous RT back
+
+	bool ret = true;
+
+	if (tex == 0)
+	{
+		if (PrevRenderTarget)
+		{
+			if (FAILED(pID3DDevice->SetRenderTarget(0, PrevRenderTarget)))
+			{
+				os::Printer::log("Error: Could not set back to previous render target.", ELL_ERROR);
+				ret = false;
+			}
+
+			CurrentRendertargetSize = core::dimension2d<s32>(0,0);
+			PrevRenderTarget->Release();
+			PrevRenderTarget = 0;
+		}
+	}
+	else
+	{
+		// we want to set a new target. so do this.
+
+		// store previous target
+
+		if (!PrevRenderTarget)
+			if (FAILED(pID3DDevice->GetRenderTarget(0, &PrevRenderTarget)))
+			{
+				os::Printer::log("Could not get previous render target.", ELL_ERROR);
+				return false;
+			}
+
+		// set new render target
+
+			if (FAILED(pID3DDevice->SetRenderTarget(0, tex->getRenderTargetSurface(m_renderAdapter))))
+		{
+			os::Printer::log("Error: Could not set render target.", ELL_ERROR);
+			return false;
+		}
+
+		CurrentRendertargetSize = tex->getSize();
+	}
+
+	if (clearBackBuffer || clearZBuffer)
+	{
+		DWORD flags = 0;
+
+		if (clearBackBuffer)
+			flags |= D3DCLEAR_TARGET;
+
+		if (clearZBuffer)
+			flags |= D3DCLEAR_ZBUFFER;
+
+		pID3DDevice->Clear(0, NULL, flags, color.color, 1.0f, 0);
+	}
+
+	return ret;
+}
+
+
+
+//! sets a viewport
+void CD3D9MDriver::setViewPort(const core::rect<s32>& area)
+{
+	HRESULT hr;
+	core::rect<s32> vp = area;
+	s32 curRenderAdapter = -1;
+	u32 ordinal = 0;
+	s32 adapterAdd = 0;
+	s32 monitorCount = 0;
+
+	//if already exist, then clear
+	if(m_pBackBuffer)
+	{
+		m_pBackBuffer->Release();
+		m_pBackBuffer = NULL;
+	}
+    if(m_pSwapChain)
+	{
+		m_pSwapChain->Release();
+		m_pSwapChain = NULL;
+	}
+	
+	monitorCount = area.UpperLeftCorner.X / ScreenSize.Width;
+	
+	for(s32 idx = 0; idx < (s32)m_Device.iNumAdapters; ++idx)
+	{
+		for(u32 idy = 0; idy < m_Device.Adapters[idx].Ordinal; ++idy)
+		{
+			if(monitorCount == (idx+idy+adapterAdd))
+			{
+				curRenderAdapter = idx;
+				ordinal = idy;
+				break;
+			}
+		}
+		adapterAdd++;
+		if(curRenderAdapter > -1)
+			break;
+	}
+	pID3DDevice = pID3DDevices[curRenderAdapter];
+	m_renderAdapter = curRenderAdapter;
+
+	if(monitorCount > 0)
+	{
+		vp = core::rect<s32>((area.UpperLeftCorner.X / monitorCount - ScreenSize.Width), 
+								area.UpperLeftCorner.Y, (area.LowerRightCorner.X / monitorCount), area.getHeight());
+
+	}
+
+	u32 numSwapChains = pID3DDevice->GetNumberOfSwapChains();
+
+	if(ordinal > numSwapChains)
+	{
+		char tmp[255];
+		sprintf(tmp, "DirectX9 multihead error! More adapter supposed as available. adapter: %d  ordinal: %d chain: %d", curRenderAdapter, ordinal, numSwapChains);
+		os::Printer::log(tmp, ELL_WARNING);
+		return;
+	}
+	hr = pID3DDevice->GetSwapChain( ordinal, &m_pSwapChain );
+	if (FAILED(hr))
+	{
+		os::Printer::log("DirectX9 multihead error! Get swap chain failed.", ELL_WARNING);
+		return;
+	}
+	hr = m_pSwapChain->GetBackBuffer( 0, D3DBACKBUFFER_TYPE_MONO, &m_pBackBuffer );
+	if (FAILED(hr))
+	{
+		os::Printer::log("DirectX9 multihead error!  Get back buffer failed.", ELL_WARNING);
+		return;
+	}
+	hr = pID3DDevice->SetRenderTarget( 0, m_pBackBuffer );
+	if (FAILED(hr))
+	{
+		os::Printer::log("DirectX9 multihead error! Set render target failed.", ELL_WARNING);
+		return;
+	}
+	BackBuffer = true;
+
+	core::rect<s32> rendert(0,0, ScreenSize.Width, ScreenSize.Height);
+	vp.clipAgainst(rendert);
+
+	D3DVIEWPORT9 viewPort;
+	viewPort.X = vp.UpperLeftCorner.X;
+	viewPort.Y = vp.UpperLeftCorner.Y;
+	viewPort.Width = vp.getWidth();
+	viewPort.Height = vp.getHeight();
+	viewPort.MinZ = 0.0f;
+	viewPort.MaxZ = 1.0f;
+
+	hr = D3DERR_INVALIDCALL;
+	if (vp.getHeight()>0 && vp.getWidth()>0)
+		hr = pID3DDevice->SetViewport(&viewPort);
+
+	if (FAILED(hr))
+		os::Printer::log("Failed setting the viewport.", ELL_WARNING);
+
+	DWORD flags = 0;
+
+	if (BackBuffer)
+		flags |= D3DCLEAR_TARGET;
+
+	if (ZBuffer)
+		flags |= D3DCLEAR_ZBUFFER;
+
+	if (StencilBuffer)
+		flags |= D3DCLEAR_STENCIL;
+
+	hr = pID3DDevice->Clear( 0, NULL, flags, Color.color, 1.0, 0);
+	if (FAILED(hr))
+		os::Printer::log("DirectX9 clear viewport failed.", ELL_WARNING);
+
+	ViewPort = vp;
+}
+
+
+
+//! gets the area of the current viewport
+const core::rect<s32>& CD3D9MDriver::getViewPort() const
+{
+	return ViewPort;
+}
+
+
+
+//! draws a vertex primitive list
+void CD3D9MDriver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
+{
+	if (!checkPrimitiveCount(primitiveCount))
+		return;
+
+	CNullDriver::drawVertexPrimitiveList(vertices, vertexCount, indexList, primitiveCount, vType, pType);
+
+	if (!vertexCount || !primitiveCount)
+		return;
+
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setVertexShader(vType);
+
+	size_t stride=0;
+	switch (vType)
+	{
+		case EVT_STANDARD:
+			stride=sizeof(S3DVertex);
+			break;
+		case EVT_2TCOORDS:
+			stride=sizeof(S3DVertex2TCoords);
+			break;
+		case EVT_TANGENTS:
+			stride=sizeof(S3DVertexTangents);
+			break;
+	}
+	if (setRenderStates3DMode())
+	{
+		switch (pType)
+		{
+			case scene::EPT_POINTS:
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_POINTLIST, 0, vertexCount,
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
+				break;
+			case scene::EPT_LINE_STRIP:
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
+				break;
+			case scene::EPT_LINE_LOOP:
+			{
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINESTRIP, 0, vertexCount,
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
+				u16 tmpIndices[] = {0, primitiveCount};
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
+					1, tmpIndices, D3DFMT_INDEX16, vertices, stride);
+			}
+				break;
+			case scene::EPT_LINES:
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_LINELIST, 0, vertexCount,
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
+				break;
+			case scene::EPT_TRIANGLE_STRIP:
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLESTRIP, 0, vertexCount,
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
+				break;
+			case scene::EPT_TRIANGLE_FAN:
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLEFAN, 0, vertexCount,
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
+				break;
+			case scene::EPT_TRIANGLES:
+				pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, vertexCount,
+					primitiveCount, indexList, D3DFMT_INDEX32, vertices, stride);
+				break;
+		}
+	}
+	endPartScene();
+}
+
+
+
+void CD3D9MDriver::draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
+		const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect,
+		video::SColor* colors, bool useAlphaChannelOfTexture)
+{
+	if(!texture)
+		return;
+
+	core::rect<s32> trgRect(destRect);
+
+	const core::dimension2d<s32>& ss = texture->getOriginalSize();
+	f32 ssw=1.0f/ss.Width;
+	f32 ssh=1.0f/ss.Height;
+
+	core::rect<f32> tcoords;
+	tcoords.UpperLeftCorner.X = (((f32)sourceRect.UpperLeftCorner.X)+0.5f) * ssw ;
+	tcoords.UpperLeftCorner.Y = (((f32)sourceRect.UpperLeftCorner.Y)+0.5f) * ssh;
+	tcoords.LowerRightCorner.X = (((f32)sourceRect.UpperLeftCorner.X +0.5f + (f32)sourceRect.getWidth())) * ssw;
+	tcoords.LowerRightCorner.Y = (((f32)sourceRect.UpperLeftCorner.Y +0.5f + (f32)sourceRect.getHeight())) * ssh;
+
+	core::dimension2d<s32> renderTargetSize = getCurrentRenderTargetSize();
+
+	s32 xPlus = -(renderTargetSize.Width>>1);
+	f32 xFact = 1.0f / (renderTargetSize.Width>>1);
+
+	s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1);
+	f32 yFact = 1.0f / (renderTargetSize.Height>>1);
+
+	core::rect<f32> npos;
+	npos.UpperLeftCorner.X = (f32)(trgRect.UpperLeftCorner.X+xPlus+0.5f) * xFact;
+	npos.UpperLeftCorner.Y = (f32)(yPlus-trgRect.UpperLeftCorner.Y+0.5f) * yFact;
+	npos.LowerRightCorner.X = (f32)(trgRect.LowerRightCorner.X+xPlus+0.5f) * xFact;
+	npos.LowerRightCorner.Y = (f32)(yPlus-trgRect.LowerRightCorner.Y+0.5f) * yFact;
+
+	video::SColor temp[4] =
+	{
+		0xFFFFFFFF,
+		0xFFFFFFFF,
+		0xFFFFFFFF,
+		0xFFFFFFFF
+	};
+
+	video::SColor* useColor = colors ? colors : temp;
+
+	S3DVertex vtx[4]; // clock wise
+	vtx[0] = S3DVertex(npos.UpperLeftCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[0], tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
+	vtx[1] = S3DVertex(npos.LowerRightCorner.X, npos.UpperLeftCorner.Y , 0.0f, 0.0f, 0.0f, 0.0f, useColor[3], tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
+	vtx[2] = S3DVertex(npos.LowerRightCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[2], tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
+	vtx[3] = S3DVertex(npos.UpperLeftCorner.X, npos.LowerRightCorner.Y, 0.0f, 0.0f, 0.0f, 0.0f, useColor[1], tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
+
+	s16 indices[6] = {0,1,2,0,2,3};
+
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 || useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255, true, useAlphaChannelOfTexture);
+
+	setTexture(0, texture);
+
+	setVertexShader(EVT_STANDARD);
+
+	pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0],
+				D3DFMT_INDEX16,&vtx[0], sizeof(S3DVertex));
+
+	endPartScene();
+}
+
+
+
+//! draws a 2d image, using a color and the alpha channel of the texture if
+//! desired. The image is drawn at pos and clipped against clipRect (if != 0).
+void CD3D9MDriver::draw2DImage(video::ITexture* texture,
+				const core::position2d<s32>& pos,
+				const core::rect<s32>& sourceRect,
+				const core::rect<s32>* clipRect, SColor color,
+				bool useAlphaChannelOfTexture)
+{
+	if (!texture)
+		return;
+
+	if (!sourceRect.isValid())
+		return;
+
+	if (!setTexture(0, texture))
+		return;
+
+	core::position2d<s32> targetPos = pos;
+	core::position2d<s32> sourcePos = sourceRect.UpperLeftCorner;
+	core::dimension2d<s32> sourceSize(sourceRect.getSize());
+
+	core::dimension2d<s32> renderTargetSize = getCurrentRenderTargetSize();
+
+	if (clipRect)
+	{
+		if (targetPos.X < clipRect->UpperLeftCorner.X)
+		{
+			sourceSize.Width += targetPos.X - clipRect->UpperLeftCorner.X;
+			if (sourceSize.Width <= 0)
+				return;
+
+			sourcePos.X -= targetPos.X - clipRect->UpperLeftCorner.X;
+			targetPos.X = clipRect->UpperLeftCorner.X;
+		}
+
+		if (targetPos.X + sourceSize.Width > clipRect->LowerRightCorner.X)
+		{
+			sourceSize.Width -= (targetPos.X + sourceSize.Width) - clipRect->LowerRightCorner.X;
+			if (sourceSize.Width <= 0)
+				return;
+		}
+
+		if (targetPos.Y < clipRect->UpperLeftCorner.Y)
+		{
+			sourceSize.Height += targetPos.Y - clipRect->UpperLeftCorner.Y;
+			if (sourceSize.Height <= 0)
+				return;
+
+			sourcePos.Y -= targetPos.Y - clipRect->UpperLeftCorner.Y;
+			targetPos.Y = clipRect->UpperLeftCorner.Y;
+		}
+
+		if (targetPos.Y + sourceSize.Height > clipRect->LowerRightCorner.Y)
+		{
+			sourceSize.Height -= (targetPos.Y + sourceSize.Height) - clipRect->LowerRightCorner.Y;
+			if (sourceSize.Height <= 0)
+				return;
+		}
+	}
+
+	// clip these coordinates
+
+	if (targetPos.X<0)
+	{
+		sourceSize.Width += targetPos.X;
+		if (sourceSize.Width <= 0)
+			return;
+
+		sourcePos.X -= targetPos.X;
+		targetPos.X = 0;
+	}
+
+	if (targetPos.X + sourceSize.Width > renderTargetSize.Width)
+	{
+		sourceSize.Width -= (targetPos.X + sourceSize.Width) - renderTargetSize.Width;
+		if (sourceSize.Width <= 0)
+			return;
+	}
+
+	if (targetPos.Y<0)
+	{
+		sourceSize.Height += targetPos.Y;
+		if (sourceSize.Height <= 0)
+			return;
+
+		sourcePos.Y -= targetPos.Y;
+		targetPos.Y = 0;
+	}
+
+	if (targetPos.Y + sourceSize.Height > renderTargetSize.Height)
+	{
+		sourceSize.Height -= (targetPos.Y + sourceSize.Height) - renderTargetSize.Height;
+		if (sourceSize.Height <= 0)
+			return;
+	}
+
+	// ok, we've clipped everything.
+	// now draw it.
+
+	f32 xPlus = - renderTargetSize.Width / 2.f;
+	f32 xFact = 1.0f / (renderTargetSize.Width / 2.f);
+
+	f32 yPlus = renderTargetSize.Height-(renderTargetSize.Height / 2.f);
+	f32 yFact = 1.0f / (renderTargetSize.Height / 2.f);
+
+	const core::dimension2d<s32>& sourceSurfaceSize = texture->getOriginalSize();
+	core::rect<f32> tcoords;
+	tcoords.UpperLeftCorner.X = (((f32)sourcePos.X)+0.5f) / texture->getOriginalSize().Width ;
+	tcoords.UpperLeftCorner.Y = (((f32)sourcePos.Y)+0.5f) / texture->getOriginalSize().Height;
+	tcoords.LowerRightCorner.X = (((f32)sourcePos.X +0.5f + (f32)sourceSize.Width)) / texture->getOriginalSize().Width;
+	tcoords.LowerRightCorner.Y = (((f32)sourcePos.Y +0.5f + (f32)sourceSize.Height)) / texture->getOriginalSize().Height;
+
+	core::rect<s32> poss(targetPos, sourceSize);
+
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setRenderStates2DMode(color.getAlpha()<255, true, useAlphaChannelOfTexture);
+
+	S3DVertex vtx[4];
+	vtx[0] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.UpperLeftCorner.Y ) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.UpperLeftCorner.Y);
+	vtx[1] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- poss.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.UpperLeftCorner.Y);
+	vtx[2] = S3DVertex((f32)(poss.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.LowerRightCorner.X, tcoords.LowerRightCorner.Y);
+	vtx[3] = S3DVertex((f32)(poss.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-poss.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, color, tcoords.UpperLeftCorner.X, tcoords.LowerRightCorner.Y);
+
+	s16 indices[6] = {0,1,2,0,2,3};
+
+	setVertexShader(EVT_STANDARD);
+
+	pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0],
+										D3DFMT_INDEX16,&vtx[0],	sizeof(S3DVertex));
+	endPartScene();
+}
+
+
+
+//!Draws a 2d rectangle with a gradient.
+void CD3D9MDriver::draw2DRectangle(const core::rect<s32>& position,
+	SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
+	const core::rect<s32>* clip)
+{
+	core::rect<s32> pos(position);
+
+	if (clip)
+		pos.clipAgainst(*clip);
+
+	if (!pos.isValid())
+		return;
+
+	const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
+
+	s32 xPlus = -(renderTargetSize.Width>>1);
+	f32 xFact = 1.0f / (renderTargetSize.Width>>1);
+
+	s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1);
+	f32 yFact = 1.0f / (renderTargetSize.Height>>1);
+
+	S3DVertex vtx[4];
+	vtx[0] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.UpperLeftCorner.Y) * yFact , 0.0f, 0.0f, 0.0f, 0.0f, colorLeftUp, 0.0f, 0.0f);
+	vtx[1] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus- pos.UpperLeftCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightUp, 0.0f, 1.0f);
+	vtx[2] = S3DVertex((f32)(pos.LowerRightCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorRightDown, 1.0f, 0.0f);
+	vtx[3] = S3DVertex((f32)(pos.UpperLeftCorner.X+xPlus) * xFact, (f32)(yPlus-pos.LowerRightCorner.Y) * yFact, 0.0f, 0.0f, 0.0f, 0.0f, colorLeftDown, 1.0f, 1.0f);
+
+	s16 indices[6] = {0,1,2,0,2,3};
+
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setRenderStates2DMode(
+		colorLeftUp.getAlpha() < 255 ||
+		colorRightUp.getAlpha() < 255 ||
+		colorLeftDown.getAlpha() < 255 ||
+		colorRightDown.getAlpha() < 255, false, false);
+
+	setTexture(0,0);
+
+	setVertexShader(EVT_STANDARD);
+
+	pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0],
+											D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex));
+	endPartScene();
+}
+
+
+
+//! Draws a 2d line.
+void CD3D9MDriver::draw2DLine(const core::position2d<s32>& start,
+				const core::position2d<s32>& end,
+				SColor color)
+{
+	// thanks to Vash TheStampede who sent in his implementation
+
+	const core::dimension2d<s32>& renderTargetSize = getCurrentRenderTargetSize();
+	const s32 xPlus = -(renderTargetSize.Width>>1);
+	const f32 xFact = 1.0f / (renderTargetSize.Width>>1);
+
+	const s32 yPlus = renderTargetSize.Height-(renderTargetSize.Height>>1);
+	const f32 yFact = 1.0f / (renderTargetSize.Height>>1);
+
+	S3DVertex vtx[2];
+	vtx[0] = S3DVertex((f32)(start.X + xPlus) * xFact,
+						(f32)(yPlus - start.Y) * yFact,
+						0.0f, // z
+						0.0f, 0.0f, 0.0f, // normal
+						color,
+						0.0f, 0.0f); // texture
+
+	vtx[1] = S3DVertex((f32)(end.X+xPlus) * xFact,
+						(f32)(yPlus- end.Y) * yFact,
+						0.0f,
+						0.0f, 0.0f, 0.0f,
+						color,
+						0.0f, 0.0f);
+
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setRenderStates2DMode(color.getAlpha() < 255, false, false);
+	setTexture(0,0);
+
+	setVertexShader(EVT_STANDARD);
+
+	pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1,
+					&vtx[0], sizeof(S3DVertex) );
+
+	endPartScene();
+}
+
+
+
+//! sets right vertex shader
+void CD3D9MDriver::setVertexShader(E_VERTEX_TYPE newType)
+{
+	if (newType != LastVertexTypes[m_renderAdapter])
+	{
+		LastVertexTypes[m_renderAdapter] = newType;
+		HRESULT hr = 0;
+
+		switch(newType)
+		{
+		case EVT_STANDARD:
+			hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1);
+			break;
+		case EVT_2TCOORDS:
+			hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX2);
+			break;
+		case EVT_TANGENTS:
+			hr = pID3DDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX3 |
+				D3DFVF_TEXCOORDSIZE2(0) | // real texture coord
+				D3DFVF_TEXCOORDSIZE3(1) | // misuse texture coord 2 for tangent
+				D3DFVF_TEXCOORDSIZE3(2)   // misuse texture coord 3 for binormal
+				);
+			break;
+		}
+
+		if (FAILED(hr))
+		{
+			os::Printer::log("Could not set vertex Shader.", ELL_ERROR);
+			return;
+		}
+	}
+}
+
+
+
+//! sets the needed renderstates
+bool CD3D9MDriver::setRenderStates3DMode()
+{
+	if (!pID3DDevice)
+		return false;
+
+	if (CurrentRenderMode != ERM_3D)
+	{
+		// switch back the matrices
+		pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matricess[m_renderAdapter][ETS_VIEW]));
+		pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matricess[m_renderAdapter][ETS_WORLD]));
+		pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matricess[m_renderAdapter][ETS_PROJECTION]));
+
+		pID3DDevice->SetRenderState(D3DRS_STENCILENABLE, FALSE);
+
+		ResetRenderStatess[m_renderAdapter] = true;
+	}
+
+	if (ResetRenderStatess[m_renderAdapter] || LastMaterials[m_renderAdapter] != Materials[m_renderAdapter])
+	{
+		// unset old material
+
+		if (CurrentRenderMode == ERM_3D &&
+			LastMaterials[m_renderAdapter].MaterialType != Materials[m_renderAdapter].MaterialType &&
+			LastMaterials[m_renderAdapter].MaterialType >= 0 && LastMaterials[m_renderAdapter].MaterialType < (s32)MaterialRenderers.size())
+		{
+			MaterialRenderers[LastMaterials[m_renderAdapter].MaterialType].Renderer->setRenderDevice(m_renderAdapter);
+			MaterialRenderers[LastMaterials[m_renderAdapter].MaterialType].Renderer->OnUnsetMaterial();
+		}
+
+		// set new material.
+
+		if (Materials[m_renderAdapter].MaterialType >= 0 && Materials[m_renderAdapter].MaterialType < (s32)MaterialRenderers.size())
+		{
+			MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->setRenderDevice(m_renderAdapter);
+			MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->OnSetMaterial(
+				Materials[m_renderAdapter], LastMaterials[m_renderAdapter], ResetRenderStatess[m_renderAdapter], this);
+		}
+	}
+
+	bool shaderOK = true;
+	if (Materials[m_renderAdapter].MaterialType >= 0 && Materials[m_renderAdapter].MaterialType < (s32)MaterialRenderers.size())
+	{
+		MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->setRenderDevice(m_renderAdapter);
+		shaderOK = MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->OnRender(this, LastVertexTypes[m_renderAdapter]);
+	}
+
+	LastMaterials[m_renderAdapter] = Materials[m_renderAdapter];
+
+	ResetRenderStatess[m_renderAdapter] = false;
+
+	CurrentRenderMode = ERM_3D;
+
+	return shaderOK;
+}
+
+
+
+//! Can be called by an IMaterialRenderer to make its work easier.
+void CD3D9MDriver::setBasicRenderStates(const SMaterial& material, const SMaterial& lastmaterial,
+	bool resetAllRenderstates)
+{
+	if (resetAllRenderstates ||
+		lastmaterial.AmbientColor != material.AmbientColor ||
+		lastmaterial.DiffuseColor != material.DiffuseColor ||
+		lastmaterial.SpecularColor != material.SpecularColor ||
+		lastmaterial.EmissiveColor != material.EmissiveColor ||
+		lastmaterial.Shininess != material.Shininess)
+	{
+		D3DMATERIAL9 mat;
+		mat.Diffuse = colorToD3D(material.DiffuseColor);
+		mat.Ambient = colorToD3D(material.AmbientColor);
+		mat.Specular = colorToD3D(material.SpecularColor);
+		mat.Emissive = colorToD3D(material.EmissiveColor);
+		mat.Power = material.Shininess;
+		pID3DDevice->SetMaterial(&mat);
+	}
+
+	// Bilinear and/or trilinear
+	if (resetAllRenderstates ||
+		lastmaterial.BilinearFilter != material.BilinearFilter ||
+		lastmaterial.TrilinearFilter != material.TrilinearFilter ||
+		lastmaterial.AnisotropicFilter != material.AnisotropicFilter ||
+		!LastTextureMipMapsAvailable[0] ||
+		!LastTextureMipMapsAvailable[1])
+	{
+		if (material.BilinearFilter || material.TrilinearFilter || material.AnisotropicFilter)
+		{
+			pID3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, material.AnisotropicFilter ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR);
+			pID3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, material.AnisotropicFilter ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR);
+			pID3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, material.TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT);
+
+			pID3DDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, material.AnisotropicFilter ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR);
+			pID3DDevice->SetSamplerState(1, D3DSAMP_MINFILTER, material.AnisotropicFilter ? D3DTEXF_ANISOTROPIC : D3DTEXF_LINEAR);
+			pID3DDevice->SetSamplerState(1, D3DSAMP_MIPFILTER, material.TrilinearFilter ? D3DTEXF_LINEAR : D3DTEXF_POINT);
+		}
+		else
+		{
+			pID3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+			pID3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+			pID3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+
+			pID3DDevice->SetSamplerState(1, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+			pID3DDevice->SetSamplerState(1, D3DSAMP_MIPFILTER,  D3DTEXF_NONE);
+			pID3DDevice->SetSamplerState(1, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+		}
+	}
+
+	// fillmode
+
+	if (resetAllRenderstates || lastmaterial.Wireframe != material.Wireframe || lastmaterial.PointCloud != material.PointCloud)
+	{
+		if (material.Wireframe)
+			pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_WIREFRAME);
+		else
+		if (material.PointCloud)
+			pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_POINT);
+		else
+			pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
+	}
+
+	// shademode
+
+	if (resetAllRenderstates || lastmaterial.GouraudShading != material.GouraudShading)
+	{
+		if (material.GouraudShading)
+			pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD);
+		else
+			pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT);
+	}
+
+	// lighting
+
+	if (resetAllRenderstates || lastmaterial.Lighting != material.Lighting)
+	{
+		if (material.Lighting)
+			pID3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
+		else
+			pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
+	}
+
+	// zbuffer
+
+	if (resetAllRenderstates || lastmaterial.ZBuffer != material.ZBuffer)
+	{
+		if (material.ZBuffer)
+			pID3DDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
+		else
+			pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
+	}
+
+	// zwrite
+	if (resetAllRenderstates || lastmaterial.ZWriteEnable != material.ZWriteEnable)
+	{
+		if (material.ZWriteEnable)
+			pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, TRUE);
+		else
+			pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE, FALSE);
+	}
+
+	// back face culling
+
+	if (resetAllRenderstates || lastmaterial.BackfaceCulling != material.BackfaceCulling)
+	{
+		if (material.BackfaceCulling)
+			pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
+		else
+			pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_NONE);
+	}
+
+	// fog
+	if (resetAllRenderstates || lastmaterial.FogEnable != material.FogEnable)
+	{
+		pID3DDevice->SetRenderState(D3DRS_FOGENABLE, material.FogEnable);
+	}
+
+	// specular highlights
+	if (resetAllRenderstates || !core::equals(lastmaterial.Shininess,material.Shininess))
+	{
+		bool enable = (material.Shininess!=0.0f);
+		pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, enable);
+		pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS, enable);
+		pID3DDevice->SetRenderState(D3DRS_SPECULARMATERIALSOURCE, D3DMCS_MATERIAL);
+	}
+
+	// normalization
+	if (resetAllRenderstates || lastmaterial.NormalizeNormals != material.NormalizeNormals)
+	{
+		pID3DDevice->SetRenderState(D3DRS_NORMALIZENORMALS,  material.NormalizeNormals);
+	}
+}
+
+
+
+//! sets the needed renderstates
+void CD3D9MDriver::setRenderStatesStencilShadowMode(bool zfail)
+{
+	if ((CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL &&
+		CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS) ||
+		Transformation3DChanged)
+	{
+		// switch back the matrices
+		pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&Matricess[m_renderAdapter][ETS_VIEW]));
+		pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&Matricess[m_renderAdapter][ETS_WORLD]));
+		pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&Matricess[m_renderAdapter][ETS_PROJECTION]));
+
+		Transformation3DChanged = false;
+
+		setTexture(0,0);
+		setTexture(1,0);
+		setTexture(2,0);
+		setTexture(3,0);
+
+		pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+		pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+		pID3DDevice->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
+		pID3DDevice->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+
+		pID3DDevice->SetFVF(D3DFVF_XYZ);
+		LastVertexTypes[m_renderAdapter] = (video::E_VERTEX_TYPE)(-1);
+
+		pID3DDevice->SetRenderState( D3DRS_ZWRITEENABLE,  FALSE );
+		pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, TRUE );
+		pID3DDevice->SetRenderState( D3DRS_SHADEMODE, D3DSHADE_FLAT);
+
+		// unset last 3d material
+		if (CurrentRenderMode == ERM_3D &&
+			Materials[m_renderAdapter].MaterialType >= 0 && Materials[m_renderAdapter].MaterialType < (s32)MaterialRenderers.size())
+		{
+			MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->setRenderDevice(m_renderAdapter);
+			MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->OnUnsetMaterial();
+		}
+
+		//pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
+		//pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+	}
+
+	if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZPASS && !zfail)
+	{
+		// USE THE ZPASS METHOD
+
+		pID3DDevice->SetRenderState( D3DRS_STENCILFUNC,  D3DCMP_ALWAYS );
+		pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP );
+		pID3DDevice->SetRenderState( D3DRS_STENCILFAIL,  D3DSTENCILOP_KEEP );
+
+		pID3DDevice->SetRenderState( D3DRS_STENCILREF,       0x1 );
+		pID3DDevice->SetRenderState( D3DRS_STENCILMASK,      0xffffffff );
+		pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff );
+
+		pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE);
+		pID3DDevice->SetRenderState( D3DRS_SRCBLEND,  D3DBLEND_ZERO );
+		pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
+	}
+	else
+	if (CurrentRenderMode != ERM_SHADOW_VOLUME_ZFAIL && zfail)
+	{
+		// USE THE ZFAIL METHOD
+
+		pID3DDevice->SetRenderState( D3DRS_STENCILFUNC,  D3DCMP_ALWAYS );
+		pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP );
+		pID3DDevice->SetRenderState( D3DRS_STENCILFAIL,  D3DSTENCILOP_KEEP );
+		pID3DDevice->SetRenderState( D3DRS_STENCILPASS,  D3DSTENCILOP_KEEP );
+
+		pID3DDevice->SetRenderState( D3DRS_STENCILREF,       0x0 );
+		pID3DDevice->SetRenderState( D3DRS_STENCILMASK,      0xffffffff );
+		pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff );
+
+		pID3DDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
+		pID3DDevice->SetRenderState( D3DRS_SRCBLEND,  D3DBLEND_ZERO );
+		pID3DDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
+	}
+
+	CurrentRenderMode = zfail ? ERM_SHADOW_VOLUME_ZFAIL : ERM_SHADOW_VOLUME_ZPASS;
+}
+
+
+
+//! sets the needed renderstates
+void CD3D9MDriver::setRenderStatesStencilFillMode(bool alpha)
+{
+	if (CurrentRenderMode != ERM_STENCIL_FILL || Transformation3DChanged)
+	{
+		core::matrix4 mat;
+		pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&mat));
+		pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&mat));
+		pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&mat));
+
+		pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
+		pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
+		pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
+
+		pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+		pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+
+		pID3DDevice->SetRenderState( D3DRS_STENCILREF, 0x1);
+		pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_LESSEQUAL);
+		//pID3DDevice->SetRenderState(D3DRS_STENCILFUNC, D3DCMP_GREATEREQUAL);
+		pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_KEEP );
+		pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_KEEP );
+		pID3DDevice->SetRenderState( D3DRS_STENCILMASK,      0xffffffff );
+		pID3DDevice->SetRenderState( D3DRS_STENCILWRITEMASK, 0xffffffff );
+
+		pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
+
+		Transformation3DChanged = false;
+
+		if (alpha)
+		{
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1);
+			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
+			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+			pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+			pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
+		}
+		else
+		{
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE );
+			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+		}
+	}
+
+	CurrentRenderMode = ERM_STENCIL_FILL;
+}
+
+
+
+//! sets the needed renderstates
+void CD3D9MDriver::setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel)
+{
+	if (!pID3DDevice)
+		return;
+
+	if (CurrentRenderMode != ERM_2D || Transformation3DChanged)
+	{
+		core::matrix4 mat;
+		core::matrix4 mat1;
+		pID3DDevice->SetTransform(D3DTS_VIEW, (D3DMATRIX*)((void*)&mat));
+		pID3DDevice->SetTransform(D3DTS_WORLD, (D3DMATRIX*)((void*)&mat));
+		pID3DDevice->SetTransform(D3DTS_PROJECTION, (D3DMATRIX*)((void*)&mat));
+
+		pID3DDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
+		//pID3DDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT);
+		pID3DDevice->SetRenderState(D3DRS_FILLMODE, D3DFILL_SOLID);
+		pID3DDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
+		pID3DDevice->SetRenderState(D3DRS_FOGENABLE, FALSE);
+		pID3DDevice->SetRenderState(D3DRS_SPECULARENABLE, FALSE);
+
+		pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+		pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+
+		pID3DDevice->SetRenderState( D3DRS_STENCILENABLE, FALSE );
+
+		pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
+
+		pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
+		pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
+
+		pID3DDevice->SetTransform( D3DTS_TEXTURE0, (D3DMATRIX*)((void*)&mat1) );//??
+
+		Transformation3DChanged = false;
+
+		// unset last 3d material
+		if (CurrentRenderMode == ERM_3D &&
+			Materials[m_renderAdapter].MaterialType >= 0 && Materials[m_renderAdapter].MaterialType < (s32)MaterialRenderers.size())
+		{
+			MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->setRenderDevice(m_renderAdapter);
+			MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer->OnUnsetMaterial();
+		}
+	}
+
+	if (texture)
+	{
+		pID3DDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+		pID3DDevice->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
+		pID3DDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+
+		if (alphaChannel)
+		{
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+
+			if (alpha)
+			{
+				pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_MODULATE );
+				pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
+				pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE );
+			}
+			else
+			{
+				pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_SELECTARG1 );
+				pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
+			}
+
+			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+			pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+			pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
+		}
+		else
+		{
+			if (alpha)
+			{
+				pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2);
+				pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+				pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+				pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+				pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
+			}
+			else
+			{
+				pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+				pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+				pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+				pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+				pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+			}
+		}
+	}
+	else
+	{
+		if (alpha)
+		{
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,  D3DTOP_SELECTARG1);
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
+			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+			pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+			pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
+		}
+		else
+		{
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
+			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+		}
+	}
+
+	CurrentRenderMode = ERM_2D;
+}
+
+
+
+//! deletes all dynamic lights there are
+void CD3D9MDriver::deleteAllDynamicLights()
+{
+	for (s32 i=0; i<LastSetLights[m_renderAdapter]+1; ++i)
+		pID3DDevice->LightEnable(i, false);
+
+	LastSetLights[m_renderAdapter] = -1;
+
+	CNullDriver::deleteAllDynamicLights();
+}
+
+
+
+//! adds a dynamic light
+void CD3D9MDriver::addDynamicLight(const SLight& dl)
+{
+	if ((u32)LastSetLights[m_renderAdapter] == Capss[m_renderAdapter].MaxActiveLights-1)
+		return;
+
+	CNullDriver::addDynamicLight(dl);
+
+	D3DLIGHT9 light;
+
+	if ( dl.Type == ELT_POINT )
+	{
+		light.Type = D3DLIGHT_POINT;
+		light.Position = *(D3DVECTOR*)((void*)(&dl.Position));
+	}
+	else
+	if ( dl.Type == ELT_DIRECTIONAL )
+	{
+		light.Type = D3DLIGHT_DIRECTIONAL;
+		light.Direction = *(D3DVECTOR*)((void*)(&dl.Position));
+	}
+
+	light.Diffuse = *(D3DCOLORVALUE*)((void*)(&dl.DiffuseColor));
+	light.Specular = *(D3DCOLORVALUE*)((void*)(&dl.SpecularColor));
+	light.Ambient = *(D3DCOLORVALUE*)((void*)(&dl.AmbientColor));
+	light.Range = MaxLightDistance;
+
+	light.Attenuation0 = 0.0f;
+	light.Attenuation1 = 1.0f / dl.Radius;
+	light.Attenuation2 = 0.0f;
+
+	++LastSetLights[m_renderAdapter];
+	pID3DDevice->SetLight(LastSetLights[m_renderAdapter], &light);
+	pID3DDevice->LightEnable(LastSetLights[m_renderAdapter], true);
+}
+
+
+
+//! returns the maximal amount of dynamic lights the device can handle
+s32 CD3D9MDriver::getMaximalDynamicLightAmount()
+{
+	return Capss[m_renderAdapter].MaxActiveLights;
+}
+
+
+
+//! Sets the dynamic ambient light color. The default color is
+//! (0,0,0,0) which means it is dark.
+//! \param color: New color of the ambient light.
+void CD3D9MDriver::setAmbientLight(const SColorf& color)
+{
+	if (!pID3DDevice)
+		return;
+
+	AmbientLight = color;
+	D3DCOLOR col = color.toSColor().color;
+	pID3DDevice->SetRenderState(D3DRS_AMBIENT, col);
+	//for(u32 idx = 0; idx = pID3DDevices.size(); ++idx)
+	//{
+	//	if(pID3DDevices[idx])
+	//		pID3DDevices[idx]->SetRenderState(D3DRS_AMBIENT, col);
+	//}
+}
+
+
+
+//! \return Returns the name of the video driver. Example: In case of the DIRECT3D9
+//! driver, it would return "Direct3D9.1".
+const wchar_t* CD3D9MDriver::getName()
+{
+	return L"Direct3D 9.0";
+}
+
+
+
+//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
+//! this: Frist, draw all geometry. Then use this method, to draw the shadow
+//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
+void CD3D9MDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
+{
+	if (!StencilBuffer || !count)
+		return;
+
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setRenderStatesStencilShadowMode(zfail);
+
+	if (!zfail)
+	{
+		// ZPASS Method
+
+		// Draw front-side of shadow volume in stencil/z only
+		pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW );
+		pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT);
+		pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
+
+		// Now reverse cull order so front sides of shadow volume are written.
+		pID3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CW );
+		pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT);
+		pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
+	}
+	else
+	{
+		// ZFAIL Method
+
+		// Draw front-side of shadow volume in stencil/z only
+		pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW );
+		pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT );
+		pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
+
+		// Now reverse cull order so front sides of shadow volume are written.
+		pID3DDevice->SetRenderState( D3DRS_CULLMODE,   D3DCULL_CCW );
+		pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL,  D3DSTENCILOP_DECRSAT );
+		pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
+	}
+	endPartScene();
+}
+
+
+
+//! Fills the stencil shadow with color. After the shadow volume has been drawn
+//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
+//! to draw the color of the shadow.
+void CD3D9MDriver::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge,
+			video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge)
+{
+	if (!StencilBuffer)
+		return;
+
+	S3DVertex vtx[4];
+	vtx[0] = S3DVertex(1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftUpEdge, 0.0f, 0.0f);
+	vtx[1] = S3DVertex(1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightUpEdge, 0.0f, 1.0f);
+	vtx[2] = S3DVertex(-1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, leftDownEdge, 1.0f, 0.0f);
+	vtx[3] = S3DVertex(-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, rightDownEdge, 1.0f, 1.0f);
+
+	s16 indices[6] = {0,1,2,1,3,2};
+
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setRenderStatesStencilFillMode(
+		leftUpEdge.getAlpha() < 255 ||
+		rightUpEdge.getAlpha() < 255 ||
+		leftDownEdge.getAlpha() < 255 ||
+		rightDownEdge.getAlpha() < 255);
+
+	setTexture(0,0);
+
+	setVertexShader(EVT_STANDARD);
+
+	pID3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, 0, 4, 2, &indices[0],
+										D3DFMT_INDEX16, &vtx[0], sizeof(S3DVertex));
+
+	if (clearStencilBuffer)
+		pID3DDevice->Clear( 0, NULL, D3DCLEAR_STENCIL,0, 1.0, 0);
+
+	endPartScene();
+}
+
+
+
+//! Returns the maximum amount of primitives (mostly vertices) which
+//! the device is able to render with one drawIndexedTriangleList
+//! call.
+s32 CD3D9MDriver::getMaximalPrimitiveCount()
+{
+	return Capss[m_renderAdapter].MaxPrimitiveCount;
+}
+
+
+
+//! Sets the fog mode.
+void CD3D9MDriver::setFog(SColor color, bool linearFog, f32 start,
+	f32 end, f32 density, bool pixelFog, bool rangeFog)
+{
+	CNullDriver::setFog(color, linearFog, start, end, density, pixelFog, rangeFog);
+
+	if (!pID3DDevice)
+		return;
+
+	pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color.color);
+
+	pID3DDevice->SetRenderState(
+		pixelFog  ? D3DRS_FOGTABLEMODE : D3DRS_FOGVERTEXMODE,
+		linearFog ? D3DFOG_LINEAR : D3DFOG_EXP);
+
+	if(linearFog)
+	{
+		pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD*)(&start));
+		pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD*)(&end));
+	}
+	else
+		pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD*)(&density));
+
+	if(!pixelFog)
+		pID3DDevice->SetRenderState(D3DRS_RANGEFOGENABLE, rangeFog);
+}
+
+
+
+//! Draws a 3d line.
+void CD3D9MDriver::draw3DLine(const core::vector3df& start,
+	const core::vector3df& end, SColor color)
+{
+	if(!beginPartScene())
+	{
+		os::Printer::log("DirectX9 beginPartScene failed.", ELL_WARNING);
+		return;
+	}
+	setVertexShader(EVT_STANDARD);
+	setRenderStates3DMode();
+	video::S3DVertex v[2];
+	v[0].Color = color;
+	v[1].Color = color;
+	v[0].Pos = start;
+	v[1].Pos = end;
+
+	pID3DDevice->DrawPrimitiveUP(D3DPT_LINELIST, 1, v, sizeof(S3DVertex));
+	endPartScene();
+}
+
+
+
+//! resets the device
+bool CD3D9MDriver::reset()
+{
+    // reset
+	os::Printer::log("Resetting D3D9 device.", ELL_INFORMATION);
+	bool state = true;
+	//push the current device
+	IDirect3DDevice9* oldpID3DDevice = pID3DDevice;
+	for(u32 idx = 0; idx < pID3DDevices.size(); ++idx)
+	{
+		pID3DDevice = pID3DDevices[idx];
+		if (FAILED(pID3DDevice->Reset(m_pPresentParams[idx])))
+		{
+			char tmp[255];
+			sprintf(tmp, "Resetting failed. index: %d", idx);
+			os::Printer::log(tmp, ELL_WARNING);
+			return false;
+		}
+		DeviceLost = false;
+		ResetRenderStatess[m_renderAdapter] = true;
+		LastVertexTypes[m_renderAdapter] = (E_VERTEX_TYPE)-1;
+
+		for (s32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
+		{
+			if (CurrentTexture[i])
+				CurrentTexture[i]->drop();
+
+			CurrentTexture[i] = 0;
+		}
+
+		setVertexShader(EVT_STANDARD);
+		setRenderStates3DMode();
+		setFog(FogColor, LinearFog, FogStart, FogEnd, FogDensity, PixelFog, RangeFog);
+		setAmbientLight(AmbientLight);
+	}
+	pID3DDevice = oldpID3DDevice;
+
+	return true;
+}
+
+
+
+void CD3D9MDriver::OnResize(const core::dimension2d<s32>& size)
+{
+	return;
+}
+
+
+
+//! Returns type of video driver
+E_DRIVER_TYPE CD3D9MDriver::getDriverType()
+{
+	return EDT_DIRECT3D9;
+}
+
+
+
+//! Returns the transformation set by setTransform
+const core::matrix4& CD3D9MDriver::getTransform(E_TRANSFORMATION_STATE state)
+{
+	return Matricess[m_renderAdapter][state];
+}
+
+
+
+//! Sets a vertex shader constant.
+void CD3D9MDriver::setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
+{
+	if (data)
+		pID3DDevices[m_renderAdapter]->SetVertexShaderConstantF(startRegister, data, constantAmount);
+}
+
+//! Sets a pixel shader constant.
+void CD3D9MDriver::setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount)
+{
+	if (data)
+		pID3DDevices[m_renderAdapter]->SetPixelShaderConstantF(startRegister, data, constantAmount);
+}
+
+//! Sets a constant for the vertex shader based on a name.
+bool CD3D9MDriver::setVertexShaderConstant(const c8* name, const f32* floats, int count)
+{
+	if (Materials[m_renderAdapter].MaterialType >= 0 && Materials[m_renderAdapter].MaterialType < (s32)MaterialRenderers.size())
+	{
+		CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer;
+		r->setRenderDevice(m_renderAdapter);
+		return r->setVariable(true, name, floats, count);
+	}
+
+	return false;
+}
+
+//! Sets a constant for the pixel shader based on a name.
+bool CD3D9MDriver::setPixelShaderConstant(const c8* name, const f32* floats, int count)
+{
+	if (Materials[m_renderAdapter].MaterialType >= 0 && Materials[m_renderAdapter].MaterialType < (s32)MaterialRenderers.size())
+	{
+		CD3D9MaterialRenderer* r = (CD3D9MaterialRenderer*)MaterialRenderers[Materials[m_renderAdapter].MaterialType].Renderer;
+		r->setRenderDevice(m_renderAdapter);
+		return r->setVariable(false, name, floats, count);
+	}
+
+	return false;
+}
+
+//! Returns pointer to the IGPUProgrammingServices interface.
+IGPUProgrammingServices* CD3D9MDriver::getGPUProgrammingServices()
+{
+	return this;
+}
+
+//! Adds a new material renderer to the VideoDriver, using pixel and/or
+//! vertex shaders to render geometry.
+s32 CD3D9MDriver::addShaderMaterial(const c8* vertexShaderProgram,
+	const c8* pixelShaderProgram,
+	IShaderConstantSetCallBack* callback,
+	E_MATERIAL_TYPE baseMaterial, s32 userData)
+{
+	s32 nr = -1;
+	CD3D9ShaderMaterialRenderer* r = new CD3D9ShaderMaterialRenderer(
+		pID3DDevices, this, nr, vertexShaderProgram, pixelShaderProgram,
+		callback, getMaterialRenderer(baseMaterial), userData);
+
+	r->drop();
+	return nr;
+}
+
+
+//! Adds a new material renderer to the VideoDriver, based on a high level shading
+//! language.
+s32 CD3D9MDriver::addHighLevelShaderMaterial(
+	const c8* vertexShaderProgram,
+	const c8* vertexShaderEntryPointName,
+	E_VERTEX_SHADER_TYPE vsCompileTarget,
+	const c8* pixelShaderProgram,
+	const c8* pixelShaderEntryPointName,
+	E_PIXEL_SHADER_TYPE psCompileTarget,
+	IShaderConstantSetCallBack* callback,
+	E_MATERIAL_TYPE baseMaterial,
+	s32 userData)
+{
+	s32 nr = -1;
+
+	CD3D9HLSLMaterialRenderer* hlsl = new CD3D9HLSLMaterialRenderer(
+		pID3DDevices, this, nr,
+		vertexShaderProgram,
+		vertexShaderEntryPointName,
+		vsCompileTarget,
+		pixelShaderProgram,
+		pixelShaderEntryPointName,
+		psCompileTarget,
+		callback,
+		getMaterialRenderer(baseMaterial),
+		userData);
+
+	hlsl->drop();
+	return nr;
+}
+
+
+//! Returns a pointer to the IVideoDriver interface. (Implementation for
+//! IMaterialRendererServices)
+IVideoDriver* CD3D9MDriver::getVideoDriver()
+{
+	return this;
+}
+
+
+//! Creates a render target texture.
+ITexture* CD3D9MDriver::createRenderTargetTexture(const core::dimension2d<s32>& size)
+{
+	return new CD3D9Texture(this, pID3DDevices, size, 0);
+}
+
+
+//! Clears the ZBuffer.
+void CD3D9MDriver::clearZBuffer()
+{
+	HRESULT hr = pID3DDevice->Clear( 0, NULL, D3DCLEAR_ZBUFFER, 0, 1.0, 0);
+
+	if (FAILED(hr))
+		os::Printer::log("CD3D9MDriver clearZBuffer() failed.", ELL_WARNING);
+}
+
+
+//! Returns an image created from the last rendered frame.
+IImage* CD3D9MDriver::createScreenShot()
+{
+	HRESULT hr;
+
+	// query the screen dimensions of the current adapter
+	D3DDISPLAYMODE displayMode;
+	pID3DDevice->GetDisplayMode(0, &displayMode);
+
+	// create the image surface to store the front buffer image [always A8R8G8B8]
+	LPDIRECT3DSURFACE9 lpSurface;
+	if (FAILED(hr = pID3DDevice->CreateOffscreenPlainSurface(displayMode.Width, displayMode.Height, D3DFMT_A8R8G8B8, D3DPOOL_SCRATCH, &lpSurface, 0)))
+		return 0;
+
+	// read the front buffer into the image surface
+	if (FAILED(hr = pID3DDevice->GetFrontBufferData(0, lpSurface)))
+	{
+		lpSurface->Release();
+		return 0;
+	}
+
+	RECT clientRect;
+	{
+		POINT clientPoint;
+		clientPoint.x = 0;
+		clientPoint.y = 0;
+
+		ClientToScreen((HWND)getExposedVideoData().D3D8.HWnd, &clientPoint);
+
+		clientRect.left   = clientPoint.x;
+		clientRect.top    = clientPoint.y;
+		clientRect.right  = clientRect.left + ScreenSize.Width;
+		clientRect.bottom = clientRect.top  + ScreenSize.Height;
+	}
+
+	// lock our area of the surface
+	D3DLOCKED_RECT lockedRect;
+	if (FAILED(lpSurface->LockRect(&lockedRect, &clientRect, D3DLOCK_READONLY)))
+	{
+		lpSurface->Release();
+		return 0;
+	}
+
+	// this could throw, but we aren't going to worry about that case very much
+	IImage* newImage = new CImage(ECF_A8R8G8B8, ScreenSize);
+
+	// d3d pads the image, so we need to copy the correct number of bytes
+	u32* pPixels = (u32*)newImage->lock();
+	if (pPixels)
+	{
+		u8 * sP = (u8 *)lockedRect.pBits;
+		u32* dP = (u32*)pPixels;
+
+		s32 y;
+		for (y = 0; y < ScreenSize.Height; ++y)
+		{
+			memcpy(dP, sP, ScreenSize.Width * 4);
+
+			sP += lockedRect.Pitch;
+			dP += ScreenSize.Width;
+		}
+
+		newImage->unlock();
+	}
+
+	// we can unlock and release the surface
+	lpSurface->UnlockRect();
+
+	// release the image surface
+	lpSurface->Release();
+
+	// return status of save operation to caller
+	return newImage;
+}
+
+
+// returns the current size of the screen or rendertarget
+core::dimension2d<s32> CD3D9MDriver::getCurrentRenderTargetSize()
+{
+	if ( CurrentRendertargetSize.Width == 0 )
+		return ScreenSize;
+	else
+		return CurrentRendertargetSize;
+}
+
+int CD3D9MDriver::getMultiheadDevicesCount()
+{
+	if(!initDirect3DInterface())
+		return 0;
+
+    UINT adapterCount = pID3D->GetAdapterCount();
+	int result = 0;
+	
+    for ( UINT i = 0; i < adapterCount; i++ )
+    {
+		// Get caps only for HAL device
+		D3DCAPS9 caps;
+		pID3D->GetDeviceCaps( i, D3DDEVTYPE_HAL, &caps );
+
+		// Look for multi-head adpater
+		if ( caps.NumberOfAdaptersInGroup > 1 )
+		{
+			result += caps.NumberOfAdaptersInGroup;
+		}
+    }
+
+	return result;
+}
+
+
+} // end namespace video
+} // end namespace irr
+
+#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
+#endif // _IRR_WINDOWS_
+
+
+
+
+namespace irr
+{
+namespace video
+{
+
+#if (defined(_IRR_WINDOWS_) || defined(_XBOX))
+IVideoDriver* createDirectX9DriverMultihead(const core::array<core::dimension2d<s32> >& screenSize, core::array<HWND> window,
+											u32 bits, bool fullscreen, bool stencilbuffer,
+											io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, bool vsync,
+											bool antiAlias)
+{
+    #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
+	CD3D9MDriver* dx9 =  new CD3D9MDriver(screenSize[0], window[0], fullscreen, stencilbuffer, io, pureSoftware);
+	if (!dx9->initDriver(screenSize, window, bits, fullscreen, pureSoftware, highPrecisionFPU, vsync, antiAlias))
+	{
+		dx9->drop();
+		dx9 = 0;
+	}
+
+	return dx9;
+	
+	#else
+	
+	return 0;
+	
+	#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
+}
+int getDirectX9MultiheadAdapterCount()
+{
+    #ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
+	CD3D9MDriver *dx9 = new CD3D9MDriver(core::dimension2d<s32>(10,10), NULL, true, true, NULL, false);
+	s32 adapterCount = dx9->getMultiheadDevicesCount();
+	dx9->drop();
+	dx9 = 0;
+
+	return adapterCount;
+	
+	#else
+	
+	return 0;
+	
+	#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
+}
+#endif
+
+} // end namespace video
+} // end namespace irr
+
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9MDriver.h irrlicht_multipatch/source/Irrlicht/CD3D9MDriver.h
--- irrlicht/source/Irrlicht/CD3D9MDriver.h	1970-01-01 01:00:00.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CD3D9MDriver.h	2006-12-11 12:34:37.000000000 +0100
@@ -0,0 +1,367 @@
+// Copyright (C) 2002-2006 Nikolaus Gebhardt
+// This file is part of the "Irrlicht Engine".
+// For conditions of distribution and use, see copyright notice in irrlicht.h
+
+#ifndef __C_VIDEO_DIRECTX_9_H_INCLUDED__
+#define __C_VIDEO_DIRECTX_9_H_INCLUDED__
+
+#include "IrrCompileConfig.h"
+
+#ifdef _IRR_WINDOWS_
+#define WIN32_LEAN_AND_MEAN
+#include "CNullDriver.h"
+#include <windows.h>
+#include "IMaterialRendererServices.h"
+
+#define MAX_DEPTH_FORMATS 5
+#define MAX_MODES 200
+#define MAX_ADAPTERS 16
+
+#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
+#include <d3d9.h>
+
+namespace irr
+{
+namespace video
+{
+	// Display mode description and its supported depth formats.
+	typedef struct
+	{
+		D3DDISPLAYMODE DisplayMode;
+		UINT iNumDepthFormats;
+		D3DFORMAT DepthFormats[MAX_DEPTH_FORMATS];
+		D3DFORMAT *CurrDepthFormat;
+	} MODE_INFO;
+
+	// Adapter information.
+	typedef struct
+	{
+		char DeviceName[MAX_DEVICE_IDENTIFIER_STRING];
+		UINT AdapterID;
+		UINT Ordinal;
+		UINT iNumModes;
+		MODE_INFO Modes[MAX_MODES];
+		MODE_INFO *CurrMode;
+		TCHAR CurrModeDescr[50];
+		LPDIRECT3DSURFACE9 pDepthStencil;
+		D3DSURFACE_DESC sdBackBuffer;
+	} ADAPTER_INFO;
+
+	// Multihead capable device description.
+	typedef struct
+	{
+		ADAPTER_INFO Adapters[MAX_ADAPTERS];
+		UINT iNumAdapters;
+	} DEVICE_INFO;
+}
+}
+
+namespace irr
+{
+namespace video
+{
+	class CD3D9MDriver : public CNullDriver, IMaterialRendererServices
+	{
+	public:
+
+		//! constructor
+		CD3D9MDriver(const core::dimension2d<s32>& screenSize, HWND window, bool fullscreen,
+			bool stencibuffer, io::IFileSystem* io, bool pureSoftware=false);
+
+		//! destructor
+		virtual ~CD3D9MDriver();
+
+		//! applications must call this method before performing any rendering. returns false if failed.
+		virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color);
+
+		//! applications must call this method after performing any rendering. returns false if failed.
+		virtual bool endScene( s32 windowId = 0, core::rect<s32>* sourceRect=0 );
+
+		//! queries the features of the driver, returns true if feature is available
+		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1);
+
+		//! sets transformation
+		virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
+
+		//! sets a material
+		virtual void setMaterial(const SMaterial& material);
+
+		//! sets a render target
+		virtual bool setRenderTarget(video::ITexture* texture,
+			bool clearBackBuffer=false, bool clearZBuffer=false,
+			SColor color=video::SColor(0,0,0,0));
+
+		//! sets a viewport
+		virtual void setViewPort(const core::rect<s32>& area);
+
+		//! gets the area of the current viewport
+		virtual const core::rect<s32>& getViewPort() const;
+
+		//! draws a vertex primitive list
+		virtual void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
+
+		//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
+		virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
+			const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
+			SColor color=SColor(255,255,255,255), bool useAlphaChannelOfTexture=false);
+
+		//! Draws a part of the texture into the rectangle.
+		virtual void draw2DImage(video::ITexture* texture, const core::rect<s32>& destRect,
+			const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect = 0,
+			video::SColor* colors=0, bool useAlphaChannelOfTexture=false);
+
+		//!Draws an 2d rectangle with a gradient.
+		virtual void draw2DRectangle(const core::rect<s32>& pos,
+			SColor colorLeftUp, SColor colorRightUp, SColor colorLeftDown, SColor colorRightDown,
+			const core::rect<s32>* clip);
+
+		//! Draws a 2d line.
+		virtual void draw2DLine(const core::position2d<s32>& start,
+					const core::position2d<s32>& end,
+					SColor color=SColor(255,255,255,255));
+
+		//! Draws a 3d line.
+		virtual void draw3DLine(const core::vector3df& start,
+			const core::vector3df& end, SColor color = SColor(255,255,255,255));
+
+		//! initialises the Direct3D API for multihead support.
+		bool initDriver(const core::array<core::dimension2d<s32> >& screenSize, core::array<HWND> hwnd,
+						u32 bits, bool fullScreen, bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias);
+
+		//! \return Returns the name of the video driver. Example: In case of the DIRECT3D8
+		//! driver, it would return "Direct3D8.1".
+		virtual const wchar_t* getName();
+
+		//! deletes all dynamic lights there are
+		virtual void deleteAllDynamicLights();
+
+		//! adds a dynamic light
+		virtual void addDynamicLight(const SLight& light);
+
+		//! returns the maximal amount of dynamic lights the device can handle
+		virtual s32 getMaximalDynamicLightAmount();
+
+		//! Sets the dynamic ambient light color. The default color is
+		//! (0,0,0,0) which means it is dark.
+		//! \param color: New color of the ambient light.
+		virtual void setAmbientLight(const SColorf& color);
+
+		//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
+		//! this: Frist, draw all geometry. Then use this method, to draw the shadow
+		//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
+		virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail);
+
+		//! Fills the stencil shadow with color. After the shadow volume has been drawn
+		//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
+		//! to draw the color of the shadow.
+		virtual void drawStencilShadow(bool clearStencilBuffer=false,
+			video::SColor leftUpEdge = video::SColor(0,0,0,0),
+			video::SColor rightUpEdge = video::SColor(0,0,0,0),
+			video::SColor leftDownEdge = video::SColor(0,0,0,0),
+			video::SColor rightDownEdge = video::SColor(0,0,0,0));
+
+		//! Returns the maximum amount of primitives (mostly vertices) which
+		//! the device is able to render with one drawIndexedTriangleList
+		//! call.
+		virtual s32 getMaximalPrimitiveCount();
+
+		//! Enables or disables a texture creation flag.
+		virtual void setTextureCreationFlag(E_TEXTURE_CREATION_FLAG flag, bool enabled);
+
+		//! Sets the fog mode.
+		virtual void setFog(SColor color, bool linearFog, f32 start,
+			f32 end, f32 density, bool pixelFog, bool rangeFog);
+
+		//! Only used by the internal engine. Used to notify the driver that
+		//! the window was resized.
+		virtual void OnResize(const core::dimension2d<s32>& size);
+
+		//! Can be called by an IMaterialRenderer to make its work easier.
+		virtual void setBasicRenderStates(const SMaterial& material, const SMaterial& lastMaterial,
+			bool resetAllRenderstates);
+
+		//! Returns type of video driver
+		virtual E_DRIVER_TYPE getDriverType();
+
+		//! Returns the transformation set by setTransform
+		virtual const core::matrix4& getTransform(E_TRANSFORMATION_STATE state);
+
+		//! Sets a vertex shader constant.
+		virtual void setVertexShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1);
+
+		//! Sets a pixel shader constant.
+		virtual void setPixelShaderConstant(const f32* data, s32 startRegister, s32 constantAmount=1);
+
+		//! Sets a constant for the vertex shader based on a name.
+		virtual bool setVertexShaderConstant(const c8* name, const f32* floats, int count);
+
+		//! Sets a constant for the pixel shader based on a name.
+		virtual bool setPixelShaderConstant(const c8* name, const f32* floats, int count);
+
+		//! Returns pointer to the IGPUProgrammingServices interface.
+		virtual IGPUProgrammingServices* getGPUProgrammingServices();
+
+		//! Returns a pointer to the IVideoDriver interface. (Implementation for
+		//! IMaterialRendererServices)
+		virtual IVideoDriver* getVideoDriver();
+
+		//! Creates a render target texture.
+		virtual ITexture* createRenderTargetTexture(const core::dimension2d<s32>& size);
+
+		//! Clears the ZBuffer.
+		virtual void clearZBuffer();
+
+		//! Returns an image created from the last rendered frame.
+		virtual IImage* createScreenShot();
+
+		//! Returns the count of multihead devices.
+		int getMultiheadDevicesCount();
+	private:
+
+		//! initialises the Direct3D Interface.
+		bool initDirect3DInterface();
+
+		//! find and initialises multihead informations
+		bool findMultiHeadDevice();
+		
+		//! create and init list of presentation parameters.
+		void buildPresentParams(const core::array<core::dimension2d<s32> >& screenSize, core::array<HWND> hwnd, u32 bits, bool vsync);
+
+		//! begins a part scene.
+		bool beginPartScene();
+		
+		//! ends a part scene.
+		bool endPartScene();
+
+		// enumeration for rendering modes such as 2d and 3d for minizing the switching of renderStates.
+		enum E_RENDER_MODE
+		{
+			ERM_NONE = 0,	// no render state has been set yet.
+			ERM_2D,			// 2d drawing rendermode
+			ERM_3D,			// 3d rendering mode
+			ERM_STENCIL_FILL, // stencil fill mode
+			ERM_SHADOW_VOLUME_ZFAIL, // stencil volume draw mode
+			ERM_SHADOW_VOLUME_ZPASS // stencil volume draw mode
+		};
+
+		//! sets right vertex shader
+		void setVertexShader(video::E_VERTEX_TYPE newType);
+
+		//! sets the needed renderstates
+		bool setRenderStates3DMode();
+
+		//! sets the needed renderstates
+		void setRenderStates2DMode(bool alpha, bool texture, bool alphaChannel);
+
+		//! sets the needed renderstates
+		void setRenderStatesStencilFillMode(bool alpha);
+
+		//! sets the needed renderstates
+		void setRenderStatesStencilShadowMode(bool zfail);
+
+		//! sets the current Texture
+		bool setTexture(s32 stage, video::ITexture* texture);
+
+		//! resets the device
+		bool reset();
+
+		//! returns a device dependent texture from a software surface (IImage)
+		//! THIS METHOD HAS TO BE OVERRIDDEN BY DERIVED DRIVERS WITH OWN TEXTURES
+		virtual video::ITexture* createDeviceDependentTexture(IImage* surface, const char* name);
+
+		// returns the current size of the screen or rendertarget
+		core::dimension2d<s32> getCurrentRenderTargetSize();
+
+		//! Adds a new material renderer to the VideoDriver, using pixel and/or
+		//! vertex shaders to render geometry.
+		s32 addShaderMaterial(const c8* vertexShaderProgram, const c8* pixelShaderProgram,
+			IShaderConstantSetCallBack* callback,
+			E_MATERIAL_TYPE baseMaterial, s32 userData);
+
+		//! Adds a new material renderer to the VideoDriver, based on a high level shading
+		//! language.
+		virtual s32 addHighLevelShaderMaterial(
+			const c8* vertexShaderProgram,
+			const c8* vertexShaderEntryPointName = "main",
+			E_VERTEX_SHADER_TYPE vsCompileTarget = EVST_VS_1_1,
+			const c8* pixelShaderProgram = 0,
+			const c8* pixelShaderEntryPointName = "main",
+			E_PIXEL_SHADER_TYPE psCompileTarget = EPST_PS_1_1,
+			IShaderConstantSetCallBack* callback = 0,
+			E_MATERIAL_TYPE baseMaterial = video::EMT_SOLID,
+			s32 userData=0);
+
+		void createMaterialRenderers();
+
+		inline D3DCOLORVALUE colorToD3D(const SColor& col)
+		{
+			const f32 f = 1.0f / 255.0f;
+			D3DCOLORVALUE v;
+			v.r = col.getRed() * f;
+			v.g = col.getGreen() * f;
+			v.b = col.getBlue() * f;
+			v.a = col.getAlpha() * f;
+			return v;
+		}
+
+
+		E_RENDER_MODE CurrentRenderMode;
+
+		core::array<core::matrix4*> Matricess;
+
+		core::array<SMaterial> Materials;
+		core::array<SMaterial> LastMaterials;
+
+		core::array<bool> ResetRenderStatess;
+
+		bool Transformation3DChanged;
+		bool StencilBuffer;
+		bool LastTextureMipMapsAvailable[MATERIAL_MAX_TEXTURES];
+		ITexture* CurrentTexture[MATERIAL_MAX_TEXTURES];
+
+		HINSTANCE D3DLibrary;
+		IDirect3D9* pID3D;
+		IDirect3DDevice9* pID3DDevice;
+
+		//we use multiple devices
+		core::array<IDirect3DDevice9*> pID3DDevices;
+
+		IDirect3DSurface9* PrevRenderTarget;
+		core::dimension2d<s32> CurrentRendertargetSize;
+
+		core::array<D3DCAPS9> Capss;
+
+		core::array<E_VERTEX_TYPE> LastVertexTypes;
+
+		f32 MaxLightDistance;
+		core::array<s32> LastSetLights;
+		bool DeviceLost;
+		bool Fullscreen;
+
+		SColorf AmbientLight;
+
+		bool BackBuffer;
+		bool ZBuffer;
+		SColor Color;
+
+		MODE_INFO *m_curMode;
+		DEVICE_INFO m_Device;
+		core::array<D3DPRESENT_PARAMETERS*> m_pPresentParams;
+		u32 m_renderAdapter;
+		bool m_beginScene;
+
+		core::array<LPDIRECT3DSURFACE9> m_pRenderTargets;
+
+		LPDIRECT3DSWAPCHAIN9 m_pSwapChain;
+		LPDIRECT3DSURFACE9 m_pBackBuffer;
+	};
+
+
+} // end namespace video
+} // end namespace irr
+
+
+#endif // _IRR_COMPILE_WITH_DIRECT3D_9_
+#endif // _IRR_WINDOWS_
+#endif // __C_VIDEO_DIRECTX_8_H_INCLUDED__
+
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9MaterialRenderer.h irrlicht_multipatch/source/Irrlicht/CD3D9MaterialRenderer.h
--- irrlicht/source/Irrlicht/CD3D9MaterialRenderer.h	2006-11-01 08:01:46.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CD3D9MaterialRenderer.h	2006-11-30 18:35:48.000000000 +0100
@@ -18,22 +18,35 @@
 namespace video
 {
 
-D3DMATRIX UnitMatrixD3D9;
-D3DMATRIX SphereMapMatrixD3D9;
-
 //! Base class for all internal D3D9 material renderers
 class CD3D9MaterialRenderer : public IMaterialRenderer
 {
 public:
 
 	//! Constructor
-	CD3D9MaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver)
-		: pID3DDevice(d3ddev), Driver(driver)
+	CD3D9MaterialRenderer(core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver)
+		: Driver(driver)
 	{
+		for(u32 idx = 0; idx < d3ddev.size(); ++idx)
+			pID3DDevices.push_back(d3ddev[idx]);
+
+		core::matrix4 mat;
+		m_UnitMatrixD3D9 = *(D3DMATRIX*)((void*)&mat);
+
+		m_SphereMapMatrixD3D9._11 = 0.5f; m_SphereMapMatrixD3D9._12 = 0.0f; 
+		m_SphereMapMatrixD3D9._13 = 0.0f; m_SphereMapMatrixD3D9._14 = 0.0f; 
+		m_SphereMapMatrixD3D9._21 = 0.0f; m_SphereMapMatrixD3D9._22 =-0.5f;
+		m_SphereMapMatrixD3D9._23 = 0.0f; m_SphereMapMatrixD3D9._24 = 0.0f; 
+		m_SphereMapMatrixD3D9._31 = 0.0f; m_SphereMapMatrixD3D9._32 = 0.0f;
+		m_SphereMapMatrixD3D9._33 = 1.0f; m_SphereMapMatrixD3D9._34 = 0.0f; 
+		m_SphereMapMatrixD3D9._41 = 0.5f; m_SphereMapMatrixD3D9._42 = 0.5f; 
+		m_SphereMapMatrixD3D9._43 = 0.0f; m_SphereMapMatrixD3D9._44 = 1.0f; 
+		deviceIndex = 0;
 	}
 
 	~CD3D9MaterialRenderer()
 	{
+		pID3DDevices.clear();
 	}
 
 	//! sets a variable in the shader.
@@ -50,8 +63,11 @@
 
 protected:
 
-	IDirect3DDevice9* pID3DDevice;
+	core::array<IDirect3DDevice9*> pID3DDevices;
 	video::IVideoDriver* Driver;
+	D3DMATRIX m_UnitMatrixD3D9;
+	D3DMATRIX m_SphereMapMatrixD3D9;
+
 };
 
 
@@ -60,7 +76,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_SOLID(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_SOLID(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -68,14 +84,14 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
 		}
 
-		pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-		pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+		pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+		pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
 
 		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
 	}
@@ -87,7 +103,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_SOLID_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_SOLID_2_LAYER(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -95,14 +111,14 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-			pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+			pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
 
-			pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 0);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_BLENDDIFFUSEALPHA);
 
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
 		}
 
 		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
@@ -115,7 +131,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_TRANSPARENT_ADD_COLOR(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -123,15 +139,15 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
-
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
-			pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
-			pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR);
 		}
 
 		material.ZWriteEnable = false;
@@ -152,7 +168,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_TRANSPARENT_VERTEX_ALPHA(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -160,18 +176,18 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_SELECTARG1);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAARG1,  D3DTA_DIFFUSE);
-
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
-
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
-			pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
-			pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_SELECTARG1);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAARG1,  D3DTA_DIFFUSE);
+
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
+
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
 		}
 
 		material.ZWriteEnable = false;
@@ -192,7 +208,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -201,26 +217,26 @@
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates
 			|| material.MaterialTypeParam != lastMaterial.MaterialTypeParam )
 		{
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1 );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
-
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
-
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
-			pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
-			pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
+
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
+
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
 
 			s32 refValue = (s32)(material.MaterialTypeParam * 255);
 			if ( !refValue )
 				refValue = 127; // default value
 
-			pID3DDevice->SetRenderState(D3DRS_ALPHAREF, refValue);
-			pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
-			pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHAREF, refValue);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
 		}
 
 		//material.ZWriteEnable = false;
@@ -229,7 +245,7 @@
 
 	virtual void OnUnsetMaterial()
 	{
-		pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+		pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
 	}
 
 	//! Returns if the material is transparent. The scene managment needs to know this
@@ -247,7 +263,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -255,20 +271,20 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1 );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
-
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
-
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
-
-			pID3DDevice->SetRenderState(D3DRS_ALPHAREF,127);
-			pID3DDevice->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
-			pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_MODULATE );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_CURRENT );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_ALPHAOP,   D3DTOP_SELECTARG1 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE );
+
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_COLOROP,   D3DTOP_DISABLE );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_ALPHAOP,   D3DTOP_DISABLE );
+
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHAREF,127);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
 		}
 
 		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
@@ -276,7 +292,7 @@
 
 	virtual void OnUnsetMaterial()
 	{
-		pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
+		pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE);
 	}
 
 	//! Returns if the material is transparent. The scene managment needs to know this
@@ -293,7 +309,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_LIGHTMAP(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_LIGHTMAP(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -304,35 +320,35 @@
 			if (material.MaterialType >= EMT_LIGHTMAP_LIGHTING)
 			{
 				// with lighting
-				pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-				pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-				pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+				pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+				pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+				pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
 			}
 			else
 			{
-				pID3DDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
-				pID3DDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+				pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1);
+				pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
 			}
 
-			pID3DDevice->SetTextureStageState(0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
+			pID3DDevices[deviceIndex]->SetTextureStageState(0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
 
 			if (material.MaterialType == EMT_LIGHTMAP_ADD)
-				pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD);
+				pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD);
 			else
 			if (material.MaterialType == EMT_LIGHTMAP_M4)
-				pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X);
+				pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE4X);
 			else
 			if (material.MaterialType == EMT_LIGHTMAP_M2)
-				pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X);
+				pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE2X);
 			else
-				pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+				pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
 
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-			pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+			pID3DDevices[deviceIndex]->SetTextureStageState (1, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
 
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
 		}
 
 		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
@@ -346,7 +362,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_DETAIL_MAP(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_DETAIL_MAP(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -354,18 +370,18 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
-
-			pID3DDevice->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED);
-			pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-			pID3DDevice->SetTextureStageState (1, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+
+			pID3DDevices[deviceIndex]->SetTextureStageState (1, D3DTSS_COLOROP, D3DTOP_ADDSIGNED);
+			pID3DDevices[deviceIndex]->SetTextureStageState (1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+			pID3DDevices[deviceIndex]->SetTextureStageState (1, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
 
-			pID3DDevice->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_TEXCOORDINDEX, 1);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
 		}
 
 		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
@@ -378,7 +394,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_SPHERE_MAP(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_SPHERE_MAP(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -386,17 +402,17 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
-
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
-
-			pID3DDevice->SetTransform( D3DTS_TEXTURE0, &SphereMapMatrixD3D9 );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
-			pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL );
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+
+			pID3DDevices[deviceIndex]->SetTransform( D3DTS_TEXTURE0, &m_SphereMapMatrixD3D9 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACENORMAL );
 		}
 
 		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
@@ -404,9 +420,9 @@
 
 	virtual void OnUnsetMaterial()
 	{
-		pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
-		pID3DDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
-		pID3DDevice->SetTransform( D3DTS_TEXTURE0, &UnitMatrixD3D9 );
+		pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
+		pID3DDevices[deviceIndex]->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, 0);
+		pID3DDevices[deviceIndex]->SetTransform( D3DTS_TEXTURE0, &m_UnitMatrixD3D9 );
 	}
 };
 
@@ -416,7 +432,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_REFLECTION_2_LAYER(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -424,19 +440,19 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
-
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-
-			pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 );
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+
+			pID3DDevices[deviceIndex]->SetTransform( D3DTS_TEXTURE1, &m_SphereMapMatrixD3D9 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
 		}
 
 		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
@@ -444,9 +460,9 @@
 
 	virtual void OnUnsetMaterial()
 	{
-		pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
-		pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);
-		pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 );
+		pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
+		pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);
+		pID3DDevices[deviceIndex]->SetTransform( D3DTS_TEXTURE1, &m_UnitMatrixD3D9 );
 	}
 };
 
@@ -456,7 +472,7 @@
 {
 public:
 
-	CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(IDirect3DDevice9* p, video::IVideoDriver* d)
+	CD3D9MaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(core::array<IDirect3DDevice9*> p, video::IVideoDriver* d)
 		: CD3D9MaterialRenderer(p, d) {}
 
 	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
@@ -464,23 +480,23 @@
 	{
 		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 		{
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
-			pID3DDevice->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
-
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
-			pID3DDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
-
-			pID3DDevice->SetTransform( D3DTS_TEXTURE1, &SphereMapMatrixD3D9 );
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
-			pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
-
-			pID3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
-			pID3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
-			pID3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
+			pID3DDevices[deviceIndex]->SetTextureStageState (0, D3DTSS_ALPHAOP,  D3DTOP_DISABLE);
+
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
+			pID3DDevices[deviceIndex]->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
+
+			pID3DDevices[deviceIndex]->SetTransform( D3DTS_TEXTURE1, &m_SphereMapMatrixD3D9 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2 );
+			pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
+
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
+			pID3DDevices[deviceIndex]->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
 		}
 
 		material.ZWriteEnable = false;
@@ -489,9 +505,9 @@
 
 	virtual void OnUnsetMaterial()
 	{
-		pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
-		pID3DDevice->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);
-		pID3DDevice->SetTransform( D3DTS_TEXTURE1, &UnitMatrixD3D9 );
+		pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
+		pID3DDevices[deviceIndex]->SetTextureStageState( 1, D3DTSS_TEXCOORDINDEX, 1);
+		pID3DDevices[deviceIndex]->SetTransform( D3DTS_TEXTURE1, &m_UnitMatrixD3D9 );
 	}
 
 	//! Returns if the material is transparent. The scene managment needs to know this
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9NormalMapRenderer.cpp irrlicht_multipatch/source/Irrlicht/CD3D9NormalMapRenderer.cpp
--- irrlicht/source/Irrlicht/CD3D9NormalMapRenderer.cpp	2006-10-15 08:48:46.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9NormalMapRenderer.cpp	2006-12-05 12:19:43.000000000 +0100
@@ -109,7 +109,7 @@
 		"";
 
 	CD3D9NormalMapRenderer::CD3D9NormalMapRenderer(
-		IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, 
+		core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver, 
 		s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial)
 		: CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial)
 	{
@@ -120,7 +120,6 @@
 
 		// basicly, this thing simply compiles these hardcoded shaders if the
 		// hardware is able to do them, otherwise it maps to the base material
-
 		if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_1) ||
 			!driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1))
 		{
@@ -135,16 +134,21 @@
 		video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_NORMAL_MAP_SOLID);
 		if (renderer)
 		{
+			u32 idx = 0;
 			// use the already compiled shaders 
 			video::CD3D9NormalMapRenderer* nmr = (video::CD3D9NormalMapRenderer*)renderer;
-			VertexShader = nmr->VertexShader;
-			if (VertexShader)
-				VertexShader->AddRef();
-
-			PixelShader = nmr->PixelShader;
-			if (PixelShader)
-				PixelShader->AddRef();
-
+			for(idx = 0; idx < nmr->VertexShaders.size(); ++idx)
+			{
+				VertexShaders[idx] = nmr->VertexShaders[idx];
+				if (VertexShaders[idx])
+					VertexShaders[idx]->AddRef();
+			}
+			for(idx = 0; idx < nmr->PixelShaders.size(); ++idx)
+			{
+				PixelShaders[idx] = nmr->PixelShaders[idx];
+				if (PixelShaders[idx])
+					PixelShaders[idx]->AddRef();
+			}
 			outMaterialTypeNr = driver->addMaterialRenderer(this);
 		}
 		else
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9NormalMapRenderer.h irrlicht_multipatch/source/Irrlicht/CD3D9NormalMapRenderer.h
--- irrlicht/source/Irrlicht/CD3D9NormalMapRenderer.h	2006-06-17 08:11:38.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9NormalMapRenderer.h	2006-11-30 18:42:58.000000000 +0100
@@ -26,7 +26,7 @@
 public:
 
 	CD3D9NormalMapRenderer(
-		IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, 
+		core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver, 
 		s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial);
 
 	~CD3D9NormalMapRenderer();
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9ParallaxMapRenderer.cpp irrlicht_multipatch/source/Irrlicht/CD3D9ParallaxMapRenderer.cpp
--- irrlicht/source/Irrlicht/CD3D9ParallaxMapRenderer.cpp	2006-10-15 08:48:46.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9ParallaxMapRenderer.cpp	2006-12-05 12:19:34.000000000 +0100
@@ -221,7 +221,7 @@
 		"\n";	
 
 	CD3D9ParallaxMapRenderer::CD3D9ParallaxMapRenderer(
-		IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, 
+		core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver, 
 		s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial)
 		: CD3D9ShaderMaterialRenderer(d3ddev, driver, 0, baseMaterial),
 		CurrentScale(0.0f)
@@ -233,9 +233,8 @@
 
 		// basicly, this thing simply compiles these hardcoded shaders if the
 		// hardware is able to do them, otherwise it maps to the base material
-
-		if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4) ||
-			!driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1))
+		if (!driver->queryFeature(video::EVDF_PIXEL_SHADER_1_4, deviceIndex) ||
+			!driver->queryFeature(video::EVDF_VERTEX_SHADER_1_1, deviceIndex))
 		{
 			// this hardware is not able to do shaders. Fall back to
 			// base material.
@@ -248,16 +247,21 @@
 		video::IMaterialRenderer* renderer = driver->getMaterialRenderer(EMT_PARALLAX_MAP_SOLID);
 		if (renderer)
 		{
+			u32 idx = 0;
 			// use the already compiled shaders 
 			video::CD3D9ParallaxMapRenderer* nmr = (video::CD3D9ParallaxMapRenderer*)renderer;
-			VertexShader = nmr->VertexShader;
-			if (VertexShader)
-				VertexShader->AddRef();
-
-			PixelShader = nmr->PixelShader;
-			if (PixelShader)
-				PixelShader->AddRef();
-
+			for(idx = 0; idx < nmr->VertexShaders.size(); ++idx)
+			{
+				VertexShaders.push_back(nmr->VertexShaders[idx]);
+				if (VertexShaders[idx])
+					VertexShaders[idx]->AddRef();
+			}
+			for(idx = 0; idx < nmr->VertexShaders.size(); ++idx)
+			{
+				PixelShaders.push_back(nmr->PixelShaders[idx]);
+				if (PixelShaders[idx])
+					PixelShaders[idx]->AddRef();
+			}
 			outMaterialTypeNr = driver->addMaterialRenderer(this);
 		}
 		else
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9ParallaxMapRenderer.h irrlicht_multipatch/source/Irrlicht/CD3D9ParallaxMapRenderer.h
--- irrlicht/source/Irrlicht/CD3D9ParallaxMapRenderer.h	2006-06-17 08:12:08.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9ParallaxMapRenderer.h	2006-11-30 18:45:16.000000000 +0100
@@ -26,7 +26,7 @@
 public:
 
 	CD3D9ParallaxMapRenderer(
-		IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, 
+		core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver, 
 		s32& outMaterialTypeNr, IMaterialRenderer* baseMaterial);
 
 	~CD3D9ParallaxMapRenderer();
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp irrlicht_multipatch/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp
--- irrlicht/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp	2006-06-17 08:11:54.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9ShaderMaterialRenderer.cpp	2006-12-11 13:57:51.000000000 +0100
@@ -23,12 +23,19 @@
 {
 
 //! Public constructor
-CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, 
+	CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver, 
 		s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
 		IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData)
-: pID3DDevice(d3ddev), Driver(driver), BaseMaterial(baseMaterial), CallBack(callback),
-	VertexShader(0), PixelShader(0), UserData(userData)
+:  Driver(driver), BaseMaterial(baseMaterial), CallBack(callback), UserData(userData)
 {
+	for(u32 idx = 0; idx < d3ddev.size(); ++idx)
+	{
+		pID3DDevices.push_back(d3ddev[idx]);
+		VertexShaders.push_back(NULL);
+		PixelShaders.push_back(NULL);
+		OldVertexShaders.push_back(NULL);
+	}
+
 	if (BaseMaterial)
 		BaseMaterial->grab();
 
@@ -36,25 +43,35 @@
 		CallBack->grab();
 
 	init(outMaterialTypeNr, vertexShaderProgram, pixelShaderProgram);
+	deviceIndex = 0;
 }
 
 
 
 //! constructor only for use by derived classes who want to
 //! create a fall back material for example.
-CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev,
+CD3D9ShaderMaterialRenderer::CD3D9ShaderMaterialRenderer(core::array<IDirect3DDevice9*> d3ddev,
 														 video::IVideoDriver* driver, 
 														 IShaderConstantSetCallBack* callback,
 														 IMaterialRenderer* baseMaterial,
 														 s32 userData)
-: pID3DDevice(d3ddev), Driver(driver), BaseMaterial(baseMaterial), CallBack(callback),
-	VertexShader(0), PixelShader(0), UserData(userData)
+: Driver(driver), BaseMaterial(baseMaterial), CallBack(callback), UserData(userData)
+{
+	for(u32 idx = 0; idx < d3ddev.size(); ++idx)
 {
+		pID3DDevices.push_back(d3ddev[idx]);
+		VertexShaders.push_back(NULL);
+		PixelShaders.push_back(NULL);
+		OldVertexShaders.push_back(NULL);
+	}
+
 	if (BaseMaterial)
 		BaseMaterial->grab();
 
 	if (CallBack)
 		CallBack->grab();
+
+	deviceIndex = 0;
 }
 
 
@@ -63,6 +80,10 @@
 {
 	outMaterialTypeNr = -1;
 
+	for(u32 idx = 0; idx < pID3DDevices.size(); ++idx)
+	{
+		deviceIndex = idx;
+
 	// create vertex shader
 	if (!createVertexShader(vertexShaderProgram))
 		return;
@@ -70,6 +91,7 @@
 	// create pixel shader
 	if (!createPixelShader(pixelShaderProgram))
 		return;
+	}
 
 	// register myself as new material
 	outMaterialTypeNr = Driver->addMaterialRenderer(this);
@@ -83,21 +105,34 @@
 	if (CallBack)
 		CallBack->drop();
 
-	if (VertexShader)
-		VertexShader->Release();
+	for(u32 idx = 0; idx < VertexShaders.size(); ++idx)
+	{
+		if(VertexShaders[idx])
+			VertexShaders[idx]->Release();
+	}
+
+	VertexShaders.clear();
 
-	if (PixelShader)
-		PixelShader->Release();
+	for(u32 idx = 0; idx < PixelShaders.size(); ++idx)
+	{
+		if(PixelShaders[idx])
+			PixelShaders[idx]->Release();
+	}
+	PixelShaders.clear();
 
 	if (BaseMaterial)
 		BaseMaterial->drop ();
+
+	pID3DDevices.clear();
 }
 
 bool CD3D9ShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, E_VERTEX_TYPE vtxtype)
 {
 	// call callback to set shader constants
-	if (CallBack && (VertexShader || PixelShader))
+	if (CallBack && (VertexShaders[deviceIndex] || PixelShaders[deviceIndex]))
+	{
 		CallBack->OnSetConstants(service, UserData);
+	}
 
 	return true;
 }
@@ -107,49 +142,74 @@
 {
 	if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
 	{		
-		if (VertexShader)
+		if (VertexShaders[deviceIndex])
 		{
+
 			// save old vertex shader
-			pID3DDevice->GetVertexShader(&OldVertexShader);
+			pID3DDevices[deviceIndex]->GetVertexShader(&OldVertexShaders[deviceIndex]);
 			
 			// set new vertex shader
-			if (FAILED(pID3DDevice->SetVertexShader(VertexShader)))
+			if (FAILED(pID3DDevices[deviceIndex]->SetVertexShader(VertexShaders[deviceIndex])))
 				os::Printer::log("Could not set vertex shader.");
 		}
+		else
+		{
+			char tmp[255];
+			sprintf(tmp, "could not set the vertex shader on device %d", deviceIndex);
+			os::Printer::log(tmp, ELL_ERROR);
+		}
+
 
 		// set new pixel shader
-		if (PixelShader)
+		if (PixelShaders[deviceIndex])
 		{
-			if (FAILED(pID3DDevice->SetPixelShader(PixelShader)))
+			if (FAILED(pID3DDevices[deviceIndex]->SetPixelShader(PixelShaders[deviceIndex])))
 				os::Printer::log("Could not set pixel shader.");
 		}
+		else
+		{
+			char tmp[255];
+			sprintf(tmp, "could not set the pixel shader on device %d", deviceIndex);
+			os::Printer::log(tmp, ELL_ERROR);
+		}
 
 		if (BaseMaterial)
+		{
+			BaseMaterial->setRenderDevice(deviceIndex);
 			BaseMaterial->OnSetMaterial(material, material, true, services);
 	}
+	}
 
 	services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
 }
 
 void CD3D9ShaderMaterialRenderer::OnUnsetMaterial() 
 {
-	if (VertexShader)
-		pID3DDevice->SetVertexShader(OldVertexShader);
+	if (VertexShaders[deviceIndex])
+		pID3DDevices[deviceIndex]->SetVertexShader(OldVertexShaders[deviceIndex]);
 
-	if (PixelShader)
-		pID3DDevice->SetPixelShader(0);
+	if (PixelShaders[deviceIndex])
+		pID3DDevices[deviceIndex]->SetPixelShader(0);
 
 	if (BaseMaterial)
+	{
+		BaseMaterial->setRenderDevice(deviceIndex);
 		BaseMaterial->OnUnsetMaterial();
 }
+}
 
 	
 //! Returns if the material is transparent. The scene managment needs to know this
 //! for being able to sort the materials by opaque and transparent.
 bool CD3D9ShaderMaterialRenderer::isTransparent() 
 {
+	if(BaseMaterial)
+	{
+		BaseMaterial->setRenderDevice(deviceIndex);
 	return BaseMaterial ? BaseMaterial->isTransparent() : false; 
 }
+	return false;
+}
 
 bool CD3D9ShaderMaterialRenderer::createPixelShader(const c8* pxsh)
 {
@@ -195,7 +255,7 @@
 		return false;
 	}
 
-	if (FAILED(pID3DDevice->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShader)))
+	if (FAILED(pID3DDevices[deviceIndex]->CreatePixelShader((DWORD*)code->GetBufferPointer(), &PixelShaders[deviceIndex])))
 	{
 		os::Printer::log("Could not create pixel shader.");
 		code->Release();
@@ -253,7 +313,7 @@
 		return false;
 	}
 
-	if (!code || FAILED(pID3DDevice->CreateVertexShader((DWORD*)code->GetBufferPointer(), &VertexShader)))
+	if (FAILED(pID3DDevices[deviceIndex]->CreateVertexShader((DWORD*)code->GetBufferPointer(), &VertexShaders[deviceIndex])))
 	{
 		os::Printer::log("Could not create vertex shader.");
 		if (code)
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9ShaderMaterialRenderer.h irrlicht_multipatch/source/Irrlicht/CD3D9ShaderMaterialRenderer.h
--- irrlicht/source/Irrlicht/CD3D9ShaderMaterialRenderer.h	2006-06-17 08:11:54.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9ShaderMaterialRenderer.h	2006-11-30 18:55:34.000000000 +0100
@@ -13,6 +13,7 @@
 #include <d3dx9shader.h>
 
 #include "IMaterialRenderer.h"
+#include "irrArray.h"
 
 namespace irr
 {
@@ -29,7 +30,7 @@
 public:
 
 	//! Public constructor
-	CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev, video::IVideoDriver* driver, 
+	CD3D9ShaderMaterialRenderer(core::array<IDirect3DDevice9*> d3ddev, video::IVideoDriver* driver, 
 		s32& outMaterialTypeNr, const c8* vertexShaderProgram, const c8* pixelShaderProgram,
 		IShaderConstantSetCallBack* callback, IMaterialRenderer* baseMaterial, s32 userData);
 
@@ -50,7 +51,7 @@
 
 	//! constructor only for use by derived classes who want to
 	//! create a fall back material for example.
-	CD3D9ShaderMaterialRenderer(IDirect3DDevice9* d3ddev,
+	CD3D9ShaderMaterialRenderer(core::array<IDirect3DDevice9*> d3ddev,
 								video::IVideoDriver* driver, 
 								IShaderConstantSetCallBack* callback,
 								IMaterialRenderer* baseMaterial, s32 userData=0);
@@ -79,14 +80,14 @@
 								LPCSTR pProfile, DWORD Flags, LPD3DXBUFFER* ppShader, LPD3DXBUFFER* ppErrorMsgs,
 								LPD3DXCONSTANTTABLE* ppConstantTable);
 
-	IDirect3DDevice9* pID3DDevice;
+	core::array<IDirect3DDevice9*> pID3DDevices;
 	video::IVideoDriver* Driver;
 	IShaderConstantSetCallBack* CallBack;
 	IMaterialRenderer* BaseMaterial;
 
-	IDirect3DVertexShader9* VertexShader;
-	IDirect3DVertexShader9* OldVertexShader;
-	IDirect3DPixelShader9* PixelShader;
+	core::array<IDirect3DVertexShader9*> VertexShaders;
+	core::array<IDirect3DVertexShader9*> OldVertexShaders;
+	core::array<IDirect3DPixelShader9*> PixelShaders;
 	s32 UserData;
 };
 
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9Texture.cpp irrlicht_multipatch/source/Irrlicht/CD3D9Texture.cpp
--- irrlicht/source/Irrlicht/CD3D9Texture.cpp	2006-10-15 08:48:50.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9Texture.cpp	2006-12-08 11:42:10.000000000 +0100
@@ -31,29 +31,51 @@
 {
 
 //! rendertarget constructor
-CD3D9Texture::CD3D9Texture(CD3D9Driver* driver, core::dimension2d<s32> size, const char* name)
+CD3D9Texture::CD3D9Texture(IVideoDriver* driver, core::dimension2d<s32> size, const char* name)
 : ITexture(name), Image(0), Driver(driver), TextureSize(size),
-	Texture(0), Pitch(0), ImageSize(size), HasMipMaps(0), HardwareMipMaps(0),
-	IsRenderTarget(true), RTTSurface(0)
+	Pitch(0), ImageSize(size), HasMipMaps(0), HardwareMipMaps(0),
+	IsRenderTarget(true)
 {
 	#ifdef _DEBUG
 	setDebugName("CD3D9Texture");
 	#endif
 
-	Device=driver->getExposedVideoData().D3D9.D3DDev9;
-	if (Device)
-		Device->AddRef();
+	RTTSurfaces.push_back(NULL);
 
-	createRenderTarget();
+	Devices.push_back(driver->getExposedVideoData().D3D9.D3DDev9);
+
+	if (Devices[Devices.size()-1])
+		Devices[Devices.size()-1]->AddRef();
+
+	createRenderTarget(Devices[Devices.size()-1]);
+}
+//! rendertarget multihead constructor
+CD3D9Texture::CD3D9Texture(IVideoDriver* driver, core::array<IDirect3DDevice9*> devices, core::dimension2d<s32> size, const char* name)
+: ITexture(name), Image(0), Driver(driver), TextureSize(size),
+	Pitch(0), ImageSize(size), HasMipMaps(0), HardwareMipMaps(0),
+	IsRenderTarget(true)
+{
+	#ifdef _DEBUG
+    setDebugName("CD3D9Texture");
+	#endif
+
+	for(u32 idx = 0; idx < devices.size(); ++idx)
+	{
+		RTTSurfaces.push_back(NULL);
+		Devices.push_back(devices[idx]);
+		if(Devices[Devices.size()-1])
+			Devices[Devices.size()-1]->AddRef();
+		createRenderTarget(Devices[Devices.size()-1]);
+	}
 }
 
 
 //! constructor
-CD3D9Texture::CD3D9Texture(IImage* image, CD3D9Driver* driver,
+CD3D9Texture::CD3D9Texture(IImage* image, IVideoDriver* driver,
 					   u32 flags, const char* name)
 : ITexture(name), Image(image), Driver(driver), TextureSize(0,0),
-Texture(0), Pitch(0), ImageSize(0,0), HasMipMaps(false), HardwareMipMaps(false),
-IsRenderTarget(false), RTTSurface(0)
+Pitch(0), ImageSize(0,0), HasMipMaps(false), HardwareMipMaps(false),
+IsRenderTarget(false)
 {
 	#ifdef _DEBUG
 	setDebugName("CD3D9Texture");
@@ -61,17 +83,19 @@
 
 	bool generateMipLevels = (flags & video::ETCF_CREATE_MIP_MAPS) != 0;
 
-	Device=driver->getExposedVideoData().D3D9.D3DDev9;
-	if (Device)
-		Device->AddRef();
+	RTTSurfaces.push_back(NULL);
+
+	Devices.push_back(driver->getExposedVideoData().D3D9.D3DDev9);
+	if (Devices[Devices.size()-1])
+		Devices[Devices.size()-1]->AddRef();
 
 	if (Image)
 	{
 		Image->grab();
 
-		createTexture(flags);
+		createTexture(flags, Devices.size()-1);
 
-		if (Texture)
+		if (Textures[0])
 		{
 			if (copyTexture() && generateMipLevels)
 			{
@@ -81,7 +105,7 @@
 					// compiling with both D3D8 and 9, causing it not to work in the D3D9 device.
 					// So mipmapgeneration is replaced with my own bad generation in d3d 8 when
 					// compiling with both D3D 8 and 9.
-					HRESULT hr  = D3DXFilterTexture(Texture, NULL, D3DX_DEFAULT, D3DX_DEFAULT);
+					HRESULT hr  = D3DXFilterTexture(Textures[0], NULL, D3DX_DEFAULT, D3DX_DEFAULT);
 					if (FAILED(hr))
 						os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING);
 					else
@@ -97,8 +121,60 @@
 	}
 }
 
+//! multihead constructor
+CD3D9Texture::CD3D9Texture(IImage* image, IVideoDriver* driver, core::array<IDirect3DDevice9*> devices, u32 flags, const char* name)
+: ITexture(name), Image(image), Driver(driver), TextureSize(0,0),
+Pitch(0), ImageSize(0,0), HasMipMaps(false), HardwareMipMaps(false),
+IsRenderTarget(false)
+{
+	#ifdef _DEBUG
+    setDebugName("CD3D9Texture");
+	#endif
+
+	bool generateMipLevels = (flags & video::ETCF_CREATE_MIP_MAPS) != 0;
+
+	for(u32 idx = 0; idx < devices.size(); ++idx)
+	{
+		RTTSurfaces.push_back(NULL);
+		Devices.push_back(devices[idx]);
+		if(Devices[Devices.size()-1])
+			Devices[Devices.size()-1]->AddRef();
+	
+		if (Image)
+		{
+			Image->grab();
+
+			createTexture(flags, Devices.size()-1);
+
+			if (Textures[idx])
+			{
+				if (copyTexture(idx) && generateMipLevels)
+				{
+					// create mip maps.
+					#ifndef _IRR_COMPILE_WITH_DIRECT3D_8_
+						// The D3DXFilterTexture function seems to get linked wrong when
+						// compiling with both D3D8 and 9, causing it not to work in the D3D9 device.
+						// So mipmapgeneration is replaced with my own bad generation in d3d 8 when
+						// compiling with both D3D 8 and 9.
+						HRESULT hr  = D3DXFilterTexture(Textures[idx], NULL, D3DX_DEFAULT, D3DX_DEFAULT);
+						if (FAILED(hr))
+							os::Printer::log("Could not create direct3d mip map levels.", ELL_WARNING);
+						else
+							HasMipMaps = true;
+					#else
+						createMipMaps(1,idx);
+						HasMipMaps = true;
+					#endif
+				}				
+			}
+			else
+				os::Printer::log("Could not create DIRECT3D9 Texture.", ELL_WARNING);
+		}
+	}
+}
+
 
-void CD3D9Texture::createRenderTarget()
+void CD3D9Texture::createRenderTarget(IDirect3DDevice9 *device)
 {
 	TextureSize.Width = getTextureSizeFromImageSize(TextureSize.Width);
 	TextureSize.Height = getTextureSizeFromImageSize(TextureSize.Height);
@@ -109,7 +185,7 @@
 	IDirect3DSurface9* bb;
 	D3DFORMAT d3DFormat = D3DFMT_A8R8G8B8;
 
-	if (!FAILED(Device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb)))
+	if (!FAILED(device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &bb)))
 	{
 		D3DSURFACE_DESC desc;
 		bb->GetDesc(&desc);
@@ -129,17 +205,19 @@
 
 	// create texture
 	HRESULT hr;
+	IDirect3DTexture9* tex;
 
-	hr = Device->CreateTexture(
+	hr = device->CreateTexture(
 		TextureSize.Width,
 		TextureSize.Height,
 		1, // mip map level count, we don't want mipmaps here
 		D3DUSAGE_RENDERTARGET,
 		d3DFormat,
 		D3DPOOL_DEFAULT,
-		&Texture,
+		&tex,
 		NULL);
 
+	Textures.push_back(tex);
 	// get irrlicht format from D3D format
 
 	switch(d3DFormat)
@@ -165,13 +243,13 @@
 }
 
 
-bool CD3D9Texture::createMipMaps(s32 level)
+bool CD3D9Texture::createMipMaps(s32 level, u32 idx)
 {
-	if (HardwareMipMaps && Texture)
+	if (HardwareMipMaps && Textures[idx])
 	{
 		// generate mipmaps in hardware
 
-		Texture->GenerateMipSubLevels();
+		Textures[idx]->GenerateMipSubLevels();
 		return true;
 	}
 	//os::Printer::log("manual mipmap");
@@ -185,7 +263,7 @@
 	IDirect3DSurface9* lowerSurface = 0;
 
 	// get upper level
-	HRESULT hr = Texture->GetSurfaceLevel(level-1, &upperSurface);
+	HRESULT hr = Textures[idx]->GetSurfaceLevel(level-1, &upperSurface);
 	if (FAILED(hr) || !upperSurface)
 	{
 		os::Printer::log("Could get upper surface level for mip map generation", ELL_WARNING);
@@ -193,7 +271,7 @@
 	}
 
 	// get lower level
-	hr = Texture->GetSurfaceLevel(level, &lowerSurface);
+	hr = Textures[idx]->GetSurfaceLevel(level, &lowerSurface);
 	if (FAILED(hr) || !lowerSurface)
 	{
 		os::Printer::log("Could get lower surface level for mip map generation", ELL_WARNING);
@@ -255,23 +333,31 @@
 		return true; // stop generating levels
 
 	// generate next level
-	return createMipMaps(level+1);
+	return createMipMaps(level+1, idx);
 }
 
 
 //! creates the hardware texture
-void CD3D9Texture::createTexture(u32 flags)
+void CD3D9Texture::createTexture(u32 flags, u32 renderDevice)
 {
 	core::dimension2d<s32> optSize;
 	ImageSize = Image->getDimension();
 
-	if (Driver->queryFeature(EVDF_TEXTURE_NPOT))
+	if(Driver)
+	{
+		if (Driver->queryFeature(EVDF_TEXTURE_NPOT, renderDevice))
 		optSize=ImageSize;
 	else
 	{
 		optSize.Width = getTextureSizeFromImageSize(ImageSize.Width);
 		optSize.Height = getTextureSizeFromImageSize(ImageSize.Height);
 	}
+	}
+	else
+	{
+		optSize.Width = getTextureSizeFromImageSize(ImageSize.Width);
+		optSize.Height = getTextureSizeFromImageSize(ImageSize.Height);
+	}
 
 	HRESULT hr;
 	D3DFORMAT format = D3DFMT_A1R5G5B5;
@@ -313,10 +399,12 @@
 	//	HardwareMipMaps = true;
 	//}
 
-	hr = Device->CreateTexture(optSize.Width, optSize.Height,
+	IDirect3DTexture9* tex;
+
+	hr = Devices[renderDevice]->CreateTexture(optSize.Width, optSize.Height,
 		mipmaps ? 0 : 1, // number of mipmaplevels (0 = automatic all)
 		usage, // usage
-		format, D3DPOOL_MANAGED , &Texture, NULL);
+		format, D3DPOOL_MANAGED , &tex, NULL);
 
 	if (FAILED(hr) && format == D3DFMT_A8R8G8B8)
 	{
@@ -324,10 +412,11 @@
 
 		format = D3DFMT_A1R5G5B5;
 
-		hr = Device->CreateTexture(optSize.Width, optSize.Height,
+		hr = Devices[renderDevice]->CreateTexture(optSize.Width, optSize.Height,
 			(flags & ETCF_CREATE_MIP_MAPS) ? 0 : 1, // number of mipmaplevels (0 = automatic all)
-			0, D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &Texture, NULL);
+			0, D3DFMT_A1R5G5B5, D3DPOOL_MANAGED, &tex, NULL);
 	}
+	Textures.push_back(tex);
 
 	ColorFormat = (format == D3DFMT_A1R5G5B5) ? ECF_A1R5G5B5 : ECF_A8R8G8B8;
 }
@@ -335,12 +424,12 @@
 
 
 //! copies the image to the texture
-bool CD3D9Texture::copyTexture()
+bool CD3D9Texture::copyTexture(u32 index)
 {
-	if (Texture && Image)
+	if (Textures[index] && Image)
 	{
 		D3DSURFACE_DESC desc;
-		Texture->GetLevelDesc(0, &desc);
+		Textures[index]->GetLevelDesc(0, &desc);
 
 		TextureSize.Width = desc.Width;
 		TextureSize.Height = desc.Height;
@@ -348,10 +437,10 @@
 		SurfaceHasSameSize = (TextureSize == ImageSize);
 
 		if (desc.Format == D3DFMT_A1R5G5B5)
-			return copyTo16BitTexture();
+			return copyTo16BitTexture(index);
 		else
 		if (desc.Format == D3DFMT_A8R8G8B8)
-			return copyTo32BitTexture();
+			return copyTo32BitTexture(index);
 		else
 			os::Printer::log("CD3D9Texture: Unsupported D3D9 hardware texture format", ELL_ERROR);
 	}
@@ -361,10 +450,10 @@
 
 
 //! copies texture to 32 bit hardware texture
-bool CD3D9Texture::copyTo32BitTexture()
+bool CD3D9Texture::copyTo32BitTexture(u32 index)
 {
 	D3DLOCKED_RECT rect;
-	HRESULT hr = Texture->LockRect(0, &rect, 0, 0);
+	HRESULT hr = Textures[index]->LockRect(0, &rect, 0, 0);
 	if (FAILED(hr))
 	{
 		os::Printer::log("Could not lock DIRECT3D9 32 bit Texture.", ELL_ERROR);
@@ -438,7 +527,7 @@
 
 	Image->unlock();
 
-	hr = Texture->UnlockRect(0);
+	hr = Textures[index]->UnlockRect(0);
 	if (FAILED(hr))
 	{
 		os::Printer::log("Could not unlock DIRECT3D9 Texture.", ELL_ERROR);
@@ -451,10 +540,10 @@
 
 
 //! optimized for 16 bit to 16 copy.
-bool CD3D9Texture::copyTo16BitTexture()
+bool CD3D9Texture::copyTo16BitTexture(u32 index)
 {
 	D3DLOCKED_RECT rect;
-	HRESULT hr = Texture->LockRect(0, &rect, 0, 0);
+	HRESULT hr = Textures[index]->LockRect(0, &rect, 0, 0);
 	if (FAILED(hr))
 	{
 		os::Printer::log("Could not lock DIRECT3D9 16 bit Texture.", ELL_ERROR);
@@ -530,7 +619,7 @@
 
 	Image->unlock();
 
-	hr = Texture->UnlockRect(0);
+	hr = Textures[index]->UnlockRect(0);
 	if (FAILED(hr))
 	{
 		os::Printer::log("Could not unlock DIRECT3D9 16 bit Texture.", ELL_ERROR);
@@ -545,17 +634,32 @@
 //! destructor
 CD3D9Texture::~CD3D9Texture()
 {
-	if (Device)
-		Device->Release();
+
+	u32 idx = 0;
+
+	for(idx = 0; idx < Devices.size(); ++idx)
+	{
+		if(Devices[idx])
+			Devices[idx]->Release();
+	}
+	Devices.clear();
 
 	if (Image)
 		Image->drop();
 
-	if (Texture)
-		Texture->Release();
+	for(idx = 0; idx < Textures.size(); ++idx)
+	{
+		if(Textures[idx])
+			Textures[idx]->Release();
+	}
+	Textures.clear();
 
-	if (RTTSurface)
-		RTTSurface->Release();
+	for(idx = 0; idx < RTTSurfaces.size(); ++idx)
+	{
+		if(RTTSurfaces[idx])
+			RTTSurfaces[idx]->Release();
+	}
+	RTTSurfaces.clear();
 }
 
 
@@ -563,22 +667,22 @@
 //! lock function
 void* CD3D9Texture::lock()
 {
-	if (!Texture)
+	if (!Textures[0])
 		return 0;
 
 	HRESULT hr;
 	D3DLOCKED_RECT rect;
 	if(!IsRenderTarget)
 	{
-		hr = Texture->LockRect(0, &rect, 0, 0);
+		hr = Textures[0]->LockRect(0, &rect, 0, 0);
 	}
 	else
 	{
 		D3DSURFACE_DESC desc;
-		Texture->GetLevelDesc(0, &desc);
-		if (!RTTSurface)
+		Textures[0]->GetLevelDesc(0, &desc);
+		if (!RTTSurfaces[0])
 		{
-			hr = Device->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurface, NULL);
+			hr = Devices[0]->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurfaces[0], NULL);
 			if (FAILED(hr))
 			{
 				os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
@@ -587,24 +691,25 @@
 		}
 
 		IDirect3DSurface9 *surface = NULL;
-		hr = Texture->GetSurfaceLevel(0, &surface);
+		hr = Textures[0]->GetSurfaceLevel(0, &surface);
 		if (FAILED(hr))
 		{
 			os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
 			return 0;
 		}
-		hr = Device->GetRenderTargetData(surface, RTTSurface);
+		hr = Devices[0]->GetRenderTargetData(surface, RTTSurfaces[0]);
 		if(FAILED(hr))
 		{
 			os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
 			return 0;
 		}
-		hr = RTTSurface->LockRect(&rect, NULL, 0);
+		hr = RTTSurfaces[0]->LockRect(&rect, NULL, 0);
 		if(FAILED(hr))
 		{
 			os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
 			return 0;
 		}
+		surfaceBits = rect.pBits;
 		return rect.pBits;
 	}
 	if (FAILED(hr))
@@ -612,7 +717,7 @@
 		os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
 		return 0;
 	}
-
+	textureBits = rect.pBits;
 	return rect.pBits;
 }
 
@@ -621,13 +726,84 @@
 //! unlock function
 void CD3D9Texture::unlock()
 {
-	if (!Texture)
+	if (!Textures[0])
 		return;
 
+	u32 idx = 0;
+	D3DLOCKED_RECT rect;
+	D3DSURFACE_DESC desc;
+	HRESULT hr;
+
 	if (!IsRenderTarget)
-		Texture->UnlockRect(0);
-	else if (RTTSurface)
-		RTTSurface->UnlockRect();
+	{
+		for(idx = 1; idx < Textures.size(); ++idx)
+		{
+			Textures[idx]->GetLevelDesc(0, &desc);
+			Textures[idx]->LockRect(0, &rect, 0, 0);
+			memcpy(rect.pBits, textureBits, rect.Pitch*desc.Height);
+			Textures[idx]->UnlockRect(0);
+		}
+		Textures[0]->UnlockRect(0);
+	}
+	else if (RTTSurfaces[0])
+	{
+		for(idx = 1; idx < RTTSurfaces.size(); ++idx)
+		{
+			bool isSurface = true;
+			
+			D3DSURFACE_DESC desc;
+			Textures[idx]->GetLevelDesc(0, &desc);
+			if (!RTTSurfaces[idx])
+			{
+				hr = Devices[idx]->CreateOffscreenPlainSurface(desc.Width, desc.Height, desc.Format, D3DPOOL_SYSTEMMEM, &RTTSurfaces[idx], NULL);
+				if (FAILED(hr))
+				{
+					os::Printer::log("Could not lock DIRECT3D9 Textures[idx].", ELL_ERROR);
+					isSurface = false;
+				}
+			}
+
+			if(isSurface)
+			{
+				bool isSurfaceLevel = true;
+				IDirect3DSurface9 *surface = NULL;
+				hr = Textures[0]->GetSurfaceLevel(0, &surface);
+				if (FAILED(hr))
+				{
+					os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
+					isSurfaceLevel = false;
+				}
+				if(isSurfaceLevel)
+				{
+					bool isRenderTargetData = true;
+					hr = Devices[idx]->GetRenderTargetData(surface, RTTSurfaces[idx]);
+					if(FAILED(hr))
+					{
+						os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
+						isRenderTargetData = false;
+					}
+					if(isRenderTargetData)
+					{
+						bool isLocked = true;
+						hr = RTTSurfaces[idx]->LockRect(&rect, NULL, 0);
+						if(FAILED(hr))
+						{
+							os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
+							isLocked = false;
+						}
+						if(isLocked)
+						{
+							//rect.pBits = surfaceBits;
+							memcpy(rect.pBits, surfaceBits, rect.Pitch*desc.Height);
+
+							RTTSurfaces[idx]->UnlockRect();
+						}
+					}
+				}
+			}
+		}
+		RTTSurfaces[0]->UnlockRect();
+	}
 }
 
 
@@ -686,9 +862,9 @@
 
 
 //! returns the DIRECT3D9 Texture
-IDirect3DTexture9* CD3D9Texture::getDX9Texture()
+IDirect3DTexture9* CD3D9Texture::getDX9Texture(u32 index)
 {
-	return Texture;
+	return Textures[index];
 }
 
 
@@ -791,14 +967,14 @@
 }
 
 //! Returns pointer to the render target surface
-IDirect3DSurface9* CD3D9Texture::getRenderTargetSurface()
+IDirect3DSurface9* CD3D9Texture::getRenderTargetSurface(u32 index)
 {
 	if (!IsRenderTarget)
 		return 0;
 
 	IDirect3DSurface9 *pRTTSurface = 0;
-	if (Texture)
-		Texture->GetSurfaceLevel(0, &pRTTSurface);
+	if (Textures[index])
+		Textures[index]->GetSurfaceLevel(0, &pRTTSurface);
 
 	if (pRTTSurface)
 		pRTTSurface->Release();
diff -r -uw -N irrlicht/source/Irrlicht/CD3D9Texture.h irrlicht_multipatch/source/Irrlicht/CD3D9Texture.h
--- irrlicht/source/Irrlicht/CD3D9Texture.h	2006-10-15 08:48:52.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CD3D9Texture.h	2006-12-05 12:31:10.000000000 +0100
@@ -11,13 +11,15 @@
 #include "ITexture.h"
 #include "IImage.h"
 #include <d3d9.h>
+#include "irrArray.h"
 
 namespace irr
 {
 namespace video
 {
 
-class CD3D9Driver;
+class IVideoDriver;
+//class CD3D9Driver;
 /*!
 	interface for a Video Driver dependent Texture.
 */
@@ -26,11 +28,18 @@
 public:
 
 	//! constructor
-	CD3D9Texture(IImage* image, CD3D9Driver* driver,
+	CD3D9Texture(IImage* image, IVideoDriver* driver,
+		u32 flags, const char* name);
+
+	//! multihead constructor
+	CD3D9Texture(IImage* image, IVideoDriver* driver, core::array<IDirect3DDevice9*> devices,
 		u32 flags, const char* name);
 
 	//! rendertarget constructor
-	CD3D9Texture(CD3D9Driver* driver, core::dimension2d<s32> size, const char* name);
+	CD3D9Texture(IVideoDriver* driver, core::dimension2d<s32> size, const char* name);
+
+	//! rendertarget multihead constructor
+	CD3D9Texture(IVideoDriver* driver, core::array<IDirect3DDevice9*> devices, core::dimension2d<s32> size, const char* name);
 
 	//! destructor
 	virtual ~CD3D9Texture();
@@ -57,7 +66,7 @@
 	virtual s32 getPitch();
 
 	//! returns the DIRECT3D9 Texture
-	IDirect3DTexture9* getDX9Texture();
+	IDirect3DTexture9* getDX9Texture(u32 index = 0);
 
 	//! returns if texture has mipmap levels
 	bool hasMipMaps();
@@ -70,28 +79,28 @@
 	bool isRenderTarget();
 
 	//! Returns pointer to the render target surface
-	IDirect3DSurface9* getRenderTargetSurface();
+	IDirect3DSurface9* getRenderTargetSurface(u32 index = 0);
 
 private:
 
-	void createRenderTarget();
+	void createRenderTarget(IDirect3DDevice9 *device);
 
 	//! returns the size of a texture which would be the optimize size for rendering it
 	inline s32 getTextureSizeFromImageSize(s32 size);
 
 	//! creates the hardware texture
-	void createTexture(u32 flags);
+	void createTexture(u32 flags, u32 renderDevice = 0);
 
 	//! copies the image to the texture
-	bool copyTexture();
+	bool copyTexture(u32 index = 0);
 
 	//! optimized for 16 bit to 16 copy.
-	bool copyTo16BitTexture();
+	bool copyTo16BitTexture(u32 index = 0);
 
 	//! copies texture to 32 bit hardware texture
-	bool copyTo32BitTexture();
+	bool copyTo32BitTexture(u32 index = 0);
 
-	bool createMipMaps(s32 level=1);
+	bool createMipMaps(s32 level=1, u32 idx = 0);
 	
 	void copy16BitMipMap(char* src, char* tgt,
 		s32 width, s32 height,  s32 pitchsrc, s32 pitchtgt);
@@ -100,10 +109,19 @@
 		s32 width, s32 height,  s32 pitchsrc, s32 pitchtgt);
 
 	IImage* Image;
-	IDirect3DDevice9* Device;
-	IDirect3DTexture9* Texture;
-	IDirect3DSurface9* RTTSurface;
-	CD3D9Driver* Driver;
+	
+	core::array<IDirect3DDevice9*>  Devices;
+	core::array<IDirect3DTexture9*> Textures;
+	core::array<IDirect3DSurface9*> RTTSurfaces;
+
+	void *textureBits;
+	void *surfaceBits;
+
+	//IDirect3DDevice9* Device;
+	//IDirect3DTexture9* Texture;
+	//IDirect3DSurface9* RTTSurface;
+	//CD3D9Driver* Driver;
+	video::IVideoDriver* Driver;
 	core::dimension2d<s32> TextureSize;
 	core::dimension2d<s32> ImageSize;
 	s32 Pitch;
diff -r -uw -N irrlicht/source/Irrlicht/CGUIContextMenu.cpp irrlicht_multipatch/source/Irrlicht/CGUIContextMenu.cpp
--- irrlicht/source/Irrlicht/CGUIContextMenu.cpp	2006-11-11 09:29:20.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CGUIContextMenu.cpp	2006-11-30 12:39:52.000000000 +0100
@@ -51,7 +51,7 @@
 
 
 //! Adds a menu item.
-s32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu)
+s32 CGUIContextMenu::addItem(const wchar_t* text, s32 id, bool enabled, bool hasSubMenu, bool checked)
 {
 	SItem s;
 	s.Enabled = enabled;
@@ -59,6 +59,7 @@
 	s.IsSeparator = (text == 0);
 	s.SubMenu = 0;
 	s.CommandId = id;
+	s.IsChecked = checked;
 
 	if (hasSubMenu)
 	{
@@ -125,6 +126,27 @@
 	Items[idx].Enabled = enabled;
 }
 
+//! Sets if the menu item should be checked.
+void CGUIContextMenu::setItemChecked(s32 idx, bool checked)
+{
+	if (idx < 0 || idx >= (s32)Items.size())
+		return;
+
+	Items[idx].IsChecked = checked;
+}
+
+//! Returns if a menu item is checked
+bool CGUIContextMenu::isItemChecked(s32 idx)
+{
+	if (idx < 0 || idx >= (s32)Items.size())
+	{
+		_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
+		return false;
+	}
+
+	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;
+	return Items[idx].IsChecked;
+}
 
 //! Removes a menu item
 void CGUIContextMenu::removeItem(s32 idx)
@@ -397,6 +419,15 @@
 					skin->getColor(c), true, true, clip);
 			}
 
+			// draw checked symbol
+			if (Items[i].IsChecked && defaultFont)
+			{
+				core::rect<s32> r = rect;
+				r.UpperLeftCorner.X = r.LowerRightCorner.X - 45;
+
+				defaultFont->draw(GUI_ICON_CHECK_BOX_CHECKED, r, 
+					skin->getColor(c), true, true, clip);
+			}
 		}
 	}
 
diff -r -uw -N irrlicht/source/Irrlicht/CGUIContextMenu.h irrlicht_multipatch/source/Irrlicht/CGUIContextMenu.h
--- irrlicht/source/Irrlicht/CGUIContextMenu.h	2006-11-11 09:29:20.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CGUIContextMenu.h	2006-11-30 12:37:42.000000000 +0100
@@ -32,7 +32,7 @@
 
 		//! Adds a menu item.
 		virtual s32 addItem(const wchar_t* text, s32 commandid, bool enabled=true,
-			bool hasSubMenu=false);
+			bool hasSubMenu=false, bool checked=false);
 
 		//! Adds a separator item to the menu
 		virtual void addSeparator();
@@ -49,6 +49,12 @@
 		//! Sets if the menu item should be enabled.
 		virtual void setItemEnabled(s32 idx, bool enabled);
 
+		//! Returns if a menu item is checked
+		virtual bool isItemChecked(s32 idx);
+
+		//! Sets if the menu item should be checked.
+		virtual void setItemChecked(s32 idx, bool checked);
+
 		//! Removes a menu item
 		virtual void removeItem(s32 idx);
 
@@ -84,6 +90,7 @@
 			core::stringw Text;
 			bool IsSeparator;
 			bool Enabled;
+			bool IsChecked;
 			core::dimension2d<s32> Dim;
 			s32 PosY;
 			CGUIContextMenu* SubMenu;
diff -r -uw -N irrlicht/source/Irrlicht/CGUIEditBox.cpp irrlicht_multipatch/source/Irrlicht/CGUIEditBox.cpp
--- irrlicht/source/Irrlicht/CGUIEditBox.cpp	2006-11-11 09:29:20.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CGUIEditBox.cpp	2006-12-01 13:18:04.000000000 +0100
@@ -399,6 +399,12 @@
 				MarkBegin = 0;
 				MarkEnd = 0;
 			}
+			SEvent e;
+			e.EventType = EET_GUI_EVENT;
+			e.GUIEvent.Caller = this;
+			e.GUIEvent.EventType = EGET_EDITBOX_KEY_PRESS;
+			Parent->OnEvent(e);
+
 		}
 		break;
 	}
diff -r -uw -N irrlicht/source/Irrlicht/CGUIWindow.cpp irrlicht_multipatch/source/Irrlicht/CGUIWindow.cpp
--- irrlicht/source/Irrlicht/CGUIWindow.cpp	2006-11-11 09:29:22.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CGUIWindow.cpp	2006-11-30 12:31:56.000000000 +0100
@@ -77,6 +77,12 @@
 		{
 			if (event.GUIEvent.Caller == CloseButton)
 			{
+				SEvent levent;
+				levent.EventType = EET_GUI_EVENT;
+				levent.GUIEvent.Caller = this;
+				levent.GUIEvent.EventType = EGET_WINDOW_CLOSED;
+				Parent->OnEvent(levent);
+
 				remove();
 				return true;
 			}
diff -r -uw -N irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp irrlicht_multipatch/source/Irrlicht/CIrrDeviceWin32.cpp
--- irrlicht/source/Irrlicht/CIrrDeviceWin32.cpp	2006-10-15 08:48:48.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CIrrDeviceWin32.cpp	2006-12-01 10:38:54.000000000 +0100
@@ -31,6 +31,12 @@
 			u32 bits, bool fullscreen, bool stencilbuffer, io::IFileSystem* io,
 			bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias);
 
+		IVideoDriver* createDirectX9DriverMultihead(const core::array<core::dimension2d<s32> > & screenSize, core::array<HWND> window,
+													u32 bits, bool fullscreen, bool stencilbuffer,
+													io::IFileSystem* io, bool pureSoftware, bool highPrecisionFPU, bool vsync, bool antiAlias);
+
+		int getDirectX9MultiheadAdapterCount();
+
 		IVideoDriver* createOpenGLDriver(const core::dimension2d<s32>& screenSize, HWND window, 
 			u32 bits, bool fullscreen, bool stencilBuffer, io::IFileSystem* io,
 			bool vsync, bool antiAlias);
@@ -84,6 +90,12 @@
 
 	switch (message) 
 	{
+	case WM_CLOSE:
+		dev = getDeviceFromHWnd(hWnd); 
+		if (dev) 
+			dev->closeDevice();
+		return 0;
+
 	case WM_PAINT:
 		{
 			PAINTSTRUCT ps;
@@ -270,7 +282,7 @@
 				 IEventReceiver* receiver,
 				 HWND externalWindow,
 				 const char* version)
-: CIrrDeviceStub(version, receiver), HWnd(0), ChangedToFullScreen(false),
+: CIrrDeviceStub(version, receiver), ChangedToFullScreen(false),
 	Win32CursorControl(0), IsNonNTWindows(false), Resized(false),
 	FullScreen(fullscreen), ExternalWindow(false)
 {
@@ -287,6 +299,11 @@
 	setDebugName("CIrrDeviceWin32");	
 	#endif
 
+	m_adapterCount = 0;
+
+	//add a null device
+	mHWnd.push_back(NULL);
+
 	if (driverType != video::EDT_NULL && externalWindow==0)
 	{
 		// create the window, only if we do not use the null device
@@ -297,7 +314,12 @@
 
 		WNDCLASSEX wcex;
 		wcex.cbSize		= sizeof(WNDCLASSEX); 
+
+		if(driverType == video::EDT_DIRECT3D9_MULTIHEAD && fullscreen)
+			wcex.style			= 0;
+		else
 		wcex.style		= CS_HREDRAW | CS_VREDRAW;
+
 		wcex.lpfnWndProc	= (WNDPROC)WndProc;
 		wcex.cbClsExtra		= 0;
 		wcex.cbWndExtra		= 0;
@@ -339,26 +361,62 @@
 		{
 			windowLeft = 0;
 			windowTop = 0;
+
+			if(driverType == video::EDT_DIRECT3D9_MULTIHEAD)
+			{
+				m_adapterCount = video::getDirectX9MultiheadAdapterCount();
+				if(m_adapterCount <= 1)
+				{
+					os::Printer::log("Could not initialise directx9 multihead device.", ELL_WARNING);
+					driverType = video::EDT_DIRECT3D9;
+				}
+				for(s32 idx = 1; idx < m_adapterCount; idx++)
+				{
+					mHWnd.push_back(NULL);
+				}
+			}
+		}
+		else
+		{
+			if(driverType == video::EDT_DIRECT3D9_MULTIHEAD)
+			{
+				//we do not support multihead in window mode
+				driverType = video::EDT_DIRECT3D9;
+			}
 		}
 
+		if(m_adapterCount <= 1)
+		{
 		// create window
-
-		HWnd = CreateWindow( ClassName, "", style, windowLeft, windowTop, 
+			mHWnd[0] = CreateWindow( ClassName, "", style, windowLeft, windowTop, 
 					realWidth, realHeight,	NULL, NULL, hInstance, NULL);
 
-		ShowWindow(HWnd , SW_SHOW);
-		UpdateWindow(HWnd);
+			ShowWindow(mHWnd[0] , SW_SHOW);
+			UpdateWindow(mHWnd[0]);
 
 		// fix ugly ATI driver bugs. Thanks to ariaci
-		MoveWindow(HWnd, windowLeft, windowTop, realWidth, realHeight, TRUE);
+			MoveWindow(mHWnd[0], windowLeft, windowTop, realWidth, realHeight, TRUE);
+			m_multiHead = false;
+		}
+		else if(m_adapterCount > 1)
+		{
+			for(s32 idx = 0; idx < m_adapterCount; idx++)
+			{
+				mHWnd[idx] = CreateWindow( ClassName, "", style, CW_USEDEFAULT, CW_USEDEFAULT, 
+									CW_USEDEFAULT, CW_USEDEFAULT, mHWnd[0], NULL, hInstance, NULL);
+				ShowWindow(mHWnd[idx] , SW_SHOW);
+				UpdateWindow(mHWnd[idx]);
+			}
+			m_multiHead = true;
+		}
 	}
 
 	// attach external window
 	if (externalWindow)
 	{
-		HWnd = externalWindow;
+		mHWnd[0] = externalWindow;
 		RECT r;
-		GetWindowRect(HWnd, &r);
+		GetWindowRect(mHWnd[0], &r);
 		windowSize.Width = r.right - r.left;
 		windowSize.Height = r.bottom - r.top;
 		fullscreen = false;
@@ -367,7 +425,7 @@
 
 	// create cursor control
 
-	Win32CursorControl = new CCursorControl(windowSize, HWnd, fullscreen);
+	Win32CursorControl = new CCursorControl(windowSize, mHWnd[0], fullscreen);
 	CursorControl = Win32CursorControl;
 
 	// create driver
@@ -380,12 +438,15 @@
 
 	SEnvMapper em;
 	em.irrDev = this;
-	em.hWnd = HWnd;
+	em.hWnd = mHWnd[0];
 	EnvMap.push_back(em);
 
+	if(driverType != video::EDT_DIRECT3D9_MULTIHEAD)
+	{
 	// set this as active window
-	SetActiveWindow(HWnd);
-	SetForegroundWindow(HWnd);
+		SetActiveWindow(mHWnd[0]);
+		SetForegroundWindow(mHWnd[0]);
+	}
 }
 
 
@@ -397,7 +458,7 @@
 
 	irr::core::list<SEnvMapper>::Iterator it = EnvMap.begin();
 	for (; it!= EnvMap.end(); ++it)
-		if ((*it).hWnd == HWnd)
+		if ((*it).hWnd == mHWnd[0])
 		{
 			EnvMap.erase(it);
 			break;
@@ -405,6 +466,9 @@
 
 	if (ChangedToFullScreen)
 		ChangeDisplaySettings(NULL,0);
+
+	if(m_multiHead)
+		closeDevice();
 }
 
 
@@ -423,7 +487,7 @@
 	{
 	case video::EDT_DIRECT3D8:
 		#ifdef _IRR_COMPILE_WITH_DIRECT3D_8_
-		VideoDriver = video::createDirectX8Driver(windowSize, HWnd, bits, fullscreen, 
+		VideoDriver = video::createDirectX8Driver(windowSize, mHWnd[0], bits, fullscreen, 
 			stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias);
 		if (!VideoDriver)
 		{
@@ -437,7 +501,7 @@
 
 	case video::EDT_DIRECT3D9:
 		#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
-		VideoDriver = video::createDirectX9Driver(windowSize, HWnd, bits, fullscreen, 
+		VideoDriver = video::createDirectX9Driver(windowSize, mHWnd[0], bits, fullscreen, 
 			stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias);
 		if (!VideoDriver)
 		{
@@ -449,11 +513,34 @@
 
 		break;	
 	
+	case video::EDT_DIRECT3D9_MULTIHEAD:
+		#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
+		{
+			core::array<core::dimension2d<s32> > windowSizes;
+			for(s32 idx = 0; idx < m_adapterCount; ++idx)
+				windowSizes.push_back(windowSize);
+
+			VideoDriver = video::createDirectX9DriverMultihead(windowSizes, mHWnd, bits, fullscreen, 
+															stencilbuffer, FileSystem, false, highPrecisionFPU, vsync, antiAlias);
+		}
+		#endif
+
+		if (!VideoDriver)
+		{
+			#ifdef _IRR_COMPILE_WITH_DIRECT3D_9_
+			os::Printer::log("Could not create DirectX9 Multihead Driver.", ELL_ERROR);
+			#else
+			os::Printer::log("DIRECT3D9 Driver was not compiled into this dll. Try another one.", ELL_ERROR);
+			#endif
+		}
+
+		break;	
+
 	case video::EDT_OPENGL:
 
 		#ifdef _IRR_COMPILE_WITH_OPENGL_
 		if (fullscreen)	switchToFullScreen(windowSize.Width, windowSize.Height, bits);
-		VideoDriver = video::createOpenGLDriver(windowSize, HWnd, bits, fullscreen, stencilbuffer, FileSystem,
+		VideoDriver = video::createOpenGLDriver(windowSize, mHWnd[0], bits, fullscreen, stencilbuffer, FileSystem,
 			vsync, antiAlias);
 		if (!VideoDriver)
 		{
@@ -496,8 +583,8 @@
 	{
 		TranslateMessage(&msg);
 
-		if (ExternalWindow && msg.hwnd == HWnd)
-			WndProc(HWnd, msg.message, msg.wParam, msg.lParam);
+		if (ExternalWindow && msg.hwnd == mHWnd[0])
+			WndProc(mHWnd[0], msg.message, msg.wParam, msg.lParam);
 		else
 			DispatchMessage(&msg);
 
@@ -519,7 +606,7 @@
 		return;
 
 	RECT r;
-	GetClientRect(HWnd, &r);
+	GetClientRect(mHWnd[0], &r);
 
 	char tmp[255];
 
@@ -553,10 +640,10 @@
 	if (IsNonNTWindows)
 	{
 		core::stringc s = text;
-		SetWindowTextA(HWnd, s.c_str());
+		SetWindowTextA(mHWnd[0], s.c_str());
 	}
 	else
-		SetWindowTextW(HWnd, text);
+		SetWindowTextW(mHWnd[0], text);
 }
 
 
@@ -564,7 +651,7 @@
 //! presents a surface in the client area
 void CIrrDeviceWin32::present(video::IImage* image, s32 windowId, core::rect<s32>* src )
 {
-	HWND hwnd = HWnd;
+	HWND hwnd = mHWnd[0];
 	if ( windowId )
 		hwnd = (HWND)windowId;
 
@@ -614,7 +701,7 @@
 //! notifies the device that it should close itself
 void CIrrDeviceWin32::closeDevice()
 {
-	DestroyWindow(HWnd); 	//PostQuitMessage(0);
+	DestroyWindow(mHWnd[0]); 	//PostQuitMessage(0);
 }
 
 
@@ -622,7 +709,7 @@
 //! returns if window is active. if not, nothing need to be drawn
 bool CIrrDeviceWin32::isWindowActive()
 {
-	bool ret = (GetActiveWindow() == HWnd);
+	bool ret = (GetActiveWindow() == mHWnd[0]);
 	_IRR_IMPLEMENT_MANAGED_MARSHALLING_BUGFIX;	
 	return ret;
 }
@@ -840,7 +927,7 @@
 	else
 		style = WS_THICKFRAME | WS_SYSMENU | WS_CAPTION | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_MAXIMIZEBOX;
 
-	if (!SetWindowLong(HWnd, GWL_STYLE, style))
+	if (!SetWindowLong(mHWnd[0], GWL_STYLE, style))
 		os::Printer::log("Could not change window style.");
 
 	RECT clientSize;
@@ -857,7 +944,7 @@
 	s32 windowLeft = (GetSystemMetrics(SM_CXSCREEN) - realWidth) / 2;
 	s32 windowTop = (GetSystemMetrics(SM_CYSCREEN) - realHeight) / 2;
 
-	SetWindowPos(HWnd, HWND_TOP, windowLeft, windowTop, realWidth, realHeight, 
+	SetWindowPos(mHWnd[0], HWND_TOP, windowLeft, windowTop, realWidth, realHeight, 
 		SWP_FRAMECHANGED | SWP_NOMOVE | SWP_SHOWWINDOW);
 }
 
@@ -889,6 +976,10 @@
 	return dev;
 }
 
+IRRLICHT_API s32 IRRCALLCONV getMultiHeadAdapterCountDX9()
+{
+	return (s32) video::getDirectX9MultiheadAdapterCount();
+}
 
 } // end namespace 
 
diff -r -uw -N irrlicht/source/Irrlicht/CIrrDeviceWin32.h irrlicht_multipatch/source/Irrlicht/CIrrDeviceWin32.h
--- irrlicht/source/Irrlicht/CIrrDeviceWin32.h	2006-08-03 19:43:54.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CIrrDeviceWin32.h	2006-11-30 17:23:56.000000000 +0100
@@ -181,7 +181,10 @@
 
 		void resizeIfNecessary();
 
-		HWND HWnd;
+		//HWND HWnd;
+		core::array<HWND> mHWnd;
+		bool m_multiHead;
+		s32  m_adapterCount;
 
 		bool ChangedToFullScreen;
 		bool FullScreen;
diff -r -uw -N irrlicht/source/Irrlicht/CMeshManipulator.cpp irrlicht_multipatch/source/Irrlicht/CMeshManipulator.cpp
--- irrlicht/source/Irrlicht/CMeshManipulator.cpp	2006-08-29 08:13:04.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CMeshManipulator.cpp	2006-11-29 22:02:38.000000000 +0100
@@ -21,7 +21,7 @@
 //! visual studio 6.0 didn't like it.
 template<class VTXTYPE>
 inline void recalculateNormalsT_Flat(VTXTYPE* v, int vtxcnt,
-					u16* idx, int idxcnt)
+					u32* idx, int idxcnt)
 {
 	for (int i=0; i<idxcnt; i+=3)
 	{
@@ -34,7 +34,7 @@
 
 template<class VTXTYPE>
 inline void recalculateNormalsT_Smooth(VTXTYPE* v, int vtxcnt,
-					u16* idx, int idxcnt)
+					u32* idx, int idxcnt)
 {
 	s32 i;
 
@@ -65,7 +65,7 @@
 template<class VERTEXTYPE>
 inline void makePlanarMappingT(VERTEXTYPE *v,
 				   int vtxcnt,
-				   u16* idx, int idxcnt, f32 resolution)
+				   u32* idx, int idxcnt, f32 resolution)
 {
 	for (int i=0; i<idxcnt; i+=3)
 	{
@@ -127,7 +127,7 @@
 	{
 		IMeshBuffer* buffer = mesh->getMeshBuffer(b);
 		s32 idxcnt = buffer->getIndexCount();
-		u16* idx = buffer->getIndices();
+		u32* idx = buffer->getIndices();
 		s32 tmp;
 
 		for (s32 i=0; i<idxcnt; i+=3)
@@ -230,7 +230,7 @@
 
 	s32 vtxcnt = buffer->getVertexCount();
 	s32 idxcnt = buffer->getIndexCount();
-	u16* idx = buffer->getIndices();
+	u32* idx = buffer->getIndices();
 
 	switch(buffer->getVertexType())
 	{
@@ -411,7 +411,7 @@
 	{
 		s32 vtxCnt = mesh->getMeshBuffer(b)->getVertexCount();
 		s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
-		const u16* idx = mesh->getMeshBuffer(b)->getIndices();
+		const u32* idx = mesh->getMeshBuffer(b)->getIndices();
 
 		switch(mesh->getMeshBuffer(b)->getVertexType())
 		{
@@ -501,7 +501,7 @@
 		IMeshBuffer* buffer = mesh->getMeshBuffer(b);
 		s32 vtxcnt = buffer->getVertexCount();
 		s32 idxcnt = buffer->getIndexCount();
-		u16* idx = buffer->getIndices();
+		u32* idx = buffer->getIndices();
 
 		switch(buffer->getVertexType())
 		{
@@ -542,7 +542,7 @@
 	for (s32 b=0; b<meshBufferCount; ++b)
 	{
 		s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
-		const u16* idx = mesh->getMeshBuffer(b)->getIndices();
+		const u32* idx = mesh->getMeshBuffer(b)->getIndices();
 
 		switch(mesh->getMeshBuffer(b)->getVertexType())
 		{
@@ -639,7 +639,7 @@
 	for (b=0; b<meshBufferCount; ++b)
 	{
 		s32 idxCnt = mesh->getMeshBuffer(b)->getIndexCount();
-		const u16* idx = mesh->getMeshBuffer(b)->getIndices();
+		const u32* idx = mesh->getMeshBuffer(b)->getIndices();
 
 		SMeshBufferTangents* buffer = new SMeshBufferTangents();
 		buffer->Material = mesh->getMeshBuffer(b)->getMaterial();
@@ -698,7 +698,7 @@
 	{
 		s32 idxCnt = clone->getMeshBuffer(b)->getIndexCount();
 
-		u16* idx = clone->getMeshBuffer(b)->getIndices();
+		u32* idx = clone->getMeshBuffer(b)->getIndices();
 		video::S3DVertexTangents* v =
 			(video::S3DVertexTangents*)clone->getMeshBuffer(b)->getVertices();
 
diff -r -uw -N irrlicht/source/Irrlicht/CNullDriver.cpp irrlicht_multipatch/source/Irrlicht/CNullDriver.cpp
--- irrlicht/source/Irrlicht/CNullDriver.cpp	2006-11-01 08:01:48.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CNullDriver.cpp	2006-12-05 11:49:27.000000000 +0100
@@ -208,7 +208,7 @@
 
 
 //! queries the features of the driver, returns true if feature is available
-bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature)
+bool CNullDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice)
 {
 	return false;
 }
@@ -467,7 +467,7 @@
 
 
 //! draws a vertex primitive list
-void CNullDriver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
+void CNullDriver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
 {
 	PrimitivesDrawn += primitiveCount;
 }
@@ -475,7 +475,7 @@
 
 
 //! draws an indexed triangle list
-inline void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+inline void CNullDriver::drawIndexedTriangleList(const S3DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 {
 	drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLES);
 }
@@ -483,7 +483,7 @@
 
 
 //! draws an indexed triangle list
-inline void CNullDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+inline void CNullDriver::drawIndexedTriangleList(const S3DVertex2TCoords* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 {
 	drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLES);
 }
@@ -491,7 +491,7 @@
 
 //! Draws an indexed triangle list.
 inline void CNullDriver::drawIndexedTriangleList(const S3DVertexTangents* vertices,
-	s32 vertexCount, const u16* indexList, s32 triangleCount)
+	s32 vertexCount, const u32* indexList, s32 triangleCount)
 {
 	drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_TANGENTS, scene::EPT_TRIANGLES);
 }
@@ -500,7 +500,7 @@
 
 //! Draws an indexed triangle fan.
 inline void CNullDriver::drawIndexedTriangleFan(const S3DVertex* vertices,
-	s32 vertexCount, const u16* indexList, s32 triangleCount)
+	s32 vertexCount, const u32* indexList, s32 triangleCount)
 {
 	drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_STANDARD, scene::EPT_TRIANGLE_FAN);
 }
@@ -509,7 +509,7 @@
 
 //! Draws an indexed triangle fan.
 inline void CNullDriver::drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
-	s32 vertexCount, const u16* indexList, s32 triangleCount)
+	s32 vertexCount, const u32* indexList, s32 triangleCount)
 {
 	drawVertexPrimitiveList(vertices, vertexCount, indexList, triangleCount, EVT_2TCOORDS, scene::EPT_TRIANGLE_FAN);
 }
diff -r -uw -N irrlicht/source/Irrlicht/CNullDriver.h irrlicht_multipatch/source/Irrlicht/CNullDriver.h
--- irrlicht/source/Irrlicht/CNullDriver.h	2006-11-01 08:01:48.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CNullDriver.h	2006-12-05 11:49:34.000000000 +0100
@@ -36,7 +36,7 @@
 		virtual bool endScene( s32 windowId = 0, core::rect<s32>* sourceRect=0 );
 
 		//! queries the features of the driver, returns true if feature is available
-		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature);
+		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1);
 
 		//! sets transformation
 		virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
@@ -70,25 +70,25 @@
 		virtual const core::rect<s32>& getViewPort() const;
 
 		//! draws a vertex primitive list
-		virtual void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
+		virtual void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
 
 		//! draws an indexed triangle list
-		virtual void drawIndexedTriangleList(const S3DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount);
+		virtual void drawIndexedTriangleList(const S3DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount);
 
 		//! draws an indexed triangle list
-		virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount);
+		virtual void drawIndexedTriangleList(const S3DVertex2TCoords* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount);
 
 		//! Draws an indexed triangle list.
 		virtual void drawIndexedTriangleList(const S3DVertexTangents* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount);
+			s32 vertexCount, const u32* indexList, s32 triangleCount);
 
 		//! Draws an indexed triangle fan.
 		virtual void drawIndexedTriangleFan(const S3DVertex* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount);
+			s32 vertexCount, const u32* indexList, s32 triangleCount);
 
 		//! Draws an indexed triangle list.
 		virtual void drawIndexedTriangleFan(const S3DVertex2TCoords* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount);
+			s32 vertexCount, const u32* indexList, s32 triangleCount);
 
 		//! Draws a 3d line.
 		virtual void draw3DLine(const core::vector3df& start,
diff -r -uw -N irrlicht/source/Irrlicht/COpenGLDriver.cpp irrlicht_multipatch/source/Irrlicht/COpenGLDriver.cpp
--- irrlicht/source/Irrlicht/COpenGLDriver.cpp	2006-11-27 16:44:10.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/COpenGLDriver.cpp	2006-12-05 11:48:31.000000000 +0100
@@ -83,7 +83,7 @@
 		0,				// Shift Bit Ignored
 		0,				// No Accumulation Buffer
 		0, 0, 0, 0,			// Accumulation Bits Ignored
-		24,				// Z-Buffer (Depth Buffer)
+		16,				// Z-Buffer (Depth Buffer)
 		StencilBuffer ? 1 : 0,		// Stencil Buffer
 		0,				// No Auxiliary Buffer
 		PFD_MAIN_PLANE,			// Main Drawing Layer
@@ -814,7 +814,7 @@
 
 
 //! draws a vertex primitive list
-void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
+void COpenGLDriver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
 {
 	if (!primitiveCount || !vertexCount)
 		return;
@@ -922,31 +922,31 @@
 			glDrawArrays(GL_POINTS, 0, primitiveCount);
 			break;
 		case scene::EPT_LINE_STRIP:
-			glDrawElements(GL_LINE_STRIP, primitiveCount+1, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_LINE_STRIP, primitiveCount+1, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_LINE_LOOP:
-			glDrawElements(GL_LINE_LOOP, primitiveCount, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_LINE_LOOP, primitiveCount, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_LINES:
-			glDrawElements(GL_LINES, primitiveCount*2, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_LINES, primitiveCount*2, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_TRIANGLE_STRIP:
-			glDrawElements(GL_TRIANGLE_STRIP, primitiveCount+2, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_TRIANGLE_STRIP, primitiveCount+2, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_TRIANGLE_FAN:
-			glDrawElements(GL_TRIANGLE_FAN, primitiveCount+2, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_TRIANGLE_FAN, primitiveCount+2, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_TRIANGLES:
-			glDrawElements(GL_TRIANGLES, primitiveCount*3, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_TRIANGLES, primitiveCount*3, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_QUAD_STRIP:
-			glDrawElements(GL_QUAD_STRIP, primitiveCount*2+2, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_QUAD_STRIP, primitiveCount*2+2, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_QUADS:
-			glDrawElements(GL_QUADS, primitiveCount*4, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_QUADS, primitiveCount*4, GL_UNSIGNED_INT, indexList);
 			break;
 		case scene::EPT_POLYGON:
-			glDrawElements(GL_POLYGON, primitiveCount, GL_UNSIGNED_SHORT, indexList);
+			glDrawElements(GL_POLYGON, primitiveCount, GL_UNSIGNED_INT, indexList);
 			break;
 	}
 
@@ -1392,7 +1392,7 @@
 
 
 //! queries the features of the driver, returns true if feature is available
-bool COpenGLDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature)
+bool COpenGLDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice)
 {
 	switch (feature)
 	{
diff -r -uw -N irrlicht/source/Irrlicht/COpenGLDriver.h irrlicht_multipatch/source/Irrlicht/COpenGLDriver.h
--- irrlicht/source/Irrlicht/COpenGLDriver.h	2006-11-25 13:46:52.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/COpenGLDriver.h	2006-12-05 11:48:50.000000000 +0100
@@ -86,10 +86,10 @@
 		virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
 
 		//! draws a vertex primitive list
-		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
+		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
 
 		//! queries the features of the driver, returns true if feature is available
-		bool queryFeature(E_VIDEO_DRIVER_FEATURE feature);
+		bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1);
 
 		//! Sets a material. All 3d drawing functions draw geometry now
 		//! using this material.
diff -r -uw -N irrlicht/source/Irrlicht/CSceneManager.cpp irrlicht_multipatch/source/Irrlicht/CSceneManager.cpp
--- irrlicht/source/Irrlicht/CSceneManager.cpp	2006-11-18 08:23:10.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CSceneManager.cpp	2006-12-03 16:22:08.000000000 +0100
@@ -791,6 +791,10 @@
 	}
 }
 
+void CSceneManager::updateEffects()
+{
+	OnUpdateEffect();
+}
 
 //! This method is called just before the rendering process of the whole scene.
 //! draws all scene nodes
@@ -938,10 +942,10 @@
 //! Creates a texture animator, which switches the textures of the target scene
 //! node based on a list of textures.
 ISceneNodeAnimator* CSceneManager::createTextureAnimator(const core::array<video::ITexture*>& textures,
-	s32 timePerFrame, bool loop)
+	s32 timePerFrame, bool loop, s32 layer)
 {
 	ISceneNodeAnimator* anim = new CSceneNodeAnimatorTexture(textures,
-		timePerFrame, loop, os::Timer::getTime());
+		timePerFrame, loop, os::Timer::getTime(), layer);
 
 	return anim;
 }
diff -r -uw -N irrlicht/source/Irrlicht/CSceneManager.h irrlicht_multipatch/source/Irrlicht/CSceneManager.h
--- irrlicht/source/Irrlicht/CSceneManager.h	2006-11-11 09:31:16.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CSceneManager.h	2006-12-03 16:20:52.000000000 +0100
@@ -87,6 +87,9 @@
 		//! registers a node for rendering it at a specific time.
 		virtual void registerNodeForRendering(ISceneNode* node, E_SCENE_NODE_RENDER_PASS = ESNRP_AUTOMATIC);
 
+		//! draws the effect of all scene nodes
+		virtual void updateEffects();
+
 		//! draws all scene nodes
 		virtual void drawAll();
 
@@ -246,7 +249,7 @@
 		//! Creates a texture animator, which switches the textures of the target scene
 		//! node based on a list of textures.
 		virtual ISceneNodeAnimator* createTextureAnimator(const core::array<video::ITexture*>& textures,
-			s32 timePerFrame, bool loop);
+			s32 timePerFrame, bool loop, s32 layer=0);
 
 		//! Creates a scene node animator, which deletes the scene node after
 		//! some time automaticly.
diff -r -uw -N irrlicht/source/Irrlicht/CSceneNodeAnimatorTexture.cpp irrlicht_multipatch/source/Irrlicht/CSceneNodeAnimatorTexture.cpp
--- irrlicht/source/Irrlicht/CSceneNodeAnimatorTexture.cpp	2006-08-29 08:13:02.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CSceneNodeAnimatorTexture.cpp	2006-12-01 13:38:24.000000000 +0100
@@ -12,8 +12,8 @@
 
 //! constructor
 CSceneNodeAnimatorTexture::CSceneNodeAnimatorTexture(const core::array<video::ITexture*>& textures, 
-						 s32 timePerFrame, bool loop, u32 now)
-: Loop(loop), StartTime(now), TimePerFrame(timePerFrame)
+						 s32 timePerFrame, bool loop, u32 now, s32 layer)
+: Loop(loop), StartTime(now), TimePerFrame(timePerFrame), Layer(layer)
 {
 	#ifdef _DEBUG
 	setDebugName("CSceneNodeAnimatorTexture");
@@ -64,7 +64,7 @@
 			idx = (t/TimePerFrame) % Textures.size();
 
 		if (idx < (s32)Textures.size())
-			node->setMaterialTexture(0, Textures[idx]);
+			node->setMaterialTexture(Layer, Textures[idx]);
 	}
 }
 
diff -r -uw -N irrlicht/source/Irrlicht/CSceneNodeAnimatorTexture.h irrlicht_multipatch/source/Irrlicht/CSceneNodeAnimatorTexture.h
--- irrlicht/source/Irrlicht/CSceneNodeAnimatorTexture.h	2006-06-17 08:11:54.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CSceneNodeAnimatorTexture.h	2006-12-01 13:37:32.000000000 +0100
@@ -18,7 +18,7 @@
 
 		//! constructor
 		CSceneNodeAnimatorTexture(const core::array<video::ITexture*>& textures,
-			s32 timePerFrame, bool loop, u32 now);
+			s32 timePerFrame, bool loop, u32 now, s32 layer);
 
 		//! destructor
 		virtual ~CSceneNodeAnimatorTexture();
@@ -44,6 +44,7 @@
 		u32 StartTime;
 		u32 EndTime;
 		bool Loop;
+		s32 Layer;
 	};
 
 
diff -r -uw -N irrlicht/source/Irrlicht/CShadowVolumeSceneNode.cpp irrlicht_multipatch/source/Irrlicht/CShadowVolumeSceneNode.cpp
--- irrlicht/source/Irrlicht/CShadowVolumeSceneNode.cpp	2006-08-29 08:13:00.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CShadowVolumeSceneNode.cpp	2006-11-29 23:36:36.000000000 +0100
@@ -305,7 +305,7 @@
 	if (totalIndices > IndexCountAllocated)
 	{
 		delete [] Indices;
-		Indices = new u16[totalIndices];
+		Indices = new u32[totalIndices];
 		IndexCountAllocated = totalIndices;
 
 		if (UseZFailMethod)
@@ -324,8 +324,8 @@
 		s32 idxcnt = b->getIndexCount();
 		s32 vtxnow = VertexCount;
 
-		const u16* idxp = b->getIndices();
-		const u16* idxpend = idxp + idxcnt;
+		const u32* idxp = b->getIndices();
+		const u32* idxpend = idxp + idxcnt;
 
 		for (; idxp!=idxpend; ++idxp)
 			Indices[IndexCount++] = *idxp + vtxnow;
@@ -443,7 +443,7 @@
 void CShadowVolumeSceneNode::calculateAdjacency(f32 epsilon)
 {
 	delete [] Adjacency;
-	Adjacency = new u16[IndexCount];
+	Adjacency = new u32[IndexCount];
 
 	epsilon *= epsilon;
 
diff -r -uw -N irrlicht/source/Irrlicht/CShadowVolumeSceneNode.h irrlicht_multipatch/source/Irrlicht/CShadowVolumeSceneNode.h
--- irrlicht/source/Irrlicht/CShadowVolumeSceneNode.h	2006-08-29 08:13:00.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CShadowVolumeSceneNode.h	2006-11-29 23:36:34.000000000 +0100
@@ -66,9 +66,9 @@
 		bool UseZFailMethod;
 		core::aabbox3d<f32> Box;
 
-		u16* Indices;
+		u32* Indices;
 		core::vector3df* Vertices;
-		u16* Adjacency;
+		u32* Adjacency;
 		bool* FaceData; // used for zfail method, if face is front facing
 
 		s32 IndexCountAllocated;
diff -r -uw -N irrlicht/source/Irrlicht/CSkyBoxSceneNode.h irrlicht_multipatch/source/Irrlicht/CSkyBoxSceneNode.h
--- irrlicht/source/Irrlicht/CSkyBoxSceneNode.h	2006-08-13 14:44:42.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CSkyBoxSceneNode.h	2006-11-29 23:36:52.000000000 +0100
@@ -50,7 +50,7 @@
 	private:
 
 		core::aabbox3d<f32> Box;
-		u16 Indices[4];
+		u32 Indices[4];
 		video::S3DVertex Vertices[4*6];
 		video::SMaterial Material[6];
 	};
diff -r -uw -N irrlicht/source/Irrlicht/CSoftwareDriver.cpp irrlicht_multipatch/source/Irrlicht/CSoftwareDriver.cpp
--- irrlicht/source/Irrlicht/CSoftwareDriver.cpp	2006-11-01 12:04:00.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CSoftwareDriver.cpp	2006-12-05 11:50:58.000000000 +0100
@@ -164,7 +164,7 @@
 
 
 //! queries the features of the driver, returns true if feature is available
-bool CSoftwareDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature)
+bool CSoftwareDriver::queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice)
 {
 	switch (feature)
 	{
@@ -316,10 +316,10 @@
 
 
 //! draws a vertex primitive list
-void CSoftwareDriver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
+void CSoftwareDriver::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
 {
-	const u16* indexPointer=0;
-	core::array<u16> newBuffer;
+	const u32* indexPointer=0;
+	core::array<u32> newBuffer;
 	switch (pType)
 	{
 		case scene::EPT_TRIANGLE_FAN:
@@ -357,7 +357,7 @@
 
 template<class VERTEXTYPE>
 void CSoftwareDriver::drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices,
-	s32 vertexCount, const u16* indexList, s32 triangleCount)
+	s32 vertexCount, const u32* indexList, s32 triangleCount)
 {
 	if (!RenderTargetSurface || !ZBuffer || !triangleCount)
 		return;
@@ -367,7 +367,7 @@
 
 	// arrays for storing clipped vertices
 	core::array<VERTEXTYPE> clippedVertices;
-	core::array<u16> clippedIndices;
+	core::array<u32> clippedIndices;
 
 	// calculate inverse world transformation
 	core::matrix4 worldinv(TransformationMatrix[ETS_WORLD]);
@@ -612,7 +612,7 @@
 	vtx[2].Pos = start + vect;
 	vtx[3].Pos = end + vect;
 
-	u16 idx[12] = {0,1,2, 0,2,1, 0,1,3, 0,3,1};
+	u32 idx[12] = {0,1,2, 0,2,1, 0,1,3, 0,3,1};
 
 	drawIndexedTriangleList(vtx, 4, idx, 4);
 }
diff -r -uw -N irrlicht/source/Irrlicht/CSoftwareDriver.h irrlicht_multipatch/source/Irrlicht/CSoftwareDriver.h
--- irrlicht/source/Irrlicht/CSoftwareDriver.h	2006-10-15 08:48:46.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CSoftwareDriver.h	2006-12-05 11:48:24.000000000 +0100
@@ -28,7 +28,7 @@
 		virtual bool endScene( s32 windowId = 0, core::rect<s32>* sourceRect=0 );
 
 		//! queries the features of the driver, returns true if feature is available
-		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature);
+		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1);
 
 		//! sets transformation
 		virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
@@ -46,7 +46,7 @@
 		virtual bool beginScene(bool backBuffer, bool zBuffer, SColor color);
 
 		//! draws a vertex primitive list
-		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
+		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
 
 		//! Draws a 3d line.
 		virtual void draw3DLine(const core::vector3df& start,
@@ -121,7 +121,7 @@
 
 		template<class VERTEXTYPE>
 		void drawClippedIndexedTriangleListT(const VERTEXTYPE* vertices,
-			s32 vertexCount, const u16* indexList, s32 triangleCount);
+			s32 vertexCount, const u32* indexList, s32 triangleCount);
 
 		core::array<S2DVertex> TransformedPoints;
 
diff -r -uw -N irrlicht/source/Irrlicht/CSoftwareDriver2.cpp irrlicht_multipatch/source/Irrlicht/CSoftwareDriver2.cpp
--- irrlicht/source/Irrlicht/CSoftwareDriver2.cpp	2006-10-15 08:48:46.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CSoftwareDriver2.cpp	2006-12-05 11:54:19.000000000 +0100
@@ -235,7 +235,7 @@
 
 
 //! queries the features of the driver, returns true if feature is available
-bool CSoftwareDriver2::queryFeature(E_VIDEO_DRIVER_FEATURE feature)
+bool CSoftwareDriver2::queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice)
 {
 	switch (feature)
 	{
@@ -819,7 +819,7 @@
 }
 
 //! draws a vertex primitive list
-void CSoftwareDriver2::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
+void CSoftwareDriver2::drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType)
 {
 	if (!checkPrimitiveCount(primitiveCount))
 		return;
diff -r -uw -N irrlicht/source/Irrlicht/CSoftwareDriver2.h irrlicht_multipatch/source/Irrlicht/CSoftwareDriver2.h
--- irrlicht/source/Irrlicht/CSoftwareDriver2.h	2006-11-18 08:23:10.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CSoftwareDriver2.h	2006-12-05 11:54:29.000000000 +0100
@@ -30,7 +30,7 @@
 		virtual bool endScene( s32 windowId = 0, core::rect<s32>* sourceRect=0 );
 
 		//! queries the features of the driver, returns true if feature is available
-		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature);
+		virtual bool queryFeature(E_VIDEO_DRIVER_FEATURE feature, s32 renderDevice = -1);
 
 		//! sets transformation
 		virtual void setTransform(E_TRANSFORMATION_STATE state, const core::matrix4& mat);
@@ -62,7 +62,7 @@
 		virtual void setAmbientLight(const SColorf& color);
 
 		//! draws a vertex primitive list
-		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u16* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
+		void drawVertexPrimitiveList(const void* vertices, s32 vertexCount, const u32* indexList, s32 primitiveCount, E_VERTEX_TYPE vType, scene::E_PRIMITIVE_TYPE pType);
 
 		//! draws an 2d image, using a color (if color is other then Color(255,255,255,255)) and the alpha channel of the texture if wanted.
 		virtual void draw2DImage(video::ITexture* texture, const core::position2d<s32>& destPos,
diff -r -uw -N irrlicht/source/Irrlicht/CTRFlat.cpp irrlicht_multipatch/source/Irrlicht/CTRFlat.cpp
--- irrlicht/source/Irrlicht/CTRFlat.cpp	2006-11-01 09:51:50.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRFlat.cpp	2006-11-29 23:58:06.000000000 +0100
@@ -22,7 +22,7 @@
 	}
 
 	//! draws an indexed triangle list
-	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 	{
 		const S2DVertex *v1, *v2, *v3;
 
diff -r -uw -N irrlicht/source/Irrlicht/CTRFlatWire.cpp irrlicht_multipatch/source/Irrlicht/CTRFlatWire.cpp
--- irrlicht/source/Irrlicht/CTRFlatWire.cpp	2006-11-01 09:51:42.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRFlatWire.cpp	2006-11-29 23:58:20.000000000 +0100
@@ -22,7 +22,7 @@
 	}
 
 	//! draws an indexed triangle list
-	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 	{
 		const S2DVertex *v1, *v2, *v3;
 
diff -r -uw -N irrlicht/source/Irrlicht/CTRGouraud.cpp irrlicht_multipatch/source/Irrlicht/CTRGouraud.cpp
--- irrlicht/source/Irrlicht/CTRGouraud.cpp	2006-11-01 11:47:58.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRGouraud.cpp	2006-11-29 23:59:00.000000000 +0100
@@ -23,7 +23,7 @@
 	}
 
 	//! draws an indexed triangle list
-	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 	{
 		const S2DVertex *v1, *v2, *v3;
 
diff -r -uw -N irrlicht/source/Irrlicht/CTRGouraudWire.cpp irrlicht_multipatch/source/Irrlicht/CTRGouraudWire.cpp
--- irrlicht/source/Irrlicht/CTRGouraudWire.cpp	2006-11-01 09:51:26.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRGouraudWire.cpp	2006-11-29 23:59:00.000000000 +0100
@@ -22,7 +22,7 @@
 	}
 
 	//! draws an indexed triangle list
-	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 	{
 		const S2DVertex *v1, *v2, *v3;
 
diff -r -uw -N irrlicht/source/Irrlicht/CTRTextureFlat.cpp irrlicht_multipatch/source/Irrlicht/CTRTextureFlat.cpp
--- irrlicht/source/Irrlicht/CTRTextureFlat.cpp	2006-11-01 09:52:02.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRTextureFlat.cpp	2006-11-29 23:59:00.000000000 +0100
@@ -22,7 +22,7 @@
 	}
 
 	//! draws an indexed triangle list
-	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 	{
 		const S2DVertex *v1, *v2, *v3;
 
diff -r -uw -N irrlicht/source/Irrlicht/CTRTextureFlatWire.cpp irrlicht_multipatch/source/Irrlicht/CTRTextureFlatWire.cpp
--- irrlicht/source/Irrlicht/CTRTextureFlatWire.cpp	2006-11-01 09:51:20.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRTextureFlatWire.cpp	2006-11-29 23:59:00.000000000 +0100
@@ -22,7 +22,7 @@
 	}
 
 	//! draws an indexed triangle list
-	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+	virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 	{
 		const S2DVertex *v1, *v2, *v3;
 
diff -r -uw -N irrlicht/source/Irrlicht/CTRTextureGouraud.cpp irrlicht_multipatch/source/Irrlicht/CTRTextureGouraud.cpp
--- irrlicht/source/Irrlicht/CTRTextureGouraud.cpp	2006-11-01 11:55:30.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRTextureGouraud.cpp	2006-11-29 23:59:00.000000000 +0100
@@ -89,7 +89,7 @@
 
 
 //! draws an indexed triangle list
-void CTRTextureGouraud::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount)
+void CTRTextureGouraud::drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount)
 {
 	const S2DVertex *v1, *v2, *v3;
 
diff -r -uw -N irrlicht/source/Irrlicht/CTRTextureGouraud.h irrlicht_multipatch/source/Irrlicht/CTRTextureGouraud.h
--- irrlicht/source/Irrlicht/CTRTextureGouraud.h	2006-11-01 09:50:00.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CTRTextureGouraud.h	2006-11-29 23:59:24.000000000 +0100
@@ -27,7 +27,7 @@
 		virtual void setRenderTarget(video::IImage* surface, const core::rect<s32>& viewPort);
 
 		//! draws an indexed triangle list
-		virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount);
+		virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount);
 
 		//! en or disables the backface culling
 		virtual void setBackfaceCulling(bool enabled = true);
diff -r -uw -N irrlicht/source/Irrlicht/CTerrainSceneNode.cpp irrlicht_multipatch/source/Irrlicht/CTerrainSceneNode.cpp
--- irrlicht/source/Irrlicht/CTerrainSceneNode.cpp	2006-10-15 08:48:50.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CTerrainSceneNode.cpp	2006-12-01 14:45:40.000000000 +0100
@@ -548,6 +548,13 @@
 		return TerrainData.Patches[patchX * TerrainData.PatchCount + patchZ].BoundingBox;
 	}
 
+	//!destroy the mesh buffer
+	void CTerrainSceneNode::destroyMeshBuffer(SMeshBufferLightMap& mb)
+	{
+		mb.Indices.clear();
+		mb.Vertices.clear();
+	}
+
 	//! Gets the meshbuffer data based on a specified Level of Detail.
 	//! \param mb: A reference to an SMeshBuffer object
 	//! \param LOD: The Level Of Detail you want the indices from.
diff -r -uw -N irrlicht/source/Irrlicht/CTerrainSceneNode.h irrlicht_multipatch/source/Irrlicht/CTerrainSceneNode.h
--- irrlicht/source/Irrlicht/CTerrainSceneNode.h	2006-09-24 11:30:54.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CTerrainSceneNode.h	2006-12-01 14:45:46.000000000 +0100
@@ -136,6 +136,9 @@
 		//! Returns the mesh
 		virtual IMesh* getMesh() { return &Mesh; }
 
+		//!a helper function to destroy the meshbuffer.
+		void destroyMeshBuffer(SMeshBufferLightMap& mb);
+
 		//! Gets the meshbuffer data based on a specified Level of Detail.
 		//! \param mb: A reference to an SMeshBufferLightMap object
 		//! \param LOD: The Level Of Detail you want the indices from.
diff -r -uw -N irrlicht/source/Irrlicht/CTriangleSelector.cpp irrlicht_multipatch/source/Irrlicht/CTriangleSelector.cpp
--- irrlicht/source/Irrlicht/CTriangleSelector.cpp	2006-07-15 08:41:46.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/CTriangleSelector.cpp	2006-11-29 23:43:46.000000000 +0100
@@ -34,7 +34,7 @@
 		IMeshBuffer* buf = mesh->getMeshBuffer(i);
 
 		s32 idxCnt = buf->getIndexCount();
-		const u16* indices = buf->getIndices();
+		const u32* indices = buf->getIndices();
 		core::triangle3df tri;
 
 		switch (buf->getVertexType())
diff -r -uw -N irrlicht/source/Irrlicht/CXAnimationPlayer.cpp irrlicht_multipatch/source/Irrlicht/CXAnimationPlayer.cpp
--- irrlicht/source/Irrlicht/CXAnimationPlayer.cpp	2006-11-01 08:12:56.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/CXAnimationPlayer.cpp	2006-12-05 17:54:08.000000000 +0100
@@ -205,10 +205,17 @@
 	
 	if (xmat.TextureFileName.size() != 0)
 	{
+		
+		if(getTextureFileName(xmat.TextureFileName).size() > 0)
+		{
 		mat.Texture1 = Driver->getTexture(getTextureFileName(xmat.TextureFileName).c_str());
+		}
+
 		if (mat.Texture1 == 0)
+		{
 			mat.Texture1 = Driver->getTexture(xmat.TextureFileName.c_str());
 	}
+	}
 
 	return mat;
 }
diff -r -uw -N irrlicht/source/Irrlicht/ITriangleRenderer.h irrlicht_multipatch/source/Irrlicht/ITriangleRenderer.h
--- irrlicht/source/Irrlicht/ITriangleRenderer.h	2006-06-17 08:11:56.000000000 +0200
+++ irrlicht_multipatch/source/Irrlicht/ITriangleRenderer.h	2006-11-29 23:57:48.000000000 +0100
@@ -49,7 +49,7 @@
 		virtual void setTexture(video::IImage* texture) = 0;
 
 		//! draws an indexed triangle list
-		virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u16* indexList, s32 triangleCount) = 0;
+		virtual void drawIndexedTriangleList(S2DVertex* vertices, s32 vertexCount, const u32* indexList, s32 triangleCount) = 0;
 	};
 
 
diff -r -uw -N irrlicht/source/Irrlicht/Irrlicht.dev irrlicht_multipatch/source/Irrlicht/Irrlicht.dev
--- irrlicht/source/Irrlicht/Irrlicht.dev	2006-11-04 09:42:22.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/Irrlicht.dev	2006-12-05 12:56:03.452832587 +0100
@@ -9,7 +9,7 @@
 Includes=..\..\include;zlib
 Linker=-lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lglu32 -lopengl32_@@_
 Libs=
-UnitCount=497
+UnitCount=499
 Folders=doc,gui_impl,include,include/core,include/gui,include/io,include/scene,include/video,io_impl,other_impl,other_impl/extern,other_impl/extern/jpeglib,other_impl/extern/libpng,other_impl/extern/zlib,scene_impl,video_impl,video_impl/DirectX8,video_impl/DirectX9,video_impl/Null,video_impl/OpenGL,video_impl/Software,video_impl/Software2
 ObjFiles=
 PrivateResource=
@@ -5015,3 +5015,22 @@
 OverrideBuildCmd=0
 BuildCmd=
 
+[Unit498]
+FileName=CD3D9MDriver.cpp
+Folder=video_impl/DirectX9
+Compile=1
+CompileCpp=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
+
+[Unit499]
+FileName=CD3D9MDriver.h
+Folder=video_impl/DirectX9
+Compile=1
+CompileCpp=1
+Link=1
+Priority=1000
+OverrideBuildCmd=0
+BuildCmd=
diff -r -uw -N irrlicht/source/Irrlicht/Irrlicht.dsp irrlicht_multipatch/source/Irrlicht/Irrlicht.dsp
--- irrlicht/source/Irrlicht/Irrlicht.dsp	2006-11-01 12:08:24.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/Irrlicht.dsp	2006-12-05 12:53:44.057526364 +0100
@@ -909,6 +909,14 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\CD3D9MDriver.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\CD3D9MDriver.h
+# End Source File
+# Begin Source File
+
 SOURCE=.\CD3D9NormalMapRenderer.cpp
 # End Source File
 # Begin Source File
Binary files irrlicht/source/Irrlicht/Irrlicht7.1.ncb and irrlicht_multipatch/source/Irrlicht/Irrlicht7.1.ncb differ
Binary files irrlicht/source/Irrlicht/Irrlicht7.1.suo and irrlicht_multipatch/source/Irrlicht/Irrlicht7.1.suo differ
diff -r -uw -N irrlicht/source/Irrlicht/Irrlicht7.1.vcproj irrlicht_multipatch/source/Irrlicht/Irrlicht7.1.vcproj
--- irrlicht/source/Irrlicht/Irrlicht7.1.vcproj	2006-11-01 11:17:48.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/Irrlicht7.1.vcproj	2006-12-05 12:50:18.087271661 +0100
@@ -500,9 +500,6 @@
 					RelativePath=".\..\..\include\ISceneNodeFactory.h">
 				</File>
 				<File
-					RelativePath=".\..\..\include\ISceneNodeMeshLoader.h">
-				</File>
-				<File
 					RelativePath=".\..\..\include\IShadowVolumeSceneNode.h">
 				</File>
 				<File
@@ -1040,6 +1037,12 @@
 					RelativePath=".\CD3D9MaterialRenderer.h">
 				</File>
 				<File
+					RelativePath=".\CD3D9MDriver.cpp">
+				</File>
+				<File
+					RelativePath=".\CD3D9MDriver.h">
+				</File>
+				<File
 					RelativePath=".\CD3D9NormalMapRenderer.cpp">
 				</File>
 				<File
diff -r -uw -N irrlicht/source/Irrlicht/Irrlicht8.0.vcproj irrlicht_multipatch/source/Irrlicht/Irrlicht8.0.vcproj
--- irrlicht/source/Irrlicht/Irrlicht8.0.vcproj	2006-11-04 09:42:20.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/Irrlicht8.0.vcproj	2006-12-05 12:52:43.747982245 +0100
@@ -1263,6 +1263,12 @@
 					>
 				</File>
 				<File
+					RelativePath=".\CD3D9MDriver.cpp">
+				</File>
+				<File
+					RelativePath=".\CD3D9MDriver.h">
+				</File>
+				<File
 					RelativePath=".\CD3D9NormalMapRenderer.cpp"
 					>
 				</File>
diff -r -uw -N irrlicht/source/Irrlicht/OctTree.h irrlicht_multipatch/source/Irrlicht/OctTree.h
--- irrlicht/source/Irrlicht/OctTree.h	2006-11-18 08:23:10.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/OctTree.h	2006-11-30 10:56:46.000000000 +0100
@@ -26,19 +26,19 @@
 	struct SMeshChunk
 	{
 		core::array<T> Vertices;
-		core::array<u16> Indices;
+		core::array<u32> Indices;
 		s32 MaterialId;
 	};
 
 	struct SIndexChunk
 	{
-		core::array<u16> Indices;
+		core::array<u32> Indices;
 		s32 MaterialId;
 	};
 
 	struct SIndexData
 	{
-		u16* Indices;
+		u32* Indices;
 		s32 CurrentSize;
 		s32 MaxSize;
 	};
@@ -62,7 +62,7 @@
 		{
 			IndexData[i].CurrentSize = 0;
 			IndexData[i].MaxSize = meshes[i].Indices.size();
-			IndexData[i].Indices = new u16[IndexData[i].MaxSize];
+			IndexData[i].Indices = new u32[IndexData[i].MaxSize];
 
 			ic.MaterialId = meshes[i].MaterialId;
 			(*indexChunks).push_back(ic);
@@ -267,8 +267,7 @@
 
 					if (idxcnt)
 					{
-						memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize], 
-							&(*IndexData)[i].Indices[0], idxcnt * sizeof(s16));
+						memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize], &(*IndexData)[i].Indices[0], idxcnt * sizeof(s32));
 						idxdata[i].CurrentSize += idxcnt;
 					}
 				}
@@ -320,8 +319,7 @@
 
 					if (idxcnt)
 					{
-						memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize], 
-							&(*IndexData)[i].Indices[0], idxcnt * sizeof(s16));
+						memcpy(&idxdata[i].Indices[idxdata[i].CurrentSize],	&(*IndexData)[i].Indices[0], idxcnt * sizeof(s32));
 						idxdata[i].CurrentSize += idxcnt;
 					}
 				}
diff -r -uw -N irrlicht/source/Irrlicht/obj/IrrRelease/BuildLog.htm irrlicht_multipatch/source/Irrlicht/obj/IrrRelease/BuildLog.htm
--- irrlicht/source/Irrlicht/obj/IrrRelease/BuildLog.htm	1970-01-01 01:00:00.000000000 +0100
+++ irrlicht_multipatch/source/Irrlicht/obj/IrrRelease/BuildLog.htm	2006-11-30 10:57:36.000000000 +0100
@@ -0,0 +1,277 @@
+<html>
+<head>
+<META HTTP-EQUIV="Content-Type" content="text/html; charset=Windows-1252">
+</head>
+<body>
+<pre>
+<table width=100% bgcolor=#CFCFE5><tr> <td> <font face=arial size=+3>
+Buildprotokoll</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>
+<h3>------- Buildvorgang wurde gestartet: Projekt: Irrlicht, Konfiguration: Release|Win32 -------</h3>
+</pre></table><table width=100% bgcolor=#DFDFE5><tr><td><font face=arial size=+2>
+Befehlszeilen</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>Die temporäre Datei "d:\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\Irrlicht\obj\IrrRelease\RSP000004.rsp" wird erstellt. Inhalt:
[
/O2 /Ot /GL /I "..\..\include" /I "zlib" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_USRDLL" /D "IRRLICHT_EXPORTS" /D "_WINDLL" /D "_MBCS" /FD /ML /Fo".\..\obj\IrrRelease/" /Fd".\..\obj\IrrRelease/" /W3 /c /TP
+".\COctTreeSceneNode.cpp"
+".\CSceneManager.cpp"
]Erstellen der Befehlszeile "cl.exe @"d:\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\Irrlicht\obj\IrrRelease\RSP000004.rsp" /nologo"Die temporäre Datei "d:\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\Irrlicht\obj\IrrRelease\RSP000005.rsp" wird erstellt. Inhalt:
[
/OUT:"..\..\bin\Win32-visualstudio\Irrlicht.dll" /INCREMENTAL:NO /NOLOGO /DLL /NODEFAULTLIB:"libci.lib" /PDB:"..\obj\IrrRelease\Irrlicht.pdb" /LTCG /IMPLIB:"..\..\lib\Win32-visualstudio\Irrlicht.lib" /MACHINE:I386 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIButton.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUICheckbox.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIColorSelectDialog.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIComboBox.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIContextMenu.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIEditBox.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIEnvironment.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIFileOpenDialog.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIFont.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIImage.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIInOutFader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIListBox.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIMenu.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIMeshViewer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIMessageBox.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIModalScreen.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIScrollBar.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUISkin.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIStaticText.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUITabControl.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIToolBar.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGUIWindow.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CVideoModeList.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSoftwareDriver.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSoftwareTexture.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRFlat.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRFlatWire.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRGouraud.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRGouraudWire.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureFlat.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureFlatWire.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraud.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraudAdd.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraudNoZ.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraudWire.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CZBuffer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COpenGLDriver.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COpenGLNormalMapRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COpenGLParallaxMapRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COpenGLShaderMaterialRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COpenGLSLMaterialRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COpenGLTexture.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D8Driver.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D8NormalMapRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D8ParallaxMapRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D8ShaderMaterialRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D8Texture.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CColorConverter.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CFPSCounter.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImage.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageLoaderBMP.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageLoaderJPG.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageLoaderPCX.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageLoaderPNG.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageLoaderPSD.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageLoaderTGA.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CNullDriver.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageWriterBMP.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageWriterJPG.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageWriterPCX.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageWriterPNG.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageWriterPPM.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageWriterPSD.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CImageWriterTGA.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D9Driver.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D9HLSLMaterialRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D9NormalMapRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D9ParallaxMapRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D9ShaderMaterialRenderer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CD3D9Texture.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSoftwareDriver2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSoftwareTexture2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRGouraud2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRGouraudAlpha2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRGouraudAlphaNoZ2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureDetailMap2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraud2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraudAdd2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraudAddNoZ2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraudNoZ2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureGouraudVertexAlpha2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureLightMap2_Add.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureLightMap2_M1.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureLightMap2_M2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureLightMap2_M4.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureLightMapGouraud2_M4.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTRTextureWire2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CZBuffer2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\ITriangleRenderer2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CDefaultSceneNodeAnimatorFactory.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CDefaultSceneNodeFactory.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CGeometryCreator.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CMeshCache.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CMeshManipulator.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneManager.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\C3DSMeshFileLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CAnimatedMeshB3d.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CAnimatedMeshMD2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CAnimatedMeshMS3D.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CColladaFileLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CCSMLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CDefaultMeshFormatLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CDMFLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CLMTSMeshFileLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CMY3DMeshFileLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COBJMeshFileLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COCTLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COgreMeshFileLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CQ3LevelMesh.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CXAnimationPlayer.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CXFileReader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CXMeshFileLoader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CAnimatedMeshSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CBillboardSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CCameraFPSSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CCameraMayaSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CCameraSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CCubeSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CDummyTransformationSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CEmptySceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CLightSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CMeshSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COctTreeSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CShadowVolumeSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSkyBoxSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSkyDomeSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSphereSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTerrainSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTextSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CWaterSurfaceSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CParticleBoxEmitter.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CParticleFadeOutAffector.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CParticleGravityAffector.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CParticlePointEmitter.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CParticleSystemSceneNode.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneNodeAnimatorCollisionResponse.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneNodeAnimatorDelete.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneNodeAnimatorFlyCircle.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneNodeAnimatorFlyStraight.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneNodeAnimatorFollowSpline.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneNodeAnimatorRotation.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneNodeAnimatorTexture.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CMetaTriangleSelector.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COctTreeTriangleSelector.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CSceneCollisionManager.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTerrainTriangleSelector.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTriangleBBSelector.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CTriangleSelector.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CAttributes.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CFileList.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CFileSystem.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CLimitReadFile.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CMemoryReadFile.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CPakReader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CReadFile.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CWriteFile.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CXMLReader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CXMLWriter.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CZipReader.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\irrXML.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CIrrDeviceLinux.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CIrrDeviceStub.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CIrrDeviceWin32.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\CLogger.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\COSOperator.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\Irrlicht.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\os.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\adler32.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\compress.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\crc32.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\deflate.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\inffast.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\inflate.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\inftrees.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\trees.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\uncompr.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\zutil.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\cdjpeg.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcapimin.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcapistd.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jccoefct.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jccolor.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcdctmgr.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jchuff.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcinit.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcmainct.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcmarker.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcmaster.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcomapi.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcparam.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcphuff.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcprepct.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jcsample.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jctrans.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdapimin.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdapistd.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdatadst.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdatasrc.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdcoefct.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdcolor.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jddctmgr.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdhuff.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdinput.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdmainct.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdmarker.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdmaster.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdmerge.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdphuff.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdpostct.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdsample.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jdtrans.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jerror.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jfdctflt.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jfdctfst.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jfdctint.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jidctflt.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jidctfst.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jidctint.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jidctred.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jmemmgr.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jmemnobs.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jquant1.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jquant2.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\jutils.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\rdbmp.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\rdcolmap.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\rdgif.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\rdppm.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\rdrle.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\rdswitch.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\rdtarga.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\transupp.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\wrbmp.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\wrgif.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\wrppm.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\wrrle.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\wrtarga.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\png.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngerror.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngget.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngmem.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngpread.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngread.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngrio.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngrtran.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngrutil.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngset.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngtrans.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngwio.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngwrite.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngwtran.obj"
+"\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\obj\irrrelease\pngwutil.obj"
]Erstellen der Befehlszeile "link.exe @"d:\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\Irrlicht\obj\IrrRelease\RSP000005.rsp""</pre></table><table width=100% bgcolor=#DFDFE5><tr><td><font face=arial size=+2>
+Ausgabefenster</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>Kompilieren...
+COctTreeSceneNode.cpp
+CSceneManager.cpp
+Verknüpfen...
+   Bibliothek '..\..\lib\Win32-visualstudio\Irrlicht.lib' und Objekt '..\..\lib\Win32-visualstudio\Irrlicht.exp' wird erstellt
+Code wird generiert
+Codegenerierung abgeschlossen
+LINK : warning LNK4089: Alle Verweise auf 'GLU32.dll' wurden durch /OPT:REF verworfen
+</pre></table><table width=100% bgcolor=#DFDFE5><tr><td><font face=arial size=+2>
+Ergebnisse</font></table><table width=* cellspacing=0 cellpadding=0><tr><td width=0 bgcolor=#EDEDF5>&nbsp;</td><td width=0 bgcolor=#FFFFFF>&nbsp;</td><td width=*><pre>
+Das Build-Protokoll wurde unter "file://d:\Development\c++\Ds\DEV_DELIGHT_plugendplay2003\Xtra\spikes\irrlicht-1.2\irrlicht-1.2\source\Irrlicht\obj\IrrRelease\BuildLog.htm" gespeichert.
Irrlicht - 0 Fehler, 1 Warnung(en)</pre></table><table   width=100% height=20 bgcolor=#CFCFE5><tr><td><font face=arial size=+2>
+</font></table></body></html>
\ No newline at end of file
