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:ru.axialshift.vram.gl.IndicesVBO.java

License:Apache License

@Override
protected void unload_gl() {
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    super.unload_gl();
}

From source file:ru.axialshift.vram.gl.IndicesVBO.java

License:Apache License

public void draw() {
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, glpointer);
    GL11.glDrawElements(GL11.GL_TRIANGLES, indicesCount, GL11.GL_UNSIGNED_BYTE, 0);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}

From source file:ru.axialshift.vram.gl.VertexVBO.java

License:Apache License

@Override
protected void upload_gl() {
    //Allocation//from  ww w. j a  v  a  2 s .c o  m
    glpointer = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, glpointer);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, (FloatBuffer) tovram, GL15.GL_STATIC_DRAW);

    //Mapping
    int stride = 4 * (MeshData.VERTICES_STRIDE + MeshData.UVS_STRIDE + MeshData.NORMALS_STRIDE
            + MeshData.TANGENTS_STRIDE + MeshData.BITANGENTS_STRIDE);
    int offset = 0;
    //Vertices
    int bytesPerVertex = MeshData.VERTICES_STRIDE * 4;
    GL20.glVertexAttribPointer(id_pos, MeshData.VERTICES_STRIDE, GL11.GL_FLOAT, false, stride, offset);
    //UVs
    int bytesPerUVs = MeshData.UVS_STRIDE * 4;
    offset += bytesPerVertex;
    GL20.glVertexAttribPointer(id_uvs, MeshData.UVS_STRIDE, GL11.GL_FLOAT, false, stride, offset);
    //Normals
    int bytesPerNormals = MeshData.NORMALS_STRIDE * 4;
    offset += bytesPerUVs;
    GL20.glVertexAttribPointer(id_nor, MeshData.NORMALS_STRIDE, GL11.GL_FLOAT, false, stride, offset);
    //Tangents
    int bytesPerTangents = MeshData.TANGENTS_STRIDE * 4;
    offset += bytesPerNormals;
    GL20.glVertexAttribPointer(id_tan, MeshData.TANGENTS_STRIDE, GL11.GL_FLOAT, false, stride, offset);
    //BiTangents
    //int bytesPerBiTangents = MeshData.BITANGENTS_STRIDE*4;
    offset += bytesPerTangents;
    GL20.glVertexAttribPointer(id_btan, MeshData.BITANGENTS_STRIDE, GL11.GL_FLOAT, false, stride, offset);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}

From source file:ru.axialshift.vram.gl.VertexVBO.java

License:Apache License

@Override
protected void unload_gl() {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    super.unload_gl();
}

From source file:se.angergard.engine.graphics.Mesh.java

License:Apache License

public Mesh(long vertexBufferSize, long indicesBufferSize, int usage) {
    if (aMeshCreated) {
        new Exception("You can't create multiple meshes as of right now. This is due to a bug")
                .printStackTrace();//ww w  . j  a  v  a 2s .c o  m
    }

    vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBufferSize, usage);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    ibo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBufferSize, usage);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

    this.VERTEX_BUFFER_SIZE = vertexBufferSize;
    this.INDICES_BUFFER_SIZE = indicesBufferSize;

    this.INDICES_LENGTH = (int) indicesBufferSize / 4; // removes bytes

    aMeshCreated = true;
}

From source file:se.angergard.engine.graphics.Mesh.java

License:Apache License

public final void setVertices(FloatBuffer buffer) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
    GL15.glBufferSubData(GL15.GL_ARRAY_BUFFER, 0, buffer);
    // GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_DYNAMIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}

From source file:se.angergard.engine.graphics.Mesh.java

License:Apache License

public final void setIndices(IntBuffer buffer) {
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo);
    GL15.glBufferSubData(GL15.GL_ELEMENT_ARRAY_BUFFER, 0, buffer);
    // GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, buffer, GL15.GL_DYNAMIC_DRAW);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
}

From source file:se.angergard.engine.graphics.Mesh.java

License:Apache License

public void draw() {
    GL20.glEnableVertexAttribArray(0);/*  w  w  w.  j a v a 2s .  co  m*/
    GL20.glEnableVertexAttribArray(1);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vbo);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, ibo);

    GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, Vertex2D.SIZE_BYTES, 0);
    GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, Vertex2D.SIZE_BYTES, 8);
    GL11.glDrawElements(GL11.GL_TRIANGLES, INDICES_LENGTH, GL11.GL_UNSIGNED_INT, 0);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

    GL20.glDisableVertexAttribArray(0);
    GL20.glDisableVertexAttribArray(1);
}

From source file:thebounzer.org.lwgldemo.Chapter5.java

License:Open Source License

private void createAndBindVertexObject(float[] data) throws IOException {
    FloatBuffer fBuffer = BufferUtils.createFloatBuffer(data.length);
    fBuffer.put(data);//from   w w  w.ja v  a2  s .c o  m
    fBuffer.flip();
    int vboId = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, fBuffer, GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glBindBuffer(int a, int b) {
    GL15.glBindBuffer(a, b);
}