I don't understand why one of my vbo is overwritten by another
Posted
by
Alays
on Game Development
See other posts from Game Development
or by Alays
Published on 2014-06-04T17:24:32Z
Indexed on
2014/06/04
21:45 UTC
Read the original article
Hit count: 242
to create a vbo I use this function:
public void loadVBO(){
vboID = GL15.glGenBuffers();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buf, GL15.GL_STATIC_DRAW);
// Put the position coordinates in attribute list 0
GL20.glVertexAttribPointer(0, 4, GL11.GL_FLOAT,
false,4*4+4*4+4*4+2*4 , 0);
// Put the color components in attribute list 1
GL20.glVertexAttribPointer(1, 4, GL11.GL_FLOAT,
false,4*4+4*4+4*4+2*4 , 4*4);
GL20.glVertexAttribPointer(2, 4, GL11.GL_FLOAT,
false,4*4+4*4+4*4+2*4 , 4*4+4*4);
// Put the texture coordinates in attribute list 2
GL20.glVertexAttribPointer(3, 4, GL11.GL_FLOAT,
false,4*4+4*4+4*4+2*4 , 4*4+4*4+4*4);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
to display a vbo I use this function:
public void displayVBO(){
GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboID);
GL20.glEnableVertexAttribArray(0);
GL20.glEnableVertexAttribArray(1);
GL20.glEnableVertexAttribArray(2);
GL20.glEnableVertexAttribArray(3);
GL11.glDrawArrays(GL_TRIANGLES, 0, buf.capacity());
GL20.glDisableVertexAttribArray(0);
GL20.glDisableVertexAttribArray(1);
GL20.glDisableVertexAttribArray(2);
GL20.glDisableVertexAttribArray(3);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
So when I call map.loadVBO() and then ocean.loadVBO(), I think the second call overwrite the first vbo I don't know how ...
When I call map.display() and ocean.display(), I have the ocean draw 2 times ....
Thanks.
© Game Development or respective owner