我想让GLTools在Android设备上启动。(GLTools是一个OpenGL SuperBible库)。这本书只讨论iOS而不是Android。 有一个问题。
void GLBatch::CopyVertexData3f(M3DVector3f *vVerts)
{
// First time, create the buffer object, allocate the space
if(uiVertexArray == 0) {
glGenBuffers(1, &uiVertexArray);
glBindBuffer(GL_ARRAY_BUFFER, uiVertexArray);
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * nNumVerts, vVerts, GL_DYNAMIC_DRAW);
}
else { // Just bind to existing object
glBindBuffer(GL_ARRAY_BUFFER, uiVertexArray);
__android_log_print(ANDROID_LOG_ERROR, "CopyVertexData3f", "uiVertexArray = %d",
glIsBuffer(uiVertexArray));
// Copy the data in
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(GLfloat) * 3 * nNumVerts, vVerts);
//glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * nNumVerts, vVerts, GL_DYNAMIC_DRAW);
pVerts = NULL;
}
}
如果变量uiVertexArray不为零。代码将在else块中输入并抛出A GL_INVALID_OPERATION,如下所示:
<qgl2DrvAPI_glBufferSubData:769>: GL_INVALID_OPERATION
如果保留的缓冲区对象名称0绑定到目标,则生成GL_INVALID_OPERATION。 但uiVertexArray不是零。为什么代码在调用glBufferSubData?
时抛出GL_INVALID_OPERATION一旦我将glBufferSubData改为glBufferData,它就可以了。