#ifndef __RTEFFECTSCOMMON__
#define __RTEFFECTSCOMMON__

// Forward declarations
class TransformMatrixesManager;

/////////////////////////////////////////////////////////////////////////////
// RTEffectCommon is the common parameters to all real-time effects
/////////////////////////////////////////////////////////////////////////////
class RTEffectsCommon
{
	protected:

		LPD3DXEFFECT m_pEffect;						// The effect interface

		D3DXHANDLE m_hMatWorld;						// Handle on the World matrix
		D3DXHANDLE m_hMatWorldView;					// Handle on the WorldView matrix
		D3DXHANDLE m_hMatProj;						// Handle on the Projection matrix

		D3DXHANDLE m_hMatPreviousWVP;				// Handle on the previous frame WVP matrix
		
		D3DXHANDLE m_hEyeWorldPos;					// Handle on the eye position in world space
		
		D3DXHANDLE m_hLightPos;						// Handle on the light position
		D3DXHANDLE m_hLightVect;					// Handle on the light vector

		D3DXHANDLE m_hDiffuseTexture;				// Handle on the diffuse texture

		TransformMatrixesManager * m_pTransMatMgr;	// A pointer to the matrix manager


	public:

		// Construction / destruction
		RTEffectsCommon(LPCWSTR filePath);
		~RTEffectsCommon();

		// Effect Setup
		HRESULT CompileEffect(LPCWSTR filePath);	// Compile an effect file
		void SetupCommonHandles();					// Prepare the common handles
		void SetupEffectMatrixes();
		void SetupEffectLightAndObs(CDXUTDirectionWidget * pLightWidget, const D3DXVECTOR3 *pEyeWorldPos);
		virtual void SetupCurrentEffectParameters(){};

		// Effect interface getter
		LPD3DXEFFECT getEffect(){return m_pEffect;}	
		D3DXHANDLE GetDiffuseTextureHandle(){return m_hDiffuseTexture;}

		// DirectX device handling
		HRESULT OnResetDevice();
		HRESULT OnLostDevice();
};


#endif