Example usage for org.lwjgl.opengl GL15 GL_ARRAY_BUFFER

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

Introduction

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

Prototype

int GL_ARRAY_BUFFER

To view the source code for org.lwjgl.opengl GL15 GL_ARRAY_BUFFER.

Click Source Link

Document

Accepted by the target parameters of BindBuffer, BufferData, BufferSubData, MapBuffer, UnmapBuffer, GetBufferSubData, GetBufferParameteriv, and GetBufferPointerv.

Usage

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.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  w  w  .  j a  v  a2s.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.github.kajdreef.mazerunnermvn.Object.GameObject.java

public void destroy() {
    // Disable the VBO index from the VAO attributes list
    GL20.glDisableVertexAttribArray(0);/*from w  ww .  j a v  a  2 s.  c  o m*/

    // Delete the vertex VBO
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboVerticesId);

    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(vboIndicesId);

    // Delete the VAO
    GL30.glBindVertexArray(0);
    GL30.glDeleteVertexArrays(vaoId);
}

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 v a 2  s . com
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);
}

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

License:Apache License

void bind() {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, handle);
}

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

/** set VertexArray attribute depending on bounded VertexBuffer */
public void setAttributei(GLVertexBuffer vbo, int index, int size, int type, int stride, long pointer) {
    vbo.bind(GL15.GL_ARRAY_BUFFER);
    GL30.glVertexAttribIPointer(index, size, type, stride, pointer);
    //      vbo.unbind(GL15.GL_ARRAY_BUFFER);
}

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

/** bind the given VertexBuffer and set the attribute in the VertexArray */
public void setAttribute(GLVertexBuffer vbo, int attributeID, int length, int type, boolean normalized,
        int stride, int offset) {
    vbo.bind(GL15.GL_ARRAY_BUFFER);
    this.setAttribute(attributeID, length, type, normalized, stride, offset);
    //      vbo.unbind(GL15.GL_ARRAY_BUFFER);
}

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

/** bind the given VertexBuffer and set the attribute in the VertexArray */
public void setAttribute(float[] floats, int attributeID, int length, int type, boolean normalized, int stride,
        int offset) {
    GLVertexBuffer vbo = GLH.glhGenVBO();
    vbo.bind(GL15.GL_ARRAY_BUFFER);
    vbo.bufferData(GL15.GL_ARRAY_BUFFER, floats, GL15.GL_STATIC_DRAW);
    this.setAttribute(attributeID, length, type, normalized, stride, offset);
    //      vbo.unbind(GL15.GL_ARRAY_BUFFER);
}

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

/**
 * bind the given vertex buffer, and set it as an instanced attribute to the
 * vertex array/*from   w  w w.jav  a  2 s  .c  o m*/
 */
public void setAttributeInstanced(GLVertexBuffer vbo, int attributeID, int length, int type, boolean normalized,
        int stride, int offset) {

    vbo.bind(GL15.GL_ARRAY_BUFFER);
    this.setAttributeInstanced(attributeID, length, type, normalized, stride, offset);
    //      vbo.unbind(GL15.GL_ARRAY_BUFFER);
}

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

/**
 * /*from   w ww  . jav a2 s  .  c om*/
 * @param offset
 *            : buffer offset
 * @param floats_count
 *            : number of floats to get
 * @return
 */
public ByteBuffer getContent(int offset, int byteCount) {
    ByteBuffer buffer = BufferUtils.createByteBuffer(byteCount);
    this.bind(GL15.GL_ARRAY_BUFFER);
    GL15.glGetBufferSubData(GL15.GL_ARRAY_BUFFER, offset, buffer);
    //      this.unbind(GL15.GL_ARRAY_BUFFER);
    return (buffer);
}