Example usage for org.lwjgl.opengl GL11 glDepthMask

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

Introduction

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

Prototype

public static void glDepthMask(@NativeType("GLboolean") boolean flag) 

Source Link

Document

Masks the writing of depth values to the depth buffer.

Usage

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawWayPointTracer(Waypoint w) {
    try {/*  w  ww.  j  ava  2s. c  o m*/
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_LINE_SMOOTH);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glLineWidth(1.5F);
        GL11.glColor3d(w.red, w.green, w.blue);
        GL11.glBegin(GL11.GL_LINE_LOOP);
        Vec3d eyes = new Vec3d(0, 0, 1).rotatePitch(-(float) Math.toRadians(Wrapper.getPlayer().rotationPitch))
                .rotateYaw(-(float) Math.toRadians(Wrapper.getPlayer().rotationYaw));

        GL11.glVertex3d(eyes.xCoord, Wrapper.getPlayer().getEyeHeight() + eyes.yCoord, eyes.zCoord);
        GL11.glVertex3d(w.dX + 0.5, w.dY + 0.5, w.dZ + 0.5);
        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        GL11.glPopMatrix();
    } catch (Exception e) {
    }
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawEntityESP(Entity entity, Color c) {
    GL11.glPushMatrix();//  ww w. jav a 2s.c  o m
    GL11.glBlendFunc(770, 771);
    GL11.glEnable(GL_BLEND);
    GL11.glLineWidth(1.0F);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL_DEPTH_TEST);
    GL11.glDepthMask(false);
    GL11.glColor4d(c.getRed() / 255f, c.getGreen() / 255f, c.getBlue() / 255f, 0.15F);
    RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
    drawColorBox(
            new AxisAlignedBB(
                    entity.boundingBox.minX - 0.05 - entity.posX + (entity.posX - renderManager.renderPosX),
                    entity.boundingBox.minY - entity.posY + (entity.posY - renderManager.renderPosY),
                    entity.boundingBox.minZ - 0.05 - entity.posZ + (entity.posZ - renderManager.renderPosZ),
                    entity.boundingBox.maxX + 0.05 - entity.posX + (entity.posX - renderManager.renderPosX),
                    entity.boundingBox.maxY + 0.1 - entity.posY + (entity.posY - renderManager.renderPosY),
                    entity.boundingBox.maxZ + 0.05 - entity.posZ + (entity.posZ - renderManager.renderPosZ)),
            0F, 0F, 0F, 0F);
    GL11.glColor4d(0, 0, 0, 0.5);
    drawSelectionBoundingBox(new AxisAlignedBB(
            entity.boundingBox.minX - 0.05 - entity.posX + (entity.posX - renderManager.renderPosX),
            entity.boundingBox.minY - entity.posY + (entity.posY - renderManager.renderPosY),
            entity.boundingBox.minZ - 0.05 - entity.posZ + (entity.posZ - renderManager.renderPosZ),
            entity.boundingBox.maxX + 0.05 - entity.posX + (entity.posX - renderManager.renderPosX),
            entity.boundingBox.maxY + 0.1 - entity.posY + (entity.posY - renderManager.renderPosY),
            entity.boundingBox.maxZ + 0.05 - entity.posZ + (entity.posZ - renderManager.renderPosZ)));
    GL11.glLineWidth(2.0F);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDisable(GL_BLEND);
    GL11.glPopMatrix();
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawPlayerESP(double d, double d1, double d2, EntityPlayer ep, double e, double f) {
    if (!(ep instanceof EntityPlayerSP)) {
        GL11.glPushMatrix();//w w w. j a  v  a2 s  .c o  m
        GL11.glEnable(3042);
        if (Wrapper.getFriends().isFriend(ep.getName())) {
            GL11.glColor4f(0.0F, 1F, 0.0F, 0.15F);
        } else {
            GL11.glColor4f(0.7F, 0.0F, 0.0F, 0.15F);
        }
        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDepthMask(false);
        GL11.glLineWidth(1.0F);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_LINE_SMOOTH);
        drawBoundingBox(new AxisAlignedBB(d - f, d1 + 0.1, d2 - f, d + f, d1 + e + 0.25, d2 + f));
        if (Wrapper.getFriends().isFriend(ep.getName())) {
            GL11.glColor4f(0.0F, 1F, 0.0F, 1F);
        } else {
            GL11.glColor4f(0.7F, 0.0F, 0.0F, 1F);
        }
        drawOutlinedBoundingBox(new AxisAlignedBB(d - f, d1 + 0.1, d2 - f, d + f, d1 + e + 0.25, d2 + f));
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        GL11.glDisable(3042);
        GL11.glPopMatrix();
    }
}

From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

private void drawPanorama(int par1, int par2, float par3) {
    Tessellator tessellator = Tessellator.instance;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();//  w w w . j av  a 2s  .c  om
    GL11.glLoadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GL11.glPushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GL11.glTranslatef(f1, f2, f3);
        GL11.glRotatef(MathHelper.sin(((float) this.panoramaTimer + par3) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F,
                0.0F);
        GL11.glRotatef(-((float) this.panoramaTimer + par3) * 0.1F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GL11.glPushMatrix();

            if (l == 1) {
                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 2) {
                GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 3) {
                GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 4) {
                GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
            }

            if (l == 5) {
                GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
            }

            this.mc.getTextureManager().bindTexture(titlePanoramaPaths[l]);
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_I(16777215, 255 / (k + 1));
            float f4 = 0.0F;
            tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, (double) (0.0F + f4), (double) (0.0F + f4));
            tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, (double) (1.0F - f4), (double) (0.0F + f4));
            tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, (double) (1.0F - f4), (double) (1.0F - f4));
            tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, (double) (0.0F + f4), (double) (1.0F - f4));
            tessellator.draw();
            GL11.glPopMatrix();
        }

        GL11.glPopMatrix();
        GL11.glColorMask(true, true, true, false);
    }

    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
    GL11.glColorMask(true, true, true, true);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Context.java

License:MIT License

@Override
public void setDepthMask(boolean enabled) {
    checkCreated();//from  w  w  w. ja v a 2  s.c o m
    GL11.glDepthMask(enabled);
    // Check for errors
    LWJGLUtil.checkForGLError();
}

From source file:com.github.kajdreef.mazerunnermvn.Launcher.java

/**
 * Initialize the display./*ww w . j  av a  2s.c om*/
 */
public void initDisplayLWJGL() {
    PixelFormat pixelFormat = new PixelFormat();
    ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true)
            .withProfileCore(true);

    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.setTitle("MazeRunner");
        Display.create(pixelFormat, contextAtrributes);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }

    GL11.glClearColor(0.4f, 0.6f, 0.9f, 0f);
    GL11.glViewport(0, 0, WIDTH, HEIGHT);

    // Enable depth test so the objects are rendered in the right way.
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glDepthMask(true);

    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:com.hilburn.dimensionguard.client.DisabledRenderer.java

License:Open Source License

