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

Method setProgramState

core/2d/MotionStreak.cpp:225–262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223}
224
225bool MotionStreak::setProgramState(backend::ProgramState* programState, bool ownPS /*= false*/)
226{
227 if (Node::setProgramState(programState, ownPS))
228 {
229 AXASSERT(programState, "argument should not be nullptr");
230 auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
231 pipelineDescriptor.programState = _programState;
232
233 _mvpMatrixLocaiton = _programState->getUniformLocation("u_MVPMatrix");
234 _textureLocation = _programState->getUniformLocation("u_tex0");
235
236 // setup custom vertex layout for V2F_T2F_C4B
237 const auto& attributeInfo = _programState->getProgram()->getActiveAttributes();
238 auto iter = attributeInfo.find("a_position");
239 auto layout = _programState->getMutableVertexLayout();
240 if (iter != attributeInfo.end())
241 {
242 layout->setAttrib("a_position", iter->second.location, backend::VertexFormat::FLOAT2, 0, false);
243 }
244 iter = attributeInfo.find("a_texCoord");
245 if (iter != attributeInfo.end())
246 {
247 layout->setAttrib("a_texCoord", iter->second.location, backend::VertexFormat::FLOAT2,
248 2 * sizeof(float), false);
249 }
250 iter = attributeInfo.find("a_color");
251 if (iter != attributeInfo.end())
252 {
253 layout->setAttrib("a_color", iter->second.location, backend::VertexFormat::UBYTE4,
254 4 * sizeof(float), true);
255 }
256 layout->setStride(4 * sizeof(float) + 4 * sizeof(uint8_t));
257
258 updateProgramStateTexture(_texture);
259 return true;
260 }
261 return false;
262}
263
264void MotionStreak::setBlendFunc(const BlendFunc& blendFunc)
265{

Callers

nothing calls this directly

Calls 8

setProgramStateFunction · 0.85
getProgramMethod · 0.80
setAttribMethod · 0.80
setStrideMethod · 0.80
getUniformLocationMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected