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.savageboy74.savagetech.gui.GuiLootBag.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    this.mc.getTextureManager().bindTexture(Textures.Gui.LOOT_BAG);

    int xStart = (width - xSize) / 2;
    int yStart = (height - ySize) / 2;

    this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
}

From source file:com.savageboy74.savagetech.gui.GuiLootBox.java

License:Open Source License

@Override
public void drawGuiContainerBackgroundLayer(float opacity, int x, int y) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    this.mc.getTextureManager().bindTexture(Textures.Gui.LOOT_BOX);

    int xStart = (width - xSize) / 2;
    int yStart = (height - ySize) / 2;
    this.drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
}

From source file:com.savoycraft.gui.GuiButtonL.java

License:Open Source License

@Override
public void drawButton(Minecraft mc, int mx, int my) {
    if (drawButton) {
        // Check for hover
        field_82253_i = isMouseOver(mx, my);

        // Set up texture
        // GL11.glBindTexture(GL11.GL_TEXTURE_2D,
        // mc.renderEngine.getTexture("/gui/gui.png"));
        mc.renderEngine.bindTexture("/gui/gui.png");
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        // Draw texture, grabbing a half from each end of the button texture
        // and moving them closer or farther to match the button's width
        int hoverState = getHoverState(isMouseOver(mx, my));
        drawTexturedModalRect(xPosition, yPosition, 0, 46 + hoverState * 20, width / 2, height);
        drawTexturedModalRect(xPosition + width / 2, yPosition, 200 - width / 2, 46 + hoverState * 20,
                width / 2, height);//w  w  w .  ja  v a 2 s  .co m

        // Fire a mouse dragged event
        mouseDragged(mc, mx, my);

        // Decide the label's color
        int labelColor = 0xE0E0E0;
        if (!enabled) {
            labelColor = 0xFFA0A0A0;
        } else if (field_82253_i) {
            labelColor = 0xFFFFA0;
        }

        // Draw label
        int labelOffset = 0;
        int textWidth = mc.fontRenderer.getStringWidth(displayString);
        if (isIconShown() && width < textWidth + 40) {
            labelOffset += 9;
        }
        drawCenteredString(mc.fontRenderer, displayString, xPosition + width / 2 + labelOffset,
                yPosition + (height - 8) / 2, labelColor);

        // Draw icon
        if (isIconShown()) {
            //GL11.glBindTexture(GL11.GL_TEXTURE_2D, iconTex);
            mc.renderEngine.bindTexture(iconTex);
            drawTexturedModalRect(xPosition + 2, yPosition + 2, (iconIndex % 16) * 16, (iconIndex / 16) * 16,
                    16, 16);
        }
    }
}

From source file:com.savoycraft.gui.GuiScrollingTextPanel.java

License:Open Source License

public void draw(int mx, int my) {
    mouseMovedOrUp(mx, my, -1);//from   w ww .ja v  a2  s. c o m

    if (visible) {
        // Draw background

        if (textureBackground) {
            //            int bgTextureNumber = Minecraft.getMinecraft().renderEngine
            //                  .getTexture("/com/minetunes/resources/textures/signBG2.png");
            Minecraft.getMinecraft().renderEngine.bindTexture("/com/minetunes/resources/textures/signBG2.png");
            int currBGTextureY = y;
            // Tile background texture vertically
            while (currBGTextureY - y < height) {
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5f);
                // Minecraft.getMinecraft().renderEngine
                // .bindTexture(bgTextureNumber);
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5f);

                int textureHeight = 128;
                // If too tall, decide how much to shorten
                if (height - (currBGTextureY - y) < 128) {
                    textureHeight = height % 128;
                }

                // Draw background texture
                drawTexturedModalRect(x, currBGTextureY, 0, 0, width, textureHeight);

                currBGTextureY += 128;
            }
        } else {
            // drawRect(x, y, width + x, height + y, 0x44666666);
        }

        // Draw Text
        // Update lines that can be shown at current size
        // Draw as many lines as can fit
        linesShown = 0;
        if (text != null) {
            int currLine = startLine;
            for (int textY = y + MARGIN; textY < y + height - MARGIN * 2; textY += 10) {
                if (currLine < text.length) {
                    int textX = x + MARGIN;
                    if (scrollbarOnLeft) {
                        textX += SCROLL_BAR_WIDTH;
                    }
                    drawString(fontRenderer, text[currLine], x + MARGIN, textY, 0xffffff);
                    linesShown++;
                    currLine++;
                } else {
                    break;
                }
            }
        }

        // Draw Scrollbar
        if (linesShown < text.length) {
            placeInText = (double) startLine / ((double) text.length - (double) linesShown);
            double scrollBarMovementRange = ((double) height * (1d - (1d / SCROLLBAR_FRAC_HEIGHT)));
            scrollBarTopY = (int) (scrollBarMovementRange * (placeInText) + y);
            // System.out.println((double) placeInText / ((double)
            // text.length -
            // (double) linesShown));
            scrollBarHeight = (int) ((double) height / SCROLLBAR_FRAC_HEIGHT);
            int scrollbarColor = 0xffffffff;
            if (draggingScrollBar) {
                scrollbarColor = 0xff00ff00;
            } else if (scrollbarHighlighted) {
                scrollbarColor = 0xffffffff;
            } else {
                scrollbarColor = 0xbbbbbbbb;
            }
            int scrollBarX;
            if (scrollbarOnLeft) {
                scrollBarX = 0;
            } else {
                scrollBarX = x + width - SCROLL_BAR_WIDTH;
            }
            drawRect(scrollBarX, y, scrollBarX + SCROLL_BAR_WIDTH, y + height, 0x44888888);
            drawGradientRect(scrollBarX - 1, scrollBarTopY, scrollBarX + SCROLL_BAR_WIDTH + 1,
                    scrollBarTopY + scrollBarHeight, scrollbarColor, 0x88888888);
        }
    }
}