@Override
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
    ItemStack thisStack = ItemStack//from ww w . jav  a 2  s .co  m
            .loadItemStackFromNBT((NBTTagCompound) itemStack.stackTagCompound.getTag("ItemStack"));

    boolean isInventory = type == ItemRenderType.INVENTORY;

    Tessellator tess = Tessellator.instance;
    FontRenderer fontRenderer = mc.fontRenderer;
    TextureManager textureManager = mc.getTextureManager();
    GL11.glPushMatrix();
    Item item = thisStack.getItem();
    Block block = Block.getBlockFromItem(item);

    if (thisStack != null && block != null && block.getRenderBlockPass() != 0) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_CULL_FACE);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    }
    IItemRenderer storedRenderer = MinecraftForgeClient.getItemRenderer(thisStack, type);
    //======Handles Special Blocks and Items======
    if (storedRenderer != null) {
        storedRenderer.renderItem(type, thisStack, data);
    } else {
        if (thisStack.getItemSpriteNumber() == 0 && item instanceof ItemBlock
                && RenderBlocks.renderItemIn3d(block.getRenderType())) {
            //=====Handles regular blocks======
            textureManager.bindTexture(textureManager.getResourceLocation(0));
            switch (type) {
            case EQUIPPED_FIRST_PERSON:
            case EQUIPPED:
            case ENTITY:
                GL11.glTranslatef(0.5F, 0.5F, 0.5F);
            default:
            }
            if (thisStack != null && block != null && block.getRenderBlockPass() != 0) {
                GL11.glDepthMask(false);
                renderBlocksIr.renderBlockAsItem(block, thisStack.getItemDamage(), 1.0F);
                GL11.glDepthMask(true);
            } else {
                renderBlocksIr.renderBlockAsItem(block, thisStack.getItemDamage(), 1.0F);
            }
        } else {
            //=======Handles Regular Items======
            if (isInventory) {
                renderItem.renderItemIntoGUI(fontRenderer, textureManager, thisStack, 0, 0);
            } else {
                GL11.glEnable(GL12.GL_RESCALE_NORMAL);
                switch (type) {
                case EQUIPPED_FIRST_PERSON:
                    //TODO: get items to render in the right place
                    GL11.glRotated(90F, 0F, 1F, 0F);
                    GL11.glTranslatef(-1F, 0.5F, 0F);
                    break;
                case EQUIPPED:
                    GL11.glRotated(90F, 0F, 1F, 0F);
                    GL11.glTranslatef(-1F, 0.5F, 0F);
                    GL11.glRotated(90F, 1F, 0F, 0F);
                    //GL11.glTranslatef(0, -4 / 16f, 0);
                    break;
                case ENTITY:
                    //GL11.glTranslatef(-0.5f, 0f, 1f / 16f); // correction of the rotation point when items lie on the ground
                default:
                }

                IIcon icon = thisStack.getIconIndex();
                float xMax;
                float yMin;
                float xMin;
                float yMax;
                float depth = 1f / 16f;

                float width;
                float height;
                float xDiff;
                float yDiff;
                float xSub;
                float ySub;

                xMin = icon.getMinU();
                xMax = icon.getMaxU();
                yMin = icon.getMinV();
                yMax = icon.getMaxV();
                width = icon.getIconWidth();
                height = icon.getIconHeight();
                xDiff = xMin - xMax;
                yDiff = yMin - yMax;
                xSub = 0.5f * (xMax - xMin) / width;
                ySub = 0.5f * (yMax - yMin) / height;

                //=====Front and back=====
                tess.startDrawingQuads();
                tess.setNormal(0, 0, 1);
                tess.addVertexWithUV(0, 0, 0, xMax, yMax);
                tess.addVertexWithUV(1, 0, 0, xMin, yMax);
                tess.addVertexWithUV(1, 1, 0, xMin, yMin);
                tess.addVertexWithUV(0, 1, 0, xMax, yMin);
                tess.draw();

                tess.startDrawingQuads();
                tess.setNormal(0, 0, -1);
                tess.addVertexWithUV(0, 1, -depth, xMax, yMin);
                tess.addVertexWithUV(1, 1, -depth, xMin, yMin);
                tess.addVertexWithUV(1, 0, -depth, xMin, yMax);
                tess.addVertexWithUV(0, 0, -depth, xMax, yMax);
                tess.draw();

                // =========Sides============
                tess.startDrawingQuads();
                tess.setNormal(-1, 0, 0);
                float pos;
                float iconPos;
                float w = width, m = xMax, d = xDiff, s = xSub;
                for (int k = 0, e = (int) w; k < e; ++k) {
                    pos = k / w;
                    iconPos = m + d * pos - s;
                    tess.addVertexWithUV(pos, 0, -depth, iconPos, yMax);
                    tess.addVertexWithUV(pos, 0, 0, iconPos, yMax);
                    tess.addVertexWithUV(pos, 1, 0, iconPos, yMin);
                    tess.addVertexWithUV(pos, 1, -depth, iconPos, yMin);
                }
                tess.draw();
                tess.startDrawingQuads();
                tess.setNormal(1, 0, 0);
                float posEnd;
                w = width;
                m = xMax;
                d = xDiff;
                s = xSub;
                float d2 = 1f / w;
                for (int k = 0, e = (int) w; k < e; ++k) {
                    pos = k / w;
                    iconPos = m + d * pos - s;
                    posEnd = pos + d2;
                    tess.addVertexWithUV(posEnd, 1, -depth, iconPos, yMin);
                    tess.addVertexWithUV(posEnd, 1, 0, iconPos, yMin);
                    tess.addVertexWithUV(posEnd, 0, 0, iconPos, yMax);
                    tess.addVertexWithUV(posEnd, 0, -depth, iconPos, yMax);
                }
                tess.draw();
                tess.startDrawingQuads();
                tess.setNormal(0, 1, 0);
                float h = height;
                m = yMax;
                d = yDiff;
                s = ySub;
                d2 = 1f / h;
                for (int k = 0, e = (int) h; k < e; ++k) {
                    pos = k / h;
                    iconPos = m + d * pos - s;
                    posEnd = pos + d2;
                    tess.addVertexWithUV(0, posEnd, 0, xMax, iconPos);
                    tess.addVertexWithUV(1, posEnd, 0, xMin, iconPos);
                    tess.addVertexWithUV(1, posEnd, -depth, xMin, iconPos);
                    tess.addVertexWithUV(0, posEnd, -depth, xMax, iconPos);
                }
                tess.draw();
                tess.startDrawingQuads();
                tess.setNormal(0, -1, 0);
                h = height;
                m = yMax;
                d = yDiff;
                s = ySub;
                for (int k = 0, e = (int) h; k < e; ++k) {
                    pos = k / h;
                    iconPos = m + d * pos - s;
                    tess.addVertexWithUV(1, pos, 0, xMin, iconPos);
                    tess.addVertexWithUV(0, pos, 0, xMax, iconPos);
                    tess.addVertexWithUV(0, pos, -depth, xMax, iconPos);
                    tess.addVertexWithUV(1, pos, -depth, xMin, iconPos);
                }
                tess.draw();
                GL11.glDisable(GL12.GL_RESCALE_NORMAL);
            }
        }
    }

    if (thisStack != null && block != null && block.getRenderBlockPass() != 0) {
        GL11.glDisable(GL11.GL_BLEND);
    }

    GL11.glPopMatrix();

    if (isInventory) {
        renderItem.renderItemIntoGUI(fontRenderer, textureManager, itemStack, 0, 0);
        //TODO: only renders on items, not blocks - fix
    }
}

