This commit is contained in:
halx99 2020-02-12 20:15:09 +08:00
parent 2d3e162e21
commit f36d21c9bf
6 changed files with 14 additions and 10 deletions

View File

@ -288,7 +288,7 @@ LayerColor::LayerColor()
_blendFunc = BlendFunc::ALPHA_PREMULTIPLIED;
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR);
auto* program = backend::Program::getBuiltinProgram(backend::ProgramType::POSITION_COLOR); // TODO: noMVP?
_programState = new (std::nothrow) backend::ProgramState(program);
pipelineDescriptor.programState = _programState;

View File

@ -414,7 +414,7 @@ bool BoneNode::init()
updateColor();
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
auto* program = cocos2d::backend::Program::getBuiltinProgram(cocos2d::backend::ProgramType::POSITION);
auto* program = cocos2d::backend::Program::getBuiltinProgram(cocos2d::backend::ProgramType::POSITION_COLOR); // TODO: noMVP?
_programState = new (std::nothrow) cocos2d::backend::ProgramState(program);
pipelineDescriptor.programState = _programState;

View File

@ -53,7 +53,7 @@ bool SkeletonNode::init()
// init _customCommand
auto& pipelineDescriptor = _customCommand.getPipelineDescriptor();
auto* program = cocos2d::backend::Program::getBuiltinProgram(cocos2d::backend::ProgramType::POSITION);
auto* program = cocos2d::backend::Program::getBuiltinProgram(cocos2d::backend::ProgramType::POSITION_COLOR); // TODO: noMVP?
_programState = new (std::nothrow) cocos2d::backend::ProgramState(program);
pipelineDescriptor.programState = _programState;

View File

@ -91,7 +91,6 @@ bool ProgramCache::init()
addProgram(ProgramType::POSITION_COLOR_LENGTH_TEXTURE);
addProgram(ProgramType::POSITION_COLOR_TEXTURE_AS_POINTSIZE);
addProgram(ProgramType::POSITION_COLOR);
addProgram(ProgramType::POSITION);
addProgram(ProgramType::LAYER_RADIA_GRADIENT);
addProgram(ProgramType::POSITION_TEXTURE);
addProgram(ProgramType::POSITION_TEXTURE_COLOR_ALPHA_TEST);
@ -156,8 +155,6 @@ void ProgramCache::addProgram(ProgramType type)
case ProgramType::POSITION_COLOR:
program = backend::Device::getInstance()->newProgram(positionColor_vert, positionColor_frag);
break;
case ProgramType::POSITION:
program = backend::Device::getInstance()->newProgram(position_vert, positionColor_frag);
break;
case ProgramType::LAYER_RADIA_GRADIENT:
program = backend::Device::getInstance()->newProgram(position_vert, layer_radialGradient_frag);

View File

@ -331,7 +331,6 @@ enum class ProgramType : size_t
POSITION_COLOR_LENGTH_TEXTURE, //positionColorLengthTexture_vert, positionColorLengthTexture_frag
POSITION_COLOR_TEXTURE_AS_POINTSIZE, //positionColorTextureAsPointsize_vert, positionColor_frag
POSITION_COLOR, //positionColor_vert, positionColor_frag
POSITION, //position_vert, positionColor_frag
POSITION_UCOLOR, //positionUColor_vert, positionUColor_frag
POSITION_TEXTURE, //positionTexture_vert, positionTexture_frag
POSITION_TEXTURE_COLOR, //positionTextureColor_vert, positionTextureColor_frag

View File

@ -120,14 +120,22 @@ void ProgramGL::compileProgram()
glAttachShader(_program, vertShader);
glAttachShader(_program, fragShader);
glLinkProgram(_program);
GLint status = 0;
glGetProgramiv(_program, GL_LINK_STATUS, &status);
if (GL_FALSE == status)
{
printf("cocos2d: ERROR: %s: failed to link program ", __FUNCTION__);
GLint errorInfoLen = 0;
glGetProgramiv(_program, GL_INFO_LOG_LENGTH, &errorInfoLen);
if (errorInfoLen) {
std::string errorInfo(errorInfoLen, '\0');
glGetProgramInfoLog(_program, errorInfoLen, NULL, &errorInfo.front());
log("cocos2d: ERROR: %s: failed to link program: %s ", __FUNCTION__, errorInfo.c_str());
}
else
log("cocos2d: ERROR: %s: failed to link program ", __FUNCTION__);
glDeleteProgram(_program);
_program = 0;
}