Example usage for org.lwjgl.opengl GL11 glVertexPointer

List of usage examples for org.lwjgl.opengl GL11 glVertexPointer

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glVertexPointer.

Prototype

public static void glVertexPointer(@NativeType("GLint") int size, @NativeType("GLenum") int type,
        @NativeType("GLsizei") int stride, @NativeType("void const *") FloatBuffer pointer) 

Source Link

Document

Specifies the location and organization of a vertex array.

Usage

From source file:view.renderer.GridRenderer.java

public void draw() {

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vID);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vB, GL15.GL_STATIC_DRAW);
    GL11.glVertexPointer(2, GL11.GL_INT, 2 * 4, 0L);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, cID);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, cB, GL15.GL_STATIC_DRAW);
    GL11.glColorPointer(3, GL11.GL_FLOAT, 3 * 4, 0L);

    GL11.glDrawArrays(GL11.GL_QUADS, 0, (linesX + linesY) * 4);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
}

From source file:voxicity.ChunkNode.java

License:Open Source License

public void render(Frustum camera) {
    if (empty)/*from   w  w w .  ja  v  a2s. c o m*/
        return;

    AABB chunk_box = new AABB(Constants.Chunk.side_length, Constants.Chunk.side_length,
            Constants.Chunk.side_length);

    chunk_box.center_on(chunk.get_x() + chunk_box.dimensions().x, chunk.get_y() + chunk_box.dimensions().y,
            chunk.get_z() + chunk_box.dimensions().z);

    if (!camera.collides(chunk_box))
        return;

    Renderer.draw_calls++;

    if (shader_prog != 0)
        GL20.glUseProgram(shader_prog);

    // Bind VBO to vertex pointer
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vert_buf);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

    // Bind the texture coord VBO to texture pointer
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tex_buf);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

    int tex_bak = GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D);

    for (Batch batch : batches) {
        // Bind the texture for this batch
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, batch.tex);

        // Bind index array
        GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, batch.indices);

        // Draw the block
        GL12.glDrawRangeElements(GL11.GL_QUADS, 0, Constants.Chunk.block_number * 24 - 1, batch.num_elements,
                GL11.GL_UNSIGNED_INT, 0);

        Renderer.batch_draw_calls++;
        Renderer.quads += batch.num_elements;
    }

    // Unbind the texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_bak);

    // Unbind all buffers
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    // Disable the shader once more
    if (shader_prog != 0)
        GL20.glUseProgram(0);
}

From source file:voxicity.Renderer.java

License:Open Source License

private void render_batch(ChunkNode.Batch batch) {
    if (!camera.collides(batch.box))
        return;// w ww  . j  a va  2 s  .  c o  m

    Renderer.draw_calls++;

    // Use the shader the batch needs
    GL20.glUseProgram(batch.shader);

    // Bind VBO to vertex pointer
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, batch.vert_buf);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

    // Bind the texture coord VBO to texture pointer
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, batch.tex_buf);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

    // Bind the texture for this batch
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, batch.tex);

    // Bind index array
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, batch.indices);

    // Draw the block
    GL12.glDrawRangeElements(GL11.GL_QUADS, 0, Constants.Chunk.block_number * 24 - 1, batch.num_elements,
            GL11.GL_UNSIGNED_INT, 0);

    Renderer.batch_draw_calls++;
    Renderer.quads += batch.num_elements;

    // Unbind the texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);

    // Unbind all buffers
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);

    GL20.glUseProgram(0);
}

From source file:zildo.fwk.opengl.compatibility.VBOHardware.java

License:Open Source License

@Override
public void draw(VBOBuffers p_bufs) {
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, p_bufs.vertexBufferId);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, p_bufs.normalBufferId);
    GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0);

    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, p_bufs.textureBufferId);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);
}

From source file:zildo.platform.opengl.compatibility.VBOHardware.java

License:Open Source License

@Override
public void draw(VBOBuffers p_bufs, int start, int count) {
    preDraw();//from   w w w.  jav a 2 s  . c o  m

    int stride = 4 * 4;
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, p_bufs.vertexBufferId);
    GL11.glVertexPointer(2, GL11.GL_FLOAT, stride, 0);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, stride, 2 * 4);

    //GL12.glDrawRangeElements(GL11.GL_TRIANGLES, 0, count, count, GL11.GL_UNSIGNED_SHORT, 0);
    GL11.glDrawArrays(GL11.GL_TRIANGLES, start, count);
}