title: JOGL. OpenGL. How to update a VBO?
body: <p>The idea - to draw some line by the code like:</p>
  
  <pre><code>gl.glBindBuffer(GL_ARRAY_BUFFER, line.getVertexOpenGLArray());
  
  gl.glVertexAttribPointer(VERTEX_INDEX, 3, GL_FLOAT, false, 0, 0);
  
  gl.glEnableVertexAttribArray(VERTEX_INDEX);
  
  gl.glEnable(GL_DEPTH_TEST);
  gl.glDepthFunc(GL_LEQUAL);
  gl.glFrontFace(GL_CCW);
  
  gl.glDrawArrays(GL_LINES, 0, line.getVertices().length);
  </code></pre>
  
  <p>When <code>line.getVertexOpenGLArray()</code> returns the VBO object index that was generated by:</p>
  
  <pre><code>        FloatBuffer vertBuf = Buffers.newDirectFloatBuffer(pvalues);
          gl.glBufferData(GL_ARRAY_BUFFER, vertBuf.limit() * 4, vertBuf, GL_STATIC_DRAW);
  </code></pre>
  
  <p>pvalues is the <code>float[6] {x1,y1,z1,x2,y2,z2}</code> contains coordinates of two vertexes of this line.</p>
  
  <p>Then I try to change the second vertex in VBO by:</p>
  
  <pre><code>        FloatBuffer line_buf = Buffers.newDirectFloatBuffer(new_vertexes); 
  
          gl.glBufferSubData(GL_ARRAY_BUFFER, 0, line_buf.limit() * 4, line_buf);
          Buffer f = Buffers.newDirectFloatBuffer(line_vertexes);
  
          gl.glGetBufferSubData(GL_ARRAY_BUFFER, 0, line_buf.limit() * 4, f);
  
          System.out.println("Vertexes: " +
                  ((FloatBuffer) f).get() + ", "+
                  ((FloatBuffer) f).get() + ", "+
                  ((FloatBuffer) f).get() + ", "+
                  ((FloatBuffer) f).get() + ", "+
                  ((FloatBuffer) f).get() + ", "+
                  ((FloatBuffer) f).get());
  </code></pre>
  
  <p>And it report that values was changed successfuly. But when I render the next frame I see that line placed by old vertexes coordinates.</p>
  
  <p>I tried to use gl.glInvalidateBufferData(vbo[VERTEX_INDEX]); but same result.</p>
  
  <p>Is there some cache or something?</p>