From source file:com.kegare.caveworld.client.gui.GuiListSlot.java

License:Minecraft Mod Public

private void drawPanorama(float ticks) {
    Tessellator tessellator = Tessellator.instance;
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();/*  w w w  .  ja v  a  2  s  . co  m*/
    GL11.glLoadIdentity();
    Project.gluPerspective(120.0F, 1.0F, 0.05F, 10.0F);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(90.0F, 0.0F, 0.0F, 1.0F);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    byte b0 = 8;

    for (int k = 0; k < b0 * b0; ++k) {
        GL11.glPushMatrix();
        float f1 = ((float) (k % b0) / (float) b0 - 0.5F) / 64.0F;
        float f2 = ((float) (k / b0) / (float) b0 - 0.5F) / 64.0F;
        float f3 = 0.0F;
        GL11.glTranslatef(f1, f2, f3);
        GL11.glRotatef(MathHelper.sin((panoramaTimer + ticks) / 400.0F) * 25.0F + 20.0F, 1.0F, 0.0F, 0.0F);
        GL11.glRotatef(-(panoramaTimer + ticks) * 0.1F, 0.0F, 1.0F, 0.0F);

        for (int l = 0; l < 6; ++l) {
            GL11.glPushMatrix();

            if (l == 1) {
                GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 2) {
                GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 3) {
                GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
            }

            if (l == 4) {
                GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F);
            }

            if (l == 5) {
                GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
            }

            mc.getTextureManager().bindTexture(getPanoramaPaths().getPath(l));
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_I(16777215, 255 / (k + 1));
            float f4 = 0.0F;
            tessellator.addVertexWithUV(-1.0D, -1.0D, 1.0D, 0.0F + f4, 0.0F + f4);
            tessellator.addVertexWithUV(1.0D, -1.0D, 1.0D, 1.0F - f4, 0.0F + f4);
            tessellator.addVertexWithUV(1.0D, 1.0D, 1.0D, 1.0F - f4, 1.0F - f4);
            tessellator.addVertexWithUV(-1.0D, 1.0D, 1.0D, 0.0F + f4, 1.0F - f4);
            tessellator.draw();
            GL11.glPopMatrix();
        }

        GL11.glPopMatrix();
        GL11.glColorMask(true, true, true, false);
    }

    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
    GL11.glColorMask(true, true, true, true);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:com.kegare.caveworld.client.renderer.RenderCaveman.java

License:Minecraft Mod Public

