/////////////////////////////////////////////////////////////////////////////// // // ## ###### // ###### ### // ## ############### Shark 3D Engine (www.shark3d.com) // ########## # # # // ######## Copyright (c) 1996-2006 Spinor GmbH. // ######### # # # All rights reserved. // ## ########## // ## // /////////////////////////////////////////////////////////////////////////////// //@cpp #ifndef S3D_DRV_D3D9_PARAMBLK_H #define S3D_DRV_D3D9_PARAMBLK_H #include "drv_d3d9_types.h" #include "drv_d3d9_settings.h" #include "drv_d3d9_tex.h" #include "sys/core/sys_util.h" /////////////////////////////////////////////////////////////////////////////// //@ struct s3d_CDrvD3d9ParamBlkState { enum CDirty { Dirty_MatProj = (1 << 0), Dirty_MatView = (1 << 1), Dirty_MatGen = (1 << 2), Dirty_Light = (1 << 3), Dirty_Mtl = (1 << 4), Dirty_Fog = (1 << 5), }; int m_DirtyMask; void Invalidate(); void Done(); }; /////////////////////////////////////////////////////////////////////////////// //@ struct s3d_CDrvD3d9ParamBlk { D3DXMATRIXA16 m_MatProj; D3DXMATRIXA16 m_MatView; D3DXMATRIXA16 m_MatGenArray[S3D_DRV_D3D9_MAX_ATTR_CNT]; s3d_CSysIntps m_CurLightCnt; D3DLIGHT9 m_LightArray[S3D_DRV_D3D9_MAX_LIGHT_CNT]; D3DMATERIAL9 m_Mtl; bool m_UseConstColorAlpha; D3DCOLORVALUE m_ColorAlphaVal; // Color:= x,y,z // Density:= w D3DXVECTOR4 m_FogColDensity; // Highest sampler with texture bound to. // All entries of m_CurSampTexArray with index < m_SampMaxUsedCnt // are guaranteed to be NOT 0 and with index >= m_SampMaxUsedCnt are 0. int m_SampMaxUsedCnt; s3d_CDrvD3d9TexObjBasePtr m_SampTexArray[S3D_DRV_D3D9_MAX_SAMPLER_CNT]; void Reset(); }; /////////////////////////////////////////////////////////////////////////////// // Definitions S3D_SYS_INLINE void s3d_CDrvD3d9ParamBlkState::Invalidate() { m_DirtyMask = -1; } S3D_SYS_INLINE void s3d_CDrvD3d9ParamBlkState::Done() { m_DirtyMask = 0; } /////////////////////////////////////////////////////////////////////////////// S3D_SYS_INLINE void s3d_CDrvD3d9ParamBlk::Reset() { D3DXMatrixIdentity(&m_MatProj); D3DXMatrixIdentity(&m_MatView); s3d_CSysIntps iAttr; for(iAttr = 0; iAttr < S3D_SYS_ARRAYCNTS(m_MatGenArray); iAttr++) D3DXMatrixIdentity(&m_MatGenArray[iAttr]); m_CurLightCnt = 0; s3d_SysMemset(&m_LightArray, 0, S3D_SYS_SIZEOFS(m_LightArray)); D3DCOLORVALUE Black = D3DXCOLOR(DWORD(0)); m_Mtl.Ambient = Black; m_Mtl.Diffuse = Black; m_Mtl.Specular = Black; m_Mtl.Emissive = Black; m_Mtl.Power = 0.f; m_UseConstColorAlpha = false; m_ColorAlphaVal = Black; m_FogColDensity = D3DXVECTOR4(0.f, 0.f, 0.f, 0.f); s3d_CSysIntps iSamp; for(iSamp = 0; iSamp < S3D_SYS_ARRAYCNTS(m_SampTexArray); iSamp++) m_SampTexArray[iSamp] = 0; } /////////////////////////////////////////////////////////////////////////////// #endif