mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
[bugfix] spine-cocos2dx renderer issues (#1577)
* fix some bugs * auto release program
This commit is contained in:
parent
3f9d7b1c63
commit
8c8b08f80b
@ -810,7 +810,7 @@ namespace spine {
|
||||
}
|
||||
|
||||
void SkeletonRenderer::setTwoColorTint(bool enabled) {
|
||||
#if COCOS2D_VERSION > 0x00040000
|
||||
#if COCOS2D_VERSION >= 0x00040000
|
||||
_twoColorTint = enabled;
|
||||
#endif
|
||||
setupGLProgramState(enabled);
|
||||
|
||||
@ -59,15 +59,17 @@ void SkeletonBatch::destroyInstance () {
|
||||
|
||||
SkeletonBatch::SkeletonBatch () {
|
||||
|
||||
auto program = backend::Device::getInstance()->newProgram(positionTextureColor_vert, positionTextureColor_frag);
|
||||
auto program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_TEXTURE_COLOR);
|
||||
_programState = std::make_shared<backend::ProgramState>(program);
|
||||
program->autorelease();
|
||||
|
||||
|
||||
auto vertexLayout = _programState->getVertexLayout();
|
||||
|
||||
vertexLayout->setAttribute("a_position", 0, backend::VertexFormat::FLOAT3, offsetof(V3F_C4B_T2F, vertices), false);
|
||||
vertexLayout->setAttribute("a_color", 2, backend::VertexFormat::UBYTE4, offsetof(V3F_C4B_T2F, colors), true);
|
||||
vertexLayout->setAttribute("a_texCoord", 1, backend::VertexFormat::FLOAT2, offsetof(V3F_C4B_T2F, texCoords), false);
|
||||
auto locPosition = _programState->getAttributeLocation("a_position");
|
||||
auto locTexcoord = _programState->getAttributeLocation("a_texCoord");
|
||||
auto locColor = _programState->getAttributeLocation("a_color");
|
||||
vertexLayout->setAttribute("a_position", locPosition, backend::VertexFormat::FLOAT3, offsetof(V3F_C4B_T2F, vertices), false);
|
||||
vertexLayout->setAttribute("a_color", locColor, backend::VertexFormat::UBYTE4, offsetof(V3F_C4B_T2F, colors), true);
|
||||
vertexLayout->setAttribute("a_texCoord", locTexcoord, backend::VertexFormat::FLOAT2, offsetof(V3F_C4B_T2F, texCoords), false);
|
||||
vertexLayout->setLayout(sizeof(_vertices[0]));
|
||||
|
||||
|
||||
|
||||
@ -114,10 +114,15 @@ namespace {
|
||||
|
||||
auto layout = programState->getVertexLayout();
|
||||
|
||||
layout->setAttribute("a_position", 0, backend::VertexFormat::FLOAT3, offsetof(spine::V3F_C4B_C4B_T2F, position), false);
|
||||
layout->setAttribute("a_color", 1, backend::VertexFormat::UBYTE4, offsetof(spine::V3F_C4B_C4B_T2F, color), true);
|
||||
layout->setAttribute("a_color2", 2, backend::VertexFormat::UBYTE4, offsetof(spine::V3F_C4B_C4B_T2F, color2), true);
|
||||
layout->setAttribute("a_texCoords", 3, backend::VertexFormat::FLOAT2, offsetof(spine::V3F_C4B_C4B_T2F, texCoords), false);
|
||||
auto locPosition = programState->getAttributeLocation("a_position");
|
||||
auto locTexcoord = programState->getAttributeLocation("a_texCoords");
|
||||
auto locColor = programState->getAttributeLocation("a_color");
|
||||
auto locColor2 = programState->getAttributeLocation("a_color2");
|
||||
|
||||
layout->setAttribute("a_position", locPosition, backend::VertexFormat::FLOAT3, offsetof(spine::V3F_C4B_C4B_T2F, position), false);
|
||||
layout->setAttribute("a_color", locColor, backend::VertexFormat::UBYTE4, offsetof(spine::V3F_C4B_C4B_T2F, color), true);
|
||||
layout->setAttribute("a_color2", locColor2, backend::VertexFormat::UBYTE4, offsetof(spine::V3F_C4B_C4B_T2F, color2), true);
|
||||
layout->setAttribute("a_texCoords", locTexcoord, backend::VertexFormat::FLOAT2, offsetof(spine::V3F_C4B_C4B_T2F, texCoords), false);
|
||||
layout->setLayout(sizeof(spine::V3F_C4B_C4B_T2F));
|
||||
|
||||
__twoColorProgramState = std::shared_ptr<backend::ProgramState>(programState);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user