Example usage for org.lwjgl.opengl GL15 glBufferSubData

List of usage examples for org.lwjgl.opengl GL15 glBufferSubData

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL15 glBufferSubData.

Prototype

public static void glBufferSubData(@NativeType("GLenum") int target, @NativeType("GLintptr") long offset,
        @NativeType("void const *") double[] data) 

Source Link

Document

Array version of: #glBufferSubData BufferSubData

Usage

From source file:wrapper.vbo.Vbo.java

License:Open Source License

public void edit_data(ProgressiveBuffer[] b) {
    if (b[0].get_data() == null || b[1].get_data() == null) {
        return;//from   w w w  . j  a va  2  s  .co  m
    }
    vertex.clear();
    texture.clear();
    vertex = BufferUtils.createFloatBuffer(b[0].get_data().capacity());
    texture = BufferUtils.createFloatBuffer(b[1].get_data().capacity());
    b[0].get_data().rewind();
    b[1].get_data().rewind();
    vertex = b[0].get_data();
    texture = b[1].get_data();
    vertcount = b[0].get_data().capacity();

    vertex.rewind();
    texture.rewind();

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
    GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, vertex);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texcoordid);
    GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, texture);// doesnt
    // reassing
    // meaning its
    // more
    // efficient,
    // only for
    // removing
    // objects
}

From source file:wrapper.vbo.Vbo.java

License:Open Source License

public void clear_data() {
    vertex.clear();//from w w w  .  java 2s  .  c  o m
    texture.clear();
    vertex = BufferUtils.createFloatBuffer(vertcount);
    texture = BufferUtils.createFloatBuffer(vertcount);
    vertex.rewind();
    texture.rewind();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
    GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, vertex);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texcoordid);
    GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, texture);
    vertcount = 0;

}

From source file:wrapper.vbo.Vbo.java

License:Open Source License

public void rebind(int size) {

    FloatBuffer temp = BufferUtils.createFloatBuffer(size);
    FloatBuffer temp_tex = BufferUtils.createFloatBuffer(size);
    vertex.rewind();/*  w ww.  j av  a  2  s.c  o  m*/
    maxlength = size;
    texture.rewind();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);// clear and generate
    // two new memory
    // locations with a
    // large amount of space
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, temp, GL15.GL_DYNAMIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, temp_tex, GL15.GL_DYNAMIC_DRAW);
    // reassign the previous data to this , useful for string generation.
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
    GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, vertex);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texid);
    GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, texture);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

}