Example usage for org.lwjgl.opengl GL30 glBindVertexArray

List of usage examples for org.lwjgl.opengl GL30 glBindVertexArray

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL30 glBindVertexArray.

Prototype

public static void glBindVertexArray(@NativeType("GLuint") int array) 

Source Link

Document

Binds a vertex array object

Usage

From source file:opengl.test.object.tivi.tivi.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);
    this.VertexAttribPointer();

    GL20.glEnableVertexAttribArray(0);// set index ve 0 
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, this.size);
    //GL11.glDrawElements(GL11.GL_TRIANGLES, this.indices.capacity(), GL11.GL_UNSIGNED_INT, 0);// capacity --> luon luon chua max
    //GL11./*from   ww w  . ja  v a 2  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.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);
    // delete vbo
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glDeleteBuffers(this.vbo);

    //delete vbo//from   w  ww.  j  ava  2  s .  com
    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./*from   w  w w .  ja v a  2 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./*w  w  w . ja v  a 2  s .  c om*/
    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:org.bonsaimind.badgersvoyage.opengl.RenderObject.java

License:Open Source License

public void render() {
    GL30.glBindVertexArray(vaoId);
    GL20.glEnableVertexAttribArray(0);

    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, verticesCount);
}