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

Method drawInRect

core/renderer/Texture2D.cpp:791–821  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789}
790
791void Texture2D::drawInRect(const Rect& rect, float globalZOrder)
792{
793 initProgram();
794 _customCommand.init(globalZOrder);
795 auto director = Director::getInstance();
796 const auto& modelView = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
797 const auto& projection = director->getMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_PROJECTION);
798
799 Mat4 matrixMVP = projection * modelView;
800
801 float vertexData[] = {rect.origin.x,
802 rect.origin.y,
803 0.0f,
804 _maxT,
805 rect.size.width + rect.origin.x,
806 rect.origin.y,
807 _maxS,
808 _maxT,
809 rect.origin.x,
810 rect.size.height + rect.origin.y,
811 0.0f,
812 0.0f,
813 rect.size.width + rect.origin.x,
814 rect.size.height + rect.origin.y,
815 _maxS,
816 0.0f};
817
818 _programState->setUniform(_mvpMatrixLocation, matrixMVP.m, sizeof(matrixMVP.m));
819 _customCommand.updateVertexBuffer(vertexData, sizeof(vertexData));
820 Director::getInstance()->getRenderer()->addCommand(&_customCommand);
821}
822
823}

Callers 1

onDrawMethod · 0.80

Calls 6

getInstanceFunction · 0.85
getRendererMethod · 0.80
initMethod · 0.45
setUniformMethod · 0.45
updateVertexBufferMethod · 0.45
addCommandMethod · 0.45

Tested by 1

onDrawMethod · 0.64