From source file:com.savoycraft.gui.GuiSlider.java

License:Open Source License

/**
 * Fired when the mouse button is dragged. Equivalent of
 * MouseListener.mouseDragged(MouseEvent e).
 *///from www.  j  a  v a 2s  .com
protected void mouseDragged(Minecraft par1Minecraft, int x, int y) {
    if (!drawButton) {
        return;
    }

    if (dragging) {
        sliderValue = limitToRange((float) (x - (xPosition + 4)) / (float) (width - 8));
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    drawTexturedModalRect(xPosition + (int) (sliderValue * (float) (width - 8)), yPosition, 0, 66, 4, 20);
    drawTexturedModalRect(xPosition + (int) (sliderValue * (float) (width - 8)) + 4, yPosition, 196, 66, 4, 20);
}

From source file:com.savoycraft.gui.help.GuiHelp.java

License:Open Source License

@Override
public void drawScreen(int mx, int my, float par3) {
    drawDefaultBackground();/*from  w w w .j  av  a2 s  .co m*/

    // Draw sign background
    GL11.glColor4f(0.8f, 0.8f, 0.8f, 1.0f);
    // mc.renderEngine.bindTexture(Minecraft.getMinecraft().renderEngine
    // .getTexture("/com/minetunes/resources/textures/signBG2.png"));
    Minecraft.getMinecraft().renderEngine.bindTexture("/com/minetunes/resources/textures/signBG2.png");
    // drawTexturedModalRect(0, height - BOTTOM_MARGIN, 0, 0, width,
    // BOTTOM_MARGIN);
    for (int i = 0; i < height; i += 128) {
        drawTexturedModalRect(0, i, 0, 0, width, height);
    }

    if (badCaptions || notDownloaded) {
        return;
    }

    if (currSlide == -1) {
        changeSlide(0);
    }

    // Render the picture
    Slide slide = slides.get(currSlide);
    slide.draw(new Rectangle(width - 2 * SIDE_BUTTON_WIDTH, height - TOP_MARGIN - BOTTOM_MARGIN), true);

    // Render the title and caption
    drawCenteredString(fontRenderer, slide.getTitle(), width / 2, (TOP_MARGIN / 2) - 5, 0xffff00);
    fontRenderer.drawSplitString(slide.getCaption(), SIDE_BUTTON_WIDTH + 2, height - 40,
            width - 2 * SIDE_BUTTON_WIDTH - 4, 0xffffff);

    // Render left and right buttons
    if (currSlide < numSlides - 1) {
        fwdButton.draw(mx, my, par3, fontRenderer);
    }
    if (currSlide > 0) {
        backButton.draw(mx, my, par3, fontRenderer);
    }

    exitButton.draw(mx, my, par3, fontRenderer);
    if (printableSlide) {
        printButton.draw(mx, my, par3, fontRenderer);
    }

    // Render count
    drawString(fontRenderer, (currSlide + 1) + " of " + numSlides, width - 50, (TOP_MARGIN / 2) - 5, 0xffffff);

    // Render buttons
    super.drawScreen(mx, my, par3);
}

From source file:com.savoycraft.gui.help.Slide.java

License:Open Source License

/**
 * Draws the slide. Ignores x and y of rectangle. Call prepareToShow()
 * before calling this; otherwise it will be run automatically on the first
 * call to draw(). (dontPrepare removes this behaviour)
 *//*from w w  w .j  a  v a 2s. c  o  m*/
public void draw(Rectangle validArea, boolean dontPrepare) {
    if (image == null) {
        if (dontPrepare) {
            return;
        } else {
            prepareToShow();
        }
    }

    // Still can't load?
    if (image == null) {
        return;
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0f);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);

    // Get the width and height of the slide's image on the texture
    // Note that the way MC works, U and V in the texture will always max
    // out at 256, not 512, 1024, or whatever size it really is.
    int textureWidth = (int) (getUsedWidth() / (double) getImage().getWidth() * 256d);
    int textureHeight = (int) (getUsedHeight() / (double) getImage().getHeight() * 256d);

    // Decide the width and height to draw the texture at onto the screen
    // First, compare the aspect ratios of the slide's image and the valid
    // area for it
    double imageAspect = (double) textureWidth / (double) textureHeight;
    double areaAspect = (double) validArea.width / (double) validArea.height;
    int drawWidth, drawHeight;
    if (imageAspect > areaAspect) {
        // If texture is wider than area, width = area's width and change
        // the drawn height
        drawWidth = validArea.width;
        drawHeight = (int) ((double) drawWidth / imageAspect);
    } else {
        // Otherwise, texture is taller than area, height = area's height
        // and change the drawn width
        drawHeight = validArea.height;
        drawWidth = (int) ((double) drawHeight * imageAspect);
    }

    // Calculate the x and y coords of each corner (upper left, lower
    // right)
    int x1 = x + (validArea.width / 2) - (drawWidth / 2);
    int y1 = y + (validArea.height / 2) - (drawHeight / 2);
    int x2 = x + (validArea.width / 2) + (drawWidth / 2);
    int y2 = y + (validArea.height / 2) + (drawHeight / 2);

    // Draw
    double uScale = 1f / 256f;
    double vScale = 1f / 256f;
    Tessellator tess = Tessellator.instance;
    tess.startDrawingQuads();
    tess.addVertexWithUV(x1, y2, 0, 0, textureHeight * vScale);
    tess.addVertexWithUV(x2, y2, 0, textureWidth * uScale, textureHeight * vScale);
    tess.addVertexWithUV(x2, y1, 0, textureWidth * uScale, 0);
    tess.addVertexWithUV(x1, y1, 0, 0, vScale);
    tess.draw();
}

