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: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   ww w .j ava  2s .  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  ww .  j a  v a2s  . c  o m*/
    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.j  a va2 s.c om*/
@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 ww. ja  v  a  2s  .com*/
 * @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);
}

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

License:Open Source License

/**
 * Binds the local texture vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_TEXTURE_COORD_ARRAY GL_TEXTURE_COORD_ARRAY} before 
 * you can use this method.//from w  w  w .  jav  a2 s.  com
 * @param textureHandler - The vertex buffered object texture handler
 * @param texturePointData - The number of points per texture data (i.e. 1-1D, 2-2D, 3-3D)
 * @param stride - The stride offset; used for interleaving data
 * @param offSet - initial offset for the data
 * @param dataType - The OpenGL dataType
 */
public static void texturePointer(int textureHandler, int texturePointData, int stride, int offSet,
        @GLDataType int dataType) {
    // bind color data
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, textureHandler);
    GL11.glTexCoordPointer(texturePointData, dataType, stride, offSet);
}

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

License:Open Source License

/**
 * Draws a vertex buffered object; Uses redundant vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_VERTEX_ARRAY GL_VERTEX_ARRAY} before 
 * you can use this method.//from   w w  w  . j  a va2s . co  m
 * @param vertexHandler - The vertex buffered object vertex handler
 * @param vertexPointData - The number of points per vertex data (i.e. 1-1D, 2-2D, 3-3D)
 * @param vertexNumber - The number of vertices
 * @param first - The start point of the array
 * @param stride - The stride offset; used for interleaving data
 * @param offSet - initial offset for the data
 * @param dataType - The OpenGL dataType
 * @param beginMode - The OpenGL begin mode
 */
public static void drawVboArrays(int vertexHandler, int vertexPointData, int vertexNumber, int first,
        int stride, int offSet, @GLDataType int dataType, @BeginMode int beginMode) {
    // bind vertex data
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexHandler);
    GL11.glVertexPointer(vertexPointData, dataType, stride, offSet);
    // Draw vertex buffer object
    GL11.glDrawArrays(beginMode, first, vertexNumber);
}