Example usage for org.lwjgl.opengl GL11 GL_FLAT

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

Introduction

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

Prototype

int GL_FLAT

To view the source code for org.lwjgl.opengl GL11 GL_FLAT.

Click Source Link

Document

ShadingModel

Usage

From source file:com.oneofthesevenbillion.ziah.ZiahsClient.util.Utils.java

License:Open Source License

/**
 * Draws a rectangle with a vertical gradient between the specified colors.
 */// w w w.j ava 2 s  .  c om
public static void drawGradientRect(int x, int y, int x1, int y2, int color1, int color2, float zLevel) {
    float var7 = (color1 >> 24 & 255) / 255.0F;
    float var8 = (color1 >> 16 & 255) / 255.0F;
    float var9 = (color1 >> 8 & 255) / 255.0F;
    float var10 = (color1 & 255) / 255.0F;
    float var11 = (color2 >> 24 & 255) / 255.0F;
    float var12 = (color2 >> 16 & 255) / 255.0F;
    float var13 = (color2 >> 8 & 255) / 255.0F;
    float var14 = (color2 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator var15 = Tessellator.instance;
    var15.startDrawingQuads();
    var15.setColorRGBA_F(var8, var9, var10, var7);
    var15.addVertex(x1, y, zLevel);
    var15.addVertex(x, y, zLevel);
    var15.setColorRGBA_F(var12, var13, var14, var11);
    var15.addVertex(x, y2, zLevel);
    var15.addVertex(x1, y2, zLevel);
    var15.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.professorvennie.machinerycraft.core.helpers.RenderHelper.java

License:Creative Commons License

public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
    float var7 = (par5 >> 24 & 255) / 255F;
    float var8 = (par5 >> 16 & 255) / 255F;
    float var9 = (par5 >> 8 & 255) / 255F;
    float var10 = (par5 & 255) / 255F;
    float var11 = (par6 >> 24 & 255) / 255F;
    float var12 = (par6 >> 16 & 255) / 255F;
    float var13 = (par6 >> 8 & 255) / 255F;
    float var14 = (par6 & 255) / 255F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from w w  w  . j  a  va2s.co m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator var15 = Tessellator.instance;
    var15.startDrawingQuads();
    var15.setColorRGBA_F(var8, var9, var10, var7);
    var15.addVertex(par3, par2, z);
    var15.addVertex(par1, par2, z);
    var15.setColorRGBA_F(var12, var13, var14, var11);
    var15.addVertex(par1, par4, z);
    var15.addVertex(par3, par4, z);
    var15.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

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

License:Open Source License

/**
 * Draws a rectangle with a HORIZONTAL gradient between the specified
 * colors.// w  w w  .j  a va2s. c o m
 * 
 * From MOJANG code
 */
protected void drawGradientRectH(int par1, int par2, int par3, int par4, int par5, int par6) {
    float f = (float) (par5 >> 24 & 255) / 255.0F;
    float f1 = (float) (par5 >> 16 & 255) / 255.0F;
    float f2 = (float) (par5 >> 8 & 255) / 255.0F;
    float f3 = (float) (par5 & 255) / 255.0F;
    float f4 = (float) (par6 >> 24 & 255) / 255.0F;
    float f5 = (float) (par6 >> 16 & 255) / 255.0F;
    float f6 = (float) (par6 >> 8 & 255) / 255.0F;
    float f7 = (float) (par6 & 255) / 255.0F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA_F(f5, f6, f7, f4);
    tessellator.addVertex((double) par3, (double) par2, (double) this.zLevel);
    tessellator.setColorRGBA_F(f1, f2, f3, f);
    tessellator.addVertex((double) par1, (double) par2, (double) this.zLevel);
    tessellator.addVertex((double) par1, (double) par4, (double) this.zLevel);
    tessellator.setColorRGBA_F(f5, f6, f7, f4);
    tessellator.addVertex((double) par3, (double) par4, (double) this.zLevel);
    tessellator.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.shinoow.abyssalcraft.client.render.entity.RenderDragonBoss.java

License:Apache License

/**
 * Renders the dragon, along with its dying animation
 *///from  ww  w.  j av a 2  s . c o m
public void renderDragon(EntityDragonBoss par1entitydragonboss, double par2, double par4, double par6,
        float par8, float par9) {
    BossStatus.setBossStatus(par1entitydragonboss, false);
    super.doRender(par1entitydragonboss, par2, par4, par6, par8, par9);

    if (par1entitydragonboss.healingcircle != null) {
        float f2 = EntityDragonMinion.innerRotation + par9;
        float f3 = MathHelper.sin(f2 * 0.2F) / 2.0F + 0.5F;
        f3 = (f3 * f3 + f3) * 0.2F;
        float f4 = (float) (par1entitydragonboss.healingcircle.posX - par1entitydragonboss.posX
                - (par1entitydragonboss.prevPosX - par1entitydragonboss.posX) * (1.0F - par9));
        float f5 = (float) (f3 + par1entitydragonboss.healingcircle.posY - 1.0D - par1entitydragonboss.posY
                - (par1entitydragonboss.prevPosY - par1entitydragonboss.posY) * (1.0F - par9));
        float f6 = (float) (par1entitydragonboss.healingcircle.posZ - par1entitydragonboss.posZ
                - (par1entitydragonboss.prevPosZ - par1entitydragonboss.posZ) * (1.0F - par9));
        float f7 = MathHelper.sqrt_float(f4 * f4 + f6 * f6);
        float f8 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6);
        GL11.glPushMatrix();
        GL11.glTranslatef((float) par2, (float) par4 + 2.0F, (float) par6);
        GL11.glRotatef((float) -Math.atan2(f6, f4) * 180.0F / (float) Math.PI - 90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef((float) -Math.atan2(f7, f5) * 180.0F / (float) Math.PI - 90.0F, 1.0F, 0.0F, 0.0F);
        Tessellator tessellator = Tessellator.instance;
        RenderHelper.disableStandardItemLighting();
        GL11.glDisable(GL11.GL_CULL_FACE);
        bindTexture(field_110843_g);
        GL11.glShadeModel(GL11.GL_SMOOTH);
        float f9 = 0.0F - (par1entitydragonboss.ticksExisted + par9) * 0.01F;
        float f10 = MathHelper.sqrt_float(f4 * f4 + f5 * f5 + f6 * f6) / 32.0F
                - (par1entitydragonboss.ticksExisted + par9) * 0.01F;
        tessellator.startDrawing(5);
        byte b0 = 8;

        for (int i = 0; i <= b0; ++i) {
            float f11 = MathHelper.sin(i % b0 * (float) Math.PI * 2.0F / b0) * 0.75F;
            float f12 = MathHelper.cos(i % b0 * (float) Math.PI * 2.0F / b0) * 0.75F;
            float f13 = i % b0 * 1.0F / b0;
            tessellator.setColorOpaque_I(0);
            tessellator.addVertexWithUV(f11 * 0.2F, f12 * 0.2F, 0.0D, f13, f10);
            tessellator.setColorOpaque_I(16777215);
            tessellator.addVertexWithUV(f11, f12, f8, f13, f9);
        }

        tessellator.draw();
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glShadeModel(GL11.GL_FLAT);
        RenderHelper.enableStandardItemLighting();
        GL11.glPopMatrix();
    }
}

From source file:com.shinoow.abyssalcraft.client.render.entity.RenderDragonBoss.java

License:Apache License

/**
 * Renders the animation for when an enderdragon dies
 *//*  w w  w  . ja  v a 2s.c o m*/
protected void renderDragonDying(EntityDragonBoss par1entitydragonboss, float par2) {
    super.renderEquippedItems(par1entitydragonboss, par2);
    Tessellator tessellator = Tessellator.instance;

    if (par1entitydragonboss.deathTicks > 0) {
        RenderHelper.disableStandardItemLighting();
        float f1 = (par1entitydragonboss.deathTicks + par2) / 200.0F;
        float f2 = 0.0F;

        if (f1 > 0.8F)
            f2 = (f1 - 0.8F) / 0.2F;

        Random random = new Random(432L);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthMask(false);
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, -1.0F, -2.0F);

        for (int i = 0; i < (f1 + f1 * f1) / 2.0F * 60.0F; ++i) {
            GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F + f1 * 90.0F, 0.0F, 0.0F, 1.0F);
            tessellator.startDrawing(6);
            float f3 = random.nextFloat() * 20.0F + 5.0F + f2 * 10.0F;
            float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F;
            tessellator.setColorRGBA_I(16777215, (int) (255.0F * (1.0F - f2)));
            tessellator.addVertex(0.0D, 0.0D, 0.0D);
            tessellator.setColorRGBA_I(16711935, 0);
            tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
            tessellator.addVertex(0.866D * f4, f3, -0.5F * f4);
            tessellator.addVertex(0.0D, f3, 1.0F * f4);
            tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
            tessellator.draw();
        }

        GL11.glPopMatrix();
        GL11.glDepthMask(true);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glShadeModel(GL11.GL_FLAT);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        RenderHelper.enableStandardItemLighting();
    }
}

From source file:com.sr2610.steampunkd.client.TooltipHelper.java

License:Creative Commons License

public static void drawGradientRect(int par1, int par2, float z, int par3, int par4, int par5, int par6) {
    float var7 = ((par5 >> 24) & 255) / 255F;
    float var8 = ((par5 >> 16) & 255) / 255F;
    float var9 = ((par5 >> 8) & 255) / 255F;
    float var10 = (par5 & 255) / 255F;
    float var11 = ((par6 >> 24) & 255) / 255F;
    float var12 = ((par6 >> 16) & 255) / 255F;
    float var13 = ((par6 >> 8) & 255) / 255F;
    float var14 = (par6 & 255) / 255F;
    GlStateManager.disableTexture2D();/* w  w  w .j av a  2 s.c om*/
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    Tessellator var15 = Tessellator.getInstance();
    var15.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    var15.getBuffer().pos(par3, par2, z).color(var8, var9, var10, var7).endVertex();
    var15.getBuffer().pos(par1, par2, z).color(var8, var9, var10, var7).endVertex();
    var15.getBuffer().pos(par1, par4, z).color(var12, var13, var14, var11).endVertex();
    var15.getBuffer().pos(par3, par4, z).color(var12, var13, var14, var11).endVertex();
    var15.draw();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableTexture2D();
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

public InspectorCanvas(Composite parent, int style, GLData data) {
    super(parent, style, data);
    setCurrent();//w w  w.j  a va  2 s  .com

    // Clear the canvas.
    GL11.glClearColor(CLEAR_COLOR[0], CLEAR_COLOR[1], CLEAR_COLOR[2], CLEAR_COLOR[3]);
    GL11.glClearDepth(1.0f);
    GL11.glLineWidth(1.0f);
    GL11.glPointSize(1.0f);

    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
    GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.01f);

    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0xf);
    GL11.glStencilOp(GL11.GL_INCR, GL11.GL_KEEP, GL11.GL_INCR);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    reset();

    mTransform = new Matrix4f();
    mTransform.setIdentity();

    addListener(SWT.Resize, this);
    addListener(SWT.Paint, this);
    addMouseListener(this);
    addMouseWheelListener(this);
}

