Example usage for org.lwjgl.opengl GL11 glEnable

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

Introduction

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

Prototype

public static void glEnable(@NativeType("GLenum") int target) 

Source Link

Document

Enables the specified OpenGL state.

Usage

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

License:Minecraft Mod Public

private void rotateAndBlurSkybox(float ticks) {
    mc.getTextureManager().bindTexture(panoramaBackground);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glCopyTexSubImage2D(GL11.GL_TEXTURE_2D, 0, 0, 0, 0, 0, 256, 256);
    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(770, 771, 1, 0);
    GL11.glColorMask(true, true, true, false);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();/*from  ww w  .j  ava2 s .  c  om*/
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    byte b0 = 3;

    for (int i = 0; i < b0; ++i) {
        tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F / (i + 1));
        int j = width;
        int k = height;
        float f1 = (i - b0 / 2) / 256.0F;
        tessellator.addVertexWithUV(j, k, 0.0F, 0.0F + f1, 1.0D);
        tessellator.addVertexWithUV(j, 0.0D, 0.0F, 1.0F + f1, 1.0D);
        tessellator.addVertexWithUV(0.0D, 0.0D, 0.0F, 1.0F + f1, 0.0D);
        tessellator.addVertexWithUV(0.0D, k, 0.0F, 0.0F + f1, 0.0D);
    }

    tessellator.draw();
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glColorMask(true, true, true, true);
}

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

License:Minecraft Mod Public

@Override
protected void drawContainerBackground(Tessellator tessellator) {
    if (mc.theWorld != null) {
        Gui.drawRect(left, top, right, bottom, 0x101010);
    } else if (getPanoramaPaths() != null) {
        ++panoramaTimer;//ww  w  .j  av a2 s .c  om

        GL11.glDisable(GL11.GL_ALPHA_TEST);
        renderSkybox(panoramaTicks);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    } else
        super.drawContainerBackground(tessellator);
}

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();/*from  www. ja va 2s.  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.kegare.caveworld.client.renderer.RenderMiningPickaxe.java

License:Minecraft Mod Public

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    FontRenderer renderer = item.getItem().getFontRenderer(item);

    if (renderer == null) {
        renderer = mc.fontRenderer;/*w w w .ja v  a 2 s .  c  o m*/
    }

    itemRender.renderItemIntoGUI(renderer, mc.getTextureManager(), item, 0, 0, true);

    Item base = ((ItemMiningPickaxe) item.getItem()).getBaseTool(item);

    if (base != CaveItems.mining_pickaxe) {
        GL11.glPushMatrix();
        GL11.glTranslatef(-9.0F, 14.0F, -9.0F);
        GL11.glScalef(0.6F, 0.6F, 0.6F);
        GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
        itemRender.renderItemIntoGUI(renderer, mc.getTextureManager(), new ItemStack(base), 0,
                item.isItemDamaged() ? 13 : 16, true);
        GL11.glPopMatrix();
    }

    String refined = Roman.toRoman(((ItemMiningPickaxe) item.getItem()).getRefined(item));

    if (!Strings.isNullOrEmpty(refined)) {
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPushMatrix();
        GL11.glTranslatef(5.0F, 5.0F, 5.0F);
        GL11.glScalef(0.8F, 0.8F, 0.8F);
        renderer.drawStringWithShadow(refined, 16 - renderer.getStringWidth(refined) - 2,
                item.isItemDamaged() ? 3 : 6, 0xEEEEEE);
        GL11.glPopMatrix();
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
}

From source file:com.kegare.caveworld.handler.CaveEventHooks.java

License:Minecraft Mod Public

@SideOnly(Side.CLIENT)
@SubscribeEvent/*from   w  w  w .  j  av a  2s. c  o  m*/
public void onRenderTick(RenderTickEvent event) {
    if (event.phase != Phase.END) {
        return;
    }

    Minecraft mc = FMLClientHandler.instance().getClient();
    ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);

    if (mc.thePlayer != null) {
        ItemStack current = mc.thePlayer.getCurrentEquippedItem();

        if (current != null && current.getItem() != null && current.getItem() instanceof ItemMiningPickaxe) {
            ItemMiningPickaxe item = (ItemMiningPickaxe) current.getItem();

            if (item.highlightTicks > 0) {
                GL11.glPushMatrix();
                GL11.glEnable(GL11.GL_BLEND);
                OpenGlHelper.glBlendFunc(770, 771, 1, 0);
                mc.fontRenderer.drawStringWithShadow(item.getModeInfomation(current), 18,
                        resolution.getScaledHeight() - 20, 0xEEEEEE);
                GL11.glDisable(GL11.GL_BLEND);
                GL11.glPopMatrix();

                --item.highlightTicks;
            } else {
                int highlight = ObfuscationReflectionHelper.getPrivateValue(GuiIngame.class, mc.ingameGUI,
                        "remainingHighlightTicks", "field_92017_k");

                if (highlight == 40) {
                    item.highlightTicks = 800;
                }
            }
        }
    }
}

From source file:com.kegare.caveworld.util.CaveUtils.java

License:Minecraft Mod Public

@SideOnly(Side.CLIENT)
public static boolean renderItemStack(Minecraft mc, ItemStack itemstack, int x, int y, boolean overlay,
        String txt) {/*from w  ww . j  a v  a  2 s  .c om*/
    GL11.glColor3f(1.0F, 1.0F, 1.0F);

    boolean isLightingEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING);
    boolean rc = false;

    if (itemstack != null && itemstack.getItem() != null) {
        Block block = Block.getBlockFromItem(itemstack.getItem());

        if (GameRegistry.findUniqueIdentifierFor(block).modId.equals("EnderIO")
                && !block.renderAsNormalBlock()) {
            return false;
        }

        rc = true;
        boolean isRescaleNormalEnabled = GL11.glIsEnabled(GL12.GL_RESCALE_NORMAL);
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 0.0F, 32.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        short short1 = 240;
        short short2 = 240;
        RenderHelper.enableGUIStandardItemLighting();
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, short1 / 1.0F, short2 / 1.0F);
        RenderItem itemRender = RenderItem.getInstance();

        itemRender.zLevel += 100.0F;
        boolean rendered;

        try {
            rendered = ForgeHooksClient.renderInventoryItem(RenderBlocks.getInstance(), mc.getTextureManager(),
                    itemstack, itemRender.renderWithColor, itemRender.zLevel, x, y);
        } catch (Throwable e) {
            rendered = false;
        }

        if (!rendered) {
            try {
                itemRender.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y, true);
            } catch (Throwable e) {
            }
        }

        if (overlay) {
            try {
                itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y,
                        txt);
            } catch (Throwable e) {
            }
        }

        itemRender.zLevel -= 100.0F;

        GL11.glPopMatrix();

        if (isRescaleNormalEnabled) {
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        } else {
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        }
    }

    if (isLightingEnabled) {
        GL11.glEnable(GL11.GL_LIGHTING);
    } else {
        GL11.glDisable(GL11.GL_LIGHTING);
    }

    return rc;
}

From source file:com.kegare.frozenland.client.renderer.FrozenlandWheatherRenderer.java

License:Minecraft Mod Public

@Override
public void render(float ticks, WorldClient world, Minecraft mc) {
    ++rendererUpdateCount;//ww  w  . j a  v a 2 s  .co m

    float rainStrength = mc.theWorld.getRainStrength(ticks);

    if (rainStrength > 0.0F) {
        mc.entityRenderer.enableLightmap(ticks);

        if (rainXCoords == null) {
            rainXCoords = new float[1024];
            rainYCoords = new float[1024];

            for (int i = 0; i < 32; ++i) {
                for (int j = 0; j < 32; ++j) {
                    float f1 = j - 16;
                    float f2 = i - 16;
                    float f3 = MathHelper.sqrt_float(f1 * f1 + f2 * f2);

                    rainXCoords[i << 5 | j] = -f2 / f3;
                    rainYCoords[i << 5 | j] = f1 / f3;
                }
            }
        }

        EntityLivingBase entity = mc.renderViewEntity;
        int x = MathHelper.floor_double(entity.posX);
        int y = MathHelper.floor_double(entity.posY);
        int z = MathHelper.floor_double(entity.posZ);
        Tessellator tessellator = Tessellator.instance;
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glNormal3f(0.0F, 1.0F, 0.0F);
        GL11.glEnable(GL11.GL_BLEND);
        OpenGlHelper.glBlendFunc(770, 771, 1, 0);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * ticks;
        double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * ticks;
        double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * ticks;
        int i = MathHelper.floor_double(d1);
        byte range = 5;

        if (mc.gameSettings.fancyGraphics) {
            range = 10;
        }

        byte b1 = -1;
        float f1 = rendererUpdateCount + ticks;

        if (mc.gameSettings.fancyGraphics) {
            range = 10;
        }

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

        for (int j = z - range; j <= z + range; ++j) {
            for (int k = x - range; k <= x + range; ++k) {
                int index = (j - z + 16) * 32 + k - x + 16;
                float f2 = rainXCoords[index] * 0.5F;
                float f3 = rainYCoords[index] * 0.5F;
                int height = world.getPrecipitationHeight(k, j);
                int cloud = MathHelper.floor_float(world.provider.getCloudHeight());
                int l = MathHelper.clamp_int(y - range, height, cloud);
                int m = MathHelper.clamp_int(y + range, height, cloud);

                if (l == cloud || m == cloud) {
                    continue;
                }

                float f4 = 1.35F;
                int n = height;

                if (height < i) {
                    n = i;
                }

                if (l != m) {
                    random.setSeed(k * k * 3121 + k * 45238971 ^ j * j * 418711 + j * 13761);

                    if (b1 != 1) {
                        if (b1 >= 0) {
                            tessellator.draw();
                        }

                        b1 = 1;
                        mc.getTextureManager().bindTexture(locationSnowPng);
                        tessellator.startDrawingQuads();
                    }

                    float f5 = ((rendererUpdateCount & 0x1FF) + ticks) / 512.0F;
                    float f6 = random.nextFloat() + f1 * 0.01F * (float) random.nextGaussian();
                    float f7 = random.nextFloat() + f1 * (float) random.nextGaussian() * 0.001F;
                    double xDist = k + 0.5F - entity.posX;
                    double zDist = j + 0.5F - entity.posZ;
                    float f8 = MathHelper.sqrt_double(xDist * xDist + zDist * zDist) / range;
                    tessellator.setBrightness(
                            (world.getLightBrightnessForSkyBlocks(k, n, j, 0) * 3 + 15728880) / 4);
                    tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F,
                            ((1.0F - f8 * f8) * 0.3F + 0.5F) * rainStrength);
                    tessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D);
                    tessellator.addVertexWithUV(k - f2 + 0.5D, l, j - f3 + 0.5D, 0.0F * f4 + f6,
                            l * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k + f2 + 0.5D, l, j + f3 + 0.5D, 1.0F * f4 + f6,
                            l * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k + f2 + 0.5D, m, j + f3 + 0.5D, 1.0F * f4 + f6,
                            m * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.addVertexWithUV(k - f2 + 0.5D, m, j - f3 + 0.5D, 0.0F * f4 + f6,
                            m * f4 / 4.0F + f5 * f4 + f7);
                    tessellator.setTranslation(0.0D, 0.0D, 0.0D);
                }
            }
        }

        if (b1 >= 0) {
            tessellator.draw();
        }

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);

        mc.entityRenderer.disableLightmap(ticks);
    }
}

From source file:com.kegare.frozenland.client.renderer.RenderIceball.java

License:Minecraft Mod Public

@Override
public void doRender(Entity entity, double posX, double posY, double posZ, float yaw, float ticks) {
    IIcon icon = Items.snowball.getIconFromDamage(0);

    if (icon != null) {
        GL11.glPushMatrix();/*from   w  w w.  j a va  2s. c  o m*/
        GL11.glTranslatef((float) posX, (float) posY, (float) posZ);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        bindEntityTexture(entity);
        Tessellator tessellator = Tessellator.instance;
        int i = 0x95CBE7;
        float r = (i >> 16 & 255) / 255.0F;
        float g = (i >> 8 & 255) / 255.0F;
        float b = (i & 255) / 255.0F;
        GL11.glColor3f(r, g, b);
        GL11.glPushMatrix();
        doRender(tessellator, icon);
        GL11.glPopMatrix();
        GL11.glColor3f(1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Basic quad//from  ww  w  . j ava 2s  . c  o m
 * 
 * @param g
 * @param h
 * @param i
 * @param j
 * @param col1
 */
public static void drawRect(float g, float h, float i, float j, int col1) {
    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);

    GL11.glPushMatrix();
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2d(i, h);
    GL11.glVertex2d(g, h);
    GL11.glVertex2d(g, j);
    GL11.glVertex2d(i, j);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:com.kodehawa.gui.api.render.ModGuiUtils.java

License:Open Source License

/**
 * Gradient quad//from   w  w w. j a va  2 s .c  o  m
 * 
 * @param x
 * @param y
 * @param x2
 * @param y2
 * @param col1
 * @param col2
 */
public static void drawGradientRect(int x, int y, int x2, int y2, int col1, int col2) {
    float f = ((col1 >> 24) & 0xFF) / 255F;
    float f1 = ((col1 >> 16) & 0xFF) / 255F;
    float f2 = ((col1 >> 8) & 0xFF) / 255F;
    float f3 = (col1 & 0xFF) / 255F;

    float f4 = ((col2 >> 24) & 0xFF) / 255F;
    float f5 = ((col2 >> 16) & 0xFF) / 255F;
    float f6 = ((col2 >> 8) & 0xFF) / 255F;
    float f7 = (col2 & 0xFF) / 255F;

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL11.glPushMatrix();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glVertex2d(x2, y);
    GL11.glVertex2d(x, y);

    GL11.glColor4f(f5, f6, f7, f4);
    GL11.glVertex2d(x, y2);
    GL11.glVertex2d(x2, y2);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glShadeModel(GL11.GL_FLAT);
}