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

Method draw

tests/cpp-tests/Source/ShaderTest/ShaderTest.cpp:154–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

152}
153
154void ShaderNode::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
155{
156 _customCommand.init(_globalZOrder, transform, flags);
157
158 _programState->setUniform(_locResolution, &_resolution, sizeof(_resolution));
159 _programState->setUniform(_locCenter, &_center, sizeof(_center));
160
161 auto projectionMatrix = Director::getInstance()->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
162 auto finalMatrix = projectionMatrix * transform;
163
164 _programState->setUniform(_locMVP, finalMatrix.m, sizeof(finalMatrix.m));
165
166 float time = Director::getInstance()->getTotalFrames() * Director::getInstance()->getAnimationInterval();
167 Vec4 uTime(time / 10.0f, time, time * 2.0f, time * 4.0f);
168 Vec4 sinTime(time / 8.0f, time / 4.0f, time / 2.0f, sinf(time));
169 Vec4 cosTime(time / 8.0f, time / 4.0f, time / 2.0f, cosf(time));
170
171 _programState->setUniform(_locTime, &uTime, sizeof(uTime));
172 _programState->setUniform(_locSinTime, &sinTime, sizeof(sinTime));
173 _programState->setUniform(_locCosTime, &cosTime, sizeof(cosTime));
174
175 renderer->addCommand(&_customCommand);
176 AX_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, 6);
177}
178
179void ShaderNode::updateUniforms()
180{

Callers

nothing calls this directly

Calls 5

getInstanceFunction · 0.85
getTotalFramesMethod · 0.80
initMethod · 0.45
setUniformMethod · 0.45
addCommandMethod · 0.45

Tested by

no test coverage detected