From source file:com.teambrmodding.luxetumbra.client.gui.GuiToggleMenu.java

License:Creative Commons License

@Override
public void drawScreen(int mx, int my, float partialTicks) {
    super.drawScreen(mx, my, partialTicks);

    GlStateManager.pushMatrix();/*from   ww  w  .ja  va  2 s.  c  o m*/
    GlStateManager.disableTexture2D();

    final int x = width / 2;
    final int y = height / 2;
    final int maxRadius = 60;

    final boolean mouseIn = true;
    final float angle = mouseAngle(x, y, mx, my);
    final float distance = mouseDistance(x, y, mx, my);

    final int highlight = 5;

    GlStateManager.enableBlend();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    final int segments = 2; //TODO
    float totalDeg = 0F;
    final float degPer = 360F / segments;

    final List<int[]> stringPosition = new ArrayList<>();

    boolean wasSelected = false;

    for (int seg = 0; seg <= segments; seg++) {
        boolean mouseOverSection = distance <= maxRadius
                && (mouseIn && angle > totalDeg && angle < totalDeg + degPer);
        float radius = Math.max(0F, Math.min(timeIn * 10F, maxRadius));

        GL11.glBegin(GL11.GL_TRIANGLE_FAN);
        float gs = 0.25F;
        if (seg % 2 == 0)
            gs += 0.1F;
        float r = 200; //TODO
        float g = 200; //TODO
        float b = gs;
        float a = 0.4F;
        if (mouseOverSection) {
            selected = seg;
            wasSelected = true;
            r = 255; //TODO
            g = 255; //TODO
            a = 0.5F;
        }
        GlStateManager.color(r, g, b, a);
        GL11.glVertex2i(x, y);
        float i = degPer;
        while (i >= 0) {
            double rad = ((i + totalDeg) / 180F * Math.PI);
            double xp = x + Math.cos(rad) * radius;
            double yp = y + Math.sin(rad) * radius;
            if (i == (int) (degPer / 2))
                stringPosition.add(new int[] { seg, (int) xp, (int) yp, mouseOverSection ? 'n' : 'r' });
            GL11.glVertex2d(xp, yp);
            i -= 1;
        }
        totalDeg += degPer;

        GL11.glVertex2i(x, y);
        GL11.glEnd();

        if (mouseOverSection)
            radius -= highlight;
    }

    if (!wasSelected)
        selected = -1;

    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableTexture2D();

    for (int[] pos : stringPosition) {
        int slot = pos[0];
        float xp = pos[1];
        float yp = pos[2];
        char c = (char) pos[3];

        ItemStack displayStack = new ItemStack(Items.APPLE);
        if (displayStack != null) {
            float xsp = xp - 4;
            float ysp = yp;
            String name = "\u00a7" + c + "testing";
            int width = fontRendererObj.getStringWidth(name);

            float mod = 0.6F;
            int xdp = (int) ((xp - x) * mod + x);
            int ydp = (int) ((yp - y) * mod + y);

            RenderHelper.enableGUIStandardItemLighting();
            GlStateManager.pushMatrix();
            GlStateManager.translate(xdp - 10, ydp - 10, 2);
            GlStateManager.scale(1.25, 1.25, 1.25);
            Minecraft.getMinecraft().getRenderItem().renderItemIntoGUI(displayStack, 0, 0);
            GlStateManager.popMatrix();
            RenderHelper.disableStandardItemLighting();

            if (xsp < x)
                xsp -= width - 8;
            if (ysp < y)
                ysp -= 9;

            fontRendererObj.drawStringWithShadow(name, xsp, ysp, 0xFFFFFF);
        }
    }

    GlStateManager.popMatrix();
}

