我想变身Android上和glMapBufferRange保持并出现以下错误崩溃一个GLES应用程序的一些顶点:glMapBufferRange Android上GLES应用程序崩溃
SIGSEGV(信号SIGSEGV:地址访问保护(故障地址:0xef13d664))
我或多或少的遵循了这一网址的例子:
http://www.songho.ca/opengl/gl_vbo.html#update
,但如果我失去了一些东西不知道。
我在初始化时创建了我的VBOs,并且可以绘制没有问题的对象。创建的代码有云:
void SubObject3D::CreateVBO(VBOInfo &vboInfoIn) {
// m_vboIds[0] - used to store vertex attribute data
// m_vboIds[l] - used to store element indices
glGenBuffers(2, vboInfoIn.vboIds);
// Let the buffer all dynamic for morphing
glBindBuffer(GL_ARRAY_BUFFER, vboInfoIn.vboIds[0]);
glBufferData(GL_ARRAY_BUFFER,
(GLsizeiptr) (vboInfoIn.vertexStride * vboInfoIn.verticesCount),
vboInfoIn.pVertices, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboInfoIn.vboIds[1]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
(GLsizeiptr) (sizeof(GLushort) * vboInfoIn.indicesCount),
vboInfoIn.pIndices, GL_STATIC_DRAW);
}
struct VBOInfo {
VBOInfo() {
memset(this, 0x00, sizeof(VBOInfo));
vboIds[0] = 0xdeadbeef;
vboIds[1] = 0xdeadbeef;
}
// VertexBufferObject Ids
GLuint vboIds[2];
// Points to the source data
GLfloat *pVertices; // Pointer of original data
GLuint verticesCount;
GLushort *pIndices; // Pointer of original data
GLuint indicesCount;
GLint vertexStride;
};
然后在渲染循环我试图让我的顶点指针的保持这样以后:
// I stored the information at creation time here:
VBOInfo mVBOGeometryInfo;
//later I call here to get the pointer
GLfloat *SubObject3D::MapVBO() {
GLfloat *pVertices = nullptr;
glBindBuffer(GL_ARRAY_BUFFER, mVBOGeometryInfo.vboIds[0]);
GLsizeiptr length = (GLsizeiptr) (mVBOGeometryInfo.vertexStride *
mVBOGeometryInfo.verticesCount);
pVertices = (GLfloat *) glMapBufferRange(
GL_ARRAY_BUFFER, 0,
length,
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT
);
if (pVertices == nullptr) {
LOGE ("Could not map VBO");
}
return pVertices;
}
但就在glMapBufferRange坠毁。
这是一个使用NDK的android应用程序。硬件是三星S6手机。
thx!
您是否创建了ES 3.0环境?您能否成功使用其他ES 3.x功能? –
当SubObject3D :: MapVBO运行时,你能检查verticesCount,vertexStride和vboIds是否与SubObject3D :: CreateVBO运行时相同? – Columbo
@Columbo就数据而言,它是完全正确的。 vbo ID,顶点大小和步幅是正确和有效的。另外,如果我不调用映射函数,我可以渲染对象没有问题。至于代码,我错过了什么? – gmmo