尝试使用cocos2d-x 3.8.1绘制3d地形
Trying to draw 3d terrain using cocos2d-x 3.8.1
我正在尝试在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);
}
但是我一直得到相同的错误:
Assert failed: GLProgramState不能为空断言失败:(glProgramState),函数init,文件/Users/Juggernogger93/Desktop/StormStrike/StormStrike/cocos2d/cocos/renderer/CCMeshCommand.cpp,第108行
有没有人知道如何解决这个问题
通过getGLProgramState()
,不是0。
相关文章:
- 如何在 3D OpenGL 场景上绘制 SDL 2D 矩形?
- 是否可以使用 DirectX 3D 11 绘制由三角形组成的圆?
- 如何在 DirectX 11 中使用曲面细分绘制虚线图案 3D 线
- 如何在C++中轻松地将 3D 阵列绘制为表面
- 通过在Android(和iOS)上使用QT绘制具有3D效果的2D线
- 想要在从搅拌机导入的实体3D对象上绘制线框网格
- OpenGL在3D游戏上绘制HUD
- 如何从3d点数组在Qt中绘制和保存3D模型
- 在3D世界中的显示器上固定位置绘制2D文本-OpenGL
- 如何在 QML 场景上绘制 3D 线条
- 如何绘制3d板?过剩
- 如何在 DirectX 中绘制 2D 几何体和 3D 对象?(D3D9)
- Opengl 在移动的 3D 场景中绘制 2D 矩形
- DirectX::SpriteFont/SpriteBatch 阻止绘制 3D 场景
- 如何在 3D 点上绘制文本
- 绘制大量三角形/高度图的更快方法(直接3D,C++)
- 使用glDrawElements绘制3D网格时的奇怪行为
- 尝试使用cocos2d-x 3.8.1绘制3d地形
- 我如何在c++中绘制3d散点图
- 使用Java和OpenGL绘制3D树的方法有哪些