Example usage for org.lwjgl.opengl GL15 glBindBuffer

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

Introduction

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

Prototype

public static void glBindBuffer(@NativeType("GLenum") int target, @NativeType("GLuint") int buffer) 

Source Link

Document

Binds a named buffer object.

Usage

From source file:net.neilcsmith.praxis.video.opengl.internal.VertexBufferObject.java

License:Apache License

/** Binds this VertexBufferObject for rendering via glDrawArrays or glDrawElements
 * /*from  ww  w .  j  a  v a2 s  . co m*/
 * @param shader the shader */
public void bind(ShaderProgram shader) {

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferHandle);
    if (isDirty) {
        byteBuffer.limit(buffer.limit() * 4);
        GL15.glBufferData(GL15.GL_ARRAY_BUFFER, byteBuffer, usage);
        isDirty = false;
    }

    int numAttributes = attributes.size();
    for (int i = 0; i < numAttributes; i++) {
        VertexAttribute attribute = attributes.get(i);
        shader.enableVertexAttribute(attribute.alias);
        int colorType = GL11.GL_FLOAT;
        boolean normalize = false;
        if (attribute.usage == VertexAttributes.Usage.ColorPacked) {
            colorType = GL11.GL_UNSIGNED_BYTE;
            normalize = true;
        }
        shader.setVertexAttribute(attribute.alias, attribute.numComponents, colorType, normalize,
                attributes.vertexSize, attribute.offset);
    }
    isBound = true;
}

From source file:net.neilcsmith.praxis.video.opengl.internal.VertexBufferObject.java

License:Apache License

/** Unbinds this VertexBufferObject.
 * //from ww w .  j  a  va  2 s  .co  m
 * @param shader the shader */
public void unbind(ShaderProgram shader) {
    int numAttributes = attributes.size();
    for (int i = 0; i < numAttributes; i++) {
        VertexAttribute attribute = attributes.get(i);
        shader.disableVertexAttribute(attribute.alias);
    }
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    isBound = false;
}

From source file:net.neilcsmith.praxis.video.opengl.internal.VertexBufferObject.java

License:Apache License

/** Disposes of all resources this VertexBufferObject uses. */
public void dispose() {
    tmpHandle.clear();//  w w w .  j  a  v a2 s .  c  o m
    tmpHandle.put(bufferHandle);
    tmpHandle.flip();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(tmpHandle);
    bufferHandle = 0;

}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindColors(int vboID, int size, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL11.glColorPointer(size, type, strideBytes, offsetBytes);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindNormals(int vboID, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL11.glNormalPointer(type, strideBytes, offsetBytes);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindVertexAttrib(int vboID, int index, int size, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL20.glVertexAttribPointer(index, size, type, false, strideBytes, offsetBytes);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindVertexAttribNormalized(int vboID, int index, int size, int type, int strideBytes,
        int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL20.glVertexAttribPointer(index, size, type, true, strideBytes, offsetBytes);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindVertices(int vboID, int size, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL11.glVertexPointer(size, type, strideBytes, offsetBytes);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindVerticesIndex(int vboID) {
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, vboID);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexBufferObjectHelper.java

License:Apache License

public void bindTexCoords(int vboID, int size, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL11.glTexCoordPointer(size, type, strideBytes, offsetBytes);
}