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:com.grillecube.engine.opengl.object.GLVertexArray.java

/** bind the given vertex buffer, and set it as an instanced attribute to the vertex array */
public void setAttributeInstanced(GLVertexBuffer vbo, int attributeID, int length, int type, boolean normalized,
        int stride, int offset) {

    vbo.bind(GL15.GL_ARRAY_BUFFER);
    this.setAttributeInstanced(attributeID, length, type, normalized, stride, offset);
    vbo.unbind(GL15.GL_ARRAY_BUFFER);/*from  www. ja  va 2s  .c  o m*/
}

From source file:com.grillecube.engine.opengl.object.GLVertexBuffer.java

/**
 * //  ww  w. j av a  2s .  c om
 * @param offset
 *            : buffer offset
 * @param floats_count
 *            : number of floats to get
 * @return
 */
public float[] getContent(int offset, int floats_count) {
    FloatBuffer buffer = BufferUtils.createFloatBuffer(floats_count);
    this.bind(GL15.GL_ARRAY_BUFFER);
    GL15.glGetBufferSubData(GL15.GL_ARRAY_BUFFER, offset, buffer);
    this.unbind(GL15.GL_ARRAY_BUFFER);
    float[] array = new float[floats_count];
    int i = 0;
    while (i < floats_count && buffer.hasRemaining()) {
        array[i] = buffer.get();
        ++i;
    }
    return (array);
}

From source file:com.grillecube.engine.renderer.gui.font.FontModel.java

private void initialize() {
    this._vao = GLH.glhGenVAO();
    this._vbo = GLH.glhGenVBO();

    this._vao.bind();
    {//from  w  ww  . j  a  va  2 s . c o m
        this._vbo.bind(GL15.GL_ARRAY_BUFFER);

        this._vao.setAttribute(0, 3, GL11.GL_FLOAT, false, (3 + 2 + 4) * 4, 0);
        this._vao.setAttribute(1, 2, GL11.GL_FLOAT, false, (3 + 2 + 4) * 4, 3 * 4);
        this._vao.setAttribute(2, 4, GL11.GL_FLOAT, false, (3 + 2 + 4) * 4, (3 + 2) * 4);

        this._vbo.unbind(GL15.GL_ARRAY_BUFFER);

        this._vao.enableAttribute(0);
        this._vao.enableAttribute(1);
        this._vao.enableAttribute(2);
    }
    this._vao.unbind();

    this.setState(FontModel.STATE_INITIALIZED);
}

From source file:com.grillecube.engine.renderer.gui.font.FontModel.java

/** update FontModel GLVertexBuffer vertices depending on 'this._text' */
private void updateText() {
    float[] vertices = this.generateFontBuffer(this._text);
    this._vbo.bind(GL15.GL_ARRAY_BUFFER);
    if (vertices != null) {
        this._vbo.bufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW);
        this._vertex_count = vertices.length / 5;
    } else {/*from ww  w  . jav  a  2s .  c o m*/
        this._vbo.bufferSize(GL15.GL_ARRAY_BUFFER, 0, GL15.GL_STATIC_DRAW);
        this._vertex_count = 0;
    }
    this.setState(FontModel.STATE_TEXT_UP_TO_DATE);
}

From source file:com.grillecube.engine.renderer.MainRenderer.java

private void initialiseDefaultVAO() {
    GLH.glhCheckError("pre default vao");

    this._default_vao = GLH.glhGenVAO();
    this._default_vbo = GLH.glhGenVBO();

    this._default_vao.bind();
    this._default_vbo.bind(GL15.GL_ARRAY_BUFFER);
    this._default_vao.enableAttribute(0);
    this._default_vao.setAttribute(0, 1, GL11.GL_FLOAT, false, 0, 0);

    float[] points = { 0 };
    this._default_vbo.bufferData(GL15.GL_ARRAY_BUFFER, points, GL15.GL_STATIC_DRAW);

    GLH.glhCheckError("post default vao");
}

From source file:com.grillecube.engine.renderer.model.ModelPart.java

/** initalize opengl vao / vbo */
private void prepare() {
    if (this._vao != null) {
        Logger.get().log(Level.ERROR, "Tried to prepare an already prepared model part: " + this.toString());
        return;/*w  w w .  j  av a2s . c  o  m*/
    }

    this._primitive_count = 0;
    this._vertex_count = 0;
    this._vao = GLH.glhGenVAO();
    this._vbo = GLH.glhGenVBO();
    this._vao.bind();
    this._vbo.bind(GL15.GL_ARRAY_BUFFER);
    this._vao.setAttribute(0, 3, GL11.GL_FLOAT, false, FLOAT_PER_MODEL_VERTEX * 4, 0); // pos
    this._vao.setAttribute(1, 3, GL11.GL_FLOAT, false, FLOAT_PER_MODEL_VERTEX * 4, 3 * 4); // normal
    this._vao.enableAttribute(0);
    this._vao.enableAttribute(1);
    this._vbo.unbind(GL15.GL_ARRAY_BUFFER);
    this._vao.unbind();
}

From source file:com.grillecube.engine.renderer.model.ModelPart.java

/** set modelaprt vertices, should only be called once ! */
public void setVertices(float[] vertices) {
    this._vbo.bind(GL15.GL_ARRAY_BUFFER);
    this._vbo.bufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW);
    this._vertex_count = vertices.length / ModelPart.FLOAT_PER_MODEL_VERTEX;
    this._primitive_count = this._vertex_count / 3;
}

From source file:com.grillecube.engine.renderer.model.ModelPart.java

/** set modelaprt vertices, should only be called once ! */
public void setVertices(FloatBuffer buffer) {
    this._vbo.bind(GL15.GL_ARRAY_BUFFER);
    this._vbo.bufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
    this._vertex_count = buffer.capacity() / ModelPart.FLOAT_PER_MODEL_VERTEX;
    this._primitive_count = this._vertex_count / 3;
}

From source file:com.grillecube.engine.renderer.model.ModelPartSkin.java

public void setVertices(float[] vertices) {
    if (this._vbo == null) {
        this._vbo = GLH.glhGenVBO();
    }//from  ww w.  j a  v a  2 s .c o m

    this._vbo.bind(GL15.GL_ARRAY_BUFFER);
    this._vbo.bufferData(GL15.GL_ARRAY_BUFFER, vertices, GL15.GL_STATIC_DRAW);
}

From source file:com.grillecube.engine.renderer.model.ModelPartSkin.java

public void setVertices(FloatBuffer buffer) {
    if (this._vbo == null) {
        this._vbo = GLH.glhGenVBO();
    }//from   ww  w . j a  va2 s  .c o m

    this._vbo.bind(GL15.GL_ARRAY_BUFFER);
    this._vbo.bufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
}