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:lwjglapp.Renderer.java

void drawVBO() {
    FloatBuffer cBuffer = BufferUtils.createFloatBuffer(9);
    cBuffer.put(1).put(0).put(0);/*  ww  w. j av a2 s  .co  m*/
    cBuffer.put(0).put(1).put(0);
    cBuffer.put(0).put(0).put(1);
    cBuffer.flip();

    FloatBuffer vBuffer = BufferUtils.createFloatBuffer(9);
    vBuffer.put(-0.5f).put(-0.5f).put(0.0f);
    vBuffer.put(+0.5f).put(-0.5f).put(0.0f);
    vBuffer.put(+0.5f).put(+0.5f).put(0.0f);
    vBuffer.flip();

    IntBuffer ib = BufferUtils.createIntBuffer(2);

    glGenBuffersARB(ib);
    int vHandle = ib.get(0);
    int cHandle = ib.get(1);

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

    glBindBufferARB(GL_ARRAY_BUFFER_ARB, vHandle);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, vBuffer, GL_STATIC_DRAW_ARB);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, /* stride */ 3 << 2, 0L);

    glBindBufferARB(GL_ARRAY_BUFFER_ARB, cHandle);
    glBufferDataARB(GL_ARRAY_BUFFER_ARB, cBuffer, GL_STATIC_DRAW_ARB);
    GL11.glColorPointer(3, GL11.GL_FLOAT, /* stride */ 3 << 2, 0L);

    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3 /* elements */);

    glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);

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

    // cleanup VBO handles
    ib.put(0, vHandle);
    ib.put(1, cHandle);
    glDeleteBuffersARB(ib);
}

From source file:net.adam_keenan.voxel.world.BlockVBO.java

License:Creative Commons License

public void render(BlockType type, float x, float y, float z) {
    TextureLoader.bind(Textures.SHEET);//from  w ww. j  a  v a2  s  .  c o m
    int vertID = this.blockVertexBufferID, texID;
    switch (type) {
    case DIRT:
        texID = dirtTextureID;
        break;
    case STONE:
        texID = stoneTextureID;
        break;
    case GRASS:
        texID = grassTextureID;
        break;
    case AIR:
        texID = 0;
        break;
    case FIRE:
        texID = grassTextureID;
        vertID = this.projectileVBOID;
        break;
    default:
        texID = stoneTextureID;
        break;

    }
    if (texID == 0)
        return;
    GL11.glPushMatrix();
    GL11.glTranslatef(x, y, z);

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // Vertex array
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, vertID);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

    // Texture array
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, texID);
    GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

    // Index array
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ELEMENT_ARRAY_BUFFER_ARB, indexBufferID);

    // Draw 'em up
    GL12.glDrawRangeElements(GL11.GL_QUADS, 0, 6 * 4, 6 * 4, GL11.GL_UNSIGNED_INT, 0);

    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    GL11.glPopMatrix();
    TextureLoader.unbind();
}

From source file:net.kubin.rendering.ChunkMeshRenderer.java

License:Apache License

public static void renderChunkMesh(Chunk chunk, MeshType meshType) {
    if (chunk.getMesh().getVBO(meshType) <= 0) {
        return;/*from   w w  w. ja  v  a 2  s.c o m*/
    }

    /* Bind the correct texture */
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    TextureStorage.getTexture("blocks").bind();

    if (meshType == MeshType.OPAQUE) {
        GL11.glDisable(GL11.GL_BLEND);
    } else if (meshType == MeshType.TRANSLUCENT) {
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    }

    ChunkMesh mesh = chunk.getMesh();

    /* Bind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, mesh.getVBO(meshType));

    /* Enable the different kinds of data in the buffer */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // System.out.println("Chunk Vertices = " + mesh.getVertexCount());

    /* Define the starting positions */
    GL11.glVertexPointer(POSITION_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, POSITION_OFFSET * FLOAT_SIZE);
    GL11.glTexCoordPointer(TEX_COORD_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, TEX_COORD_OFFSET * FLOAT_SIZE);
    GL11.glColorPointer(COLOR_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, COLOR_OFFSET * FLOAT_SIZE);

    /* Draw the buffer */
    GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.getVertexCount(meshType));

    /* Unbind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);

    /* Disable the different kindds of data */
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    if (meshType == MeshType.TRANSLUCENT) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }
}

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

License:Apache License

public void bindVertices(int size, int type, ByteBuffer byteBuffer) {
    GL11.glVertexPointer(size, type, 0, byteBuffer);
}

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

License:Apache License

public void bindVertices(int vboID, int size, int type, int strideBytes, int offsetBytes) {
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vboID);
    GL11.glVertexPointer(size, type, strideBytes, offsetBytes);
}

From source file:org.ajgl.graphics.VertexBufferedObject.java

License:Open Source License

/**
 * Draws a vertex buffered object; Uses redundant vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_VERTEX_ARRAY GL_VERTEX_ARRAY} before 
 * you can use this method./* ww  w . j  a v  a  2  s . c o m*/
 * @param vertexHandler - The vertex buffered object vertex handler
 * @param vertexPointData - The number of points per vertex data (i.e. 1-1D, 2-2D, 3-3D)
 * @param vertexNumber - The number of vertices
 * @param first - The start point of the array
 * @param stride - The stride offset; used for interleaving data
 * @param offSet - initial offset for the data
 * @param dataType - The OpenGL dataType
 * @param beginMode - The OpenGL begin mode
 */
public static void drawVboArrays(int vertexHandler, int vertexPointData, int vertexNumber, int first,
        int stride, int offSet, @GLDataType int dataType, @BeginMode int beginMode) {
    // bind vertex data
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexHandler);
    GL11.glVertexPointer(vertexPointData, dataType, stride, offSet);
    // Draw vertex buffer object
    GL11.glDrawArrays(beginMode, first, vertexNumber);
}

From source file:org.ajgl.graphics.VertexBufferedObject.java

License:Open Source License

/**
 * Draws a vertex buffered object; Uses redundant vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_VERTEX_ARRAY GL_VERTEX_ARRAY} before 
 * you can use this method./*from w ww .j a  va2  s. co  m*/
 * @param vertexHandler - The vertex buffered object vertex handler
 * @param vertexPointData - The number of points per vertex data (i.e. 1-1D, 2-2D, 3-3D)
 * @param vertexNumber - The number of vertices
 * @param stride - The stride offset; used for interleaving data
 * @param offSet - initial offset for the data
 * @param dataType - The OpenGL dataType
 * @param beginMode - The OpenGL begin mode
 */
public static void drawVboElements(int vertexHandler, int vertexPointData, int vertexNumber, int stride,
        int offSet, @GLDataType int dataType, @BeginMode int beginMode) {
    // bind vertex data
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexHandler);
    GL11.glVertexPointer(vertexPointData, dataType, stride, offSet);
    // Draw vertex buffer object
    GL11.glDrawElements(beginMode, vertexNumber, dataType, offSet);
}

From source file:org.craftmania.rendering.ChunkMeshRenderer.java

License:Apache License

public static void renderChunkMesh(Chunk chunk, MeshType meshType) {
    if (chunk.getMesh().getVBO(meshType) <= 0) {
        return;//from   w w w.  j a v a  2  s . co m
    }

    /* Bind the correct texture */
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    TextureStorage.getTexture("terrain").bind();

    if (meshType == MeshType.OPAQUE) {
        GL11.glDisable(GL11.GL_BLEND);
    } else if (meshType == MeshType.TRANSLUCENT) {
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    }

    ChunkMesh mesh = chunk.getMesh();

    /* Bind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, mesh.getVBO(meshType));

    /* Enable the different kinds of data in the buffer */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    // System.out.println("Chunk Vertices = " + mesh.getVertexCount());

    /* Define the starting positions */
    GL11.glVertexPointer(POSITION_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, POSITION_OFFSET * FLOAT_SIZE);
    GL11.glTexCoordPointer(TEX_COORD_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, TEX_COORD_OFFSET * FLOAT_SIZE);
    GL11.glColorPointer(COLOR_SIZE, GL11.GL_FLOAT, STRIDE * FLOAT_SIZE, COLOR_OFFSET * FLOAT_SIZE);

    /* Draw the buffer */
    GL11.glDrawArrays(GL11.GL_QUADS, 0, mesh.getVertexCount(meshType));

    /* Unbind the buffer */
    ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, 0);

    /* Disable the different kindds of data */
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    if (meshType == MeshType.TRANSLUCENT) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glVertexPointer(int a, int b, int c, ByteBuffer d) {
    GL11.glVertexPointer(a, b, c, d);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glVertexPointer(int a, int b, int c, long d) {
    GL11.glVertexPointer(a, b, c, d);
}