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:net.minecraftforge.client.model.animation.FastTESR.java

License:Open Source License

@Override
public final void renderTileEntityAt(T te, double x, double y, double z, float partialTicks, int destroyStage) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer VertexBuffer = tessellator.getBuffer();
    this.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.enableBlend();// w  w w  . j  a  v a  2s  . co m
    GlStateManager.disableCull();

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

    VertexBuffer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);

    renderTileEntityFast(te, x, y, z, partialTicks, destroyStage, VertexBuffer);
    VertexBuffer.setTranslation(0, 0, 0);

    tessellator.draw();

    RenderHelper.enableStandardItemLighting();
}

From source file:net.minecraftforge.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;
                }// w w w.  ja  v a  2 s.  c  o m

                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 tess = Tessellator.getInstance();
    WorldRenderer worldr = tess.getWorldRenderer();
    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;
        worldr.startDrawingQuads();
        worldr.setColorOpaque_I(2105376);
        worldr.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D,
                (double) ((float) this.left / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        worldr.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.bottom + (int) this.scrollDistance) / var17));
        worldr.addVertexWithUV((double) this.right, (double) this.top, 0.0D,
                (double) ((float) this.right / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        worldr.addVertexWithUV((double) this.left, (double) this.top, 0.0D,
                (double) ((float) this.left / var17),
                (double) ((float) (this.top + (int) this.scrollDistance) / var17));
        tess.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, tess);
    }

    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);
                worldr.startDrawingQuads();
                worldr.setColorOpaque_I(8421504);
                worldr.addVertexWithUV((double) var14, (double) (var19 + var13 + 2), 0.0D, 0.0D, 1.0D);
                worldr.addVertexWithUV((double) var15, (double) (var19 + var13 + 2), 0.0D, 1.0D, 1.0D);
                worldr.addVertexWithUV((double) var15, (double) (var19 - 2), 0.0D, 1.0D, 0.0D);
                worldr.addVertexWithUV((double) var14, (double) (var19 - 2), 0.0D, 0.0D, 0.0D);
                worldr.setColorOpaque_I(0);
                worldr.addVertexWithUV((double) (var14 + 1), (double) (var19 + var13 + 1), 0.0D, 0.0D, 1.0D);
                worldr.addVertexWithUV((double) (var15 - 1), (double) (var19 + var13 + 1), 0.0D, 1.0D, 1.0D);
                worldr.addVertexWithUV((double) (var15 - 1), (double) (var19 - 1), 0.0D, 1.0D, 0.0D);
                worldr.addVertexWithUV((double) (var14 + 1), (double) (var19 - 1), 0.0D, 0.0D, 0.0D);
                tess.draw();
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

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

    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);
    worldr.startDrawingQuads();
    worldr.setColorRGBA_I(0, 0);
    worldr.addVertexWithUV((double) this.left, (double) (this.top + var20), 0.0D, 0.0D, 1.0D);
    worldr.addVertexWithUV((double) this.right, (double) (this.top + var20), 0.0D, 1.0D, 1.0D);
    worldr.setColorRGBA_I(0, 255);
    worldr.addVertexWithUV((double) this.right, (double) this.top, 0.0D, 1.0D, 0.0D);
    worldr.addVertexWithUV((double) this.left, (double) this.top, 0.0D, 0.0D, 0.0D);
    tess.draw();
    worldr.startDrawingQuads();
    worldr.setColorRGBA_I(0, 255);
    worldr.addVertexWithUV((double) this.left, (double) this.bottom, 0.0D, 0.0D, 1.0D);
    worldr.addVertexWithUV((double) this.right, (double) this.bottom, 0.0D, 1.0D, 1.0D);
    worldr.setColorRGBA_I(0, 0);
    worldr.addVertexWithUV((double) this.right, (double) (this.bottom - var20), 0.0D, 1.0D, 0.0D);
    worldr.addVertexWithUV((double) this.left, (double) (this.bottom - var20), 0.0D, 0.0D, 0.0D);
    tess.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;
        }

        worldr.startDrawingQuads();
        worldr.setColorRGBA_I(0, 255);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) this.bottom, 0.0D, 0.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) this.bottom, 0.0D, 1.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) this.top, 0.0D, 1.0D, 0.0D);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) this.top, 0.0D, 0.0D, 0.0D);
        tess.draw();
        worldr.startDrawingQuads();
        worldr.setColorRGBA_I(8421504, 255);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13), 0.0D, 0.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) (var14 + var13), 0.0D, 1.0D, 1.0D);
        worldr.addVertexWithUV((double) scrollBarXEnd, (double) var14, 0.0D, 1.0D, 0.0D);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        tess.draw();
        worldr.startDrawingQuads();
        worldr.setColorRGBA_I(12632256, 255);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) (var14 + var13 - 1), 0.0D, 0.0D, 1.0D);
        worldr.addVertexWithUV((double) (scrollBarXEnd - 1), (double) (var14 + var13 - 1), 0.0D, 1.0D, 1.0D);
        worldr.addVertexWithUV((double) (scrollBarXEnd - 1), (double) var14, 0.0D, 1.0D, 0.0D);
        worldr.addVertexWithUV((double) scrollBarXStart, (double) var14, 0.0D, 0.0D, 0.0D);
        tess.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:net.minecraftforge.fml.client.GuiScrollingList.java

