赞
踩
在iphone6s,iphone7,iphone7p 会闪退
报错位置:
void LayerColor::onDraw(const Mat4& transform, uint32_t flags)
{
getGLProgram()->use();
getGLProgram()->setUniformsForBuiltins(transform);
GL::enableVertexAttribs( GL::VERTEX_ATTRIB_FLAG_POSITION| GL::VERTEX_ATTRIB_FLAG_COLOR);
//
// Attributes
//
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_POSITION, 3, GL_FLOAT, GL_FALSE, 0, _noMVPVertices);
glVertexAttribPointer(GLProgram::VERTEX_ATTRIB_COLOR, 4, GL_FLOAT, GL_FALSE, 0, _squareColors);
GL::blendFunc( _blendFunc.src, _blendFunc.dst);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); //报错位置!!!!!!!!!
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,4);
}
cocos 官网解决方案: https://github.com/cocos2d/cocos2d-x/issues/1654
解决办法:
1、找到 PolygonBatch::flush这个方法;
2、将:
- GL::bindVAO(0);
- glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_POSITION);
- glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_COLOR);
- glEnableVertexAttribArray(GLProgram::VERTEX_ATTRIB_TEX_COORDS);
替换为:
GL::enableVertexAttribs(GL::VERTEX_ATTRIB_FLAG_POSITION | GL::VERTEX_ATTRIB_FLAG_COLOR | GL::VERTEX_ATTRIB_FLAG_TEX_COORD);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。