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

Method updatePrimitives

core/2d/FastTMXLayer.cpp:426–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424}
425
426void FastTMXLayer::updatePrimitives()
427{
428
429 for (auto& e : _customCommands)
430 {
431 e.second->setIndexDrawInfo(0, 0);
432 }
433
434 auto blendfunc =
435 _texture->hasPremultipliedAlpha() ? BlendFunc::ALPHA_PREMULTIPLIED : BlendFunc::ALPHA_NON_PREMULTIPLIED;
436 for (const auto& iter : _indicesVertexZNumber)
437 {
438 int start = _indicesVertexZOffsets.at(iter.first);
439
440 auto commandIter = _customCommands.find(iter.first);
441 if (_customCommands.end() == commandIter)
442 {
443 auto command = new CustomCommand();
444 command->setVertexBuffer(_vertexBuffer);
445
446#ifdef AX_FAST_TILEMAP_32_BIT_INDICES
447 CustomCommand::IndexFormat indexFormat = CustomCommand::IndexFormat::U_INT;
448#else
449 CustomCommand::IndexFormat indexFormat = CustomCommand::IndexFormat::U_SHORT;
450#endif
451 command->setIndexBuffer(_indexBuffer, indexFormat);
452
453 command->setIndexDrawInfo(start * 6, iter.second * 6);
454
455 auto& pipelineDescriptor = command->getPipelineDescriptor();
456
457 if (_useAutomaticVertexZ)
458 {
459 AX_SAFE_RELEASE(pipelineDescriptor.programState);
460 auto* program =
461 backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST);
462 auto programState = new backend::ProgramState(program);
463 pipelineDescriptor.programState = programState;
464 _alphaValueLocation = pipelineDescriptor.programState->getUniformLocation("u_alpha_value");
465 pipelineDescriptor.programState->setUniform(_alphaValueLocation, &_alphaFuncValue,
466 sizeof(_alphaFuncValue));
467 }
468 else
469 {
470 AX_SAFE_RELEASE(pipelineDescriptor.programState);
471 auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
472 auto programState = new backend::ProgramState(program);
473 pipelineDescriptor.programState = programState;
474 }
475
476 _mvpMatrixLocaiton = pipelineDescriptor.programState->getUniformLocation("u_MVPMatrix");
477 _textureLocation = pipelineDescriptor.programState->getUniformLocation("u_tex0");
478 pipelineDescriptor.programState->setTexture(_textureLocation, 0, _texture->getBackendTexture());
479 command->init(_globalZOrder, blendfunc);
480
481 _customCommands[iter.first] = command;
482 }
483 else

Callers

nothing calls this directly

Calls 11

hasPremultipliedAlphaMethod · 0.80
getBackendTextureMethod · 0.80
atMethod · 0.45
findMethod · 0.45
endMethod · 0.45
setVertexBufferMethod · 0.45
setIndexBufferMethod · 0.45
getUniformLocationMethod · 0.45
setUniformMethod · 0.45
setTextureMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected