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:opengl.test.object.tree.testobject.leaf.java

public void deleteProgram() {
    // disable program
    this.unbind();

    // detach shader
    GL20.glDetachShader(this.programID, this.vertexID);
    GL20.glDetachShader(this.programID, this.fragmentID);
    // delete shader
    GL20.glDeleteShader(this.vertexID);
    GL20.glDeleteShader(this.fragmentID);
    GL20.glDeleteProgram(this.programID);

    // delete vao
    GL30.glBindVertexArray(0);//from   ww w . ja v  a  2 s  .c  om
    // delete vbo
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(this.vbo);

    //delete vbo
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(this.ebo);

}

From source file:opengl.test.object.tree.testobject.leaf.java

private void initVertex() {
    GL30.glBindVertexArray(vao);//bind vao  

    this.VertexColorBuffer = objLoad.VertexColorLoad(
            leaf.class.getClassLoader().getResourceAsStream("opengl/test/object/tree/leaf.obj"));

    Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity  : " + VertexColorBuffer.capacity());

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexColorBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    this.indices = objLoad
            .indicesLoad(leaf.class.getClassLoader().getResourceAsStream("opengl/test/object/tree/leaf.obj"));

    this.ebo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_DYNAMIC_DRAW);

    GL30.glBindVertexArray(0);//unbind vao
}

From source file:opengl.test.object.tree.testobject.leaf.java

public void render() {

    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    this.VertexAttribPointer();

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max
    //GL11.//  w w  w .j ava2 s. c  o  m
    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.tree.testobject.traicay.java

private void initVertex() {
    GL30.glBindVertexArray(vao);//bind vao  

    this.VertexColorBuffer = objLoad.VertexColorLoad(
            traicay.class.getClassLoader().getResourceAsStream("opengl/test/object/tree/fruit.obj"));

    Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity  : " + VertexColorBuffer.capacity());

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexColorBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    this.indices = objLoad.indicesLoad(
            traicay.class.getClassLoader().getResourceAsStream("opengl/test/object/tree/fruit.obj"));

    this.ebo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_DYNAMIC_DRAW);

    GL30.glBindVertexArray(0);//unbind vao
}

From source file:opengl.test.object.tree.testobject.trunk.java

private void initVertex() {
    GL30.glBindVertexArray(vao);//bind vao  

    this.VertexColorBuffer = objLoad.VertexColorLoad(
            trunk.class.getClassLoader().getResourceAsStream("opengl/test/object/tree/trunk.obj"));

    Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity  : " + VertexColorBuffer.capacity());

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexColorBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    this.indices = objLoad
            .indicesLoad(trunk.class.getClassLoader().getResourceAsStream("opengl/test/object/tree/trunk.obj"));

    this.ebo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_DYNAMIC_DRAW);

    GL30.glBindVertexArray(0);//unbind vao
}

From source file:opengl.test.object.XO.java

private void initVertexX() {
    GL30.glBindVertexArray(vao);//bind vao  

    this.VertexColorBuffer = objLoad
            .VertexColorLoad(XO.class.getClassLoader().getResourceAsStream("opengl/test/object/X.obj"));

    Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity  : " + VertexColorBuffer.capacity());

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexColorBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    this.indices = objLoad
            .indicesLoad(XO.class.getClassLoader().getResourceAsStream("opengl/test/object/X.obj"));

    this.ebo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_DYNAMIC_DRAW);

    GL30.glBindVertexArray(0);//unbind vao
}

From source file:opengl.test.object.XO.java

private void initVertexO() {
    GL30.glBindVertexArray(vao);//bind vao  

    this.VertexColorBuffer = objLoad
            .VertexColorLoad(XO.class.getClassLoader().getResourceAsStream("opengl/test/object/O.obj"));

    Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity  : " + VertexColorBuffer.capacity());

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, VertexColorBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    this.indices = objLoad
            .indicesLoad(XO.class.getClassLoader().getResourceAsStream("opengl/test/object/O.obj"));

    this.ebo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indices, GL15.GL_DYNAMIC_DRAW);

    GL30.glBindVertexArray(0);//unbind vao
}

From source file:opengl.test.object.XO.java

@Override
public void render() {

    this.bind();// use porgrma --> ket thuc disable program

    GL30.glBindVertexArray(this.vao);// bind vao -- > unbind vao
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    this.VertexAttribPointer();

    GL20.glEnableVertexAttribArray(0);// set index ve 0 

    GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max
    //GL11./* ww  w. j a  va2 s .c om*/
    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:org.ajgl.graphics.VertexBufferedObject.java

License:Open Source License

/**
 * Creates a vertex buffer object handler.
 * @param drawMode - The OpenGL draw mode of the object.
 * @param vertices - The vertices of the object
 * @return The int value of the handler. 
 *//*  w w w . java  2s. co  m*/
@OpenGLInfo(fwdCompatible = false, openGLVersion = "1.5", status = "Release")
public static int createVboHandler(@DrawMode int drawMode, FloatBuffer vertices) {
    // Initialize vertex VBO handler
    int handler = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, handler);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertices, drawMode);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    return handler;
}

From source file:org.ajgl.graphics.VertexBufferedObject.java

License:Open Source License

/**
 * Binds the color vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_COLOR_ARRAY GL_COLOR_ARRAY} before 
 * you can use this method./*w w w  . jav a2 s  .  co  m*/
 * @param colorHandler - The vertex buffered object color handler
 * @param colorPointData - The number of points per color data (i.e. 3-RGB, 4-RGBA)
 * @param stride - The stride offset; used for interleaving data
 * @param offSet - initial offset for the data
 * @param dataType - The OpenGL dataType
 */
public static void colorPointer(int colorHandler, int colorPointData, int stride, int offSet,
        @GLDataType int dataType) {
    // bind color data
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorHandler);
    GL11.glColorPointer(colorPointData, dataType, stride, offSet);
}