Hi,
Using ES 2.0 on Android (java)
I using multiple VBO’s and multiple shaders and using glDrawElements and it works fine…however, I have a question.
This is a piece of code from my draw()->
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexCoordsVBO[0]);
GLES20.glVertexAttribPointer(mShader.mVertexCoordHandler, 3, GLES20.GL_FLOAT, false, 0, 0);
GLES20.glEnableVertexAttribArray(mShader.mVertexCoordHandler);
and this is a piece from my initial setup →
private void copyVertexCoordsToGPU() {
GLES20.glGenBuffers(1, mVertexCoordsVBO, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexCoordsVBO[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mDC.getVertices().capacity()*Float.SIZE/8, mDC.getVertices(), GLES20.GL_STATIC_DRAW);
}
Now, reading about the “glVertexAttribPointer” in the spec, it says “Also, the buffer object binding (GL_ARRAY_BUFFER_BINDING) is saved as generic vertex attribute array client-side state (GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING) for index index.”
spec http://www.khronos.org/opengles/sdk/docs/man/xhtml/glVertexAttribPointer.xml
Does this mean that I should be able to do it this way instead?
In the draw() →
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexCoordsVBO[0]);
// [i]GLES20.glVertexAttribPointer(mShader.mVertexCoordHandler, 3, GLES20.GL_FLOAT, false, 0, 0);[/i]
GLES20.glEnableVertexAttribArray(mShader.mVertexCoordHandler);
and in the init setup →
private void copyVertexCoordsToGPU() {
GLES20.glGenBuffers(1, mVertexCoordsVBO, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVertexCoordsVBO[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, mDC.getVertices().capacity()*Float.SIZE/8, mDC.getVertices(), GLES20.GL_STATIC_DRAW);
GLES20.glVertexAttribPointer(mShader.mVertexCoordHandler, 3, GLES20.GL_FLOAT, false, 0, 0);
}
It doesn’t work for me though…and the question is if this should be possible or if I have missunderstood something.
Thanks
Peter