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:additionalpipes.client.gui.components.GuiButtonShorter.java

License:Minecraft Mod Public

@Override
public void drawButton(Minecraft minecraft, int i, int j) {
    if (drawButton) {
        FontRenderer fontrenderer = minecraft.fontRenderer;
        minecraft.renderEngine.bindTexture(buttonTextures);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        field_82253_i = i >= xPosition && j >= yPosition && i < xPosition + width && j < yPosition + height;
        int k = getHoverState(field_82253_i);
        int width2 = width - width / 2;
        int height2 = height - height / 2;
        drawTexturedModalRect(xPosition, yPosition, 0, 46 + k * 20, width / 2, height / 2);// top left
        drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width2, 46 + k * 20, width2, height / 2);// top right
        drawTexturedModalRect(xPosition, yPosition + height / 2, 0, 46 + k * 20 + 20 - height2, width / 2,
                height2);// bottom left
        drawTexturedModalRect(xPosition + width / 2, yPosition + height / 2, 200 - width2,
                46 + k * 20 + 20 - height2, width2, height2);// bottom right
        mouseDragged(minecraft, i, j);//from  w ww  . j  av a2 s  .c o m

        int color = 0xe0e0e0;
        if (!enabled) {
            color = 0xffa0a0a0;
        } else if (field_82253_i) {
            color = 0xffffa0;
        }
        drawCenteredString(fontrenderer, displayString, xPosition + width / 2, yPosition + (height - 8) / 2,
                color);
    }
}

From source file:additionalpipes.client.gui.components.GuiSlotEx.java

License:Minecraft Mod Public

/**
 * draws the slot to the screen, pass in mouse's current x and y and partial ticks
 *//*from   www .j a v a  2 s  .  co  m*/
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    drawBackground();
    int size = getSize();
    int slotLeft = xPos + marginLeft + 2;
    int slotRight = xPos + width - 2;
    if (getHiddenHeight() > 0) {
        slotRight = getScrollBarX() - 2;
    }

    if (Mouse.isButtonDown(0)) {
        if (initialClickY == -1.0F) {
            boolean slotClicked = true;

            if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) {
                int mouseSlotY = mouseY - yPos - marginTop + (int) amountScrolled - getGradientHeight();
                int hovered = mouseSlotY / slotHeight;
                if (/*mouseX < slotLeft || mouseX > slotRight || */hovered < -1 || hovered >= size) {
                    hovered = -1;
                }

                boolean doubleClick = hovered == selectedElement
                        && Minecraft.getSystemTime() - lastClicked < 250L;
                lastClicked = Minecraft.getSystemTime();
                elementClicked(hovered, mouseX - xPos, doubleClick);

                if (hovered >= 0) {
                    selectedElement = hovered;
                } else if (mouseX >= slotLeft && mouseX <= slotRight && mouseSlotY < 0) {
                    marginClicked(mouseX - slotLeft,
                            mouseY - yPos + (int) amountScrolled - getGradientHeight());
                    slotClicked = false;
                }

                int scrollBarX = getScrollBarX();
                if (mouseX >= scrollBarX && mouseX < scrollBarX + scrollBarWidth) {
                    scrollMultiplier = -1.0F;
                    int hiddenHeight = getHiddenHeight();

                    if (hiddenHeight < 1) {
                        hiddenHeight = 1;
                    }

                    int slotBottom = height * height / getContentHeight();

                    if (slotBottom < 32) {
                        slotBottom = 32;
                    }

                    if (slotBottom > height - getGradientHeight() * 2) {
                        slotBottom = height - getGradientHeight() * 2;
                    }

                    scrollMultiplier /= (float) (height - slotBottom) / (float) hiddenHeight;
                } else {
                    scrollMultiplier = 1.0F;
                }

                if (slotClicked) {
                    initialClickY = mouseY;
                } else {
                    initialClickY = -2.0F;
                }
            } else {
                initialClickY = -2.0F;
            }
        } else if (initialClickY >= 0.0F) {
            float scroll = amountScrolled;
            amountScrolled -= (mouseY - initialClickY) * scrollMultiplier;
            bindAmountScrolled();
            if (scroll != amountScrolled) {
                initialClickY = mouseY;
            }
        }
    } else if (mouseX >= xPos && mouseX < xPos + width && mouseY >= yPos && mouseY < yPos + height) {
        while (!mc.gameSettings.touchscreen && Mouse.next()) {
            int wheel = Mouse.getEventDWheel();

            if (wheel != 0) {
                if (wheel > 0) {
                    wheel = -1;
                } else if (wheel < 0) {
                    wheel = 1;
                }

                amountScrolled += wheel * slotHeight / 2;
                bindAmountScrolled();
            }
        }

        initialClickY = -1.0F;
    }

    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    Tessellator tessellator = Tessellator.instance;
    drawContainerBackground(tessellator);
    int scrolledTop = yPos + getGradientHeight() - (int) amountScrolled;
    if (!drawGradient) {
        scrolledTop += 2;
    }

    if (drawMarginTop) {
        drawMarginTop(slotLeft, scrolledTop, tessellator);
    }

    for (int i = 0; i < size; ++i) {
        int slotTop = scrolledTop + i * slotHeight + marginTop;
        int slotHeight = this.slotHeight - 4;

        if (slotTop <= yPos + height && slotTop + slotHeight >= yPos) {
            if (showSelectionBox && isSelected(i)) {
                int outlineLeft = slotLeft - 2;
                int outlineRight = slotRight + 2;
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                tessellator.startDrawingQuads();
                tessellator.setColorOpaque_I(0x808080);
                tessellator.addVertexWithUV(outlineLeft, slotTop + slotHeight + 2, 0.0D, 0.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight, slotTop + slotHeight + 2, 0.0D, 1.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight, slotTop - 2, 0.0D, 1.0D, 0.0D);
                tessellator.addVertexWithUV(outlineLeft, slotTop - 2, 0.0D, 0.0D, 0.0D);
                tessellator.setColorOpaque_I(0x000000);
                tessellator.addVertexWithUV(outlineLeft + 1, slotTop + slotHeight + 1, 0.0D, 0.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight - 1, slotTop + slotHeight + 1, 0.0D, 1.0D, 1.0D);
                tessellator.addVertexWithUV(outlineRight - 1, slotTop - 1, 0.0D, 1.0D, 0.0D);
                tessellator.addVertexWithUV(outlineLeft + 1, slotTop - 1, 0.0D, 0.0D, 0.0D);
                tessellator.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

            drawSlot(i, slotLeft, slotTop, slotHeight, tessellator);
        }
    }

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    drawOverlay();

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    drawGradient(tessellator);
    drawScrollBar(tessellator);

    drawFinish(mouseX, mouseY);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:additionalpipes.client.gui.components.GuiSlotEx.java

License:Minecraft Mod Public

protected void drawContainerBackground(Tessellator tessellator) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    Gui.drawRect(xPos, yPos, xPos + width, yPos + height, 0xff000000);
}