License:Open Source License

protected void drawGradientRect(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);/*from ww  w .j  ava2s  .  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.getInstance();
    WorldRenderer worldrenderer = tessellator.getWorldRenderer();
    worldrenderer.startDrawingQuads();
    worldrenderer.setColorRGBA_F(f1, f2, f3, f);
    worldrenderer.addVertex((double) par3, (double) par2, 0.0D);
    worldrenderer.addVertex((double) par1, (double) par2, 0.0D);
    worldrenderer.setColorRGBA_F(f5, f6, f7, f4);
    worldrenderer.addVertex((double) par1, (double) par4, 0.0D);
    worldrenderer.addVertex((double) par3, (double) par4, 0.0D);
    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:net.smert.frameworkgl.opengl.OpenGL1.java

License:Apache License

public OpenGL1 setSmoothLighting(boolean isSmooth) {
    if (isSmooth) {
        GL11.glShadeModel(GL11.GL_SMOOTH);
    } else {/*from  w  w  w .  j av  a  2 s.co m*/
        GL11.glShadeModel(GL11.GL_FLAT);
    }
    return this;
}

From source file:net.wurstclient.gui.GuiWurstSlot.java

License:Open Source License

public void drawScreen(int p_148128_1_, int p_148128_2_, float p_148128_3_) {
    field_148150_g = p_148128_1_;//from   www  .  j  av a  2s.  c o  m
    field_148162_h = p_148128_2_;
    drawBackground();
    int var4 = getSize();
    int var5 = func_148137_d();
    int var6 = var5 + 6;
    int var9;
    int var10;
    int var13;
    int var19;

    if (p_148128_1_ > field_148152_e && p_148128_1_ < field_148151_d && p_148128_2_ > field_148153_b
            && p_148128_2_ < field_148154_c)
        if (Mouse.isButtonDown(0) && func_148125_i()) {
            if (field_148157_o == -1.0F) {
                boolean var15 = true;

                if (p_148128_2_ >= field_148153_b && p_148128_2_ <= field_148154_c) {
                    int var8 = field_148155_a / 2 - func_148139_c() / 2;
                    var9 = field_148155_a / 2 + func_148139_c() / 2;
                    var10 = p_148128_2_ - field_148153_b - field_148160_j + (int) field_148169_q - 4;
                    int var11 = var10 / field_148149_f;

                    if (p_148128_1_ >= var8 && p_148128_1_ <= var9 && var11 >= 0 && var10 >= 0
                            && var11 < var4) {
                        boolean var12 = var11 == field_148168_r
                                && Minecraft.getSystemTime() - field_148167_s < 250L;
                        elementClicked(var11, var12, p_148128_1_, p_148128_2_);
                        field_148168_r = var11;
                        field_148167_s = Minecraft.getSystemTime();
                    } else if (p_148128_1_ >= var8 && p_148128_1_ <= var9 && var10 < 0) {
                        func_148132_a(p_148128_1_ - var8,
                                p_148128_2_ - field_148153_b + (int) field_148169_q - 4);
                        var15 = false;
                    }

                    if (p_148128_1_ >= var5 && p_148128_1_ <= var6) {
                        field_148170_p = -1.0F;
                        var19 = func_148135_f();

                        if (var19 < 1)
                            var19 = 1;

                        var13 = (int) ((float) ((field_148154_c - field_148153_b)
                                * (field_148154_c - field_148153_b)) / (float) func_148138_e());

                        if (var13 < 32)
                            var13 = 32;

                        if (var13 > field_148154_c - field_148153_b - 8)
                            var13 = field_148154_c - field_148153_b - 8;

                        field_148170_p /= (float) (field_148154_c - field_148153_b - var13) / (float) var19;
                    } else
                        field_148170_p = 1.0F;

                    if (var15)
                        field_148157_o = p_148128_2_;
                    else
                        field_148157_o = -2.0F;
                } else
                    field_148157_o = -2.0F;
            } else if (field_148157_o >= 0.0F) {
                field_148169_q -= (p_148128_2_ - field_148157_o) * field_148170_p;
                field_148157_o = p_148128_2_;
            }
        } else {
            try {
                for (; !field_148161_k.gameSettings.touchscreen && Mouse.next(); field_148161_k.currentScreen
                        .handleMouseInput()) {
                    int var7 = Mouse.getEventDWheel();

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

                        field_148169_q += var7 * field_148149_f / 2;
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
            }

            field_148157_o = -1.0F;
        }

    func_148121_k();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    Tessellator ts = Tessellator.getInstance();
    WorldRenderer wr = ts.getWorldRenderer();
    field_148161_k.getTextureManager().bindTexture(Gui.optionsBackground);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    float var16 = 32.0F;
    wr.startDrawingQuads();
    wr.setColorOpaque_I(2105376);
    wr.addVertexWithUV(field_148152_e, field_148154_c, 0.0D, field_148152_e / var16,
            (field_148154_c + (int) field_148169_q) / var16);
    wr.addVertexWithUV(field_148151_d, field_148154_c, 0.0D, field_148151_d / var16,
            (field_148154_c + (int) field_148169_q) / var16);
    wr.addVertexWithUV(field_148151_d, field_148153_b, 0.0D, field_148151_d / var16,
            (field_148153_b + (int) field_148169_q) / var16);
    wr.addVertexWithUV(field_148152_e, field_148153_b, 0.0D, field_148152_e / var16,
            (field_148153_b + (int) field_148169_q) / var16);
    ts.draw();
    var9 = field_148152_e + field_148155_a / 2 - func_148139_c() / 2 + 2;
    var10 = field_148153_b + 4 - (int) field_148169_q;

    if (field_148165_u)
        func_148129_a(var9, var10, Tessellator.getInstance());

    func_148120_b(var9, var10, p_148128_1_, p_148128_2_);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    byte var18 = 4;
    func_148136_c(0, field_148153_b, 255, 255);
    func_148136_c(field_148154_c, field_148158_l, 255, 255);
    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(770, 771, 0, 1);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    wr.startDrawingQuads();
    wr.setColorRGBA_I(0, 0);
    wr.addVertexWithUV(field_148152_e, field_148153_b + var18, 0.0D, 0.0D, 1.0D);
    wr.addVertexWithUV(field_148151_d, field_148153_b + var18, 0.0D, 1.0D, 1.0D);
    wr.setColorRGBA_I(0, 255);
    wr.addVertexWithUV(field_148151_d, field_148153_b, 0.0D, 1.0D, 0.0D);
    wr.addVertexWithUV(field_148152_e, field_148153_b, 0.0D, 0.0D, 0.0D);
    ts.draw();
    wr.startDrawingQuads();
    wr.setColorRGBA_I(0, 255);
    wr.addVertexWithUV(field_148152_e, field_148154_c, 0.0D, 0.0D, 1.0D);
    wr.addVertexWithUV(field_148151_d, field_148154_c, 0.0D, 1.0D, 1.0D);
    wr.setColorRGBA_I(0, 0);
    wr.addVertexWithUV(field_148151_d, field_148154_c - var18, 0.0D, 1.0D, 0.0D);
    wr.addVertexWithUV(field_148152_e, field_148154_c - var18, 0.0D, 0.0D, 0.0D);
    ts.draw();
    var19 = func_148135_f();

    if (var19 > 0) {
        var13 = (field_148154_c - field_148153_b) * (field_148154_c - field_148153_b) / func_148138_e();

        if (var13 < 32)
            var13 = 32;

        if (var13 > field_148154_c - field_148153_b - 8)
            var13 = field_148154_c - field_148153_b - 8;

        int var14 = (int) field_148169_q * (field_148154_c - field_148153_b - var13) / var19 + field_148153_b;

        if (var14 < field_148153_b)
            var14 = field_148153_b;

        wr.startDrawingQuads();
        wr.setColorRGBA_I(0, 255);
        wr.addVertexWithUV(var5, field_148154_c, 0.0D, 0.0D, 1.0D);
        wr.addVertexWithUV(var6, field_148154_c, 0.0D, 1.0D, 1.0D);
        wr.addVertexWithUV(var6, field_148153_b, 0.0D, 1.0D, 0.0D);
        wr.addVertexWithUV(var5, field_148153_b, 0.0D, 0.0D, 0.0D);
        ts.draw();
        wr.startDrawingQuads();
        wr.setColorRGBA_I(8421504, 255);
        wr.addVertexWithUV(var5, var14 + var13, 0.0D, 0.0D, 1.0D);
        wr.addVertexWithUV(var6, var14 + var13, 0.0D, 1.0D, 1.0D);
        wr.addVertexWithUV(var6, var14, 0.0D, 1.0D, 0.0D);
        wr.addVertexWithUV(var5, var14, 0.0D, 0.0D, 0.0D);
        ts.draw();
        wr.startDrawingQuads();
        wr.setColorRGBA_I(12632256, 255);
        wr.addVertexWithUV(var5, var14 + var13 - 1, 0.0D, 0.0D, 1.0D);
        wr.addVertexWithUV(var6 - 1, var14 + var13 - 1, 0.0D, 1.0D, 1.0D);
        wr.addVertexWithUV(var6 - 1, var14, 0.0D, 1.0D, 0.0D);
        wr.addVertexWithUV(var5, var14, 0.0D, 0.0D, 0.0D);
        ts.draw();
    }

    func_148142_b(p_148128_1_, p_148128_2_);
    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:org.blockartistry.DynSurround.client.weather.AuroraRenderer.java

License:MIT License

protected void renderAurora(final float partialTick, @Nonnull final Aurora aurora) {

    final float alpha = aurora.getAlphaf();
    if (alpha <= 0.0F)
        return;/*  w w w . j  av a2  s.c  o m*/

    final Minecraft mc = Minecraft.getMinecraft();
    final Tessellator tess = Tessellator.getInstance();
    final VertexBuffer renderer = tess.getBuffer();

    final double tranY = this.dimensions.getSeaLevel(mc.world)
            - ((mc.player.lastTickPosY + (mc.player.posY - mc.player.lastTickPosY) * partialTick));

    final double tranX = mc.player.posX
            - (mc.player.lastTickPosX + (mc.player.posX - mc.player.lastTickPosX) * partialTick);

    final double tranZ = (mc.player.posZ - getZOffset())
            - (mc.player.lastTickPosZ + (mc.player.posZ - mc.player.lastTickPosZ) * partialTick);

    aurora.translate(partialTick);

    final Color base = aurora.getBaseColor();
    final Color fade = aurora.getFadeColor();
    final double zero = 0.0D;

    GlStateManager.pushMatrix();
    GlStateManager.pushAttrib();

    GlStateManager.translate(tranX, tranY, tranZ);
    GlStateManager.scale(0.5D, getScaledHeight(), 0.5D);
    GlStateManager.disableTexture2D();
    GlStateManager.disableFog();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE,
            GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
    GlStateManager.disableAlpha();
    GlStateManager.disableCull();
    GlStateManager.depthMask(false);

    final Node[] array = aurora.getNodeList();
    for (int i = 0; i < array.length - 1; i++) {

        final Node node = array[i];

        final double posY = node.getModdedY();
        final double posX = node.tetX;
        final double posZ = node.tetZ;
        final double tetX = node.tetX2;
        final double tetZ = node.tetZ2;

        final double posX2;
        final double posZ2;
        final double tetX2;
        final double tetZ2;
        final double posY2;

        if (i < array.length - 2) {
            final Node nodePlus = array[i + 1];
            posX2 = nodePlus.tetX;
            posZ2 = nodePlus.tetZ;
            tetX2 = nodePlus.tetX2;
            tetZ2 = nodePlus.tetZ2;
            posY2 = nodePlus.getModdedY();
        } else {
            posX2 = tetX2 = node.posX;
            posZ2 = tetZ2 = node.getModdedZ();
            posY2 = 0.0D;
        }

        // Front
        renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
        renderer.pos(posX, posY, posZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
        renderer.pos(posX2, posY2, posZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
        renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
        tess.draw();

        // Bottom
        renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
        renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
        renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
        renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
        tess.draw();

        // Back
        renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
        renderer.pos(tetX, posY, tetZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
        renderer.pos(tetX2, posY2, tetZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
        renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
        tess.draw();
    }

    GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA,
            GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE,
            GlStateManager.DestFactor.ZERO);
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.depthMask(true);
    GlStateManager.enableCull();
    GlStateManager.enableFog();
    GlStateManager.enableTexture2D();
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);

    GlStateManager.disableBlend();
    GlStateManager.popAttrib();
    GlStateManager.popMatrix();
}

From source file:org.blockartistry.mod.DynSurround.client.aurora.AuroraRenderer.java

License:MIT License

public static void renderAurora(final float partialTick, final Aurora aurora) {

    final Minecraft mc = FMLClientHandler.instance().getClient();
    final float alpha = (aurora.getAlpha() * moonlightFactor(mc.theWorld)) / 255.0F;
    if (alpha <= 0.0F)
        return;//from w w  w .  j  a  va 2 s  .  com

    final Tessellator tess = Tessellator.getInstance();
    final VertexBuffer renderer = tess.getBuffer();
    final float tranY;
    if (ModOptions.auroraHeightPlayerRelative) {
        // Fix height above player
        tranY = ModOptions.playerFixedHeight;
    } else {
        // Adjust to keep aurora at the same altitude
        tranY = DimensionRegistry.getCloudHeight(mc.theWorld) + 5 - (float) (mc.thePlayer.lastTickPosY
                + (mc.thePlayer.posY - mc.thePlayer.lastTickPosY) * partialTick);
    }

    final double tranX = aurora.posX
            - (mc.thePlayer.lastTickPosX + (mc.thePlayer.posX - mc.thePlayer.lastTickPosX) * partialTick);

    final double tranZ = aurora.posZ
            - (mc.thePlayer.lastTickPosZ + (mc.thePlayer.posZ - mc.thePlayer.lastTickPosZ) * partialTick);

    if (ModOptions.auroraAnimate)
        aurora.translate(partialTick);

    final Color base = aurora.getBaseColor();
    final Color fade = aurora.getFadeColor();
    final double zero = 0.0D;

    GlStateManager.pushMatrix();
    GlStateManager.translate((float) tranX, tranY, (float) tranZ);
    GlStateManager.scale(0.5D, 8.0D, 0.5D);
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.disableAlpha();
    GlStateManager.disableCull();
    GlStateManager.depthMask(false);

    for (final Node[] array : aurora.getNodeList()) {
        for (int i = 0; i < array.length - 1; i++) {

            final Node node = array[i];

            final double posY = node.getModdedY();
            final double posX = node.tetX;
            final double posZ = node.tetZ;
            final double tetX = node.tetX2;
            final double tetZ = node.tetZ2;

            final double posX2;
            final double posZ2;
            final double tetX2;
            final double tetZ2;
            final double posY2;

            if (i < array.length - 2) {
                final Node nodePlus = array[i + 1];
                posX2 = nodePlus.tetX;
                posZ2 = nodePlus.tetZ;
                tetX2 = nodePlus.tetX2;
                tetZ2 = nodePlus.tetZ2;
                posY2 = nodePlus.getModdedY();
            } else {
                posX2 = tetX2 = node.posX;
                posZ2 = tetZ2 = node.getModdedZ();
                posY2 = 0.0D;
            }

            // Front
            renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(posX, posY, posZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(posX2, posY2, posZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            tess.draw();

            // Bottom
            renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            renderer.pos(posX, zero, posZ).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(posX2, zero, posZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
            tess.draw();

            // Back
            renderer.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
            renderer.pos(tetX, zero, tetZ).color(base.red, base.green, base.blue, alpha).endVertex();
            renderer.pos(tetX, posY, tetZ).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(tetX2, posY2, tetZ2).color(fade.red, fade.green, fade.blue, 0).endVertex();
            renderer.pos(tetX2, zero, tetZ2).color(base.red, base.green, base.blue, alpha).endVertex();
            tess.draw();
        }
    }

    GlStateManager.scale(3.5D, 25.0D, 3.5D);
    GlStateManager.depthMask(true);
    GlStateManager.enableCull();
    GlStateManager.disableBlend();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    GlStateManager.popMatrix();
}

From source file:org.free.jake2.render.lwjgl.Mesh.java

License:Open Source License

/**
 * R_DrawAliasModel// ww w.  ja v a2  s .c o  m
 */
void R_DrawAliasModel(entity_t e) {
    if ((e.flags & Defines.RF_WEAPONMODEL) == 0) {
        if (R_CullAliasModel(e)) {
            return;
        }
    }

    if ((e.flags & Defines.RF_WEAPONMODEL) != 0) {
        if (r_lefthand.value == 2.0f) {
            return;
        }
    }

    qfiles.dmdl_t paliashdr = (qfiles.dmdl_t) currentmodel.extradata;

    //
    // get lighting information
    //
    // PMM - rewrote, reordered to handle new shells & mixing
    // PMM - 3.20 code .. replaced with original way of doing it to keep mod authors happy
    //
    int i;
    if ((currententity.flags & (Defines.RF_SHELL_HALF_DAM | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_RED
            | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE)) != 0) {
        Math3D.VectorClear(shadelight);
        if ((currententity.flags & Defines.RF_SHELL_HALF_DAM) != 0) {
            shadelight[0] = 0.56f;
            shadelight[1] = 0.59f;
            shadelight[2] = 0.45f;
        }
        if ((currententity.flags & Defines.RF_SHELL_DOUBLE) != 0) {
            shadelight[0] = 0.9f;
            shadelight[1] = 0.7f;
        }
        if ((currententity.flags & Defines.RF_SHELL_RED) != 0) {
            shadelight[0] = 1.0f;
        }
        if ((currententity.flags & Defines.RF_SHELL_GREEN) != 0) {
            shadelight[1] = 1.0f;
        }
        if ((currententity.flags & Defines.RF_SHELL_BLUE) != 0) {
            shadelight[2] = 1.0f;
        }
    } else if ((currententity.flags & Defines.RF_FULLBRIGHT) != 0) {
        for (i = 0; i < 3; i++) {
            shadelight[i] = 1.0f;
        }
    } else {
        R_LightPoint(currententity.origin, shadelight);

        // player lighting hack for communication back to server
        // big hack!
        if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0) {
            // pick the greatest component, which should be the same
            // as the mono value returned by software
            if (shadelight[0] > shadelight[1]) {
                if (shadelight[0] > shadelight[2]) {
                    r_lightlevel.value = 150 * shadelight[0];
                } else {
                    r_lightlevel.value = 150 * shadelight[2];
                }
            } else {
                if (shadelight[1] > shadelight[2]) {
                    r_lightlevel.value = 150 * shadelight[1];
                } else {
                    r_lightlevel.value = 150 * shadelight[2];
                }
            }
        }

        if (gl_monolightmap.string.charAt(0) != '0') {
            float s = shadelight[0];

            if (s < shadelight[1]) {
                s = shadelight[1];
            }
            if (s < shadelight[2]) {
                s = shadelight[2];
            }

            shadelight[0] = s;
            shadelight[1] = s;
            shadelight[2] = s;
        }
    }

    if ((currententity.flags & Defines.RF_MINLIGHT) != 0) {
        for (i = 0; i < 3; i++) {
            if (shadelight[i] > 0.1f) {
                break;
            }
        }
        if (i == 3) {
            shadelight[0] = 0.1f;
            shadelight[1] = 0.1f;
            shadelight[2] = 0.1f;
        }
    }

    if ((currententity.flags & Defines.RF_GLOW) != 0) { // bonus items will pulse with time
        float scale;
        float min;

        scale = (float) (0.1f * Math.sin(r_newrefdef.time * 7));
        for (i = 0; i < 3; i++) {
            min = shadelight[i] * 0.8f;
            shadelight[i] += scale;
            if (shadelight[i] < min) {
                shadelight[i] = min;
            }
        }
    }

    // =================
    // PGM   ir goggles color override
    if ((r_newrefdef.rdflags & Defines.RDF_IRGOGGLES) != 0
            && (currententity.flags & Defines.RF_IR_VISIBLE) != 0) {
        shadelight[0] = 1.0f;
        shadelight[1] = 0.0f;
        shadelight[2] = 0.0f;
    }
    // PGM
    // =================

    shadedots = r_avertexnormal_dots[((int) (currententity.angles[1] * (SHADEDOT_QUANT / 360.0)))
            & (SHADEDOT_QUANT - 1)];

    float an = (float) (currententity.angles[1] / 180 * Math.PI);
    shadevector[0] = (float) Math.cos(-an);
    shadevector[1] = (float) Math.sin(-an);
    shadevector[2] = 1;
    Math3D.VectorNormalize(shadevector);

    //
    // locate the proper data
    //
    c_alias_polys += paliashdr.num_tris;

    //
    // draw all the triangles
    //
    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0) // hack the depth range to prevent view model from poking into walls
    {
        GL11.glDepthRange(gldepthmin, gldepthmin + 0.3 * (gldepthmax - gldepthmin));
    }

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0f)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPushMatrix();
        GL11.glLoadIdentity();
        GL11.glScalef(-1, 1, 1);
        MYgluPerspective(r_newrefdef.fov_y, (float) r_newrefdef.width / r_newrefdef.height, 4, 4096);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);

        GL11.glCullFace(GL11.GL_BACK);
    }

    GL11.glPushMatrix();
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.
    R_RotateForEntity(e);
    e.angles[PITCH] = -e.angles[PITCH]; // sigh.

    image_t skin;
    // select skin
    if (currententity.skin != null) {
        skin = currententity.skin; // custom player skin
    } else {
        if (currententity.skinnum >= qfiles.MAX_MD2SKINS) {
            skin = currentmodel.skins[0];
        } else {
            skin = currentmodel.skins[currententity.skinnum];
            if (skin == null) {
                skin = currentmodel.skins[0];
            }
        }
    }
    if (skin == null) {
        skin = r_notexture; // fallback...
    }
    GL_Bind(skin.texnum);

    // draw it
    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL_TexEnv(GL11.GL_MODULATE);
    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glEnable(GL11.GL_BLEND);
    }

    if ((currententity.frame >= paliashdr.num_frames) || (currententity.frame < 0)) {
        VID.Printf(Defines.PRINT_ALL,
                "R_DrawAliasModel " + currentmodel.name + ": no such frame " + currententity.frame + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if ((currententity.oldframe >= paliashdr.num_frames) || (currententity.oldframe < 0)) {
        VID.Printf(Defines.PRINT_ALL, "R_DrawAliasModel " + currentmodel.name + ": no such oldframe "
                + currententity.oldframe + '\n');
        currententity.frame = 0;
        currententity.oldframe = 0;
    }

    if (r_lerpmodels.value == 0.0f) {
        currententity.backlerp = 0;
    }

    GL_DrawAliasFrameLerp(paliashdr, currententity.backlerp);

    GL_TexEnv(GL11.GL_REPLACE);
    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glPopMatrix();

    if ((currententity.flags & Defines.RF_WEAPONMODEL) != 0 && (r_lefthand.value == 1.0F)) {
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glCullFace(GL11.GL_FRONT);
    }

    if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0) {
        GL11.glDisable(GL11.GL_BLEND);
    }

    if ((currententity.flags & Defines.RF_DEPTHHACK) != 0) {
        GL11.glDepthRange(gldepthmin, gldepthmax);
    }

    if (gl_shadows.value != 0.0f
            && (currententity.flags & (Defines.RF_TRANSLUCENT | Defines.RF_WEAPONMODEL)) == 0) {
        GL11.glPushMatrix();
        R_RotateForEntity(e);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glColor4f(0, 0, 0, 0.5f);
        GL_DrawAliasShadow(paliashdr, currententity.frame);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
    GL11.glColor4f(1, 1, 1, 1);
}

From source file:org.free.jake2.render.lwjgl.Misc.java

License:Open Source License

void GL_SetDefaultState() {
    GL11.glClearColor(1f, 0f, 0.5f, 0.5f); // original quake2
    //GL11.glClearColor(0, 0, 0, 0); // replaced with black
    GL11.glCullFace(GL11.GL_FRONT);//from  w ww  . j  a v a  2 s .com
    GL11.glEnable(GL11.GL_TEXTURE_2D);

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

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

    GL11.glColor4f(1, 1, 1, 1);

    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glShadeModel(GL11.GL_FLAT);

    GL_TextureMode(gl_texturemode.string);
    GL_TextureAlphaMode(gl_texturealphamode.string);
    GL_TextureSolidMode(gl_texturesolidmode.string);

    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, gl_filter_min);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, gl_filter_max);

    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

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

    GL_TexEnv(GL11.GL_REPLACE);

    if (qglPointParameterfEXT) {
        // float[] attenuations = { gl_particle_att_a.value, gl_particle_att_b.value, gl_particle_att_c.value };
        FloatBuffer att_buffer = BufferUtils.createFloatBuffer(4);
        att_buffer.put(0, gl_particle_att_a.value);
        att_buffer.put(1, gl_particle_att_b.value);
        att_buffer.put(2, gl_particle_att_c.value);

        GL11.glEnable(GL11.GL_POINT_SMOOTH);
        GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MIN_EXT, gl_particle_min_size.value);
        GL14.glPointParameterf(EXTPointParameters.GL_POINT_SIZE_MAX_EXT, gl_particle_max_size.value);
        GL14.glPointParameter(EXTPointParameters.GL_DISTANCE_ATTENUATION_EXT, att_buffer);
    }

    if (qglColorTableEXT && gl_ext_palettedtexture.value != 0.0f) {
        GL11.glEnable(EXTSharedTexturePalette.GL_SHARED_TEXTURE_PALETTE_EXT);

        GL_SetTexturePalette(d_8to24table);
    }

    GL_UpdateSwapInterval();

    /*
     * vertex array extension
     */
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL13.glClientActiveTexture(GL_TEXTURE0);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}

From source file:org.jtrfp.mtmx.tools.internal.TruckViewerConfiguration.java

License:Open Source License

@Override
public void initLight() {
    GL11.glEnable(GL11.GL_LIGHTING);/* w  w  w  .j ava2 s .  c  o m*/

    float[] vec = new float[] { 1.0f, 1.0f, 1.0f, 1.0f };
    // XXX: FloatBuffer must have 4 additional floats free
    FloatBuffer diffBuffer = BufferUtils.createFloatBuffer(vec.length + 4);
    diffBuffer.put(vec);
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT_AND_DIFFUSE, diffBuffer);
    GL11.glEnable(GL11.GL_LIGHT0);

    GL11.glShadeModel(GL11.GL_FLAT);
}