source: GTP/trunk/App/Demos/Geom/Shark3D/src/drv_d3d9_paramblk.h @ 2236

Revision 2236, 3.2 KB checked in by gumbau, 17 years ago (diff)
Line 
1///////////////////////////////////////////////////////////////////////////////
2//
3//      ##  ######
4//       ######  ###
5//  ## ###############        Shark 3D Engine (www.shark3d.com)
6//   ########## # # #
7//    ########                Copyright (c) 1996-2006 Spinor GmbH.
8//   ######### # # #          All rights reserved.
9//  ##   ##########
10//      ##
11//
12///////////////////////////////////////////////////////////////////////////////
13
14//@cpp
15#ifndef S3D_DRV_D3D9_PARAMBLK_H
16#define S3D_DRV_D3D9_PARAMBLK_H
17
18#include "drv_d3d9_types.h"
19#include "drv_d3d9_settings.h"
20#include "drv_d3d9_tex.h"
21#include "sys/core/sys_util.h"
22
23///////////////////////////////////////////////////////////////////////////////
24
25//@
26struct s3d_CDrvD3d9ParamBlkState
27{
28    enum CDirty
29    {
30        Dirty_MatProj       = (1 << 0),
31        Dirty_MatView       = (1 << 1),
32        Dirty_MatGen        = (1 << 2),
33        Dirty_Light         = (1 << 3),
34        Dirty_Mtl           = (1 << 4),
35        Dirty_Fog           = (1 << 5),
36    };
37    int m_DirtyMask;
38
39    void Invalidate();
40    void Done();
41};
42
43///////////////////////////////////////////////////////////////////////////////
44
45//@
46struct s3d_CDrvD3d9ParamBlk
47{
48    D3DXMATRIXA16 m_MatProj;
49    D3DXMATRIXA16 m_MatView;
50    D3DXMATRIXA16 m_MatGenArray[S3D_DRV_D3D9_MAX_ATTR_CNT];
51   
52    s3d_CSysIntps m_CurLightCnt;
53    D3DLIGHT9 m_LightArray[S3D_DRV_D3D9_MAX_LIGHT_CNT];
54
55    D3DMATERIAL9 m_Mtl;
56    bool m_UseConstColorAlpha;
57    D3DCOLORVALUE m_ColorAlphaVal;
58   
59    // Color:= x,y,z
60    // Density:= w
61    D3DXVECTOR4 m_FogColDensity;
62
63    // Highest sampler with texture bound to.
64    // All entries of m_CurSampTexArray with index < m_SampMaxUsedCnt
65    // are guaranteed to be NOT 0 and with index >= m_SampMaxUsedCnt are 0.
66    int m_SampMaxUsedCnt;
67    s3d_CDrvD3d9TexObjBasePtr m_SampTexArray[S3D_DRV_D3D9_MAX_SAMPLER_CNT];
68   
69    void Reset();
70};
71
72
73///////////////////////////////////////////////////////////////////////////////
74// Definitions
75
76S3D_SYS_INLINE
77void s3d_CDrvD3d9ParamBlkState::Invalidate()
78{
79    m_DirtyMask = -1;
80}
81
82S3D_SYS_INLINE
83void s3d_CDrvD3d9ParamBlkState::Done()
84{
85    m_DirtyMask = 0;
86}
87
88///////////////////////////////////////////////////////////////////////////////
89
90S3D_SYS_INLINE
91void s3d_CDrvD3d9ParamBlk::Reset()
92{
93    D3DXMatrixIdentity(&m_MatProj);
94    D3DXMatrixIdentity(&m_MatView);
95    s3d_CSysIntps iAttr;
96    for(iAttr = 0; iAttr < S3D_SYS_ARRAYCNTS(m_MatGenArray); iAttr++)
97        D3DXMatrixIdentity(&m_MatGenArray[iAttr]);
98
99    m_CurLightCnt = 0;
100    s3d_SysMemset(&m_LightArray, 0, S3D_SYS_SIZEOFS(m_LightArray));
101
102    D3DCOLORVALUE Black = D3DXCOLOR(DWORD(0));
103    m_Mtl.Ambient = Black;
104    m_Mtl.Diffuse = Black;
105    m_Mtl.Specular = Black;
106    m_Mtl.Emissive = Black;
107    m_Mtl.Power = 0.f;
108
109    m_UseConstColorAlpha = false;
110    m_ColorAlphaVal = Black;
111
112    m_FogColDensity = D3DXVECTOR4(0.f, 0.f, 0.f, 0.f);
113
114    s3d_CSysIntps iSamp;
115    for(iSamp = 0; iSamp < S3D_SYS_ARRAYCNTS(m_SampTexArray); iSamp++)
116        m_SampTexArray[iSamp] = 0;
117}
118
119///////////////////////////////////////////////////////////////////////////////
120
121#endif
Note: See TracBrowser for help on using the repository browser.