From source file:cpw.mods.fml.client.GuiScrollingList.java

License:Open Source License

public void drawScreen(int mouseX, int mouseY, float p_22243_3_) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    this.drawBackground();
    int listLength = this.getSize();
    int scrollBarXStart = this.left + this.listWidth - 6;
    int scrollBarXEnd = scrollBarXStart + 6;
    int boxLeft = this.left;
    int boxRight = scrollBarXStart - 1;
    int var10;
    int var11;
    int var13;
    int var19;

    if (Mouse.isButtonDown(0)) {
        if (this.initialMouseClickY == -1.0F) {
            boolean var7 = true;

            if (mouseY >= this.top && mouseY <= this.bottom) {
                var10 = mouseY - this.top - this.field_27261_r + (int) this.scrollDistance - 4;
                var11 = var10 / this.slotHeight;

                if (mouseX >= boxLeft && mouseX <= boxRight && var11 >= 0 && var10 >= 0 && var11 < listLength) {
                    boolean var12 = var11 == this.selectedIndex
                            && System.currentTimeMillis() - this.lastClickTime < 250L;
                    this.elementClicked(var11, var12);
                    this.selectedIndex = var11;
                    this.lastClickTime = System.currentTimeMillis();
                } else if (mouseX >= boxLeft && mouseX <= boxRight && var10 < 0) {
                    this.func_27255_a(mouseX - boxLeft, mouseY - this.top + (int) this.scrollDistance - 4);
                    var7 = false;
                }/*from w  ww  . j  a v a  2s .c om*/

                if (mouseX >= scrollBarXStart && mouseX <= scrollBarXEnd) {
                    this.scrollFactor = -1.0F;
                    var19 = this.getContentHeight() - (this.bottom - this.top - 4);

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

                    var13 = (int) ((float) ((this.bottom - this.top) * (this.bottom - this.top))
                            / (float) this.getContentHeight());

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

                    if (var13 > this.bottom - this.top - 8) {
                        var13 = this.bottom - this.top - 8;
                    }

                    this.scrollFactor /= (float) (this.bottom - this.top - var13) / (float) var19;
                } else {
                    this.scrollFactor = 1.0F;
                }

                if (var7) {
                    this.initialMouseClickY = (float) mouseY;
                } else {
                    this.initialMouseClickY = -2.0F;
                }
            } else {
                this.initialMouseClickY = -2.0F;
            }
        } else if (this.initialMouseClickY >= 0.0F) {
            this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor;
            this.initialMouseClickY = (float) mouseY;
        }
    } else {
        while (Mouse.next()) {
            int var16 = Mouse.getEventDWheel();

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

                this.scrollDistance += (float) (var16 * this.slotHeight / 2);
            }
        }

        this.initialMouseClickY = -1.0F;
    }

    this.applyScrollLimits();
    Tessellator var18 = Tessellator.instance;
    if (this.client.theWorld != null) {
        this.drawGradientRect(this.left, this.top, this.right, this.bottom, -1072689136, -804253680);
    } else {
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_FOG);
        this.client.renderEngine.bindTexture(Gui.optionsBackground);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        float var17 = 32.0F;
        var18.startDrawingQuads();
        var18.setColorOpaque_I(2105376);
        var18.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D,
                (double) ((float) this.left / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        var18.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, (double) ((float) this.left / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        var18.draw();
    }
    //        boxRight = this.listWidth / 2 - 92 - 16;
    var10 = this.top + 4 - (int) this.scrollDistance;

    if (this.field_27262_q) {
        this.func_27260_a(boxRight, var10, var18);
    }

    int var14;

    for (var11 = 0; var11 < listLength; ++var11) {
        var19 = var10 + var11 * this.slotHeight + this.field_27261_r;
        var13 = this.slotHeight - 4;

        if (var19 <= this.bottom && var19 + var13 >= this.top) {
            if (this.field_25123_p && this.isSelected(var11)) {
                var14 = boxLeft;
                int var15 = boxRight;
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                var18.startDrawingQuads();
                var18.setColorOpaque_I(8421504);
                var18.addVertexWithUV((double) var14, (double) (var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
                var18.addVertexWithUV((double) var15, (double) (var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
                var18.addVertexWithUV((double) var15, (double) (var19 - 2), 0.0D, 1.0D, 0.0D);
                var18.addVertexWithUV((double) var14, (double) (var19 - 2), 0.0D, 0.0D, 0.0D);
                var18.setColorOpaque_I(0);
                var18.addVertexWithUV((double) (var14 + 1), (double) (var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
                var18.addVertexWithUV((double) (var15 - 1), (double) (var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
                var18.addVertexWithUV((double) (var15 - 1), (double) (var19 - 1), 0.0D, 1.0D, 0.0D);
                var18.addVertexWithUV((double) (var14 + 1), (double) (var19 - 1), 0.0D, 0.0D, 0.0D);
                var18.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

            this.drawSlot(var11, boxRight, var19, var13, var18);
        }
    }

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    byte var20 = 4;
    if (this.client.theWorld == null) {
        this.overlayBackground(0, this.top, 255, 255);
        this.overlayBackground(this.bottom, this.listHeight, 255, 255);
    }
    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);
    var18.startDrawingQuads();
    var18.setColorRGBA_I(0, 0);
    var18.addVertexWithUV((double) this.left, (double) (this.top + var20), 0.0D, 0.0D, 1.0D);
    var18.addVertexWithUV((double) this.right, (double) (this.top + var20), 0.0D, 1.0D, 1.0D);
    var18.setColorRGBA_I(0, 255);
    var18.addVertexWithUV((double) this.right, (double) this.top, 0.0D, 1.0D, 0.0D);
    var18.addVertexWithUV((double) this.left, (double) this.top, 0.0D, 0.0D, 0.0D);
    var18.draw();
    var18.startDrawingQuads();
    var18.setColorRGBA_I(0, 255);
    var18.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D, 0.0D, 1.0D);
    var18.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D, 1.0D, 1.0D);
    var18.setColorRGBA_I(0, 0);
    var18.addVertexWithUV((double) this.right, (double) (this.bottom - var20), 0.0D, 1.0D, 0.0D);
    var18.addVertexWithUV((double) this.left, (double) (this.bottom - var20), 0.0D, 0.0D, 0.0D);
    var18.draw();
    var19 = this.getContentHeight() - (this.bottom - this.top - 4);

    if (var19 > 0) {
        var13 = (this.bottom - this.top) * (this.bottom - this.top) / this.getContentHeight();

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

        if (var13 > this.bottom - this.top - 8) {
            var13 = this.bottom - this.top - 8;
        }

        var14 = (int) this.scrollDistance * (this.bottom - this.top - var13) / var19 + this.top;

        if (var14 < this.top) {
            var14 = this.top;
        }

        var18.startDrawingQuads();
        var18.setColorRGBA_I(0, 255);
        var18.addVertexWithUV((double) scrollBarXStart, (double) this.bottom, 0.0D, 0.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) this.bottom, 0.0D, 1.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) this.top, 0.0D, 1.0D, 0.0D);
        var18.addVertexWithUV((double) scrollBarXStart, (double) this.top, 0.0D, 0.0D, 0.0D);
        var18.draw();
        var18.startDrawingQuads();
        var18.setColorRGBA_I(8421504, 255);
        var18.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13), 0.0D, 0.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) (var14 + var13), 0.0D, 1.0D, 1.0D);
        var18.addVertexWithUV((double) scrollBarXEnd, (double) var14, 0.0D, 1.0D, 0.0D);
        var18.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        var18.draw();
        var18.startDrawingQuads();
        var18.setColorRGBA_I(12632256, 255);
        var18.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
        var18.addVertexWithUV((double) (scrollBarXEnd - 1), (double) (var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
        var18.addVertexWithUV((double) (scrollBarXEnd - 1), (double) var14, 0.0D, 1.0D, 0.0D);
        var18.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        var18.draw();
    }

    this.func_27257_b(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:de.sanandrew.core.manpack.util.client.helpers.GuiUtils.java

License:Creative Commons License

public static void drawGradientRect(int x1, int y1, int x2, int y2, int color1, int color2, float zLevel) {
    float a1 = (color1 >> 24 & 255) / 255.0F;
    float r1 = (color1 >> 16 & 255) / 255.0F;
    float g1 = (color1 >> 8 & 255) / 255.0F;
    float b1 = (color1 & 255) / 255.0F;
    float a2 = (color2 >> 24 & 255) / 255.0F;
    float r2 = (color2 >> 16 & 255) / 255.0F;
    float g2 = (color2 >> 8 & 255) / 255.0F;
    float b2 = (color2 & 255) / 255.0F;

    GL11.glDisable(GL11.GL_TEXTURE_2D);//ww w  . jav  a2 s  . c om
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    tessellator.setColorRGBA_F(r2, g2, b2, a2);
    tessellator.addVertex(x2, y1, zLevel);
    tessellator.setColorRGBA_F(r1, g1, b1, a1);
    tessellator.addVertex(x1, y1, zLevel);
    tessellator.addVertex(x1, y2, zLevel);
    tessellator.setColorRGBA_F(r2, g2, b2, a2);
    tessellator.addVertex(x2, y2, zLevel);
    tessellator.draw();
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}