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:de.sanandrew.mods.claysoldiers.client.event.SoldierBodyRenderHandler.java

License:Creative Commons License

private void renderThunderbolt(EntityClayMan clayMan, double targetX, double targetY, double targetZ) {
    NBTTagCompound effectNbt = clayMan.getEffect(SoldierEffects.EFF_THUNDER).getNbtTag();
    if (effectNbt.getShort("ticksRemaining") < 17) {
        return;//from www  . ja va2s. co m
    }

    double originX = effectNbt.getDouble("originX") - clayMan.posX + targetX;
    double originY = effectNbt.getDouble("originY") - clayMan.posY + targetY;
    double originZ = effectNbt.getDouble("originZ") - clayMan.posZ + targetZ;

    List<Triplet<Double, Double, Double>> randCoords = new ArrayList<>();
    randCoords.add(Triplet.with(0.0D, 0.0D, 0.0D));

    this.p_thunderboldRNG.setSeed(effectNbt.getLong("randomLightning"));

    int size = this.p_thunderboldRNG.nextInt(5) + 6;
    for (int i = 0; i < size; i++) {
        randCoords.add(Triplet.with(this.p_thunderboldRNG.nextDouble() * 0.5D - 0.25D,
                this.p_thunderboldRNG.nextDouble() * 0.5D - 0.25D,
                this.p_thunderboldRNG.nextDouble() * 0.5D - 0.25D));
    }
    randCoords.add(Triplet.with(0.0D, 0.25D, 0.0D));
    size++;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    float prevLightX = OpenGlHelper.lastBrightnessX;
    float prevLightY = OpenGlHelper.lastBrightnessY;
    int brightness = 0xF0;
    int brightX = brightness % 65536;
    int brightY = brightness / 65536;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX / 1.0F, brightY / 1.0F);

    for (int i = 0; i < size; i++) {
        Triplet<Double, Double, Double> origin = randCoords.get(i);
        Triplet<Double, Double, Double> target = randCoords.get(i + 1);

        double oX = originX + ((targetX - originX) / size) * (i) + origin.getValue0();
        double tX = originX + ((targetX - originX) / size) * (i + 1) + target.getValue0();

        double oY = originY + ((targetY - originY) / size) * (i) + origin.getValue1();
        double tY = originY + ((targetY - originY) / size) * (i + 1) + target.getValue1();

        double oZ = originZ + ((targetZ - originZ) / size) * (i) + origin.getValue2();
        double tZ = originZ + ((targetZ - originZ) / size) * (i + 1) + target.getValue2();

        drawThunderboldPart(Tessellator.instance, oX, oY, oZ, tX, tY, tZ);
    }

    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevLightX, prevLightY);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:de.sanandrew.mods.turretmod.client.render.world.RenderTurretPointed.java

License:Creative Commons License

private void renderLabel(EntityTurret turret, double x, double y, double z, LabelEntry lbl) {
    final Minecraft mc = Minecraft.getMinecraft();
    final FontRenderer fontrenderer = mc.fontRenderer;
    final float scale = 0.010F;
    final List<ILabelElement> fltElem = this.elements.stream().filter(el -> el.showElement(turret))
            .sorted((el1, el2) -> Integer.compare(el2.getPriority(), el1.getPriority()))
            .collect(Collectors.toList());

    lbl.maxWidth = fltElem.stream()/*from  w  w  w. ja  v  a2 s .c o  m*/
            .collect(() -> new MutableFloat(MIN_WIDTH),
                    (f, l) -> f.setValue(Math.max(f.getValue(), l.getWidth(turret, fontrenderer))),
                    (f1, f2) -> f1.setValue(Math.max(f1.getValue(), f2.getValue())))
            .floatValue();
    lbl.maxHeight = fltElem.stream().collect(() -> new MutableFloat(0.0F),
            (f, l) -> f.add(l.getHeight(turret, fontrenderer)), (f1, f2) -> f1.add(f2.getValue())).floatValue();

    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buffer = tessellator.getBuffer();

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y + (turret.isUpsideDown() ? 1.4F : 0.7F), z);
    GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(lbl.angleY, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(lbl.angleX, 1.0F, 0.0F, 0.0F);
    GlStateManager.scale(-scale, -scale, scale);
    GlStateManager.translate(-lbl.maxWidth / 2.0D, -32.0D, 0.0D);
    GlStateManager.disableLighting();
    GlStateManager.depthMask(false);
    GlStateManager.disableDepth();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA,
            GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);

    buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    float alphaMulti = Math.min(1.0F, lbl.progress);
    ColorObj clrTop = new ColorObj(0x0050FF00 | (Math.max(Math.round(0xCC * alphaMulti), 4) << 24));
    ColorObj clrBottom = new ColorObj(0x00288000 | (Math.max(Math.round(0xCC * alphaMulti), 4) << 24));
    ColorObj clrMain = new ColorObj(0x00001000 | (Math.max(Math.round(0xA0 * alphaMulti), 4) << 24));

    // main bg
    addQuad(buffer, -2.0D, -2.0D, lbl.maxWidth + 2.0D, lbl.maxHeight + 2.0D, clrMain);

    // inner frame [top, bottom, left, right]
    addQuad(buffer, -3.0D, -3.0D, lbl.maxWidth + 3.0D, -2.0D, clrTop);
    addQuad(buffer, -3.0D, lbl.maxHeight + 2.0D, lbl.maxWidth + 3.0D, lbl.maxHeight + 3.0D, clrBottom);
    addQuad(buffer, -3.0D, -2.0D, -2.0D, lbl.maxHeight + 2.0D, clrTop, clrBottom);
    addQuad(buffer, lbl.maxWidth + 2.0D, -2.0D, lbl.maxWidth + 3.0D, lbl.maxHeight + 2.0D, clrTop, clrBottom);

    // outer frame [top, bottom, left, right]
    addQuad(buffer, -3.0D, -4.0D, lbl.maxWidth + 3.0D, -3.0D, clrMain);
    addQuad(buffer, -3.0D, lbl.maxHeight + 3.0D, lbl.maxWidth + 3.0D, lbl.maxHeight + 4.0D, clrMain);
    addQuad(buffer, -4.0D, -3.0D, -3.0D, lbl.maxHeight + 3.0D, clrMain);
    addQuad(buffer, lbl.maxWidth + 3.0D, -3.0D, lbl.maxWidth + 4.0D, lbl.maxHeight + 3.0D, clrMain);

    if (lbl.progress >= 1.0F) {
        final MutableFloat currHeight = new MutableFloat(0.0F);
        fltElem.forEach(elem -> {
            elem.doRenderQuads(turret, lbl.maxWidth, lbl.progress - 1.0F, fontrenderer, currHeight.floatValue(),
                    buffer);
            currHeight.add(elem.getHeight(turret, fontrenderer));
        });
    }

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

    if (lbl.progress >= 1.0F) {
        final MutableFloat currHeight = new MutableFloat(0.0F);
        fltElem.forEach(elem -> {
            GlStateManager.pushMatrix();
            GlStateManager.translate(0.0F, currHeight.floatValue(), 0.0F);
            elem.doRenderTextured(turret, lbl.maxWidth, lbl.progress - 1.0F, fontrenderer);
            GlStateManager.popMatrix();
            currHeight.add(elem.getHeight(turret, fontrenderer));
        });
    }

    GlStateManager.enableDepth();
    GlStateManager.depthMask(true);
    GlStateManager.disableBlend();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.popMatrix();
}

From source file:derpatiel.manafluidics.util.RenderUtil.java

License:MIT License

