ScummVM API documentation
RenderState.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_RENDER_SET_H
29 #define HPL_RENDER_SET_H
30 
31 #include "hpl1/engine/graphics/GPUProgram.h"
32 #include "hpl1/engine/graphics/GraphicsTypes.h"
33 #include "hpl1/engine/graphics/Material.h"
34 #include "hpl1/engine/math/MathTypes.h"
35 #include "hpl1/engine/system/SystemTypes.h"
36 
37 namespace hpl {
38 
39 class cRenderSettings;
40 class iRenderable;
41 class iLight3D;
42 class cSector;
43 
44 enum eRenderStateType {
45  eRenderStateType_Sector = 0,
46  eRenderStateType_Pass = 1,
47  eRenderStateType_DepthTest = 2,
48  eRenderStateType_Depth = 3,
49  eRenderStateType_AlphaMode = 4,
50  eRenderStateType_BlendMode = 5,
51  eRenderStateType_VertexProgram = 6,
52  eRenderStateType_FragmentProgram = 7,
53  eRenderStateType_Texture = 8,
54  eRenderStateType_VertexBuffer = 9,
55  eRenderStateType_Matrix = 10,
56  eRenderStateType_Render = 11,
57  eRenderStateType_GpuProgram = 12,
58  eRenderStateType_LastEnum = 13
59 };
61 
62 class iRenderState {
63 public:
64  iRenderState() {}
65 
66  int Compare(const iRenderState *apState) const;
67  void SetMode(cRenderSettings *apSettings);
68 
69  void Set(const iRenderState *apState);
70 
71  eRenderStateType mType;
72 
73  // Properties:
74  // Sector
75  cSector *mpSector;
76 
77  // Pass
78  int mlPass;
79 
80  // DepthTest
81  bool mbDepthTest;
82 
83  // Depth:
84  float mfZ;
85 
86  // Alpha
87  eMaterialAlphaMode mAlphaMode;
88 
89  // Blend
90  eMaterialBlendMode mBlendMode;
91  eMaterialChannelMode mChannelMode;
92 
93  iGpuProgram *gpuProgram;
94  iMaterialProgramSetup *gpuProgramSetup;
95 
96  // Vertex program
97  iGpuProgram *mpVtxProgram;
98  iMaterialProgramSetup *mpVtxProgramSetup;
99  bool mbUsesLight;
100  bool mbUsesEye;
101  iLight3D *mpLight;
102 
103  // Fragment program
104  iGpuProgram *mpFragProgram;
105  iMaterialProgramSetup *mpFragProgramSetup;
106 
107  // Texture
108  iTexture *mpTexture[MAX_TEXTUREUNITS];
109  eMaterialBlendMode mTextureBlend[MAX_TEXTUREUNITS];
110 
111  // Vertex buffer
112  iVertexBuffer *mpVtxBuffer;
113 
114  // Matrix
115  cMatrixf *mpModelMatrix;
116  cMatrixf *mpInvModelMatrix;
117 
118  // Scale
119  cVector3f mvScale;
120 
121  // Render
122  iRenderable *mpObject;
123 
124 private:
125  // Compare
126  int CompareSector(const iRenderState *apState) const;
127  int ComparePass(const iRenderState *apState) const;
128  int CompareDepthTest(const iRenderState *apState) const;
129  int CompareDepth(const iRenderState *apState) const;
130  int CompareAlpha(const iRenderState *apState) const;
131  int CompareBlend(const iRenderState *apState) const;
132  int CompareVtxProg(const iRenderState *apState) const;
133  int CompareFragProg(const iRenderState *apState) const;
134  int CompareTexture(const iRenderState *apState) const;
135  int CompareVtxBuff(const iRenderState *apState) const;
136  int CompareMatrix(const iRenderState *apState) const;
137  int CompareRender(const iRenderState *apState) const;
138  int compareGpuProgram(const iRenderState *state) const;
139  // Set mode
140  void SetSectorMode(cRenderSettings *apSettings);
141  void SetPassMode(cRenderSettings *apSettings);
142  void SetDepthTestMode(cRenderSettings *apSettings);
143  void SetDepthMode(cRenderSettings *apSettings);
144  void SetBlendMode(cRenderSettings *apSettings);
145  void SetAlphaMode(cRenderSettings *apSettings);
146  void setGpuProgMode(cRenderSettings *settings);
147  void SetTextureMode(cRenderSettings *apSettings);
148  void SetVtxBuffMode(cRenderSettings *apSettings);
149  void SetMatrixMode(cRenderSettings *apSettings);
150  void SetRenderMode(cRenderSettings *apSettings);
151 };
152 
153 } // namespace hpl
154 
155 #endif // HPL_RENDER_SET_H
Definition: PortalContainer.h:181
Definition: AI.h:36
Definition: Renderer3D.h:77
Definition: RenderState.h:62
Definition: VertexBuffer.h:90
Definition: Light3D.h:117
Definition: Texture.h:88
Definition: Material.h:181
Definition: Renderable.h:70
Definition: GPUProgram.h:62