MCPcopy Create free account
hub / github.com/axmolengine/axmol / apply

Method apply

core/renderer/RenderState.cpp:90–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90void RenderState::StateBlock::apply(PipelineDescriptor* pipelineDescriptor)
91{
92 // AX_ASSERT(_globalState);
93
94 auto renderer = Director::getInstance()->getRenderer();
95 auto& blend = pipelineDescriptor->blendDescriptor;
96
97 // Update any state that differs from _globalState and flip _globalState bits
98 if ((_modifiedBits & RS_BLEND))
99 {
100 blend.blendEnabled = _blendEnabled;
101 }
102
103 if ((_modifiedBits & RS_BLEND_FUNC))
104 {
105 blend.sourceAlphaBlendFactor = blend.sourceRGBBlendFactor = _blendSrc;
106 blend.destinationAlphaBlendFactor = blend.destinationRGBBlendFactor = _blendDst;
107 }
108
109 if ((_modifiedBits & RS_CULL_FACE))
110 {
111 if (!_cullFaceEnabled)
112 renderer->setCullMode(CullMode::NONE);
113 }
114
115 if ((_modifiedBits & RS_CULL_FACE_SIDE))
116 {
117 renderer->setCullMode(_cullFaceSide);
118 }
119
120 if ((_modifiedBits & RS_FRONT_FACE))
121 {
122 renderer->setWinding(_frontFace);
123 }
124 if ((_modifiedBits & RS_DEPTH_TEST))
125 {
126 renderer->setDepthTest(_depthTestEnabled);
127 }
128
129 if ((_modifiedBits & RS_DEPTH_WRITE))
130 {
131 renderer->setDepthWrite(_depthWriteEnabled);
132 }
133
134 if ((_modifiedBits & RS_DEPTH_FUNC))
135 {
136 renderer->setDepthCompareFunction(_depthFunction);
137 }
138}
139
140void RenderState::StateBlock::restoreUnmodifiedStates(int32_t overrideBits, PipelineDescriptor* programState)
141{

Callers 1

bindPassMethod · 0.45

Calls 7

getInstanceFunction · 0.85
getRendererMethod · 0.80
setCullModeMethod · 0.80
setWindingMethod · 0.80
setDepthTestMethod · 0.45
setDepthWriteMethod · 0.45

Tested by

no test coverage detected