public static void pre(double x, double y, double z) {
    GlStateManager.pushMatrix();/*w  w  w  . j ava  2  s .  c om*/

    RenderHelper.disableStandardItemLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    if (Minecraft.isAmbientOcclusionEnabled()) {
        GL11.glShadeModel(GL11.GL_SMOOTH);
    } else {
        GL11.glShadeModel(GL11.GL_FLAT);
    }

    GlStateManager.translate(x, y, z);
}

From source file:dracocore.handbook.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) {
    final float var7 = ((par5 >> 24) & 255) / 255F;
    final float var8 = ((par5 >> 16) & 255) / 255F;
    final float var9 = ((par5 >> 8) & 255) / 255F;
    final float var10 = (par5 & 255) / 255F;
    final float var11 = ((par6 >> 24) & 255) / 255F;
    final float var12 = ((par6 >> 16) & 255) / 255F;
    final float var13 = ((par6 >> 8) & 255) / 255F;
    final float var14 = (par6 & 255) / 255F;
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from   www .j a  va  2 s  .  c  o  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);
    final 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:graphics.Graph.java

@Override
public void draw() {
    //if (this.changed) {
    setMinMax();/*from  ww  w .  j  a  v a2  s . c om*/
    float margin = 20;
    // White backdrop...
    GL11.glColor3f(1, 1, 1);
    GL11.glBegin(GL11.GL_POLYGON);
    GL11.glVertex2f(this.xPos, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY);
    GL11.glVertex2f(this.xPos, this.yPos + this.sizeY);
    GL11.glEnd();

    // Black lines around...
    GL11.glColor3f(0, 0, 0);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(this.xPos, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos);
    GL11.glVertex2f(this.xPos + this.sizeX, this.yPos + this.sizeY);
    GL11.glVertex2f(this.xPos, this.yPos + this.sizeY);
    GL11.glEnd();

    // Moves origo where it should be, based on the dataset...
    GL11.glColor4f(0, 0, 0, 0.25f);
    float origo = this.yPos + 2 * margin;
    if (maxValue == 0 && minValue == 0) {
        origo += (this.sizeY - 3 * margin) / 2;
    } else if (maxValue <= 0 && minValue < 0) {
        origo += this.sizeY - 3 * margin;
    } else if (maxValue > 0 && minValue < 0) {
        origo += ((minValue * -1) / (maxValue + (minValue * -1))) * (this.sizeY - 3 * margin);
    }
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(this.xPos + margin, origo);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, origo);
    GL11.glEnd();

    // draws tabs on the origo-line where the values should be put...
    float tabs = 5;
    for (int i = 0; i < dataValues.length; i++) {
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)),
                origo + tabs);
        GL11.glVertex2f(this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1)),
                origo - tabs);
        GL11.glEnd();
    }
    Line2D.Double[] lines = new Line2D.Double[dataValues.length - 1];
    for (int i = 0; i < lines.length; i++) {
        if (dataValues[i] == null) {
            continue;
        }
        float x = this.xPos + margin + (i * (this.sizeX - 2 * margin) / (this.dataValues.length - 1));
        float y = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin)
                * ((this.dataValues[i].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue))));
        float x2 = this.xPos + margin + ((i + 1) * (this.sizeX - 2 * margin) / (this.dataValues.length - 1));
        float y2 = (this.yPos + 2 * margin) + ((this.sizeY - 3 * margin)
                * ((this.dataValues[i + 1].getValue() + Math.abs(minValue)) / (maxValue + Math.abs(minValue))));
        lines[i] = new Line2D.Double(x, y, x2, y2);
    }

    // Draws the value-lines on the graph...
    Line2D.Double origLine = new Line2D.Double(this.xPos + margin, origo,
            this.xPos + margin + (this.sizeX - 2 * margin), origo);
    GL11.glLineWidth(2);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    for (Line2D.Double line : lines) {
        if (line == null) {
            continue;
        }
        if (line.intersectsLine(origLine)) {
            Point2D interSect = getIntersection(line, origLine);
            if (line.y1 > origo) {
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(interSect.getX(), interSect.getY());
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x2, line.y2);
            } else {
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(interSect.getX(), interSect.getY());
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x2, line.y2);
            }
        } else {
            if (line.y1 > origo) {
                GL11.glColor4f(0, 1, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(line.x2, line.y2);
            } else {
                GL11.glColor4f(1, 0, 0, 1);
                GL11.glVertex2d(line.x1, line.y1);
                GL11.glVertex2d(line.x2, line.y2);
            }
        }
    }
    GL11.glEnd();
    GL11.glLineWidth(1);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    // Black lines around box inside the graph...
    GL11.glColor4f(0, 0, 0, 1);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2f(this.xPos + margin, this.yPos + 2 * margin);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + 2 * margin);
    GL11.glVertex2f(this.xPos + this.sizeX - margin, this.yPos + this.sizeY - margin);
    GL11.glVertex2f(this.xPos + margin, this.yPos + this.sizeY - margin);
    GL11.glEnd();

    //this.changed = false;
    origLine = null;
    //}
}