@Override
public void doRender(Entity entity, double par2, double par3, double par4, float par5, float par6) {
    super.doRender(entity, par2, par3, par4, par5, par6);

    if (Config.cavemanShowHealthBar && entity instanceof EntityCaveman) {
        Minecraft mc = FMLClientHandler.instance().getClient();
        EntityPlayer player = mc.thePlayer;
        EntityCaveman living = (EntityCaveman) entity;

        if (living.isTamed()
                && player.getGameProfile().getId().toString()
                        .equals(Strings.nullToEmpty(living.func_152113_b()))
                && living.getEntitySenses().canSee(player) && living.getDistanceToEntity(player) <= 3.5F
                && mc.objectMouseOver.typeOfHit == MovingObjectType.ENTITY
                && mc.objectMouseOver.entityHit == living) {
            float scale = 0.01666667F * 1.5F;
            int width = 15;
            double top = 5.0D;
            double under = top + 2.0D;

            GL11.glPushMatrix();//  w w w . java2  s  .c  o  m
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            GL11.glTranslatef((float) par2, (float) par3 + 2.3F, (float) par4);
            GL11.glNormal3f(0.0F, 1.0F, 0.0F);
            GL11.glRotatef(-RenderManager.instance.playerViewY, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(RenderManager.instance.playerViewX, 1.0F, 0.0F, 0.0F);
            GL11.glScalef(-scale, -scale, scale);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glTranslatef(0.0F, (living.isSittingAndStopped() ? 0.6F : 0.12F) / scale, 0.0F);
            GL11.glDepthMask(false);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(770, 771);

            int x = living.getBrightnessForRender((float) par2);
            int y = x % 65536;
            int z = x / 65536;

            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, y / 1.0F, z / 1.0F);
            Tessellator tessellator = Tessellator.instance;
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA_I(0, 115);
            tessellator.addVertex(-width - 1, top - 0.5D, 0.0D);
            tessellator.addVertex(-width - 1, under + 0.5D, 0.0D);
            tessellator.addVertex(width + 1, under + 0.5D, 0.0D);
            tessellator.addVertex(width + 1, top - 0.5D, 0.0D);
            tessellator.draw();
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);

            Tessellator tessellator1 = Tessellator.instance;
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            float max = living.getMaxHealth();
            int health = (int) (2.0D * width * living.getHealth() / max);

            if (renderHealth < 0.0D) {
                renderHealth = health;
            } else {
                double dh = renderHealth - health;
                double distance = Math.abs(Math.sqrt(dh * dh));

                if ((int) renderHealth < health) {
                    if (distance > 10.0D) {
                        renderHealth += 0.35D;
                    } else if (distance < 1.5D) {
                        renderHealth += 0.01D;
                    } else {
                        renderHealth += 0.1D;
                    }
                } else if ((int) renderHealth > health) {
                    if (distance > 10.0D) {
                        renderHealth -= 0.35D;
                    } else if (distance < 1.5D) {
                        renderHealth -= 0.01D;
                    } else {
                        renderHealth -= 0.1D;
                    }
                }
            }

            int color = Color.GREEN.getRGB();

            if (renderHealth < max / 4) {
                color = Color.RED.getRGB();
            } else if (renderHealth < max / 2) {
                color = Color.YELLOW.getRGB();
            }

            tessellator1.startDrawingQuads();
            tessellator1.setColorRGBA_I(color, 145);
            tessellator1.addVertex(-width, top, 0.0D);
            tessellator1.addVertex(-width, under, 0.0D);
            tessellator1.addVertex(-width + renderHealth, under, 0.0D);
            tessellator1.addVertex(-width + renderHealth, top, 0.0D);
            tessellator1.draw();
            GL11.glEnable(GL11.GL_TEXTURE_2D);

            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glPopMatrix();
        } else {
            renderHealth = -1.0D;
        }
    }
}

From source file:com.minestellar.core.gui.ComputerGui.java

License:Open Source License

@Override
public void drawForeground() {
    GL11.glDisable(GL11.GL_LIGHTING);//from   w w w .jav  a 2s.  c om
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    {
        GL11.glPushMatrix();
        {
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glDepthMask(false);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glDisable(GL11.GL_TEXTURE_2D);

            // Earth
            GL11.glColor4d(0, 0, 1, 1);
            Tessellator tess = Tessellator.instance;
            tess.startDrawing(GL11.GL_LINES);

            for (Point2D.Double anEarthCoordsArray : earthCoordsArray) {
                tess.addVertex(getMid(screenWidth) + 4 + anEarthCoordsArray.x,
                        getMid(screenHeight) + 4 + anEarthCoordsArray.y, 0.0D);
            }

            tess.draw();

            if (knownPlanets.contains("moon")) {
                GL11.glColor4d(0.89, 0.89, 0.89, 1);
                tess.startDrawing(GL11.GL_LINES);

                for (Point2D.Double aMoonCoordsArray : moonCoordsArray) {
                    tess.addVertex(earth.x + 4 + aMoonCoordsArray.x, earth.y + 4 + aMoonCoordsArray.y, 0.0D);
                }

                tess.draw();
            }

            if (knownPlanets.contains("venus")) {
                GL11.glColor4d(0.84, 0.63, 0.29, 1);
                tess.startDrawing(GL11.GL_LINES);

                for (Point2D.Double aVenusCoordsArray : venusCoordsArray) {
                    tess.addVertex(getMid(screenWidth) + 4 + aVenusCoordsArray.x,
                            getMid(screenHeight) + 4 + aVenusCoordsArray.y, 0.0D);
                }

                tess.draw();
            }

        }

        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthMask(true);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}