【发布时间】:2015-09-24 11:42:08
【问题描述】:
我正在尝试在 cocos2d-x 的 3d 视图中绘制实心网格
bool MeshTerrain::init(){
if(!Node::init()){
return false;
}
positions.push_back(-5.0f);positions.push_back(-5.0f);positions.push_back(0.0f);
positions.push_back(5.0f);positions.push_back(-5.0f);positions.push_back(0.0f);
positions.push_back(5.0f);positions.push_back(5.0f);positions.push_back(0.0f);
positions.push_back(-5.0f);positions.push_back(5.0f);positions.push_back(0.0f);
texs.push_back(0.0f);texs.push_back(0.0f);
texs.push_back(1.0f);texs.push_back(0.0f);
texs.push_back(1.0f);texs.push_back(1.0f);
texs.push_back(0.0f);texs.push_back(1.0f);
indices.push_back(0);
indices.push_back(1);
indices.push_back(2);
indices.push_back(0);
indices.push_back(2);
indices.push_back(3);
mesh = cocos2d::Mesh::create(positions, normals, texs, indices);
mesh->setTexture("texture.png");
return true;
}
void MeshTerrain::draw(cocos2d::Renderer *renderer, const cocos2d::Mat4 &transform, uint32_t flags){
auto programstate = mesh->getGLProgramState();
auto& meshCommand = mesh->getMeshCommand();
GLuint textureID = mesh->getTexture() ? mesh->getTexture()->getName() : 0;
meshCommand.init(_globalZOrder
, textureID
, programstate
, 0
, mesh->getVertexBuffer()
, mesh->getIndexBuffer()
, mesh->getPrimitiveType()
, mesh->getIndexFormat()
, mesh->getIndexCount()
, transform
,flags);
renderer->addCommand(&meshCommand);
}
但我不断收到同样的错误:
断言失败:GLProgramState 不能为空 断言失败:(glProgramState),函数 init,文件 /Users/Juggernogger93/Desktop/StormStrike/StormStrike/cocos2d/cocos/renderer/CCMeshCommand.cpp,第 108 行。
有没有人知道如何解决这个问题。
【问题讨论】: