Example usage for org.lwjgl.opengl GL11 glEnableClientState

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

Introduction

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

Prototype

public static native void glEnableClientState(@NativeType("GLenum") int cap);

Source Link

Document

Enables a client-side capability.

Usage

From source file:lwjglapp.Renderer.java

void drawVBO() {
    FloatBuffer cBuffer = BufferUtils.createFloatBuffer(9);
    cBuffer.put(1).put(0).put(0);//from  w w  w.ja  v  a2s .  c  om
    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.ja v  a2s  . co  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;/* w ww.  j  av a2s.  com*/
    }

    /* 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 enableColors() {
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
}

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

License:Apache License

public void enableNormals() {
    GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
}

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

License:Apache License

public void enableTexCoords() {
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}

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

License:Apache License

public void enableVertices() {
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
}

From source file:opengl.Map.java

public void Draw() {

    float[] vertices = { -1.0f, -1.0f, -1.0f, -0.8f, 0.7f, -0.8f, 0.7f, -1.0f, 1.0f, -1.0f, 1.0f, -0.2f,
            10000.7f, -0.97f, 10000.7f, -1.0f };
    FloatBuffer triangle = BufferUtils.createFloatBuffer(vertices.length);
    triangle.put(vertices);/*from  w ww  .  j a  v a2s .  co  m*/
    triangle.flip();
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    // GL11.glColorPointer(3, GL11.GL_FLOAT, 0, triangleVertexBuffer);
    GL11.glVertexPointer(2, 0, triangle);
    GL11.glDrawArrays(GL11.GL_QUADS, 0, vertices.length / 2);
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);

}

From source file:opengl.Player.java

public void Draw() {
    float[] vertices = { (0.0f * ScaleX) + x, (0.0f * ScaleY) + y, (0.0f * ScaleX) + x, (1.0f * ScaleY) + y,
            (1.0f * ScaleX) + x, (1.0f * ScaleY) + y, (1.0f * ScaleX) + x, (0.0f * ScaleY) + y };
    FloatBuffer triangle = BufferUtils.createFloatBuffer(vertices.length);
    triangle.put(vertices);//  w  ww.  j  ava2 s. com
    triangle.flip();
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    // GL11.glColorPointer(3, GL11.GL_FLOAT, 0, triangleVertexBuffer);
    GL11.glVertexPointer(2, 0, triangle);
    GL11.glDrawArrays(GL11.GL_QUADS, 0, vertices.length / 2);
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
}

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

License:Open Source License

/**
 * Enables a OpenGL state./*  w ww  .  ja  v a2s  .  com*/
 * @param state - The list of OpenGL states to enable.
 */
public static void enableClientSideState(int... state) {
    for (int i = 0; i < state.length; i++)
        GL11.glEnableClientState(state[i]);
}