From source file:additionalpipes.client.gui.GuiAdvancedWoodPipe.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(TEXTURE);
    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}

From source file:additionalpipes.client.gui.GuiTeleportManager.java

License:Minecraft Mod Public

private void renderPipeMap(int map, MapData mapData) {
    RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDisable(GL11.GL_DEPTH_TEST);//w  w  w .j a va2  s  .c  o m
    mc.renderEngine.bindTexture(MAP_TEXTURE);

    GL11.glPushMatrix();
    Tessellator var4 = Tessellator.instance;
    var4.startDrawingQuads();
    byte var5 = 7;
    var4.addVertexWithUV(0 - var5, 128 + var5, 0.0D, 0.0D, 1.0D);
    var4.addVertexWithUV(128 + var5, 128 + var5, 0.0D, 1.0D, 1.0D);
    var4.addVertexWithUV(128 + var5, 0 - var5, 0.0D, 1.0D, 0.0D);
    var4.addVertexWithUV(0 - var5, 0 - var5, 0.0D, 0.0D, 0.0D);
    var4.draw();

    mapRenderer.renderMap(mc.thePlayer, mc.renderEngine, mapData);

    PropertyIntArray pipeArr = (PropertyIntArray) clientProps.propPipes.value.get(PropertyInteger.create(map));
    int[] pipes = pipeArr != null ? pipeArr.value : ArrayUtils.EMPTY_INT_ARRAY;
    for (int p = 0; p < pipes.length / 3; p++) {
        int centerX = pipes[p * 3 + 1];
        int centerZ = pipes[p * 3 + 2];
        GL11.glPushMatrix();
        GL11.glTranslatef(centerX / 2.0F + 64.0F - 4, centerZ / 2.0F + 64.0F - 4, -0.02F);
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.renderEngine,
                new ItemStack(getTeleportPipe(PipeType.values()[pipes[p * 3]]), 1), 0, 0);
        GL11.glPopMatrix();
    }
    GL11.glPopMatrix();
}

From source file:additionalpipes.client.gui.GuiTeleportManager.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(TEXTURE);

    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
    if (clientProps.propMaps.value.length == 0) {
        drawTexturedModalRect(guiLeft + 8 + (36 * MAPS_ROW - 16) / 2, guiTop + 18 + (36 * MAPS_COL - 16) / 2,
                xSize, 0, 16, 16);//from   w  ww.  j a  va2  s.  c  om
    }
}

