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

Function initPipelineDescriptor

core/2d/ProgressTimer.cpp:49–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47namespace
48{
49backend::ProgramState* initPipelineDescriptor(ax::CustomCommand& command,
50 bool ridal,
51 backend::UniformLocation& locMVP,
52 backend::UniformLocation& locTexture)
53{
54 auto& pipelieDescriptor = command.getPipelineDescriptor();
55 auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
56 auto programState = new backend::ProgramState(program);
57 AX_SAFE_RELEASE(pipelieDescriptor.programState);
58 pipelieDescriptor.programState = programState;
59
60 // set custom vertexLayout according to V2F_C4B_T2F structure
61 auto vertexLayout = programState->getMutableVertexLayout();
62 vertexLayout->setAttrib("a_position", program->getAttributeLocation(backend::Attribute::POSITION),
63 backend::VertexFormat::FLOAT2, 0, false);
64 vertexLayout->setAttrib("a_texCoord", program->getAttributeLocation(backend::Attribute::TEXCOORD),
65 backend::VertexFormat::FLOAT2,
66 offsetof(V2F_C4B_T2F, texCoords), false);
67 vertexLayout->setAttrib("a_color", program->getAttributeLocation(backend::Attribute::COLOR),
68 backend::VertexFormat::UBYTE4,
69 offsetof(V2F_C4B_T2F, colors), true);
70 vertexLayout->setStride(sizeof(V2F_C4B_T2F));
71
72 if (ridal)
73 {
74 command.setDrawType(CustomCommand::DrawType::ELEMENT);
75 command.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE);
76 }
77 else
78 {
79 command.setDrawType(CustomCommand::DrawType::ARRAY);
80 command.setPrimitiveType(CustomCommand::PrimitiveType::TRIANGLE_STRIP);
81 }
82
83 locMVP = programState->getUniformLocation("u_MVPMatrix");
84 locTexture = programState->getUniformLocation("u_tex0");
85
86 return programState;
87}
88} // namespace
89
90ProgressTimer* ProgressTimer::create(Sprite* sp)

Callers 1

initWithSpriteMethod · 0.85

Calls 5

setAttribMethod · 0.80
getAttributeLocationMethod · 0.80
setStrideMethod · 0.80
getUniformLocationMethod · 0.45

Tested by

no test coverage detected