Example usage for org.lwjgl.opengl GL20 glEnableVertexAttribArray

List of usage examples for org.lwjgl.opengl GL20 glEnableVertexAttribArray

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL20 glEnableVertexAttribArray.

Prototype

public static void glEnableVertexAttribArray(@NativeType("GLuint") int index) 

Source Link

Document

Enables a generic vertex attribute array.

Usage

From source file:uk.co.ifs_studios.engine.geometry.BasicDrawElement.java

License:Open Source License

/**
 * Render DrawElement.//  w  w  w  .ja v  a 2 s.  c o m
 */
public void render() {
    this.shader.getShaderProgram().use();

    Engine.getInstance().getWindow().getProjectionMatrix().store(this.matrixBuffer);
    this.matrixBuffer.flip();
    GL20.glUniformMatrix4(this.shader.getProjectionMatrixLocation(), false, this.matrixBuffer);

    Engine.getInstance().getGame().getCurrentState().getCamera().getViewMatrix().store(this.matrixBuffer);
    this.matrixBuffer.flip();
    GL20.glUniformMatrix4(this.shader.getViewMatrixLocation(), false, this.matrixBuffer);

    this.modelMatrix.store(this.matrixBuffer);
    this.matrixBuffer.flip();
    GL20.glUniformMatrix4(this.shader.getModelMatrixLocation(), false, this.matrixBuffer);

    GL30.glBindVertexArray(this.vao);
    GL20.glEnableVertexAttribArray(0);
    GL20.glEnableVertexAttribArray(1);

    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ibo);

    GL11.glDrawElements(GL11.GL_TRIANGLES, this.indiceCount, GL11.GL_UNSIGNED_BYTE, 0);

    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);

    this.shader.getShaderProgram().unuse();
}

From source file:vertigo.graphics.lwjgl.LWJGLAttribute.java

License:Open Source License

public void bindVBO(ArrayList<BO> buffer, int i) {
    for (BO bo : buffer) {
        VBO vbo = (VBO) bo;//w  w  w. jav a  2 s  . c  o  m
        if (compare(vbo)) {

            GL20.glGetAttribLocation(this.handle, name);
            GL20.glEnableVertexAttribArray(i); //set the vertex's position

            //  GL20.glenableVertexAttribArray(shaderProgram.vertexPositionAttribute);
            GL20.glVertexAttribPointer(i, vbo.capacity(), false, getSize(name), vbo.getFloatBuffer());
            ShaderUtils.useShader(this.handle);
        }
    }

}

From source file:vertigo.graphics.lwjgl.LWJGL_Renderer.java

License:Open Source License

private void drawShape(Shape obj) {
    // Geometry: VBO and IBO
    if (obj.isDirty(Node.VBO)) {
        processBO(obj);/*from   www  .j a v a 2s  .  c  o m*/
        obj.setDirty(Node.VBO, false);
    }

    ShaderProg glshader = obj.getMaterial().getShaderMaterial();
    GL20.glUseProgram(glshader.getHandle());

    updateUniform();
    VBO vbo = null;

    for (Attribute attrib : attribute) {
        if (vbo.getType().equals(attrib.getType())) {
            int alocation = GL20.glGetAttribLocation(glshader.getHandle(), attrib.getName());
            GL20.glEnableVertexAttribArray(alocation);
            GL20.glVertexAttribPointer(alocation, attrib.getSize(), GL11.GL_FLOAT, false, vbo.getStride() << 2,
                    0L);
        }
    }

    if (isIndexed) {
        // draw with index
        GL11.glDrawElements(getOpenGLStyle(obj.getDrawingStyle()), /* elements */ ibo.getSize(),
                GL_UNSIGNED_INT, 0L);
        GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        GL20.glDisableVertexAttribArray(0);
    } else {
        // draw without index
        GL11.glDrawArrays(getOpenGLStyle(obj.getDrawingStyle()), 0, capacity / vbo3f.getStride());
        GL20.glDisableVertexAttribArray(0);
        GL30.glBindVertexArray(0);
    }

    GL20.glUseProgram(0);
}

From source file:wrapper.vbo.Vbo.java

License:Open Source License

public void render() {
    if (vertid != -1) {

        shader.bind();/*from  w  w w. j  ava2  s .  c  o m*/
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texid);
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
        GL20.glEnableVertexAttribArray(vertexattrib);
        GL20.glEnableVertexAttribArray(textureattrib);
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertid);
        GL20.glVertexAttribPointer(vertexattrib, 3, GL11.GL_FLOAT, false, 0, 0);
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, texcoordid);
        GL20.glVertexAttribPointer(textureattrib, 2, GL11.GL_FLOAT, false, 0, 0);
        GL20.glUniform3f(rotationuniform, rotation_x, rotation_y, rotation_z);
        GL20.glUniform3f(transformuniform, transformation.x, transformation.y, transformation.z);
        GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, vertcount);

        GL20.glDisableVertexAttribArray(vertexattrib);
        GL20.glDisableVertexAttribArray(textureattrib);

        GL11.glEnable(GL11.GL_BLEND);
        shader.unbind();
    } else {

        System.out.println("Error no bound vertid");
        return;
    }

}

From source file:wrath.client.graphics.Model.java

License:Open Source License

@Override
public void renderSetup() {
    GL30.glBindVertexArray(vao);//from  w ww . jav  a 2s.  c  o  m
    GL20.glEnableVertexAttribArray(VERTICIES_ATTRIB_INDEX);
    GL20.glEnableVertexAttribArray(NORMALS_ATTRIB_INDEX);
    if (texture != null) {
        GL20.glEnableVertexAttribArray(TEXTURE_ATTRIB_INDEX);
        texture.bindTexture();
    }

    if (shader != null) {
        shader.updateViewMatrix();
        shader.bindShader();
    }
}