sead
Loading...
Searching...
No Matches
seadGraphicsContext.h
Go to the documentation of this file.
1#ifndef SEAD_GRAPHICS_CONTEXT_H_
2#define SEAD_GRAPHICS_CONTEXT_H_
3
4#include <gfx/seadColor.h>
5#include <gfx/seadGraphics.h>
6
7namespace sead {
8
10{
11public:
13 virtual ~GraphicsContext()
14 {
15 }
16
17 void apply() const;
18 void applyAlphaTest() const;
19 void applyDepthAndStencilTest() const;
20 void applyColorMask() const;
21 void applyBlendAndFastZ() const;
22 void applyBlendConstantColor() const;
24
25 void setDepthEnable(bool test_enable, bool write_enable)
26 {
27 setDepthTestEnable(test_enable);
28 setDepthWriteEnable(write_enable);
29 }
30
31 void setDepthTestEnable(bool test_enable)
32 {
33 mDepthTestEnable = test_enable;
34 }
35
36 void setDepthWriteEnable(bool write_enable)
37 {
38 mDepthWriteEnable = write_enable;
39 }
40
42 {
43 mDepthFunc = func;
44 }
45
47 {
48 mCullingMode = mode;
49 }
50
51 void setBlendEnable(bool blend)
52 {
53 mBlendEnable = blend;
54 }
55
57 {
58 setBlendFactorSrc(src_factor);
59 setBlendFactorDst(dst_factor);
60 }
61
62 void setBlendFactorSeparate(Graphics::BlendFactor src_factor_rgb, Graphics::BlendFactor dst_factor_rgb, Graphics::BlendFactor src_factor_a, Graphics::BlendFactor dst_factor_a)
63 {
64 setBlendFactorSrcRGB(src_factor_rgb);
65 setBlendFactorDstRGB(dst_factor_rgb);
66 setBlendFactorSrcAlpha(src_factor_a);
67 setBlendFactorDstAlpha(dst_factor_a);
68 }
69
75
81
83 {
84 mBlendFactorSrcRGB = factor;
85 }
86
88 {
89 mBlendFactorSrcA = factor;
90 }
91
93 {
94 mBlendFactorDstRGB = factor;
95 }
96
98 {
99 mBlendFactorDstA = factor;
100 }
101
103 {
104 setBlendEquationRGB(equation);
106 }
107
109 {
110 setBlendEquationRGB(equation_rgb);
111 setBlendEquationAlpha(equation_a);
112 }
113
115 {
116 mBlendEquationRGB = equation;
117 }
118
120 {
121 mBlendEquationA = equation;
122 }
123
125 {
126 mBlendConstantColor = color;
127 }
128
129 void setAlphaTestEnable(bool enable)
130 {
131 mAlphaTestEnable = enable;
132 }
133
135 {
136 mAlphaTestFunc = func;
137 mAlphaTestRef = ref;
138 }
139
140 void setColorMask(bool r, bool g, bool b, bool a)
141 {
142 mColorMaskR = r;
143 mColorMaskG = g;
144 mColorMaskB = b;
145 mColorMaskA = a;
146 }
147
148 void setStencilTestEnable(bool enable)
149 {
150 mStencilTestEnable = enable;
151 }
152
153 void setStencilTestFunc(Graphics::StencilFunc func, s32 ref, u32 mask)
154 {
155 mStencilTestFunc = func;
156 mStencilTestRef = ref;
157 mStencilTestMask = mask;
158 }
159
161 {
162 mStencilOpFail = fail;
163 mStencilOpZFail = zfail;
164 mStencilOpZPass = zpass;
165 }
166
168 {
169#ifdef cafe
170 mPolygonModeFront = front;
171 mPolygonModeBack = back;
172#endif // cafe
173 }
174
175 void setPolygonOffsetEnable(bool fill_front_enable, bool fill_back_enable, bool point_line_enable)
176 {
177#ifdef cafe
178 mPolygonOffsetFrontEnable = fill_front_enable;
179 mPolygonOffsetBackEnable = fill_back_enable;
180 mPolygonOffsetPointLineEnable = point_line_enable;
181#endif // cafe
182 }
183
185 {
186 return mDepthTestEnable;
187 }
188
190 {
191 return mDepthWriteEnable;
192 }
193
195 {
196 return mDepthFunc;
197 }
198
200 {
201 return mCullingMode;
202 }
203
204 bool getBlendEnable() const
205 {
206 return mBlendEnable;
207 }
208
213
218
223
228
233
238
240 {
241 return mBlendConstantColor;
242 }
243
245 {
246 return mAlphaTestEnable;
247 }
248
250 {
251 return mAlphaTestFunc;
252 }
253
255 {
256 return mAlphaTestRef;
257 }
258
259 bool getColorMaskR() const
260 {
261 return mColorMaskR;
262 }
263
264 bool getColorMaskG() const
265 {
266 return mColorMaskG;
267 }
268
269 bool getColorMaskB() const
270 {
271 return mColorMaskB;
272 }
273
274 bool getColorMaskA() const
275 {
276 return mColorMaskA;
277 }
278
280 {
281 return mStencilTestEnable;
282 }
283
285 {
286 return mStencilTestFunc;
287 }
288
290 {
291 return mStencilTestRef;
292 }
293
295 {
296 return mStencilTestMask;
297 }
298
300 {
301 return mStencilOpFail;
302 }
303
305 {
306 return mStencilOpZFail;
307 }
308
310 {
311 return mStencilOpZPass;
312 }
313
315 {
316#ifdef cafe
317 return mPolygonModeFront;
318#endif // cafe
319 }
320
322 {
323#ifdef cafe
324 return mPolygonModeBack;
325#endif // cafe
326 }
327
329 {
330#ifdef cafe
331 return mPolygonOffsetFrontEnable;
332#endif // cafe
333 }
334
336 {
337#ifdef cafe
338 return mPolygonOffsetBackEnable;
339#endif // cafe
340 }
341
343 {
344#ifdef cafe
345 return mPolygonOffsetPointLineEnable;
346#endif // cafe
347 }
348
349private:
376#ifdef cafe
382#endif // cafe
383};
384#ifdef cafe
385static_assert(sizeof(GraphicsContext) == 0x74, "sead::GraphicsContext size mismatch");
386#endif // cafe
387
388} // namespace sead
389
390#endif // SEAD_GRAPHICS_CONTEXT_H_
Definition seadGraphicsContext.h:10
void setBlendFactorSeparate(Graphics::BlendFactor src_factor_rgb, Graphics::BlendFactor dst_factor_rgb, Graphics::BlendFactor src_factor_a, Graphics::BlendFactor dst_factor_a)
Definition seadGraphicsContext.h:62
void setBlendFactorSrc(Graphics::BlendFactor factor)
Definition seadGraphicsContext.h:70
Graphics::BlendEquation mBlendEquationA
Definition seadGraphicsContext.h:360
void setBlendFactorSrcAlpha(Graphics::BlendFactor factor)
Definition seadGraphicsContext.h:87
void applyBlendConstantColor() const
Definition seadGraphicsContext.cpp:212
void setBlendEquationSeparate(Graphics::BlendEquation equation_rgb, Graphics::BlendEquation equation_a)
Definition seadGraphicsContext.h:108
Graphics::BlendFactor getBlendFactorDstAlpha() const
Definition seadGraphicsContext.h:224
void setBlendConstantColor(const Color4f &color)
Definition seadGraphicsContext.h:124
void setColorMask(bool r, bool g, bool b, bool a)
Definition seadGraphicsContext.h:140
void setBlendEquationRGB(Graphics::BlendEquation equation)
Definition seadGraphicsContext.h:114
u32 mStencilTestMask
Definition seadGraphicsContext.h:372
Graphics::BlendFactor mBlendFactorDstA
Definition seadGraphicsContext.h:358
Graphics::StencilOp getStencilTestOpZFail() const
Definition seadGraphicsContext.h:304
void setBlendEquation(Graphics::BlendEquation equation)
Definition seadGraphicsContext.h:102
void setBlendFactor(Graphics::BlendFactor src_factor, Graphics::BlendFactor dst_factor)
Definition seadGraphicsContext.h:56
Graphics::BlendFactor getBlendFactorSrcAlpha() const
Definition seadGraphicsContext.h:214
bool mColorMaskB
Definition seadGraphicsContext.h:367
bool mDepthTestEnable
Definition seadGraphicsContext.h:350
void setPolygonOffsetEnable(bool fill_front_enable, bool fill_back_enable, bool point_line_enable)
Definition seadGraphicsContext.h:175
bool getPolygonOffsetBackEnable() const
Definition seadGraphicsContext.h:335
f32 mAlphaTestRef
Definition seadGraphicsContext.h:364
void applyAlphaTest() const
Definition seadGraphicsContext.cpp:137
Graphics::PolygonMode getPolygonModeFront() const
Definition seadGraphicsContext.h:314
Graphics::PolygonMode getPolygonModeBack() const
Definition seadGraphicsContext.h:321
bool mAlphaTestEnable
Definition seadGraphicsContext.h:362
bool mColorMaskG
Definition seadGraphicsContext.h:366
bool getAlphaTestEnable() const
Definition seadGraphicsContext.h:244
Graphics::BlendFactor mBlendFactorDstRGB
Definition seadGraphicsContext.h:357
void setBlendFactorDst(Graphics::BlendFactor factor)
Definition seadGraphicsContext.h:76
bool mBlendEnable
Definition seadGraphicsContext.h:354
bool getColorMaskG() const
Definition seadGraphicsContext.h:264
void setAlphaTestFunc(Graphics::AlphaFunc func, f32 ref)
Definition seadGraphicsContext.h:134
Graphics::BlendFactor getBlendFactorDstRGB() const
Definition seadGraphicsContext.h:219
void setDepthFunc(Graphics::DepthFunc func)
Definition seadGraphicsContext.h:41
bool getPolygonOffsetFrontEnable() const
Definition seadGraphicsContext.h:328
Graphics::BlendFactor mBlendFactorSrcRGB
Definition seadGraphicsContext.h:355
Graphics::AlphaFunc mAlphaTestFunc
Definition seadGraphicsContext.h:363
bool getPolygonOffsetPointLineEnable() const
Definition seadGraphicsContext.h:342
void applyDepthAndStencilTest() const
Definition seadGraphicsContext.cpp:146
Graphics::DepthFunc mDepthFunc
Definition seadGraphicsContext.h:352
Graphics::StencilOp mStencilOpFail
Definition seadGraphicsContext.h:373
bool mStencilTestEnable
Definition seadGraphicsContext.h:369
bool mColorMaskR
Definition seadGraphicsContext.h:365
Color4f mBlendConstantColor
Definition seadGraphicsContext.h:361
Graphics::CullingMode getCullingMode() const
Definition seadGraphicsContext.h:199
Graphics::CullingMode mCullingMode
Definition seadGraphicsContext.h:353
void setBlendFactorDstRGB(Graphics::BlendFactor factor)
Definition seadGraphicsContext.h:92
virtual ~GraphicsContext()
Definition seadGraphicsContext.h:13
Graphics::StencilOp mStencilOpZPass
Definition seadGraphicsContext.h:375
bool mDepthWriteEnable
Definition seadGraphicsContext.h:351
f32 getAlphaTestRef() const
Definition seadGraphicsContext.h:254
Graphics::StencilFunc mStencilTestFunc
Definition seadGraphicsContext.h:370
void setAlphaTestEnable(bool enable)
Definition seadGraphicsContext.h:129
void apply() const
Definition seadGraphicsContext.cpp:48
s32 mStencilTestRef
Definition seadGraphicsContext.h:371
void setStencilTestEnable(bool enable)
Definition seadGraphicsContext.h:148
Graphics::StencilOp getStencilTestOpZPass() const
Definition seadGraphicsContext.h:309
Graphics::AlphaFunc getAlphaTestFunc() const
Definition seadGraphicsContext.h:249
void setCullingMode(Graphics::CullingMode mode)
Definition seadGraphicsContext.h:46
bool getDepthWriteEnable() const
Definition seadGraphicsContext.h:189
Graphics::BlendFactor getBlendFactorSrcRGB() const
Definition seadGraphicsContext.h:209
void setBlendFactorDstAlpha(Graphics::BlendFactor factor)
Definition seadGraphicsContext.h:97
bool getDepthTestEnable() const
Definition seadGraphicsContext.h:184
bool getBlendEnable() const
Definition seadGraphicsContext.h:204
bool getStencilTestEnable() const
Definition seadGraphicsContext.h:279
void applyColorMask() const
Definition seadGraphicsContext.cpp:170
void setPolygonMode(Graphics::PolygonMode front, Graphics::PolygonMode back)
Definition seadGraphicsContext.h:167
GraphicsContext()
Definition seadGraphicsContext.cpp:5
void setBlendEnable(bool blend)
Definition seadGraphicsContext.h:51
void setStencilTestOp(Graphics::StencilOp fail, Graphics::StencilOp zfail, Graphics::StencilOp zpass)
Definition seadGraphicsContext.h:160
void setStencilTestFunc(Graphics::StencilFunc func, s32 ref, u32 mask)
Definition seadGraphicsContext.h:153
const Color4f & getBlendConstantColor() const
Definition seadGraphicsContext.h:239
void applyCullingAndPolygonModeAndPolygonOffset() const
Definition seadGraphicsContext.cpp:222
bool getColorMaskB() const
Definition seadGraphicsContext.h:269
bool mColorMaskA
Definition seadGraphicsContext.h:368
Graphics::StencilOp getStencilTestOpFail() const
Definition seadGraphicsContext.h:299
void setDepthWriteEnable(bool write_enable)
Definition seadGraphicsContext.h:36
Graphics::BlendFactor mBlendFactorSrcA
Definition seadGraphicsContext.h:356
Graphics::DepthFunc getDepthFunc() const
Definition seadGraphicsContext.h:194
void setBlendFactorSrcRGB(Graphics::BlendFactor factor)
Definition seadGraphicsContext.h:82
void setBlendEquationAlpha(Graphics::BlendEquation equation)
Definition seadGraphicsContext.h:119
bool getColorMaskA() const
Definition seadGraphicsContext.h:274
Graphics::BlendEquation mBlendEquationRGB
Definition seadGraphicsContext.h:359
void setDepthTestEnable(bool test_enable)
Definition seadGraphicsContext.h:31
s32 getStencilTestRef() const
Definition seadGraphicsContext.h:289
Graphics::StencilOp mStencilOpZFail
Definition seadGraphicsContext.h:374
u32 getStencilTestMask() const
Definition seadGraphicsContext.h:294
void applyBlendAndFastZ() const
Definition seadGraphicsContext.cpp:189
Graphics::BlendEquation getBlendEquationAlpha() const
Definition seadGraphicsContext.h:234
void setDepthEnable(bool test_enable, bool write_enable)
Definition seadGraphicsContext.h:25
bool getColorMaskR() const
Definition seadGraphicsContext.h:259
Graphics::BlendEquation getBlendEquationRGB() const
Definition seadGraphicsContext.h:229
Graphics::StencilFunc getStencilTestFunc() const
Definition seadGraphicsContext.h:284
Definition seadGraphics.h:17
DepthFunc
Definition seadGraphics.h:44
BlendEquation
Definition seadGraphics.h:89
StencilFunc
Definition seadGraphics.h:114
PolygonMode
Definition seadGraphics.h:142
AlphaFunc
Definition seadGraphics.h:100
StencilOp
Definition seadGraphics.h:128
BlendFactor
Definition seadGraphics.h:68
CullingMode
Definition seadGraphics.h:58
Definition seadAssert.h:44
Definition seadColor.h:9