Example usage for org.lwjgl.opengl GL15 glBufferData

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

Introduction

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

Prototype

public static void glBufferData(@NativeType("GLenum") int target, @NativeType("void const *") double[] data,
        @NativeType("GLenum") int usage) 

Source Link

Document

Array version of: #glBufferData BufferData

Usage

From source file:com.geekyaubergine.geekyjgameutil.model.ModelLoader.java

License:Open Source License

/**
 * Binds indices buffer for model/* w w  w  .  j a v a  2  s  .com*/
 * @param indicies Indices
 */
private static void bindIndicesBuffer(int[] indicies) {
    int vboID = GL15.glGenBuffers();
    vbos.add(vboID);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboID);
    IntBuffer buffer = storeDataInIntBuffer(indicies);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
}

From source file:com.github.begla.blockmania.rendering.manager.VertexBufferObjectManager.java

License:Apache License

public void bufferVboData(int id, FloatBuffer buffer, int drawMode) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, id);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, drawMode);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}

From source file:com.github.begla.blockmania.rendering.manager.VertexBufferObjectManager.java

License:Apache License

public void bufferVboElementData(int id, IntBuffer buffer, int drawMode) {
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, id);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, drawMode);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}

From source file:com.github.kajdreef.mazerunnermvn.Object.GameObject.java

protected void createVBO() {
    FloatBuffer verticesBuffer = BufferUtils.createFloatBuffer(vertices.length * Vertex.elementCount);
    for (int i = 0; i < vertices.length; i++) {
        verticesBuffer.put(vertices[i].getElements());
    }/* w ww  . j av a 2s . c o m*/
    verticesBuffer.flip();

    // Create the indices buffer and place the data in it.
    ByteBuffer indicesBuffer = BufferUtils.createByteBuffer(indicesData.length);
    indicesBuffer.put(indicesData);
    indicesBuffer.flip();

    // Initialize the VAO 
    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);

    // Initialize the VBO 
    vboVerticesId = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboVerticesId);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW);

    // Put the positions in attribute list 0
    GL20.glVertexAttribPointer(0, Vertex.positionElementCount, GL11.GL_FLOAT, false, Vertex.stride,
            Vertex.positionByteOffset);
    // Put the color components in attribute list 1
    GL20.glVertexAttribPointer(1, Vertex.colorElementCount, GL11.GL_FLOAT, false, Vertex.stride,
            Vertex.colorByteOffset);
    // Put the texture coordinates in attribute list 2
    GL20.glVertexAttribPointer(2, Vertex.textureElementCount, GL11.GL_FLOAT, false, Vertex.stride,
            Vertex.textureByteOffset);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    // Deselect the VAO
    GL30.glBindVertexArray(0);

    // Create a VBO for the indices.
    vboIndicesId = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboIndicesId);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_STATIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}

From source file:com.google.gapid.glviewer.gl.Buffer.java

License:Apache License

public Buffer loadData(float[] data) {
    this.size = data.length * 4;
    GL15.glBufferData(target, data, GL15.GL_STATIC_DRAW);
    return this;
}

From source file:com.google.gapid.glviewer.gl.Buffer.java

License:Apache License

public Buffer loadData(int[] data) {
    this.size = data.length * 4;
    GL15.glBufferData(target, data, GL15.GL_STATIC_DRAW);
    return this;
}

From source file:com.google.gapid.glviewer.gl.IndexBuffer.java

License:Apache License

IndexBuffer(Renderer owner, int[] data) {
    super(owner);
    this.handle = GL15.glGenBuffers();
    this.count = data.length;
    this.type = GL11.GL_UNSIGNED_INT;
    owner.register(this);

    bind();/*from w w w .  j a  v a 2s.c om*/
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);
}

From source file:com.google.gapid.glviewer.gl.VertexBuffer.java

License:Apache License

VertexBuffer(Renderer owner, float[] data, int elementsPerVertex) {
    super(owner);
    this.handle = GL15.glGenBuffers();
    this.elementsPerVertex = elementsPerVertex;
    this.vertexCount = data.length / elementsPerVertex;
    this.elementType = GL11.GL_FLOAT;
    owner.register(this);

    bind();/* w  w  w .j  a va2  s . co  m*/
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);
}

From source file:com.grillecube.client.opengl.GLVertexBuffer.java

/** set the vbo data */
public void bufferData(int target, ByteBuffer data, int usage) {
    if (data == null) {
        this.bufferSize(target, 0, GL15.GL_STREAM_DRAW);
        this.byteCount = 0;
    } else {/*  www.java  2s .c o  m*/
        GL15.glBufferData(target, data, usage);
        GL15.glBufferSubData(target, 0, data);
        this.byteCount = data.capacity();
    }
}

From source file:com.grillecube.client.opengl.GLVertexBuffer.java

/** set vbo size */
public void bufferSize(int target, long size, int usage) {
    GL15.glBufferData(target, size, usage);
}