[QUOTE=deduu10;29300]Hi, can you help me to figure out what’s wrong with my snippet code? I could not figure out, what cause my VBO got OutOfMemoryError.
Here is my snippet code. I use Android platform, and I used no texture.
GLuint buffer[3];
glGenBuffers(3, buffer);
glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeNumVerts * 4, genData.vertex, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, buffer[1]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeColorVerts *4, genData.colors, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, buffer[2]);
glBufferData(GL_ARRAY_BUFFER, genData.cubeNormalVerts * 4, genData.normals, GL_DYNAMIC_DRAW);
if(genData.vertex == 0 || genData.normals == 0 || genData.colors == 0) LOG("Error: failed to allocate a memory");
glBindBuffer(GL_ARRAY_BUFFER, buffer[0]);
glEnableVertexAttribArray(vertexHandle);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,0);
glBindBuffer(GL_ARRAY_BUFFER, buffer[2]);
glEnableVertexAttribArray(normalHandle);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,0);
// glVertexAttrib4fv(mColorHandle, genData.colors);
glBindBuffer(GL_ARRAY_BUFFER, buffer[1]);
glEnableVertexAttribArray(mColorHandle);
glVertexAttribPointer(mColorHandle, 4, GL_FLOAT, GL_FALSE, 0,0);
glDrawArrays(GL_TRIANGLES, 0, genData.cubeNumVerts);
glDeleteBuffers(3, buffer);
Please helps…
Thanks[/QUOTE]
I recommended you try GL_STATIC_DRAW instead of GL_DYNAMIC_DRAW to see if it eliminates the error. I would also try commenting out the VBOs for the normal and color arrays temporarily to see if that helps.
I suspect this may be an OpenGL ES driver problem, rather than a bug in your code. Which GPU are you using (Nvidia, PowerVR, Adreno)? Is this code running in a native library or with the OpenGL ES wrapper classes? You should try running your code in an AVD emulator, but you must use a recent version of Android to do that. This article will help you setup an AVD for OpenGL ES 2.0:
Regards, Clay