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

Method draw

tests/cpp-tests/Source/ShaderTest/ShaderTest2.cpp:117–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115 }
116
117 void draw(Renderer* renderer, const Mat4& transform, uint32_t flags) override
118 {
119#if AX_USE_CULLING
120 // Don't do calculate the culling if the transform was not updated
121 _insideBounds =
122 (flags & FLAGS_TRANSFORM_DIRTY) ? renderer->checkVisibility(transform, _contentSize) : _insideBounds;
123
124 if (_insideBounds)
125#endif
126 {
127 // negative effects: order < 0
128 int idx = 0;
129 for (auto&&effect : _effects)
130 {
131
132 if (std::get<0>(effect) >= 0)
133 break;
134 auto* programState = std::get<1>(effect)->getProgramState();
135 if (programState)
136 {
137 QuadCommand& q = std::get<2>(effect);
138 q.init(_globalZOrder, _texture, _blendFunc, &_quad, 1, transform, flags);
139 updateUniforms(programState);
140 renderer->addCommand(&q);
141 }
142 idx++;
143 }
144
145 // normal effect: order == 0
146 _trianglesCommand.init(_globalZOrder, _texture, _blendFunc, _polyInfo.triangles, transform, flags);
147
148 updateUniforms(_trianglesCommand.getPipelineDescriptor().programState);
149 renderer->addCommand(&_trianglesCommand);
150
151 // positive effects: order >= 0
152 for (auto&& it = std::begin(_effects) + idx; it != std::end(_effects); ++it)
153 {
154 QuadCommand& q = std::get<2>(*it);
155 auto* programState = std::get<1>(*it)->getProgramState();
156 updateUniforms(programState);
157 q.init(_globalZOrder, _texture, _blendFunc, &_quad, 1, transform, flags);
158 q.getPipelineDescriptor().programState = programState;
159 renderer->addCommand(&q);
160 idx++;
161 }
162 }
163 }
164
165protected:
166 EffectSprite() : _defaultEffect(nullptr) { _effects.reserve(2); }

Callers

nothing calls this directly

Calls 7

updateUniformsFunction · 0.85
checkVisibilityMethod · 0.80
beginFunction · 0.50
endFunction · 0.50
getProgramStateMethod · 0.45
initMethod · 0.45
addCommandMethod · 0.45

Tested by

no test coverage detected