Example usage for org.lwjgl.opengl GL11 glColor3f

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

Introduction

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

Prototype

public static native void glColor3f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue);

Source Link

Document

Float version of #glColor3b Color3b

Usage

From source file:naftoreiclag.splendidanimator.Application.java

License:MIT License

public void renderGL() {
    GL11.glColor3f(0.5f, 0.5f, 1.0f);

    GL11.glPushMatrix();/*w w w .  j a va 2s .  c o  m*/

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(100 - 50, 100 - 50);
    GL11.glVertex2f(100 + 50, 100 - 50);
    GL11.glVertex2f(100 + 50, 100 + 50);
    GL11.glVertex2f(100 - 50, 100 + 50);
    GL11.glEnd();

}

From source file:name.martingeisse.gltetris.game.DrawUtil.java

License:Open Source License

/**
 * @param x the x position of the block/*from www. ja  v a  2 s. com*/
 * @param y the y position of the block
 * @param blockIndex the block index (0-63) that indicates the block image to draw
 */
public static void drawBlock(int x, int y, final int blockIndex) {

    // preparation
    x *= 16;
    y *= 16;
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    Resources.getBlockPalette().bind();
    glBegin(GL_QUADS);
    double paletteEntrySize = (1.0 / 64.0);
    double textureStartX = (blockIndex * paletteEntrySize);
    double textureEndX = ((blockIndex + 1) * paletteEntrySize);

    // upper left vertex
    glTexCoord2d(textureStartX, 0.0f);
    glVertex2f(x, y);

    // upper right vertex
    glTexCoord2d(textureEndX, 0.0f);
    glVertex2f(x + 16, y);

    // lower right vertex
    glTexCoord2d(textureEndX, 1.0);
    glVertex2f(x + 16, y + 16);

    // lower left vertex
    glTexCoord2d(textureStartX, 1.0);
    glVertex2f(x, y + 16);

    // cleanup
    glEnd();

}

From source file:name.martingeisse.meltdown.engine.Image.java

License:Open Source License

/**
 * Draws this image to the specified screen position.
 * @param x the x position to draw to//w w w. ja v a2 s.c om
 * @param y the y position to draw to
 */
public void draw(final int x, final int y) {

    // preparation
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    texture.bind();
    glBegin(GL_QUADS);

    // upper left vertex
    glTexCoord2f(0.0f, 0.0f);
    glVertex2f(x, y);

    // upper right vertex
    glTexCoord2f(texture.getWidth(), 0.0f);
    glVertex2f(x + texture.getImageWidth(), y);

    // lower right vertex
    glTexCoord2f(texture.getWidth(), texture.getHeight());
    glVertex2f(x + texture.getImageWidth(), y + texture.getImageHeight());

    // lower left vertex
    glTexCoord2f(0.0f, texture.getHeight());
    glVertex2f(x, y + texture.getImageHeight());

    // cleanup
    glEnd();
    ShaderProgram.useNone();

}

From source file:name.martingeisse.minimal.simulation.subject.FullySimulatedSubject.java

License:Open Source License

@Override
public void drawCell(final int x, final int y, int pattern) {
    if (pattern < 0 || pattern > 15) {
        pattern = 0;//from w ww. jav  a 2 s.  c om
    }
    switch (pattern) {

    case 0:
        GL11.glColor3f(0.0f, 0.0f, 0.0f);
        break;

    case 1:
        GL11.glColor3f(0.0f, 0.0f, 0.5f);
        break;

    case 2:
        GL11.glColor3f(0.0f, 0.5f, 0.0f);
        break;

    case 3:
        GL11.glColor3f(0.0f, 0.5f, 0.5f);
        break;

    case 4:
        GL11.glColor3f(0.5f, 0.0f, 0.0f);
        break;

    case 5:
        GL11.glColor3f(0.5f, 0.0f, 0.5f);
        break;

    case 6:
        GL11.glColor3f(0.5f, 0.5f, 0.0f);
        break;

    case 7:
        GL11.glColor3f(0.75f, 0.75f, 0.75f);
        break;

    case 8:
        GL11.glColor3f(0.5f, 0.5f, 0.5f);
        break;

    case 9:
        GL11.glColor3f(0.0f, 0.0f, 1.0f);
        break;

    case 10:
        GL11.glColor3f(0.0f, 1.0f, 0.0f);
        break;

    case 11:
        GL11.glColor3f(0.0f, 1.0f, 1.0f);
        break;

    case 12:
        GL11.glColor3f(1.0f, 0.0f, 0.0f);
        break;

    case 13:
        GL11.glColor3f(1.0f, 0.0f, 1.0f);
        break;

    case 14:
        GL11.glColor3f(1.0f, 1.0f, 0.0f);
        break;

    case 15:
        GL11.glColor3f(1.0f, 1.0f, 1.0f);
        break;

    }
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2i(x * 20, y * 20);
    GL11.glVertex2i(x * 20 + 20, y * 20);
    GL11.glVertex2i(x * 20 + 20, y * 20 + 20);
    GL11.glVertex2i(x * 20, y * 20 + 20);
    GL11.glEnd();
}

