【问题标题】:Trying to draw 3d terrain using cocos2d-x 3.8.1尝试使用 cocos2d-x 3.8.1 绘制 3d 地形
【发布时间】: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 行。

有没有人知道如何解决这个问题。

【问题讨论】:

    标签: c++ ios cocos2d-x


    【解决方案1】:

    通过getGLProgramState(),而不是 0。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-09-22
      • 2018-04-22
      • 2016-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多