Index: OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9Mappings.h
===================================================================
--- OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9Mappings.h	(revision 1053)
+++ OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9Mappings.h	(revision 1053)
@@ -0,0 +1,144 @@
+/*
+-----------------------------------------------------------------------------
+This source file is part of OGRE
+    (Object-oriented Graphics Rendering Engine)
+For the latest info, see http://www.ogre3d.org/
+
+Copyright (c) 2000-2005 The OGRE Team
+Also see acknowledgements in Readme.html
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+#ifndef __D3D9MAPPINGS_H__
+#define __D3D9MAPPINGS_H__
+
+#include "OgreD3D9Prerequisites.h"
+#include "OgreCommon.h"
+#include "OgreLight.h"
+#include "OgreMaterial.h"
+#include "OgreRenderSystem.h"
+#include "OgreHardwareBuffer.h"
+#include "OgreHardwareIndexBuffer.h"
+
+#include "OgreNoMemoryMacros.h"
+#include <d3d9.h>
+#include <d3dx9.h>
+#include <dxerr9.h>
+#include "OgreMemoryMacros.h"
+
+namespace Ogre 
+{
+	class D3D9Mappings
+	{
+	public:
+		/// enum identifying D3D9 tex. types
+		enum eD3DTexType
+		{
+			/// standard texture
+			D3D_TEX_TYPE_NORMAL,
+			/// cube texture
+			D3D_TEX_TYPE_CUBE,
+			/// volume texture
+			D3D_TEX_TYPE_VOLUME,
+			/// just to have it...
+			D3D_TEX_TYPE_NONE
+		};
+
+		/// enum identifying D3D9 filter usage type
+		enum eD3DFilterUsage
+		{
+			/// min filter
+			D3D_FUSAGE_MIN,
+			/// mag filter
+			D3D_FUSAGE_MAG,
+			/// mip filter
+			D3D_FUSAGE_MIP
+		};
+
+		/// return a D3D9 equivalent for a Ogre ShadeOptions value
+		static DWORD get(ShadeOptions so);
+		/// return a D3D9 equivalent for a Ogre LightTypes value
+		static D3DLIGHTTYPE get(Ogre::Light::LightTypes lightType);
+		/// return a D3D9 equivalent for a Ogre TexCoordCalsMethod value
+		static DWORD get(TexCoordCalcMethod m, const D3DCAPS9& caps);
+		/// return a D3D9 equivalent for a Ogre TextureAddressingMode value
+		static D3DTEXTUREADDRESS get(TextureUnitState::TextureAddressingMode tam);
+		/// return a D3D9 equivalent for a Ogre LayerBlendType value
+		static D3DTEXTURESTAGESTATETYPE get(LayerBlendType lbt);
+		/// return a D3D9 equivalent for a Ogre LayerBlendOperationEx value
+		static DWORD get(LayerBlendOperationEx lbo, const D3DCAPS9& devCaps);
+		/// return a D3D9 equivalent for a Ogre LayerBlendSource value
+		static DWORD get(LayerBlendSource lbs);
+		/// return a D3D9 equivalent for a Ogre SceneBlendFactor value
+		static D3DBLEND get(SceneBlendFactor sbf);
+#ifdef GAMETOOLS_ILLUMINATION_MODULE
+		static D3DBLENDOP get(SceneBlendOperation op)
+			{
+				switch( op )
+				{
+				case SBOP_ADD:
+					return D3DBLENDOP_ADD;
+				case SBOP_SUBTRACT:
+					return D3DBLENDOP_SUBTRACT;
+				case SBOP_REVSUBTRACT:
+					return D3DBLENDOP_REVSUBTRACT;
+				case SBOP_MIN:
+					return D3DBLENDOP_MIN;
+				case SBOP_MAX:
+					return D3DBLENDOP_MAX;				
+				}				
+			}
+#endif
+		/// return a D3D9 equivalent for a Ogre CompareFunction value
+		static DWORD get(CompareFunction cf);
+		/// return a D3D9 equivalent for a Ogre CillingMode value
+		static DWORD get(CullingMode cm, bool flip);
+		/// return a D3D9 equivalent for a Ogre FogMode value
+		static D3DFOGMODE get(FogMode fm);
+		/// return a D3D9 equivalent for a Ogre PolygonMode value
+		static D3DFILLMODE get(PolygonMode level);
+		/// return a D3D9 equivalent for a Ogre StencilOperation value
+		static DWORD get(StencilOperation op, bool invert = false);
+		/// return a D3D9 state type for Ogre FilterType value
+		static D3DSAMPLERSTATETYPE get(FilterType ft);
+		/// return a D3D9 filter option for Ogre FilterType & FilterOption value
+		static DWORD get(FilterType ft, FilterOptions fo, const D3DCAPS9& devCaps, eD3DTexType texType);
+		/// return the D3DtexType equivalent of a Ogre tex. type
+		static eD3DTexType get(TextureType ogreTexType);
+        /// return the combination of D3DUSAGE values for Ogre buffer usage
+        static DWORD get(HardwareBuffer::Usage usage);
+        /// Get lock options
+        static DWORD get(HardwareBuffer::LockOptions options, HardwareBuffer::Usage usage);
+        /// Get index type
+        static D3DFORMAT get(HardwareIndexBuffer::IndexType itype);
+		/// Get vertex data type
+		static D3DDECLTYPE get(VertexElementType vType);
+		/// Get vertex semantic
+		static D3DDECLUSAGE get(VertexElementSemantic sem);
+        // Convert matrix to D3D style
+        static 	D3DXMATRIX makeD3DXMatrix( const Matrix4& mat );
+        // Convert matrix from D3D style
+        static Matrix4 D3D9Mappings::convertD3DXMatrix( const D3DXMATRIX& mat );
+
+		/// utility method, convert D3D9 pixel format to Ogre pixel format
+		static PixelFormat _getPF(D3DFORMAT d3dPF);
+		/// utility method, convert Ogre pixel format to D3D9 pixel format
+		static D3DFORMAT _getPF(PixelFormat ogrePF);
+		/// utility method, find closest Ogre pixel format that D3D9 can support
+		static PixelFormat _getClosestSupportedPF(PixelFormat ogrePF);
+	};
+}
+#endif
Index: OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9RenderSystem.h
===================================================================
--- OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9RenderSystem.h	(revision 768)
+++ OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/include/OgreD3D9RenderSystem.h	(revision 1053)
@@ -241,5 +241,15 @@
         void _setTextureBorderColour(size_t stage, const ColourValue& colour);
 		void _setTextureMatrix( size_t unit, const Matrix4 &xform );
+#ifdef GAMETOOLS_ILLUMINATION_MODULE
+		virtual void _setSceneBlending(SceneBlendFactor sourceFactor,
+										SceneBlendFactor destFactor,
+										SceneBlendOperation blendOp = SBOP_ADD,
+										bool separateAlpha = false,
+										SceneBlendFactor sourceFactorAlpha = SBF_ONE,
+										SceneBlendFactor destFactorAlpha = SBF_ZERO,
+										SceneBlendOperation blendOpAlpha = SBOP_ADD);
+#else
 		void _setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor );
+#endif
 		void _setAlphaRejectSettings( CompareFunction func, unsigned char value );
 		void _setViewport( Viewport *vp );
Index: OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/src/OgreD3D9RenderSystem.cpp
===================================================================
--- OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/src/OgreD3D9RenderSystem.cpp	(revision 768)
+++ OGRE/trunk/ogre_changes/Ogre1.2/RenderSystems/Direct3D9/src/OgreD3D9RenderSystem.cpp	(revision 1053)
@@ -1912,4 +1912,56 @@
 		}
 	}
+	
+#ifdef GAMETOOLS_ILLUMINATION_MODULE
+
+	void D3D9RenderSystem::_setSceneBlending(SceneBlendFactor sourceFactor,
+										SceneBlendFactor destFactor,
+										SceneBlendOperation blendOp,
+										bool separateAlpha,
+										SceneBlendFactor sourceFactorAlpha,
+										SceneBlendFactor destFactorAlpha,
+										SceneBlendOperation blendOpAlpha)
+	{
+		HRESULT hr;
+		if( sourceFactor == SBF_ONE && destFactor == SBF_ZERO &&
+			sourceFactorAlpha == SBF_ONE && destFactorAlpha == SBF_ZERO)
+		{
+			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE)))
+				OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+		}
+		else
+		{
+			if (FAILED(hr = __SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE)))
+				OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+					
+			if(separateAlpha)
+			{
+				if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, TRUE)))
+					OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+				
+				if (FAILED(hr = __SetRenderState(D3DRS_BLENDOPALPHA, D3D9Mappings::get(blendOp))))
+					OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+
+				if( FAILED( hr = __SetRenderState( D3DRS_SRCBLENDALPHA, D3D9Mappings::get(sourceFactor) ) ) )
+					OGRE_EXCEPT( hr, "Failed to set source blend", "D3D9RenderSystem::_setSceneBlending" );
+				if( FAILED( hr = __SetRenderState( D3DRS_DESTBLENDALPHA, D3D9Mappings::get(destFactor) ) ) )
+					OGRE_EXCEPT( hr, "Failed to set destination blend", "D3D9RenderSystem::_setSceneBlending" );
+		
+			}
+			else
+			{
+				if (FAILED(hr = __SetRenderState(D3DRS_SEPARATEALPHABLENDENABLE, FALSE)))
+					OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+			}
+			
+			if (FAILED(hr = __SetRenderState(D3DRS_BLENDOP, D3D9Mappings::get(blendOpAlpha))))
+					OGRE_EXCEPT( hr, "Failed to set alpha blending option", "D3D9RenderSystem::_setSceneBlending" );
+			if( FAILED( hr = __SetRenderState( D3DRS_SRCBLEND, D3D9Mappings::get(sourceFactor) ) ) )
+				OGRE_EXCEPT( hr, "Failed to set source blend", "D3D9RenderSystem::_setSceneBlending" );
+			if( FAILED( hr = __SetRenderState( D3DRS_DESTBLEND, D3D9Mappings::get(destFactor) ) ) )
+				OGRE_EXCEPT( hr, "Failed to set destination blend", "D3D9RenderSystem::_setSceneBlending" );			
+		}
+	}
+#else
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setSceneBlending( SceneBlendFactor sourceFactor, SceneBlendFactor destFactor )
@@ -1931,4 +1983,5 @@
 		}
 	}
+#endif
 	//---------------------------------------------------------------------
 	void D3D9RenderSystem::_setAlphaRejectSettings( CompareFunction func, unsigned char value )
