#ifndef SHADER_H #define SHADER_H #include "Prerequisites.h" #include "Resource.h" #include "Lights.h" #include //function passed to function pointers to set the shader's values void SetDefaultShaderValues(ShaderPtr& shader, ModelEntity* mesh); class Shader : public Resource { public: Shader(); Shader( const std::string& name, const std::string& path = "./" ); ~Shader(); unsigned int Begin(); void BeginPass(int i); void EndPass(); void End(); void SetTechnique(const std::string& tech); virtual void AddLight(const D3DLIGHT9& light); virtual void SetMtrl(const D3DMATERIAL9& mtrl); virtual void SetTexture(IDirect3DTexture9Ptr texture); virtual void ApplyLights(); ID3DXEffectPtr GetEffect() const { return mEffect; } void Update(float dt); void OnLostDevice(){ mEffect->OnLostDevice(); } //notify effect of lost device void OnResetDevice(){ mEffect->OnResetDevice(); } //notify effect of reset device public: static const int MaxNumberOfLights = 4; protected: virtual void LoadEffectFile(); protected: std::vector mLights; //lights that effect this shader //effect and default handles ID3DXEffectPtr mEffect; D3DXHANDLE mHTech; D3DXHANDLE mHWorld; D3DXHANDLE mHWorldInvTrans; D3DXHANDLE mHWorldViewProj; D3DXHANDLE mHTexture; D3DXHANDLE mHLight; D3DXHANDLE mHMtrl; }; #endif