From source file:com.savoycraft.gui.MinetunesGui.java

License:Open Source License

@Override
public void drawScreen(int mx, int my, float par3) {
    updateTweens();//w  w  w  .  ja v  a  2  s.c o  m

    // draw background
    drawMinetunesBackground(width, height);

    // Draw logo
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.5f);
    Minecraft.getMinecraft().renderEngine.bindTexture("/com/minetunes/resources/textures/mineTunesLogo.png");
    // drawTexturedModalRect(width / 2 - 64, 10, 100, 0, 128, 64);
    drawRect(width / 2 - 55, 5, width / 2 + 55, 55, 0xddffffff);
    drawTexturedModalRect(width / 2 - 50, 10, 0, 0, 100, 36);

    // Update buttons
    updateButtonLabels();
    addTutorialCancel();

    // Update tiles
    for (TuneTileGui t : tiles) {
        t.draw(mc, mx, my);
    }

    // Draw buttons
    super.drawScreen(mx, my, par3);
}

From source file:com.savoycraft.gui.TGComponent.java

License:Open Source License

protected void setGLColorFG() {
    GL11.glColor4f(fgColor[0], fgColor[1], fgColor[2], fgColor[3]);
}

From source file:com.savoycraft.gui.TGComponent.java

License:Open Source License

protected void setGLColorBG() {
    GL11.glColor4f(bgColor[0], bgColor[1], bgColor[2], bgColor[3]);
}