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);
            GL11.glDrawArrays(GL_TRIANGLES, 0, buf.capacity());
            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 ....


  • \$\begingroup\$ Few questions: Are vboID and buf class member variables? Not static? And are there different data loaded in buf for map and for ocean? \$\endgroup\$
    – zacharmarz
    Jun 4, 2014 at 18:13
  • \$\begingroup\$ Why are you binding your VBO before drawing? The only time that needs to be bound is immediately before you call glVertexAttribPointer (...) since the object bound to GL_ARRAY_BUFFER at the time you call that function is where the pointer is relative to. You are not using glDrawElements (...) so there is no need to bind anything to GL_ELEMENT_ARRAY_BUFFER either. I think you either want to setup the vertex pointers everytime you draw or use a VAO. \$\endgroup\$ Jun 5, 2014 at 0:38

1 Answer 1



This line only makes sense if you replace GL_ELEMENT_ARRAY_BUFFER with GL_ARRAY_BUFFER, since you used vboID as an ARRAY_BUFFER to upload data to it in your loadVBO function.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .