sead
Loading...
Searching...
No Matches
seadGraphicsContextMRT.h
Go to the documentation of this file.
1#ifndef SEAD_GRAPHICS_CONTEXT_MRT_H_
2#define SEAD_GRAPHICS_CONTEXT_MRT_H_
3
4#include <container/seadSafeArray.h>
5#include <gfx/seadColor.h>
6#include <gfx/seadGraphics.h>
7#include <prim/seadBitFlag.h>
8
9namespace sead {
10
12{
13public:
15 {
16 public:
26
28 {
29 setBlendFactorSrc(src_factor);
30 setBlendFactorDst(dst_factor);
31 }
32
33 void setBlendFactorSeparate(Graphics::BlendFactor src_factor_rgb, Graphics::BlendFactor dst_factor_rgb, Graphics::BlendFactor src_factor_a, Graphics::BlendFactor dst_factor_a)
34 {
35 setBlendFactorSrcRGB(src_factor_rgb);
36 setBlendFactorDstRGB(dst_factor_rgb);
37 setBlendFactorSrcAlpha(src_factor_a);
38 setBlendFactorDstAlpha(dst_factor_a);
39 }
40
46
52
54 {
55 mBlendFactorSrcRGB = factor;
56 }
57
59 {
60 mBlendFactorSrcA = factor;
61 }
62
64 {
65 mBlendFactorDstRGB = factor;
66 }
67
69 {
70 mBlendFactorDstA = factor;
71 }
72
74 {
77 }
78
80 {
81 setBlendEquationRGB(equation_rgb);
83 }
84
86 {
87 mBlendEquationRGB = equation;
88 }
89
91 {
92 mBlendEquationA = equation;
93 }
94
99
104
109
114
119
124
125 private:
132 };
133
134public:
137 {
138 }
139
140 void apply() const;
141 void applyAlphaTest() const;
142 void applyDepthAndStencilTest() const;
143 void applyColorMask() const;
144 void applyBlendAndFastZ() const;
145 void applyBlendConstantColor() const;
147
148 void setDepthEnable(bool test_enable, bool write_enable)
149 {
150 setDepthTestEnable(test_enable);
151 setDepthWriteEnable(write_enable);
152 }
153
154 void setDepthTestEnable(bool test_enable)
155 {
156 mDepthTestEnable = test_enable;
157 }
158
159 void setDepthWriteEnable(bool write_enable)
160 {
161 mDepthWriteEnable = write_enable;
162 }
163
165 {
166 mDepthFunc = func;
167 }
168
170 {
171 mCullingMode = mode;
172 }
173
174 void setBlendEnable(u32 target, bool blend)
175 {
176 mBlendEnableMask.changeBit(target, blend);
177 }
178
179 void setBlendEnableMask(u32 mask)
180 {
181 mBlendEnableMask.setDirect(mask);
182 }
183
185 {
186 return mBlendExpression[target];
187 }
188
190 {
191 mBlendConstantColor = color;
192 }
193
194 void setAlphaTestEnable(bool enable)
195 {
196 mAlphaTestEnable = enable;
197 }
198
200 {
201 mAlphaTestFunc = func;
202 mAlphaTestRef = ref;
203 }
204
205 void setColorMask(u32 target, bool r, bool g, bool b, bool a)
206 {
207 u32 color_mask = r << 0 |
208 g << 1 |
209 b << 2 |
210 a << 3;
211 mColorMask = (mColorMask & ~(0xF << (target * 4))) | (color_mask << (target * 4));
212 }
213
214 void setColorMask(u32 mask)
215 {
216 mColorMask = mask;
217 }
218
219 void setStencilTestEnable(bool enable)
220 {
221 mStencilTestEnable = enable;
222 }
223
224 void setStencilTestFunc(Graphics::StencilFunc func, s32 ref, u32 mask)
225 {
226 mStencilTestFunc = func;
227 mStencilTestRef = ref;
228 mStencilTestMask = mask;
229 }
230
232 {
233 mStencilOpFail = fail;
234 mStencilOpZFail = zfail;
235 mStencilOpZPass = zpass;
236 }
237
239 {
240#ifdef cafe
241 mPolygonModeFront = front;
242 mPolygonModeBack = back;
243#endif // cafe
244 }
245
246 void setPolygonOffsetEnable(bool fill_front_enable, bool fill_back_enable, bool point_line_enable)
247 {
248#ifdef cafe
249 mPolygonOffsetFrontEnable = fill_front_enable;
250 mPolygonOffsetBackEnable = fill_back_enable;
251 mPolygonOffsetPointLineEnable = point_line_enable;
252#endif // cafe
253 }
254
256 {
257 return mDepthTestEnable;
258 }
259
261 {
262 return mDepthWriteEnable;
263 }
264
266 {
267 return mDepthFunc;
268 }
269
271 {
272 return mCullingMode;
273 }
274
275 bool getBlendEnable(u32 target) const
276 {
277 return mBlendEnableMask.isOnBit(target);
278 }
279
281 {
282 return mBlendEnableMask.getDirect();
283 }
284
285 const BlendExpression& getBlendExpression(u32 target) const
286 {
287 return mBlendExpression[target];
288 }
289
291 {
292 return mBlendConstantColor;
293 }
294
296 {
297 return mAlphaTestEnable;
298 }
299
301 {
302 return mAlphaTestFunc;
303 }
304
306 {
307 return mAlphaTestRef;
308 }
309
310 bool getColorMaskR(u32 target) const
311 {
312 u32 color_mask = mColorMask >> (target * 4) & 0xF;
313 return color_mask >> 0 & 1;
314 }
315
316 bool getColorMaskG(u32 target) const
317 {
318 u32 color_mask = mColorMask >> (target * 4) & 0xF;
319 return color_mask >> 1 & 1;
320 }
321
322 bool getColorMaskB(u32 target) const
323 {
324 u32 color_mask = mColorMask >> (target * 4) & 0xF;
325 return color_mask >> 2 & 1;
326 }
327
328 bool getColorMaskA(u32 target) const
329 {
330 u32 color_mask = mColorMask >> (target * 4) & 0xF;
331 return color_mask >> 3 & 1;
332 }
333
335 {
336 return mColorMask;
337 }
338
340 {
341 return mStencilTestEnable;
342 }
343
345 {
346 return mStencilTestFunc;
347 }
348
350 {
351 return mStencilTestRef;
352 }
353
355 {
356 return mStencilTestMask;
357 }
358
360 {
361 return mStencilOpFail;
362 }
363
365 {
366 return mStencilOpZFail;
367 }
368
370 {
371 return mStencilOpZPass;
372 }
373
375 {
376#ifdef cafe
377 return mPolygonModeFront;
378#endif // cafe
379 }
380
382 {
383#ifdef cafe
384 return mPolygonModeBack;
385#endif // cafe
386 }
387
389 {
390#ifdef cafe
391 return mPolygonOffsetFrontEnable;
392#endif // cafe
393 }
394
396 {
397#ifdef cafe
398 return mPolygonOffsetBackEnable;
399#endif // cafe
400 }
401
403 {
404#ifdef cafe
405 return mPolygonOffsetPointLineEnable;
406#endif // cafe
407 }
408
409private:
428#ifdef cafe
434#endif // cafe
435};
436#ifdef cafe
437static_assert(sizeof(GraphicsContextMRT) == 0x11C, "sead::GraphicsContextMRT size mismatch");
438#endif // cafe
439
440} // namespace sead
441
442#endif // SEAD_GRAPHICS_CONTEXT_MRT_H_
Definition seadGraphicsContextMRT.h:15
void setBlendFactorDst(Graphics::BlendFactor factor)
Definition seadGraphicsContextMRT.h:47
Graphics::BlendFactor getBlendFactorSrcAlpha() const
Definition seadGraphicsContextMRT.h:100
void setBlendFactor(Graphics::BlendFactor src_factor, Graphics::BlendFactor dst_factor)
Definition seadGraphicsContextMRT.h:27
void setBlendEquationRGB(Graphics::BlendEquation equation)
Definition seadGraphicsContextMRT.h:85
Graphics::BlendEquation getBlendEquationAlpha() const
Definition seadGraphicsContextMRT.h:120
Graphics::BlendFactor mBlendFactorSrcA
Definition seadGraphicsContextMRT.h:127
void setBlendEquationSeparate(Graphics::BlendEquation equation_rgb, Graphics::BlendEquation equation_a)
Definition seadGraphicsContextMRT.h:79
void setBlendFactorSeparate(Graphics::BlendFactor src_factor_rgb, Graphics::BlendFactor dst_factor_rgb, Graphics::BlendFactor src_factor_a, Graphics::BlendFactor dst_factor_a)
Definition seadGraphicsContextMRT.h:33
BlendExpression()
Definition seadGraphicsContextMRT.h:17
void setBlendFactorSrc(Graphics::BlendFactor factor)
Definition seadGraphicsContextMRT.h:41
void setBlendFactorDstRGB(Graphics::BlendFactor factor)
Definition seadGraphicsContextMRT.h:63
Graphics::BlendFactor getBlendFactorSrcRGB() const
Definition seadGraphicsContextMRT.h:95
Graphics::BlendFactor mBlendFactorDstA
Definition seadGraphicsContextMRT.h:129
void setBlendFactorDstAlpha(Graphics::BlendFactor factor)
Definition seadGraphicsContextMRT.h:68
void setBlendEquationAlpha(Graphics::BlendEquation equation)
Definition seadGraphicsContextMRT.h:90
Graphics::BlendEquation mBlendEquationA
Definition seadGraphicsContextMRT.h:131
Graphics::BlendEquation getBlendEquationRGB() const
Definition seadGraphicsContextMRT.h:115
Graphics::BlendEquation mBlendEquationRGB
Definition seadGraphicsContextMRT.h:130
void setBlendFactorSrcRGB(Graphics::BlendFactor factor)
Definition seadGraphicsContextMRT.h:53
Graphics::BlendFactor getBlendFactorDstAlpha() const
Definition seadGraphicsContextMRT.h:110
void setBlendFactorSrcAlpha(Graphics::BlendFactor factor)
Definition seadGraphicsContextMRT.h:58
Graphics::BlendFactor mBlendFactorDstRGB
Definition seadGraphicsContextMRT.h:128
void setBlendEquation(Graphics::BlendEquation equation)
Definition seadGraphicsContextMRT.h:73
Graphics::BlendFactor getBlendFactorDstRGB() const
Definition seadGraphicsContextMRT.h:105
Graphics::BlendFactor mBlendFactorSrcRGB
Definition seadGraphicsContextMRT.h:126
Definition seadGraphicsContextMRT.h:12
bool mDepthWriteEnable
Definition seadGraphicsContextMRT.h:411
bool mStencilTestEnable
Definition seadGraphicsContextMRT.h:421
u32 getColorMask() const
Definition seadGraphicsContextMRT.h:334
Graphics::StencilOp mStencilOpZPass
Definition seadGraphicsContextMRT.h:427
bool getColorMaskB(u32 target) const
Definition seadGraphicsContextMRT.h:322
u32 mColorMask
Definition seadGraphicsContextMRT.h:420
s32 mStencilTestRef
Definition seadGraphicsContextMRT.h:423
void applyCullingAndPolygonModeAndPolygonOffset() const
Definition seadGraphicsContextMRT.cpp:213
bool getPolygonOffsetBackEnable() const
Definition seadGraphicsContextMRT.h:395
void setAlphaTestEnable(bool enable)
Definition seadGraphicsContextMRT.h:194
GraphicsContextMRT()
Definition seadGraphicsContextMRT.cpp:5
u32 getStencilTestMask() const
Definition seadGraphicsContextMRT.h:354
bool getPolygonOffsetFrontEnable() const
Definition seadGraphicsContextMRT.h:388
bool getAlphaTestEnable() const
Definition seadGraphicsContextMRT.h:295
bool getPolygonOffsetPointLineEnable() const
Definition seadGraphicsContextMRT.h:402
u32 mStencilTestMask
Definition seadGraphicsContextMRT.h:424
void setColorMask(u32 target, bool r, bool g, bool b, bool a)
Definition seadGraphicsContextMRT.h:205
bool getBlendEnable(u32 target) const
Definition seadGraphicsContextMRT.h:275
void setCullingMode(Graphics::CullingMode mode)
Definition seadGraphicsContextMRT.h:169
bool mAlphaTestEnable
Definition seadGraphicsContextMRT.h:417
Graphics::AlphaFunc getAlphaTestFunc() const
Definition seadGraphicsContextMRT.h:300
Graphics::DepthFunc mDepthFunc
Definition seadGraphicsContextMRT.h:412
void setColorMask(u32 mask)
Definition seadGraphicsContextMRT.h:214
f32 getAlphaTestRef() const
Definition seadGraphicsContextMRT.h:305
void applyAlphaTest() const
Definition seadGraphicsContextMRT.cpp:128
Graphics::StencilOp getStencilTestOpFail() const
Definition seadGraphicsContextMRT.h:359
void setPolygonOffsetEnable(bool fill_front_enable, bool fill_back_enable, bool point_line_enable)
Definition seadGraphicsContextMRT.h:246
void setBlendEnableMask(u32 mask)
Definition seadGraphicsContextMRT.h:179
void setDepthWriteEnable(bool write_enable)
Definition seadGraphicsContextMRT.h:159
Graphics::StencilOp getStencilTestOpZFail() const
Definition seadGraphicsContextMRT.h:364
Graphics::CullingMode mCullingMode
Definition seadGraphicsContextMRT.h:413
bool getDepthTestEnable() const
Definition seadGraphicsContextMRT.h:255
virtual ~GraphicsContextMRT()
Definition seadGraphicsContextMRT.h:136
BlendExpression & getBlendExpression(u32 target)
Definition seadGraphicsContextMRT.h:184
Graphics::AlphaFunc mAlphaTestFunc
Definition seadGraphicsContextMRT.h:418
bool mDepthTestEnable
Definition seadGraphicsContextMRT.h:410
Color4f mBlendConstantColor
Definition seadGraphicsContextMRT.h:416
Graphics::StencilFunc mStencilTestFunc
Definition seadGraphicsContextMRT.h:422
Graphics::CullingMode getCullingMode() const
Definition seadGraphicsContextMRT.h:270
f32 mAlphaTestRef
Definition seadGraphicsContextMRT.h:419
bool getStencilTestEnable() const
Definition seadGraphicsContextMRT.h:339
void setDepthTestEnable(bool test_enable)
Definition seadGraphicsContextMRT.h:154
Graphics::StencilOp mStencilOpZFail
Definition seadGraphicsContextMRT.h:426
bool getColorMaskA(u32 target) const
Definition seadGraphicsContextMRT.h:328
void applyBlendConstantColor() const
Definition seadGraphicsContextMRT.cpp:203
u32 getBlendEnableMask() const
Definition seadGraphicsContextMRT.h:280
bool getColorMaskR(u32 target) const
Definition seadGraphicsContextMRT.h:310
void setPolygonMode(Graphics::PolygonMode front, Graphics::PolygonMode back)
Definition seadGraphicsContextMRT.h:238
void applyColorMask() const
Definition seadGraphicsContextMRT.cpp:161
void setStencilTestOp(Graphics::StencilOp fail, Graphics::StencilOp zfail, Graphics::StencilOp zpass)
Definition seadGraphicsContextMRT.h:231
void apply() const
Definition seadGraphicsContextMRT.cpp:39
void applyBlendAndFastZ() const
Definition seadGraphicsContextMRT.cpp:177
BitFlag32 mBlendEnableMask
Definition seadGraphicsContextMRT.h:414
void setAlphaTestFunc(Graphics::AlphaFunc func, f32 ref)
Definition seadGraphicsContextMRT.h:199
void setBlendConstantColor(const Color4f &color)
Definition seadGraphicsContextMRT.h:189
void setDepthFunc(Graphics::DepthFunc func)
Definition seadGraphicsContextMRT.h:164
bool getColorMaskG(u32 target) const
Definition seadGraphicsContextMRT.h:316
void setDepthEnable(bool test_enable, bool write_enable)
Definition seadGraphicsContextMRT.h:148
Graphics::StencilOp mStencilOpFail
Definition seadGraphicsContextMRT.h:425
Graphics::StencilOp getStencilTestOpZPass() const
Definition seadGraphicsContextMRT.h:369
const BlendExpression & getBlendExpression(u32 target) const
Definition seadGraphicsContextMRT.h:285
Graphics::DepthFunc getDepthFunc() const
Definition seadGraphicsContextMRT.h:265
void setStencilTestFunc(Graphics::StencilFunc func, s32 ref, u32 mask)
Definition seadGraphicsContextMRT.h:224
Graphics::StencilFunc getStencilTestFunc() const
Definition seadGraphicsContextMRT.h:344
void setBlendEnable(u32 target, bool blend)
Definition seadGraphicsContextMRT.h:174
void applyDepthAndStencilTest() const
Definition seadGraphicsContextMRT.cpp:137
Graphics::PolygonMode getPolygonModeFront() const
Definition seadGraphicsContextMRT.h:374
SafeArray< BlendExpression, Graphics::cRenderTarget_Num > mBlendExpression
Definition seadGraphicsContextMRT.h:415
bool getDepthWriteEnable() const
Definition seadGraphicsContextMRT.h:260
const Color4f & getBlendConstantColor() const
Definition seadGraphicsContextMRT.h:290
void setStencilTestEnable(bool enable)
Definition seadGraphicsContextMRT.h:219
s32 getStencilTestRef() const
Definition seadGraphicsContextMRT.h:349
Graphics::PolygonMode getPolygonModeBack() const
Definition seadGraphicsContextMRT.h:381
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 seadSafeArray.h:19
Definition seadAssert.h:44
BitFlag< u32 > BitFlag32
Definition seadBitFlag.h:125
Definition seadColor.h:9