Example usage for org.lwjgl.opengl GL20 glVertexAttribPointer

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

Introduction

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

Prototype

public static void glVertexAttribPointer(@NativeType("GLuint") int index, @NativeType("GLint") int size,
        @NativeType("GLenum") int type, @NativeType("GLboolean") boolean normalized,
        @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) 

Source Link

Document

Specifies the location and organization of a vertex attribute array.

Usage

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

License:Apache License

public void bindVertexAttribNormalized(int index, int size, int type, ByteBuffer byteBuffer) {
    GL20.glVertexAttribPointer(index, size, type, true, 0, byteBuffer);
}

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

License:Apache License

public void bindVertexAttrib(int vboID, int index, int size, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL20.glVertexAttribPointer(index, size, type, false, strideBytes, offsetBytes);
}

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

License:Apache License

public void bindVertexAttribNormalized(int vboID, int index, int size, int type, int strideBytes,
        int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL20.glVertexAttribPointer(index, size, type, true, strideBytes, offsetBytes);
}

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

/**
 * Method nay duoc tach rieng ra tu initVertex 
 * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer
 *//*  w ww . j av  a  2  s  .co  m*/
@Override
protected void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 8 * 4, 0);// float size = 4 byte --> next is 3*4 byte
    // size = 3 --> position = x,y,z vec3

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 8 * 4, 3 * 4);
    // size = 3 --> vec3

    int texcoordID = GL20.glGetAttribLocation(programID, "texcoord");
    GL20.glEnableVertexAttribArray(texcoordID);
    GL20.glVertexAttribPointer(texcoordID, 2, GL11.GL_FLOAT, false, 8 * 4, 6 * 4);
    // size = 2 --> vec2
}

From source file:opengl.test.object.cube.wall.java

@Override
protected void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 8 * 4, 0);// float size = 4 byte --> next is 3*4 byte
    // size = 3 --> position = x,y,z vec3

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 8 * 4, 3 * 4);
    // size = 3 --> vec3

    int texcoordID = GL20.glGetAttribLocation(programID, "texcoord");
    GL20.glEnableVertexAttribArray(texcoordID);
    GL20.glVertexAttribPointer(texcoordID, 2, GL11.GL_FLOAT, false, 8 * 4, 6 * 4);
    // size = 2 --> vec2
}

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

/**
 * Method nay duoc tach rieng ra tu initVertex 
 * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer
 *///from ww  w . j  av a  2 s.co  m
@Override
protected void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 8 * 4, 0);// float size = 4 byte --> next is 3*4 byte
    // size = 3 --> position = x,y,z vec3

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 8 * 4, 3 * 4);
    // size = 3 --> vec3

    int texcoordID = GL20.glGetAttribLocation(programID, "texcoord");
    GL20.glEnableVertexAttribArray(texcoordID);
    GL20.glVertexAttribPointer(texcoordID, 2, GL11.GL_FLOAT, false, 8 * 4, 6 * 4);
    // size = 2 --> vec2

}

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

@Override
protected void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 6 * 4, 0);// float size = 4 byte --> next is 3*4 byte

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 6 * 4, 3 * 4);
}

From source file:opengl.test.object.tree.testobject.leaf.java

/**
 * Method nay duoc tach rieng ra tu initVertex 
 * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer
 *//*from w w  w .  j a  va2 s . com*/
private void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 6 * 4, 0);// float size = 4 byte --> next is 3*4 byte
    // size = 3 --> position = x,y,z vec3

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 6 * 4, 3 * 4);
    // size = 3 --> vec3

}

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

/**
 * Method nay duoc tach rieng ra tu initVertex 
 * Vi render nhieu doi tuong neu dung Multi vbo --> truoc khi draw phai bind lai vbo --> moi lan bind lai se phai set lai VertexAttribPointer
 *///from w  ww .ja v a 2 s.  com
@Override
protected void VertexAttribPointer() {
    if (this.vbo == 0)
        throw new RuntimeException("Chua khoi tao VBO");

    int positionID = GL20.glGetAttribLocation(programID, "position");
    GL20.glEnableVertexAttribArray(positionID);
    GL20.glVertexAttribPointer(positionID, 3, GL11.GL_FLOAT, false, 6 * 4, 0);// float size = 4 byte --> next is 3*4 byte
    // size = 3 --> position = x,y,z vec3

    int colorID = GL20.glGetAttribLocation(programID, "color");
    GL20.glEnableVertexAttribArray(colorID);
    GL20.glVertexAttribPointer(colorID, 3, GL11.GL_FLOAT, false, 6 * 4, 3 * 4);
    // size = 3 --> vec3

}

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

License:Open Source License

protected void createOpenGL(int programId) {
    modelMatrix = new Matrix4f();
    modelMatrixLocation = GL20.glGetUniformLocation(programId, "modelMatrix");
    modelMatrixBuffer = BufferUtils.createFloatBuffer(16);

    verticesCount = vertices.length / 3;

    verticesBuffer = BufferUtils.createFloatBuffer(vertices.length);
    verticesBuffer.put(vertices);/*from  www  . j ava 2 s . com*/
    verticesBuffer.flip();

    vaoId = GL30.glGenVertexArrays();
    GL30.glBindVertexArray(vaoId);

    vboId = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboId);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, verticesBuffer, GL15.GL_STATIC_DRAW);
    GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 0, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    GL30.glBindVertexArray(0);
}