Example usage for org.lwjgl.opengl GL11 glColorPointer

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

Introduction

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

Prototype

public static void glColorPointer(@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 color array.

Usage

From source file:kuake2.render.lwjgl.Main.java

License:Open Source License

/**
 * R_DrawParticles// ww  w  .j a va  2  s  . c o m
 */
void R_DrawParticles() {

    if (gl_ext_pointparameters.value != 0.0f && qglPointParameterfEXT) {

        //GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glVertexPointer(3, 0, particle_t.vertexArray);
        GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
        GL11.glColorPointer(4, true, 0, particle_t.getColorAsByteBuffer());

        GL11.glDepthMask(false);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glPointSize(gl_particle_size.value);

        GL11.glDrawArrays(GL11.GL_POINTS, 0, r_newrefdef.num_particles);

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

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);

    } else {
        GL_DrawParticles(r_newrefdef.num_particles);
    }
}

From source file:lwjglapp.Renderer.java

void drawVBO() {
    FloatBuffer cBuffer = BufferUtils.createFloatBuffer(9);
    cBuffer.put(1).put(0).put(0);//from ww  w. j  av a  2 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.kubin.rendering.ChunkMeshRenderer.java

License:Apache License

public static void renderChunkMesh(Chunk chunk, MeshType meshType) {
    if (chunk.getMesh().getVBO(meshType) <= 0) {
        return;/*  w  w  w .  j  av a2 s .co 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 bindColors(int size, int type, ByteBuffer byteBuffer) {
    GL11.glColorPointer(size, type, 0, byteBuffer);
}

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

License:Apache License

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

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

License:Open Source License

/**
 * Binds the color vertices. You need to enable 
 * {@link org.lwjgl.opengl.GL11#GL_COLOR_ARRAY GL_COLOR_ARRAY} before 
 * you can use this method.//from ww w .j ava  2s .com
 * @param colorHandler - The vertex buffered object color handler
 * @param colorPointData - The number of points per color data (i.e. 3-RGB, 4-RGBA)
 * @param stride - The stride offset; used for interleaving data
 * @param offSet - initial offset for the data
 * @param dataType - The OpenGL dataType
 */
public static void colorPointer(int colorHandler, int colorPointData, int stride, int offSet,
        @GLDataType int dataType) {
    // bind color data
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, colorHandler);
    GL11.glColorPointer(colorPointData, dataType, stride, 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;// w  ww .ja  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:taiga.code.opengl.ColoredDrawable.java

License:Open Source License

@Override
public void draw(int x, int y, int w, int h) {
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);

    GL11.glVertexPointer(2, 0, createVertices(x, y, w, h));
    GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, colors);

    GL11.glDrawElements(GL11.GL_QUADS, indices);
}

From source file:taiga.gpvm.render.ColorTileRenderer.java

License:Open Source License

@Override
public void render(int pass, ReadableMatrix4 proj, ReadableMatrix4 modelview) {
    if (verts == null || color == null || pass != HardcodedValues.OPAQUE_WORLD_LAYER)
        return;//w w  w.j av a 2s . c  o  m

    simplecolor.bind();

    simplecolor.setUniformMatrix(projloc, proj);
    simplecolor.setUniformMatrix(mvloc, modelview);

    GL11.glPushClientAttrib(GL11.GL_VERTEX_ARRAY | GL11.GL_COLOR_ARRAY);

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

    GL11.glEnable(GL11.GL_DEPTH_TEST);

    //There are 3 elements to each vertex
    //stride is zero the vertices are tightly packed.
    GL11.glVertexPointer(3, 0, verts);

    //4 elements in each color: alpha, red, green, and blue
    GL11.glColorPointer(4, true, 0, color);

    GL11.glDrawArrays(GL11.GL_QUADS, 0, verts.limit() / 3);

    GL11.glPopClientAttrib();
}

From source file:tectonicus.rasteriser.lwjgl.LwjglMesh.java

License:BSD License

@Override
public void bind() {
    if (vertices == null)
        return;// ww w  .j  av  a2s .  co m

    assert (isFinalised);
    assert (numVertices > 0);

    org.lwjgl.opengl.Util.checkGLError();

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glVertexPointer(3, 0, vertices);

    GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
    GL11.glColorPointer(4, true, 0, colours);

    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL11.glTexCoordPointer(2, 0, texCoords);

    if (texture != null) {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getId());
    } else {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    }

    org.lwjgl.opengl.Util.checkGLError();
}