Example usage for org.lwjgl.opengl GL11 glColor4f

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

Introduction

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

Prototype

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

Source Link

Document

Float version of #glColor4b Color4b

Usage

From source file:com.theoriginalbit.moarperipherals.client.gui.GuiCrafter.java

License:Apache License

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    mc.renderEngine.bindTexture(texture);
    GL11.glColor4f(1f, 1f, 1f, 1f);
    int top = (width - xSize) / 2;
    int left = (height - ySize) / 2;
    drawTexturedModalRect(top, left, 0, 0, xSize, ySize);
}

From source file:com.theoriginalbit.moarperipherals.client.gui.GuiPrinter.java

License:Apache License

@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
    mc.renderEngine.bindTexture(texture);
    GL11.glColor4f(1f, 1f, 1f, 1f);
    int top = (width - xSize) / 2;
    int left = (height - ySize) / 2;
    drawTexturedModalRect(top, left, 0, 0, xSize, ySize);
}

From source file:com.theslarfab.tmnmod.client.renderer.tileentity.TileEntityEndWoodChestRenderer.java

License:Open Source License

public void renderTileEntityAt(TileEntityEndWoodChest p_147502_1_, double p_147502_2_, double p_147502_4_,
        double p_147502_6_, float p_147502_8_) {
    int i;/*from  w  w  w  .j a v a 2  s.co  m*/

    if (!p_147502_1_.hasWorldObj()) {
        i = 0;
    } else {
        Block block = p_147502_1_.getBlockType();
        i = p_147502_1_.getBlockMetadata();

        if (block instanceof BlockEndWoodChest && i == 0) {
            try {
                ((BlockEndWoodChest) block).func_149954_e(p_147502_1_.getWorldObj(), p_147502_1_.xCoord,
                        p_147502_1_.yCoord, p_147502_1_.zCoord);
            } catch (ClassCastException e) {
                FMLLog.severe("Attempted to render a chest at %d,  %d, %d that was not a chest",
                        p_147502_1_.xCoord, p_147502_1_.yCoord, p_147502_1_.zCoord);
            }
            i = p_147502_1_.getBlockMetadata();
        }

        p_147502_1_.checkForAdjacentChests();
    }

    if (p_147502_1_.adjacentChestZNeg == null && p_147502_1_.adjacentChestXNeg == null) {
        ModelChest modelchest;

        if (p_147502_1_.adjacentChestXPos == null && p_147502_1_.adjacentChestZPos == null) {
            modelchest = this.singleChest;

            this.bindTexture(chestTexture);

        } else {
            modelchest = this.doubleChest;

            this.bindTexture(doubleChestTexture);

        }

        GL11.glPushMatrix();
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glTranslatef((float) p_147502_2_, (float) p_147502_4_ + 1.0F, (float) p_147502_6_ + 1.0F);
        GL11.glScalef(1.0F, -1.0F, -1.0F);
        GL11.glTranslatef(0.5F, 0.5F, 0.5F);
        short short1 = 0;

        if (i == 2) {
            short1 = 180;
        }

        if (i == 3) {
            short1 = 0;
        }

        if (i == 4) {
            short1 = 90;
        }

        if (i == 5) {
            short1 = -90;
        }

        if (i == 2 && p_147502_1_.adjacentChestXPos != null) {
            GL11.glTranslatef(1.0F, 0.0F, 0.0F);
        }

        if (i == 5 && p_147502_1_.adjacentChestZPos != null) {
            GL11.glTranslatef(0.0F, 0.0F, -1.0F);
        }

        GL11.glRotatef((float) short1, 0.0F, 1.0F, 0.0F);
        GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
        float f1 = p_147502_1_.prevLidAngle + (p_147502_1_.lidAngle - p_147502_1_.prevLidAngle) * p_147502_8_;
        float f2;

        if (p_147502_1_.adjacentChestZNeg != null) {
            f2 = p_147502_1_.adjacentChestZNeg.prevLidAngle
                    + (p_147502_1_.adjacentChestZNeg.lidAngle - p_147502_1_.adjacentChestZNeg.prevLidAngle)
                            * p_147502_8_;

            if (f2 > f1) {
                f1 = f2;
            }
        }

        if (p_147502_1_.adjacentChestXNeg != null) {
            f2 = p_147502_1_.adjacentChestXNeg.prevLidAngle
                    + (p_147502_1_.adjacentChestXNeg.lidAngle - p_147502_1_.adjacentChestXNeg.prevLidAngle)
                            * p_147502_8_;

            if (f2 > f1) {
                f1 = f2;
            }
        }

        f1 = 1.0F - f1;
        f1 = 1.0F - f1 * f1 * f1;
        modelchest.chestLid.rotateAngleX = -(f1 * (float) Math.PI / 2.0F);
        modelchest.renderAll();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}

From source file:com.theupstairsroom.roadiemod.GuiPoopBar.java

License:Open Source License

@SubscribeEvent(priority = EventPriority.NORMAL)
public void onRenderExperienceBar(RenderGameOverlayEvent event) {
    if (event.isCancelable() || event.type != ElementType.EXPERIENCE) {
        return;//from w  ww.  j a  va2s  . co m
    }

    // Get our extended player properties and assign it locally so we can easily access it
    ExtendedPlayerP props = ExtendedPlayerP.get(this.mc.thePlayer);
    if (props == null || props.MAX_POOP_LEVEL == 0) {
        return;
    }
    int xPos = 2;
    int yPos = 2;

    // setting all color values to 1.0F will render the texture as it appears in your texture file
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    // Somewhere in Minecraft vanilla code it says to do this because of a lighting bug
    GL11.glDisable(GL11.GL_LIGHTING);

    // Bind your texture to the render engine
    this.mc.getTextureManager().bindTexture(texturepath);

    // First draw the background layer. In my texture file, it starts at the upper-
    // left corner (x=0, y=0), is 50 pixels long and 4 pixels thick (y value)
    this.drawTexturedModalRect(xPos, yPos, 0, 0, 50, 4);
    // Then draw the foreground; it's located just below the background in my
    // texture file, so it starts at x=0, y=4, is only 2 pixels thick and 50 length
    // Why y=4 and not y=5? Y starts at 0, so 0,1,2,3 = 4 pixels for the background
    // However, we want the length to be based on current mana, so we need a new variable:
    int poopbarwidth = (int) (((float) props.getCurrentPoop() / props.MAX_POOP_LEVEL) * 50);
    // Now we can draw our mana bar at yPos+1 so it centers in the background:
    this.drawTexturedModalRect(xPos, yPos + 1, 0, 4, poopbarwidth, 2);
}

From source file:com.timvisee.voxeltex.module.render.RenderOverlayHelper.java

License:Open Source License

/**
 * Set the drawing color.//  w w  w  . j  a  v  a 2  s .c o  m
 *
 * @param r Red channel intensity.
 * @param g Green channel intensity.
 * @param b Blue channel intensity.
 * @param a Alpha channel intensity.
 */
public static void color(float r, float g, float b, float a) {
    GL11.glColor4f(r, g, b, a);
}

From source file:com.wicpar.sinkingsimulatorclassic.Ground.java

License:Open Source License

@Override
public void draw() {
    GL11.glEnable(GL11.GL_DEPTH_TEST);//www .java2 s .c  om
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(FloorColor.r, FloorColor.g, FloorColor.b, FloorColor.a);
    double h = Main.ClassicSinkingSim.getInstance().getCam().transformY(this.h);
    GL11.glVertex3d(-1, h, -0.8);
    GL11.glVertex3d(-1, -1, -0.8);
    GL11.glVertex3d(1, -1, -0.8);
    GL11.glVertex3d(1, h, -0.8);
    GL11.glEnd();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
}

From source file:com.wicpar.sinkingsimulatorclassic.Sea.java

License:Open Source License

@Override
public void draw() {
    GL11.glEnable(GL11.GL_DEPTH_TEST);//from w  w w  .  j  a v a2 s.c  o m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
    time = Base.getTimePassed();
    GL11.glBegin(GL11.GL_QUAD_STRIP);
    GL11.glColor4f(SeaColor.r, SeaColor.g, SeaColor.b, SeaColor.a);
    for (int i = 0; i <= divisions; i++) {
        double pos = ((double) (i) / (divisions)) * 2 - 1;
        GL11.glVertex3d(pos, -1, -0.07);
        GL11.glVertex3d(pos, cam.transformY(getHeight(cam.untransformX(pos), time)), -0.07);
    }
    GL11.glEnd();
    GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
    GL11.glLineWidth(2);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    GL11.glColor4f(SeaColor.r, SeaColor.g, SeaColor.b, 1);
    for (int i = 0; i <= divisions; i++) {
        double pos = ((double) (i) / (divisions)) * 2 - 1;
        GL11.glVertex3d(pos, cam.transformY(getHeight(cam.untransformX(pos), time)), -0.07);
    }
    GL11.glEnd();
    GL11.glLineWidth(1);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glLineWidth(1);
}

From source file:com.wicpar.sinkingsimulatorclassic.Ship.java

License:Open Source License

@Override
public void draw() {
    final Camera cam = Main.ClassicSinkingSim.getInstance().getCam();
    GL11.glEnable(GL11.GL_DEPTH_TEST);//from www  . ja  va  2  s  .c o  m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPointSize((float) Main.ClassicSinkingSim.getInstance().getCam().scaleSize(0.1));
    GL11.glBegin(GL11.GL_POINTS);
    for (Shipsel[] s : shipsels) {
        if (s != null)
            for (Shipsel shipsel : s) {
                if (shipsel != null) {
                    Color c = shipsel.getColor();
                    Vector3d pos = shipsel.getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.8);
                }
            }
    }
    GL11.glEnd();
    GL11.glPointSize(1);

    GL11.glLineWidth((float) Main.ClassicSinkingSim.getInstance().getCam().scaleSize(0.1));
    boolean t, b, l, r, e, f;

    Color c;
    Vector3d pos;
    GL11.glBegin(GL11.GL_LINES);
    for (int y = 0; y < springs[1].length; y++) {
        for (int x = 0; x < springs[1][y].length; x++) {
            t = springs[0][y][x];
            l = springs[2][y][x];
            e = springs[1][y][x];
            f = springs[3][y][x];

            if (t && (shipsels[y][x] == null || shipsels[y][x + 1] == null)) {
                springs[0][y][x] = false;
            }
            if (l && (shipsels[y][x] == null || shipsels[y + 1][x] == null)) {
                springs[2][y][x] = false;
            }
            if (e && (shipsels[y][x] == null || shipsels[y + 1][x + 1] == null)) {
                springs[1][y][x] = false;
            }
            if (f && (shipsels[y][x + 1] == null || shipsels[y + 1][x] == null)) {
                springs[3][y][x] = false;
            }

            t = springs[0][y][x];
            b = springs[0][y + 1][x];
            l = springs[2][y][x];
            r = springs[2][y][x + 1];
            e = springs[1][y][x];
            f = springs[3][y][x];

            if (t && b && l && r && e && f)
                continue;
            if (t && r && e)
                continue;
            if (b && l && e)
                continue;
            if (t && l && f)
                continue;
            if (b && r && f)
                continue;
            if (t) {
                c = shipsels[y][x].getColor();
                pos = shipsels[y][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);
                c = shipsels[y][x + 1].getColor();
                pos = shipsels[y][x + 1].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);

            }
            if (l) {
                c = shipsels[y][x].getColor();
                pos = shipsels[y][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);
                c = shipsels[y + 1][x].getColor();
                pos = shipsels[y + 1][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);

            }
            if (e) {
                c = shipsels[y][x].getColor();
                pos = shipsels[y][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);
                c = shipsels[y + 1][x + 1].getColor();
                pos = shipsels[y + 1][x + 1].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);

            }
            if (f) {
                c = shipsels[y][x + 1].getColor();
                pos = shipsels[y][x + 1].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);
                c = shipsels[y + 1][x].getColor();
                pos = shipsels[y + 1][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 0.9);

            }
        }
    }
    GL11.glEnd();
    GL11.glBegin(GL11.GL_TRIANGLES);
    for (int y = 0; y < springs[1].length; y++) {
        for (int x = 0; x < springs[1][y].length; x++) {
            t = springs[0][y][x];
            b = springs[0][y + 1][x];
            l = springs[2][y][x];
            r = springs[2][y][x + 1];
            e = springs[1][y][x];
            f = springs[3][y][x];

            if (t && b && l && r && e && f) {

                c = shipsels[y][x].getColor();
                pos = shipsels[y][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                c = shipsels[y][x + 1].getColor();
                pos = shipsels[y][x + 1].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                c = shipsels[y + 1][x].getColor();
                pos = shipsels[y + 1][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                c = shipsels[y][x + 1].getColor();
                pos = shipsels[y][x + 1].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                c = shipsels[y + 1][x].getColor();
                pos = shipsels[y + 1][x].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                c = shipsels[y + 1][x + 1].getColor();
                pos = shipsels[y + 1][x + 1].getPos();
                GL11.glColor4f(c.r, c.g, c.b, c.a);
                GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

            } else {
                if (t && r && e) {
                    c = shipsels[y][x].getColor();
                    pos = shipsels[y][x].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y][x + 1].getColor();
                    pos = shipsels[y][x + 1].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y + 1][x + 1].getColor();
                    pos = shipsels[y + 1][x + 1].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);
                }
                if (b && l && e) {
                    c = shipsels[y][x].getColor();
                    pos = shipsels[y][x].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y + 1][x].getColor();
                    pos = shipsels[y + 1][x].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y + 1][x + 1].getColor();
                    pos = shipsels[y + 1][x + 1].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);
                }
                if (t && l && f) {
                    c = shipsels[y][x].getColor();
                    pos = shipsels[y][x].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y][x + 1].getColor();
                    pos = shipsels[y][x + 1].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y + 1][x].getColor();
                    pos = shipsels[y + 1][x].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);
                }
                if (b && r && f) {
                    c = shipsels[y + 1][x].getColor();
                    pos = shipsels[y + 1][x].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y + 1][x + 1].getColor();
                    pos = shipsels[y + 1][x + 1].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);

                    c = shipsels[y][x + 1].getColor();
                    pos = shipsels[y][x + 1].getPos();
                    GL11.glColor4f(c.r, c.g, c.b, c.a);
                    GL11.glVertex3d(cam.transformX(pos.x), cam.transformY(pos.y), 1);
                }
            }
        }
    }
    GL11.glEnd();
    GL11.glLineWidth(1);

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
}

From source file:com.wicpar.sinkingsimulatorclassic.Sky.java

License:Open Source License

@Override
public void draw() {

    GL11.glEnable(GL11.GL_DEPTH_TEST);/* www  . j a  v  a2  s.  com*/
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(SkyColor.r, SkyColor.g, SkyColor.b, SkyColor.a);
    GL11.glVertex3d(-1, -1, -0.9);
    GL11.glVertex3d(-1, 1, -0.9);
    GL11.glVertex3d(1, 1, -0.9);
    GL11.glVertex3d(1, -1, -0.9);
    GL11.glEnd();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
}

From source file:com.xlogisticzz.learningModding.client.interfaces.gui.GuiCakeStorage.java

License:LGPL

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glColor4f(1, 1, 1, 1);
    Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);

    float filled = cakeStorage.getCake() / 10F;
    int barHeight = (int) (filled * 34);
    if (barHeight > 0) {
        int srcX = xSize;
        int srcY = 34 - barHeight;

        drawTexturedModalRect(guiLeft + 100, guiTop + 17 + 34 - barHeight, srcX, srcY, 7, barHeight);
    }/*  w w w  .j av a 2  s  .  co  m*/

    int timerWidth = cakeStorage.getTimer();
    if (timerWidth > 0) {
        int srcX = xSize + 10;
        int srcY = 0;

        drawTexturedModalRect(guiLeft + 119, guiTop + 44, srcX, srcY, timerWidth, 7);
    }

    filled = cakeStorage.getBuffer() / 6F;
    barHeight = (int) (filled * 34);
    if (barHeight > 0) {
        int srcX = xSize + 7;
        int srcY = 34 - barHeight;

        drawTexturedModalRect(guiLeft + 108, guiTop + 17 + 34 - barHeight, srcX, srcY, 3, barHeight);
    }

    int srcX = cakeStorage.getCurrentDir() * 20;
    int srcY = ySize;
    drawTexturedModalRect(guiLeft + 70, guiTop + 58, srcX, srcY, 20, 22);

    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);

    if (!cakeStorage.isAirInCurrentDir()) {
        int id = cakeStorage.getBlockIdAtCurrentPos();
        Block block = Block.blocksList[id];
        if (block.blockID != 0) {
            drawTexturedModelRectFromIcon(guiLeft + 90, guiTop + 60, block.getIcon(1, 0), 16, 16);
        }
    }

}