From source file:name.martingeisse.swtlib.canvas.OpenGlImageBlockCanvas.java

License:Open Source License

@Override
protected void onBeforeDraw() {
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);
}

From source file:name.martingeisse.swtlib.color.OpenGlColors.java

License:Open Source License

/**
 * Uses the color with the specified index as the current OpenGL
 * color via glColor3*(). /*ww w  .  jav  a2 s  .  c  o m*/
 * @param index the index of the color to use
 */
public static void useColor(int index) {
    index = index & 15;
    if (index == 7) {
        GL11.glColor3f(0.75f, 0.75f, 0.75f);
    } else if (index == 8) {
        GL11.glColor3f(0.5f, 0.5f, 0.5f);
    } else {
        float baseValue = (index > 7) ? 1.0f : 0.5f;
        float red = ((index & 4) == 0) ? 0.0f : baseValue;
        float green = ((index & 2) == 0) ? 0.0f : baseValue;
        float blue = ((index & 1) == 0) ? 0.0f : baseValue;
        GL11.glColor3f(red, green, blue);
    }
}

From source file:net.adam_keenan.voxel.world.player.Player.java

License:Creative Commons License

@Override
public void render() {
    curBlock = getBlockLookedAt();/*from  w w w .j  a  v  a  2 s  . co  m*/
    GL11.glColor4f(1, 1, 1, .5f);
    for (int row = 0; row < SIZE; row++)
        for (int col = 0; col < SIZE; col++) {
            glBegin(GL11.GL_QUADS);
            {
                GL11.glVertex3f(x1, y1 + 1, col + z1);
                GL11.glVertex3f(x1 + 1, y1 + 1, col + z1);
                GL11.glVertex3f(x1 + 1, y1 + 1, col + z1 + 1);
                GL11.glVertex3f(x1, y1 + 1, col + z1 + 1);
            }
            glEnd();
        }
    GL11.glColor3f(1, 1, 1);
    camera.drawDebug();
    camera.drawString(100, 300, String.format("%f, %f, %f", projectile.x, projectile.y, projectile.z));
    camera.drawString(Display.getWidth() - 200, Display.getHeight() - 20, String.format("Power: %s", power));
    HUD.drawCrosshairs();

}

From source file:net.BiggerOnTheInside.Binder.BlockRenderer.java

License:Open Source License

public static void renderBlock(Block b, float x, float y, float z) {
    GL11.glPushMatrix();//from   ww  w. j a va  2  s  .  c om
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTranslatef(x * 2f, y * 2f, z * 2f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor3f(1f, 1f, 1f);

    // Top face.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x(), b.getTextureCoordinates(BlockFace.Top).y());
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Top).y());
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Top).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x(),
            b.getTextureCoordinates(BlockFace.Top).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);

    // Bottom.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x(),
            b.getTextureCoordinates(BlockFace.Bottom).y());
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Bottom).y());
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Bottom).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x(),
            b.getTextureCoordinates(BlockFace.Bottom).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);

    // Front.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x(),
            b.getTextureCoordinates(BlockFace.Front).y());
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Front).y());
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Front).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x(),
            b.getTextureCoordinates(BlockFace.Front).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);

    // Back.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x(), b.getTextureCoordinates(BlockFace.Back).y());
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Back).y());
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Back).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x(),
            b.getTextureCoordinates(BlockFace.Back).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);

    // Left
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x(), b.getTextureCoordinates(BlockFace.Left).y());
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Left).y());
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Left).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x(),
            b.getTextureCoordinates(BlockFace.Left).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);

    // Right.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x(),
            b.getTextureCoordinates(BlockFace.Right).y());
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Right).y());
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Right).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x(),
            b.getTextureCoordinates(BlockFace.Right).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();
    GL11.glTranslatef(0f, 0f, 0f);
    GL11.glPopMatrix();
}

From source file:net.BiggerOnTheInside.Binder.BlockRenderer.java

License:Open Source License

public static void renderWireframeBlock(Block b, float x, float y, float z) {
    GL11.glTranslatef(x * 2f, y * 2f, z * 2f);
    GL11.glBegin(GL11.GL_LINE_LOOP);//from  www  .j  a  v  a  2 s  . c o m
    GL11.glColor3f(0.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.5f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();
    GL11.glTranslatef(0f, 0f, 0f);
}

From source file:net.BiggerOnTheInside.Binder.engine.BlockRenderer.java

License:Open Source License

public static void renderBlock(Block b, float x, float y, float z) {
    GL11.glTranslatef(x * 2f, y * 2f, z * 2f);

    GL11.glBegin(GL11.GL_QUADS);/*from   w  w  w .j  a va 2s.  c om*/
    GL11.glColor3f(0.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.5f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();

    GL11.glTranslatef(0f, 0f, 0f);
}