Example usage for org.lwjgl.opengl GL20 glDisableVertexAttribArray

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

Introduction

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

Prototype

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

Source Link

Document

Disables a generic vertex attribute array.

Usage

From source file:me.thehutch.fusion.engine.render.opengl.gl30.OpenGL30VertexArray.java

License:Open Source License

@Override
public void draw() {
    ensureCreated("VertexArray must be created to draw.");

    //Bind the vertex array object
    GL30.glBindVertexArray(vao);/*from  w  ww .  j  a va2 s  . c  o m*/

    // Enable the vertex attributes
    for (int i = 0; i < attributes.size(); ++i) {
        GL20.glEnableVertexAttribArray(i);
    }

    // Bind the index buffer
    GL15.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibo);
    // Draw the vertex elements
    GL11.glDrawElements(GL_TRIANGLES, drawCount, DataType.UNSIGNED_INT.getGLConstant(), 0L);
    // Unbind the index buffer
    GL15.glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

    // Disable the vertex attributes
    for (int i = 0; i < attributes.size(); ++i) {
        GL20.glDisableVertexAttribArray(i);
    }

    // Unbind the vertex array object
    GL30.glBindVertexArray(0);
}

From source file:model.ModelMD2.java

@Override
public void destroy() {
    //Delete VAO/*w  w  w  . j av a 2 s . c om*/
    GL30.glBindVertexArray(vao_id);
    {
        for (int i = 0; i < 6; i++) {
            GL20.glDisableVertexAttribArray(i);
        }

        //Delete VBOs
        GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
        for (int i = 0; i < frame_ids.length; i++) {
            GL15.glDeleteBuffers(frame_ids[i]);
        }
    }
    GL30.glBindVertexArray(0);
    GL30.glDeleteVertexArrays(vao_id);
    GL11.glDeleteTextures(tex_id);
}

From source file:model.ModelMD2.java

@Override
public void draw(float frame, float[] vpMatrix, float[] matrix, RenderEngine engine) {
    if (frame < 0 || frame > header.num_frames - 1)
        return;/*from  w w  w  .  j  a v  a2 s  .c om*/

    //Select current frame and next
    int frame_0 = frame_ids[(int) Math.floor(frame)];

    int frame_1 = frame_ids[(int) Math.min(Math.ceil(frame), header.num_frames - 1)];
    //Upload frame interpolation

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_id);

    ShaderUtils.useProgram(shader_id);
    {
        //Upload uniform values
        ShaderUtils.setUniformMatrix4(shader_id, "viewprojMatrix", vpMatrix);
        ShaderUtils.setUniformMatrix4(shader_id, "modelMatrix", matrix);
        ShaderUtils.setUniformVar(shader_id, "frame_interpolated", (float) (frame - Math.floor(frame)));
        //ShaderUtils.setUniformVar(shader_id, "cameraDir", engine.camera.yaw, engine.camera.pitch, engine.camera.roll);
        //Bind frames to VAO
        GL30.glBindVertexArray(vao_id);
        {

            GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, frame_0);//Bind frame 0
            {
                GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 32, 0);
                GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 32, 12);
                GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 32, 20);
            }
            GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

            GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, frame_1);//Bind frame 1
            {
                GL20.glVertexAttribPointer(3, 3, GL11.GL_FLOAT, false, 32, 0);
                GL20.glVertexAttribPointer(4, 2, GL11.GL_FLOAT, false, 32, 12);
                GL20.glVertexAttribPointer(5, 3, GL11.GL_FLOAT, false, 32, 20);
            }

            GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

            //Enable attribs and render
            for (int i = 0; i < 6; i++) {
                GL20.glEnableVertexAttribArray(i);
            }
            {
                GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, header.num_tris * 3);
            }
            for (int i = 0; i < 6; i++) {
                GL20.glDisableVertexAttribArray(i);
            }

        }
        GL30.glBindVertexArray(0);
    }
    ShaderUtils.useProgram(0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
}

From source file:Model.Render.java

public void render(Model model) {
    GL30.glBindVertexArray(model.getVaoID());
    GL20.glEnableVertexAttribArray(0);/*from w  ww .  j a  v a2s.  c om*/
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.getVertexCount());
    GL20.glDisableVertexAttribArray(0);
    GL30.glBindVertexArray(0);
}

From source file:net.neilcsmith.praxis.video.opengl.internal.ShaderProgram.java

License:Apache License

/** Disables the vertex attribute with the given name
 * //from w  w w  .  j  av  a2  s .c  o  m
 * @param name the vertex attribute name */
public void disableVertexAttribute(String name) {
    checkContext();
    int location = fetchAttributeLocation(name);
    if (location == -1)
        return;
    GL20.glDisableVertexAttribArray(location);
}

From source file:net.smert.frameworkgl.opengl.helpers.VertexArrayHelper.java

License:Apache License

public void disableVertexAttribArray(int index) {
    GL20.glDisableVertexAttribArray(index);
}

From source file:opengl.test.object.CaroTable.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();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);

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

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.cube.wall.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();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);

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

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glDrawElements(GL11.GL_TRIANGLE_STRIP, 6, GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

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

public void render(int status) {

    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 
    if (status == endgame.win)
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDWIN);
    else if (status == endgame.lose)
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDLOSE);
    else/* www.j av  a  2 s .com*/
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDDRAW);
    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.
    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}

From source file:opengl.test.object.image.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.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glDrawElements(GL11.GL_TRIANGLES, 6, GL11.GL_UNSIGNED_INT, 0);

    GL20.glDisableVertexAttribArray(0);// disable 

    GL30.glBindVertexArray(0);// unbind vao

    this.unbind();// dsiable program
}