From source file:additionalpipes.client.gui.GuiTeleportManager.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    super.drawGuiContainerForegroundLayer(mouseX, mouseY);

    float scrollPercent = scrollLine / (float) getScrollMax();
    int scrollBarLeft = guiLeft + xSize - 20;
    int scrollBarTop = guiTop + 18;
    int scrollBarBottom = scrollBarTop + 113;
    boolean isClicking = Mouse.isButtonDown(0);
    if (!wasClicking && isClicking && mouseX >= scrollBarLeft && mouseX < scrollBarLeft + 20
            && mouseY >= scrollBarTop && mouseY < scrollBarBottom) {
        isScrolling = needsScrollBars();
    }//from www.  j  a v a 2  s  .c  o m
    if (!isClicking) {
        isScrolling = false;
    }
    wasClicking = isClicking;
    if (isScrolling) {
        scrollPercent = (mouseY - scrollBarTop - 7.5F) / (scrollBarBottom - scrollBarTop - 20.0F);
        if (scrollPercent < 0.0F) {
            scrollPercent = 0.0F;
        } else if (scrollPercent > 1.0F) {
            scrollPercent = 1.0F;
        }
        scrollLine = (int) (scrollPercent * getScrollMax() + 0.5D);
        validateScrollLine();
    }

    fontRenderer.drawString(StringUtils.localize("container.teleportManager"), 8, 6,
            clientProps.propIsPublic.value ? 0x0000FF : 0x404040);
    fontRenderer.drawString(StringUtils.localize("gui.inventory"), 8, 130, 0x404040);

    RenderHelper.disableStandardItemLighting();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(CREATIVE_TEXTURE);
    drawTexturedModalRect(xSize - 20, 18 + (int) (93 * scrollPercent), 232 + (needsScrollBars() ? 0 : 12), 0,
            12, 15);

    theMap = -1;
    int[] maps = clientProps.propMaps.value;
    if (maps.length == 0) {
        if (mouseX >= guiLeft + 8 && mouseX < guiLeft + 8 + 36 * MAPS_ROW && mouseY >= guiTop + 18
                && mouseY < guiTop + 18 + 36 * MAPS_COL) {
            String text = StringUtils
                    .localize(AdditionalPipes.disableLinkingUsage ? "gui.map.emptyHint.position"
                            : "gui.map.emptyHint.link");
            int width = fontRenderer.getStringWidth(text);
            GL11.glPushMatrix();
            GL11.glTranslatef(-guiLeft, -guiTop, 0);
            drawCreativeTabHoveringText(text, mouseX - 12 - width / 2, mouseY - 4);
            GL11.glPopMatrix();
        }
    } else if (currentMap == -1) {
        ItemStack mapStack = new ItemStack(Item.map, 1, 0);
        for (int i = 0; i < MAPS_COL; i++) {
            for (int j = 0; j < MAPS_ROW; j++) {
                int index = j + (scrollLine + i) * MAPS_ROW;
                if (index < maps.length) {
                    mapStack.setItemDamage(maps[index]);
                    MapData mapData = Item.map.getMapData(mapStack, mc.theWorld);
                    if (mapData != null) {
                        int x = 10 + j * 36;
                        int y = 20 + i * 36;
                        GL11.glPushMatrix();
                        GL11.glTranslatef(x, y, 0.0F);
                        GL11.glScalef(0.25F, 0.25F, 0.25F);
                        renderPipeMap(maps[index], mapData);
                        GL11.glPopMatrix();
                    }
                }
            }
        }
        int index = getMapIndexAtPos(mouseX, mouseY);
        if (index >= 0 && index < maps.length) {
            theMap = index;
            mapStack.setItemDamage(maps[index]);
            drawItemStackTooltip(mapStack, mouseX - guiLeft + 8, mouseY - guiTop + 8);
        }
    } else {
        MapData mapData = Item.map.getMapData(new ItemStack(Item.map, 1, maps[currentMap]), mc.theWorld);
        if (mapData != null) {
            GL11.glPushMatrix();
            GL11.glTranslatef(7, guiTop, 0.0F);
            GL11.glScalef(1.25F, 1.25F, 1.25F);
            renderPipeMap(maps[currentMap], mapData);
            GL11.glPopMatrix();
        }
    }
    RenderHelper.enableGUIStandardItemLighting();
}

From source file:additionalpipes.client.gui.GuiTeleportPipe.java

License:Minecraft Mod Public

@Override
public void overlayBackground(int xPos, int yPos, int width, int height) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(TEXTURE);

    drawTexturedModalRect(xPos, yPos, xPos - guiLeft, yPos - guiTop, width, height);
}

From source file:additionalpipes.client.gui.GuiTeleportTether.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(TEXTURE);

    drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
}

From source file:advancedbrewing.gui.GuiButtonIcon.java

License:Minecraft Mod Public

@Override
public void drawButton(Minecraft minecraft, int par2, int par3) {
    if (this.drawButton) {
        minecraft.getTextureManager().bindTexture(GuiButtonIcon.buttonTextures);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        boolean mouseOver = par2 >= this.xPosition && par3 >= this.yPosition
                && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;

        if (mouseOver) {
            this.drawTexturedModalRect(this.xPosition, this.yPosition, 20, 0, this.width, this.height);
        } else {/*from www.j a  v a2  s.c o m*/
            this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 0, this.width, this.height);
        }

        this.drawTexturedModalRect(this.xPosition, this.yPosition, this.iconIndexX * 20, this.iconIndexY * 20,
                this.width, this.height);
    }
}