From source file:hellfirepvp.astralsorcery.client.sky.RenderAstralSkybox.java

License:Open Source License

private void renderSunsetToBackground(float[] sunsetColors, float partialTicks) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vb = tessellator.getBuffer();

    GlStateManager.disableTexture2D();//from w  w w.  ja  v  a2s  .  c  om
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.pushMatrix();
    GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
    GlStateManager
            .rotate(MathHelper.sin(Minecraft.getMinecraft().world.getCelestialAngleRadians(partialTicks)) < 0.0F
                    ? 180.0F
                    : 0.0F, 0.0F, 0.0F, 1.0F);
    GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
    float f6 = sunsetColors[0];
    float f7 = sunsetColors[1];
    float f8 = sunsetColors[2];

    if (Minecraft.getMinecraft().gameSettings.anaglyph) {
        float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
        float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
        float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
        f6 = f9;
        f7 = f10;
        f8 = f11;
    }

    vb.begin(6, DefaultVertexFormats.POSITION_COLOR);
    vb.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, sunsetColors[3]).endVertex();
    //int j = 16;

    for (int l = 0; l <= 16; ++l) {
        float f21 = (float) l * (float) Math.PI * 2.0F / 16.0F;
        float f12 = MathHelper.sin(f21);
        float f13 = MathHelper.cos(f21);
        vb.pos((double) (f12 * 120.0F), (double) (f13 * 120.0F), (double) (-f13 * 40.0F * sunsetColors[3]))
                .color(sunsetColors[0], sunsetColors[1], sunsetColors[2], 0.0F).endVertex();
    }

    tessellator.draw();
    GlStateManager.popMatrix();
    GlStateManager.shadeModel(GL11.GL_FLAT);
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void renderLightRayEffects(double x, double y, double z, Color effectColor, long seed,
        long continuousTick, int dstJump, float scale, int countFancy, int countNormal) {
    rand.setSeed(seed);/*from   w w  w.  j av  a2 s . c  om*/
    GL11.glPushMatrix();
    GL11.glTranslated(x, y, z);

    int fancy_count = !FMLClientHandler.instance().getClient().gameSettings.fancyGraphics ? countNormal
            : countFancy;

    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    RenderHelper.disableStandardItemLighting();
    float f1 = continuousTick / 400.0F;
    float f2 = 0.4F;

    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.glDepthMask(false);
    GL11.glPushMatrix();
    for (int i = 0; i < fancy_count; i++) {
        GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(rand.nextFloat() * 360.0F + f1 * 360.0F, 0.0F, 0.0F, 1.0F);
        vb.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        float fa = rand.nextFloat() * 20.0F + 5.0F + f2 * 10.0F;
        float f4 = rand.nextFloat() * 2.0F + 1.0F + f2 * 2.0F;
        fa /= 30.0F / (Math.min(dstJump, 10 * scale) / 10.0F);
        f4 /= 30.0F / (Math.min(dstJump, 10 * scale) / 10.0F);
        vb.pos(0, 0, 0).color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(),
                (int) (255.0F * (1.0F - f2))).endVertex();
        vb.pos(-0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(0.0D, fa, 1.0F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        vb.pos(-0.7D * f4, fa, -0.5F * f4)
                .color(effectColor.getRed(), effectColor.getGreen(), effectColor.getBlue(), 0).endVertex();
        tes.draw();
    }
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    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();

    GL11.glPopMatrix();
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void drawGradientRect(int x, int y, float z, int toX, int toY, Color color, Color colorFade) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from  ww  w  . j  a v a  2  s.  c o 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 tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
    vb.pos(toX, y, z).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
    vb.pos(x, y, z).color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()).endVertex();
    vb.pos(x, toY, z).color(colorFade.getRed(), colorFade.getGreen(), colorFade.getBlue(), colorFade.getAlpha())
            .endVertex();
    vb.pos(toX, toY, z)
            .color(colorFade.getRed(), colorFade.getGreen(), colorFade.getBlue(), colorFade.getAlpha())
            .endVertex();
    tes.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:ivorius.ivtoolkit.rendering.IvRenderHelper.java

License:Apache License

public static void renderLights(float ticks, int color, float alpha, int number) {
    float width = 2.5f;

    Tessellator tessellator = Tessellator.instance;

    float usedTicks = ticks / 200.0F;

    Random random = new Random(432L);
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from  w  w  w.j  a  va 2  s.  co  m*/
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    GL11.glPushMatrix();

    for (int var7 = 0; (float) var7 < number; ++var7) {
        float xLogFunc = (((float) var7 / number * 28493.0f + ticks) / 10.0f) % 20.0f;
        if (xLogFunc > 10.0f) {
            xLogFunc = 20.0f - xLogFunc;
        }

        float yLogFunc = 1.0f / (1.0f + (float) Math.pow(2.71828f, -0.8f * xLogFunc) * ((1.0f / 0.01f) - 1.0f));

        float lightAlpha = yLogFunc;

        if (lightAlpha > 0.01f) {
            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 + usedTicks * 90.0F, 0.0F, 0.0F, 1.0F);
            tessellator.startDrawing(6);
            float var8 = random.nextFloat() * 20.0F + 5.0F;
            float var9 = random.nextFloat() * 2.0F + 1.0F;
            tessellator.setColorRGBA_I(color, (int) (255.0F * alpha * lightAlpha));
            tessellator.addVertex(0.0D, 0.0D, 0.0D);
            tessellator.setColorRGBA_I(color, 0);
            tessellator.addVertex(-width * (double) var9, var8, (-0.5F * var9));
            tessellator.addVertex(width * (double) var9, var8, (-0.5F * var9));
            tessellator.addVertex(0.0D, var8, (1.0F * var9));
            tessellator.addVertex(-width * (double) var9, var8, (-0.5F * var9));
            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);
}

From source file:joazlazer.mods.amc.client.gui.GuiScrollingList.java

License:Open Source License

public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    this.mouseX = mouseX;
    this.mouseY = mouseY;
    this.drawBackground();

    boolean isHovering = mouseX >= this.left && mouseX <= this.left + this.listWidth && mouseY >= this.top
            && mouseY <= this.bottom;
    int listLength = this.getSize();
    int scrollBarWidth = 6;
    int scrollBarRight = this.left + this.listWidth;
    int scrollBarLeft = scrollBarRight - scrollBarWidth;
    int entryLeft = this.left;
    int entryRight = scrollBarLeft - 1;
    int viewHeight = this.bottom - this.top;
    int border = 4;

    if (Mouse.isButtonDown(0)) {
        if (this.initialMouseClickY == -1.0F) {
            if (isHovering) {
                int mouseListY = mouseY - this.top - this.headerHeight + (int) this.scrollDistance - border;
                int slotIndex = mouseListY / this.slotHeight;

                if (mouseX >= entryLeft && mouseX <= entryRight && slotIndex >= 0 && mouseListY >= 0
                        && slotIndex < listLength) {
                    this.elementClicked(slotIndex, slotIndex == this.selectedIndex
                            && System.currentTimeMillis() - this.lastClickTime < 250L);
                    this.selectedIndex = slotIndex;
                    this.lastClickTime = System.currentTimeMillis();
                } else if (mouseX >= entryLeft && mouseX <= entryRight && mouseListY < 0) {
                    this.clickHeader(mouseX - entryLeft,
                            mouseY - this.top + (int) this.scrollDistance - border);
                }/* w  w  w  . ja v  a2  s . c  o m*/

                if (mouseX >= scrollBarLeft && mouseX <= scrollBarRight) {
                    this.scrollFactor = -1.0F;
                    int scrollHeight = this.getContentHeight() - viewHeight - border;
                    if (scrollHeight < 1)
                        scrollHeight = 1;

                    int var13 = (int) ((float) (viewHeight * viewHeight) / (float) this.getContentHeight());

                    if (var13 < 32)
                        var13 = 32;
                    if (var13 > viewHeight - border * 2)
                        var13 = viewHeight - border * 2;

                    this.scrollFactor /= (float) (viewHeight - var13) / (float) scrollHeight;
                } else {
                    this.scrollFactor = 1.0F;
                }

                this.initialMouseClickY = mouseY;
            } else {
                this.initialMouseClickY = -2.0F;
            }
        } else if (this.initialMouseClickY >= 0.0F) {
            this.scrollDistance -= ((float) mouseY - this.initialMouseClickY) * this.scrollFactor;
            this.initialMouseClickY = (float) mouseY;
        }
    } else {
        this.initialMouseClickY = -1.0F;
    }

    this.applyScrollLimits();

    Tessellator tess = Tessellator.getInstance();
    BufferBuilder worldr = tess.getBuffer();

    ScaledResolution res = new ScaledResolution(client);
    double scaleW = client.displayWidth / res.getScaledWidth_double();
    double scaleH = client.displayHeight / res.getScaledHeight_double();
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    GL11.glScissor((int) (left * scaleW), (int) (client.displayHeight - (bottom * scaleH)),
            (int) (listWidth * scaleW), (int) (viewHeight * scaleH));

    if (this.client.world != null) {

    } else // Draw dark dirt background
    {
        GlStateManager.disableLighting();
        GlStateManager.disableFog();
        this.client.renderEngine.bindTexture(Gui.OPTIONS_BACKGROUND);
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        float scale = 32.0F;
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(this.left, this.bottom, 0.0D)
                .tex(this.left / scale, (this.bottom + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.right, this.bottom, 0.0D)
                .tex(this.right / scale, (this.bottom + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.right, this.top, 0.0D)
                .tex(this.right / scale, (this.top + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        worldr.pos(this.left, this.top, 0.0D)
                .tex(this.left / scale, (this.top + (int) this.scrollDistance) / scale)
                .color(0x20, 0x20, 0x20, 0xFF).endVertex();
        tess.draw();
    }

    int baseY = this.top + border - (int) this.scrollDistance;

    if (this.hasHeader) {
        this.drawHeader(entryRight, baseY, tess);
    }

    for (int slotIdx = 0; slotIdx < listLength; ++slotIdx) {
        int slotTop = baseY + slotIdx * this.slotHeight + this.headerHeight;
        int slotBuffer = this.slotHeight - border;

        if (slotTop <= this.bottom && slotTop + slotBuffer >= this.top) {
            if (this.highlightSelected && this.isSelected(slotIdx)) {
                int min = this.left;
                int max = entryRight;
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                GlStateManager.disableTexture2D();
                worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
                worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
                worldr.pos(min, slotTop + slotBuffer + 2, 0).tex(0, 1).color(0x80, 0x80, 0x80, 0xFF)
                        .endVertex();
                worldr.pos(max, slotTop + slotBuffer + 2, 0).tex(1, 1).color(0x80, 0x80, 0x80, 0xFF)
                        .endVertex();
                worldr.pos(max, slotTop - 2, 0).tex(1, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(min, slotTop - 2, 0).tex(0, 0).color(0x80, 0x80, 0x80, 0xFF).endVertex();
                worldr.pos(min + 1, slotTop + slotBuffer + 1, 0).tex(0, 1).color(0x00, 0x00, 0x00, 0xFF)
                        .endVertex();
                worldr.pos(max - 1, slotTop + slotBuffer + 1, 0).tex(1, 1).color(0x00, 0x00, 0x00, 0xFF)
                        .endVertex();
                worldr.pos(max - 1, slotTop - 1, 0).tex(1, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                worldr.pos(min + 1, slotTop - 1, 0).tex(0, 0).color(0x00, 0x00, 0x00, 0xFF).endVertex();
                tess.draw();
                GlStateManager.enableTexture2D();
            }

            this.drawSlot(slotIdx, entryRight, slotTop, slotBuffer, tess);
        }
    }

    GlStateManager.disableDepth();

    int extraHeight = (this.getContentHeight() + border) - viewHeight;
    if (extraHeight > 0) {
        int height = (viewHeight * viewHeight) / this.getContentHeight();

        if (height < 32)
            height = 32;

        if (height > viewHeight - border * 2)
            height = viewHeight - border * 2;

        int barTop = (int) this.scrollDistance * (viewHeight - height) / extraHeight + this.top;
        if (barTop < this.top) {
            barTop = this.top;
        }

        GlStateManager.disableTexture2D();
        GlStateManager.enableAlpha();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, this.bottom, 0.0D).tex(0.0D, 1.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, this.bottom, 0.0D).tex(1.0D, 1.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, this.top, 0.0D).tex(1.0D, 0.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        worldr.pos(scrollBarLeft, this.top, 0.0D).tex(0.0D, 0.0D).color(scrollBarBackground.getRed(),
                scrollBarBackground.getGreen(), scrollBarBackground.getBlue(), scrollBarBackground.getAlpha())
                .endVertex();
        tess.draw();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, barTop + height, 0.0D).tex(0.0D, 1.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, barTop + height, 0.0D).tex(1.0D, 1.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight, barTop, 0.0D).tex(1.0D, 0.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D)
                .color(scrollBarShadingColor.getRed(), scrollBarShadingColor.getGreen(),
                        scrollBarShadingColor.getBlue(), scrollBarShadingColor.getAlpha())
                .endVertex();
        tess.draw();
        worldr.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
        worldr.pos(scrollBarLeft, barTop + height - 1, 0.0D).tex(0.0D, 1.0D).color(scrollBarFillColor.getRed(),
                scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(), scrollBarFillColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight - 1, barTop + height - 1, 0.0D).tex(1.0D, 1.0D)
                .color(scrollBarFillColor.getRed(), scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(),
                        scrollBarFillColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarRight - 1, barTop, 0.0D).tex(1.0D, 0.0D).color(scrollBarFillColor.getRed(),
                scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(), scrollBarFillColor.getAlpha())
                .endVertex();
        worldr.pos(scrollBarLeft, barTop, 0.0D).tex(0.0D, 0.0D).color(scrollBarFillColor.getRed(),
                scrollBarFillColor.getGreen(), scrollBarFillColor.getBlue(), scrollBarFillColor.getAlpha())
                .endVertex();
        tess.draw();
    }

    this.drawScreen(mouseX, mouseY);
    GlStateManager.enableTexture2D();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.disableBlend();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
}