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:vazkii.botania.client.core.helper.RenderHelper.java

License:Open Source License

public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) {
    Tessellator tessellator = Tessellator.getInstance();

    int ticks = ClientTickHandler.ticksInGame % 200;
    if (ticks >= 100)
        ticks = 200 - ticks - 1;// w  w  w.  java 2 s. c  o  m

    float f1 = ticks / 200F;
    float f2 = 0F;
    if (f1 > 0.7F)
        f2 = (f1 - 0.7F) / 0.2F;
    Random random = new Random(seed);

    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GlStateManager.disableAlpha();
    GlStateManager.enableCull();
    GlStateManager.depthMask(false);
    GlStateManager.scale(xScale, yScale, zScale);

    for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) {
        GlStateManager.rotate(random.nextFloat() * 360F, 1F, 0F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 1F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 0F, 1F);
        GlStateManager.rotate(random.nextFloat() * 360F, 1F, 0F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 1F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F);
        tessellator.getBuffer().begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        float f3 = random.nextFloat() * 20F + 5F + f2 * 10F;
        float f4 = random.nextFloat() * 2F + 1F + f2 * 2F;
        float r = ((color & 0xFF0000) >> 16) / 255F;
        float g = ((color & 0xFF00) >> 8) / 255F;
        float b = (color & 0xFF) / 255F;
        tessellator.getBuffer().pos(0, 0, 0).color(r, g, b, 1F - f2).endVertex();
        tessellator.getBuffer().pos(-0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        tessellator.getBuffer().pos(0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        tessellator.getBuffer().pos(0, f3, 1F * f4).color(0, 0, 0, 0).endVertex();
        tessellator.getBuffer().pos(-0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        tessellator.draw();
    }

    GlStateManager.depthMask(true);
    GlStateManager.disableCull();
    GlStateManager.disableBlend();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    GlStateManager.popMatrix();
}

From source file:vazkii.botania.client.core.helper.RenderHelper.java

License:Open Source License

public static void renderProgressPie(int x, int y, float progress, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GlStateManager.colorMask(false, false, false, false);
    GlStateManager.depthMask(false);//from   ww w  . j ava2 s . c o  m
    GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
    GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
    GL11.glStencilMask(0xFF);
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD));
    int r = 10;
    int centerX = x + 8;
    int centerY = y + 8;
    int degs = (int) (360 * progress);
    float a = 0.5F + 0.2F
            * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10)
                    * 0.5F + 0.5F);

    GlStateManager.disableLighting();
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.depthMask(true);
    GL11.glStencilMask(0x00);
    GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);

    VertexBuffer buf = Tessellator.getInstance().getBuffer();
    buf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
    buf.pos(centerX, centerY, 0).color(0, 0.5F, 0.5F, a).endVertex();

    for (int i = degs; i > 0; i--) {
        double rad = (i - 90) / 180F * Math.PI;
        buf.pos(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r, 0).color(0F, 1F, 0.5F, a).endVertex();
    }

    buf.pos(centerX, centerY, 0).color(0F, 1F, 0.5F, a).endVertex();
    Tessellator.getInstance().draw();

    GlStateManager.disableBlend();
    GlStateManager.enableTexture2D();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_STENCIL_TEST);
}

From source file:vazkii.botania.client.render.entity.RenderBabylonWeapon.java

License:Open Source License

@Override
public void doRender(@Nonnull EntityBabylonWeapon weapon, double par2, double par4, double par6, float par8,
        float par9) {
    GlStateManager.pushMatrix();// w w  w.java2 s  .c o m
    GlStateManager.translate((float) par2, (float) par4, (float) par6);
    GlStateManager.rotate(weapon.getRotation(), 0F, 1F, 0F);

    int live = weapon.getLiveTicks();
    int delay = weapon.getDelay();
    float charge = Math.min(10F, Math.max(live, weapon.getChargeTicks()) + par9);
    float chargeMul = charge / 10F;

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

    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
    GlStateManager.pushMatrix();
    float s = 1.5F;
    GlStateManager.scale(s, s, s);
    GlStateManager.rotate(-90F, 0F, 1F, 0F);
    GlStateManager.rotate(45F, 0F, 0F, 1F);
    TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.kingKeyWeaponIcons[weapon.getVariety()];
    GlStateManager.color(1F, 1F, 1F, chargeMul);
    float f = icon.getMinU();
    float f1 = icon.getMaxU();
    float f2 = icon.getMinV();
    float f3 = icon.getMaxV();

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
    GlStateManager.disableLighting();
    IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getIconWidth(),
            icon.getIconHeight(), 1F / 16F);
    GlStateManager.popMatrix();

    GlStateManager.disableCull();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.color(1F, 1F, 1F, chargeMul);

    Minecraft.getMinecraft().renderEngine.bindTexture(babylon);

    Tessellator tes = Tessellator.getInstance();
    ShaderHelper.useShader(ShaderHelper.halo);
    Random rand = new Random(weapon.getUniqueID().getMostSignificantBits());
    GlStateManager.rotate(-90F, 1F, 0F, 0F);
    GlStateManager.translate(0F, -0.3F + rand.nextFloat() * 0.1F, 1F);

    s = chargeMul;
    if (live > delay)
        s -= Math.min(1F, (live - delay + par9) * 0.2F);
    s *= 2F;
    GlStateManager.scale(s, s, s);

    GlStateManager.rotate(charge * 9F + (weapon.ticksExisted + par9) * 0.5F + rand.nextFloat() * 360F, 0F, 1F,
            0F);

    tes.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    tes.getBuffer().pos(-1, 0, -1).tex(0, 0).endVertex();
    tes.getBuffer().pos(-1, 0, 1).tex(0, 1).endVertex();
    tes.getBuffer().pos(1, 0, 1).tex(1, 1).endVertex();
    tes.getBuffer().pos(1, 0, -1).tex(1, 0).endVertex();
    tes.draw();

    ShaderHelper.releaseShader();

    GlStateManager.enableLighting();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableCull();
    GlStateManager.popMatrix();
}

From source file:vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube.java

License:Open Source License

private void renderAnimatedModel(TileCorporeaCrystalCube te, double x, double y, double z, float partialTick) {
    // From FastTESR.renderTileEntityAt
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer worldRenderer = tessellator.getBuffer();
    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  2 s  .co  m
    GlStateManager.disableCull();

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

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

    // Inlined AnimationTESR.renderTileEntityFast
    if (!te.hasCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null)) {
        return;
    }
    if (blockRenderer == null)
        blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos pos = te.getPos();
    IBlockAccess world = MinecraftForgeClient.getRegionRenderCache(te.getWorld(), pos);
    IBlockState state = world.getBlockState(pos);
    if (state.getPropertyNames().contains(Properties.StaticProperty)) {
        state = state.withProperty(Properties.StaticProperty, false);
    }
    if (state instanceof IExtendedBlockState) {
        IExtendedBlockState exState = (IExtendedBlockState) state;
        if (exState.getUnlistedNames().contains(Properties.AnimationProperty)) {
            float time = Animation.getWorldTime(getWorld(), partialTick);
            Pair<IModelState, Iterable<Event>> pair = te
                    .getCapability(CapabilityAnimation.ANIMATION_CAPABILITY, null).apply(time);
            // handleEvents(te, time, pair.getRight());

            IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(exState.getClean());
            exState = exState.withProperty(Properties.AnimationProperty, pair.getLeft());

            worldRenderer.setTranslation(x - pos.getX(), y - pos.getY(), z - pos.getZ());

            blockRenderer.getBlockModelRenderer().renderModel(world, model, exState, pos, worldRenderer, false);
        }
    }
    // End inline AnimationTESR.renderTileEntityFast

    worldRenderer.setTranslation(0, 0, 0);

    tessellator.draw();

    RenderHelper.enableStandardItemLighting();
}

From source file:vazkii.botania.common.item.equipment.bauble.ItemFlightTiara.java

License:Open Source License

@SideOnly(Side.CLIENT)
public static void renderHalo(EntityPlayer player, float partialTicks) {
    GlStateManager.enableBlend();//from   ww  w.j  ava 2s. c  o  m
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
    GlStateManager.disableLighting();
    GlStateManager.disableCull();
    GlStateManager.color(1F, 1F, 1F, 1F);

    Minecraft.getMinecraft().renderEngine.bindTexture(textureHalo);

    if (player != null)
        Helper.translateToHeadLevel(player);
    GlStateManager.translate(0, 1.5F, 0);
    GlStateManager.rotate(30, 1, 0, -1);
    GlStateManager.translate(-0.1F, -0.5F, -0.1F);
    if (player != null)
        GlStateManager.rotate(player.ticksExisted + partialTicks, 0, 1, 0);
    else
        GlStateManager.rotate(Botania.proxy.getWorldElapsedTicks(), 0, 1, 0);

    Tessellator tes = Tessellator.getInstance();
    ShaderHelper.useShader(ShaderHelper.halo);
    tes.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    tes.getBuffer().pos(-0.75, 0, -0.75).tex(0, 0).endVertex();
    tes.getBuffer().pos(-0.75, 0, 0.75).tex(0, 1).endVertex();
    tes.getBuffer().pos(0.75, 0, 0.75).tex(1, 1).endVertex();
    tes.getBuffer().pos(0.75, 0, -0.75).tex(1, 0).endVertex();
    tes.draw();
    ShaderHelper.releaseShader();

    GlStateManager.enableLighting();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableCull();
}

From source file:vazkii.b_baubles.client.core.helper.RenderHelper.java

License:Open Source License

public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) {
    Tessellator tessellator = Tessellator.instance;

    int ticks = ClientTickHandler.ticksInGame % 200;
    if (ticks >= 100)
        ticks = 200 - ticks - 1;/*from  w  ww  .  j av  a2s  . c  o m*/

    float f1 = ticks / 200F;
    float f2 = 0F;
    if (f1 > 0.7F)
        f2 = (f1 - 0.7F) / 0.2F;
    Random random = new Random(seed);

    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(770, 1);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(false);
    GL11.glScalef(xScale, yScale, zScale);

    for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) {
        GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F);
        GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F);
        GL11.glRotatef(random.nextFloat() * 360F, 0F, 0F, 1F);
        GL11.glRotatef(random.nextFloat() * 360F, 1F, 0F, 0F);
        GL11.glRotatef(random.nextFloat() * 360F, 0F, 1F, 0F);
        GL11.glRotatef(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F);
        tessellator.startDrawing(GL11.GL_TRIANGLE_FAN);
        float f3 = random.nextFloat() * 20F + 5F + f2 * 10F;
        float f4 = random.nextFloat() * 2F + 1F + f2 * 2F;
        tessellator.setColorRGBA_I(color, (int) (255F * (1F - f2)));
        tessellator.addVertex(0, 0, 0);
        tessellator.setColorRGBA_F(0F, 0F, 0F, 0);
        tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
        tessellator.addVertex(0.866D * f4, f3, -0.5F * f4);
        tessellator.addVertex(0, f3, 1F * f4);
        tessellator.addVertex(-0.866D * f4, f3, -0.5F * f4);
        tessellator.draw();
    }

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

From source file:vazkii.psi.client.core.helper.PsiRenderHelper.java

public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder buff = tessellator.getBuffer();

    int ticks = ClientTickHandler.ticksInGame % 200;
    if (ticks >= 100)
        ticks = 200 - ticks - 1;//from   w ww .  j  av a2  s .c om

    float f1 = ticks / 200F;
    float f2 = 0F;
    if (f1 > 0.7F)
        f2 = (f1 - 0.7F) / 0.2F;
    Random random = new Random(seed);

    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);
    GlStateManager.disableAlpha();
    GlStateManager.enableCull();
    GlStateManager.depthMask(false);
    GlStateManager.scale(xScale, yScale, zScale);

    for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) {
        GlStateManager.rotate(random.nextFloat() * 360F, 1F, 0F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 1F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 0F, 1F);
        GlStateManager.rotate(random.nextFloat() * 360F, 1F, 0F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 1F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F);
        buff.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        float f3 = random.nextFloat() * 20F + 5F + f2 * 10F;
        float f4 = random.nextFloat() * 2F + 1F + f2 * 2F;
        int r = (color & 0xFF0000) >> 16;
        int g = (color & 0xFF00) >> 8;
        int b = color & 0xFF;
        buff.pos(0, 0, 0).color(r, g, b, 255F * (1F - f2)).endVertex();
        buff.pos(-0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        buff.pos(0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        buff.pos(0, f3, 1F * f4).color(0, 0, 0, 0).endVertex();
        buff.pos(-0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        tessellator.draw();
    }

    GlStateManager.depthMask(true);
    GlStateManager.disableCull();
    GlStateManager.disableBlend();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    GlStateManager.popMatrix();
}

From source file:vazkii.psi.client.core.helper.PsiRenderHelper.java

public static void renderProgressPie(int x, int y, float progress, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GlStateManager.colorMask(false, false, false, false);
    GlStateManager.depthMask(false);/*from w  ww . ja  v a  2 s. co  m*/
    GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
    GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
    GL11.glStencilMask(0xFF);
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    int r = 10;
    int centerX = x + 8;
    int centerY = y + 8;
    int degs = (int) (360 * progress);
    float a = 0.5F + 0.2F
            * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10)
                    * 0.5F + 0.5F);

    GlStateManager.disableLighting();
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.depthMask(true);
    GL11.glStencilMask(0x00);
    GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GlStateManager.color(0F, 0.5F, 0.5F, a);
    GL11.glVertex2i(centerX, centerY);
    GlStateManager.color(0F, 1F, 0.5F, a);
    for (int i = degs; i > 0; i--) {
        double rad = (i - 90) / 180F * Math.PI;
        GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r);
    }
    GL11.glVertex2i(centerX, centerY);
    GL11.glEnd();
    GlStateManager.disableBlend();
    GlStateManager.enableTexture2D();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_STENCIL_TEST);
}

From source file:vazkii.psi.client.core.helper.RenderHelper.java

License:Open Source License

public static void renderStar(int color, float xScale, float yScale, float zScale, long seed) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer buff = tessellator.getBuffer();

    int ticks = ClientTickHandler.ticksInGame % 200;
    if (ticks >= 100)
        ticks = 200 - ticks - 1;/*from   ww  w. ja  va  2s .c  om*/

    float f1 = ticks / 200F;
    float f2 = 0F;
    if (f1 > 0.7F)
        f2 = (f1 - 0.7F) / 0.2F;
    Random random = new Random(seed);

    GlStateManager.pushMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(770, 1);
    GlStateManager.disableAlpha();
    GlStateManager.enableCull();
    GlStateManager.depthMask(false);
    GlStateManager.scale(xScale, yScale, zScale);

    for (int i = 0; i < (f1 + f1 * f1) / 2F * 90F + 30F; i++) {
        GlStateManager.rotate(random.nextFloat() * 360F, 1F, 0F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 1F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 0F, 1F);
        GlStateManager.rotate(random.nextFloat() * 360F, 1F, 0F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F, 0F, 1F, 0F);
        GlStateManager.rotate(random.nextFloat() * 360F + f1 * 90F, 0F, 0F, 1F);
        buff.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
        float f3 = random.nextFloat() * 20F + 5F + f2 * 10F;
        float f4 = random.nextFloat() * 2F + 1F + f2 * 2F;
        int r = (color & 0xFF0000) >> 16;
        int g = (color & 0xFF00) >> 8;
        int b = color & 0xFF;
        buff.pos(0, 0, 0).color(r, g, b, 255F * (1F - f2)).endVertex();
        buff.pos(-0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        buff.pos(0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        buff.pos(0, f3, 1F * f4).color(0, 0, 0, 0).endVertex();
        buff.pos(-0.866D * f4, f3, -0.5F * f4).color(0, 0, 0, 0).endVertex();
        tessellator.draw();
    }

    GlStateManager.depthMask(true);
    GlStateManager.disableCull();
    GlStateManager.disableBlend();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.color(1F, 1F, 1F, 1F);
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    GlStateManager.popMatrix();
}

From source file:vazkii.psi.client.gui.GuiSocketSelect.java

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

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

    int x = width / 2;
    int y = height / 2;
    int maxRadius = 80;

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

    int highlight = 5;

    GlStateManager.enableBlend();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    int segments = slots.size();
    float totalDeg = 0;
    float degPer = 360F / segments;

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

    ItemStack cadStack = PsiAPI.getPlayerCAD(Minecraft.getMinecraft().thePlayer);
    slotSelected = -1;

    for (int seg = 0; seg < segments; seg++) {
        boolean mouseInSector = mouseIn && angle > totalDeg && angle < totalDeg + degPer;
        float radius = Math.max(0F, Math.min((timeIn + partialTicks - seg * 6F / segments) * 40F, maxRadius));

        GL11.glBegin(GL11.GL_TRIANGLE_FAN);

        float gs = 0.25F;
        if (seg % 2 == 0)
            gs += 0.1F;
        float r = gs;
        float g = gs;
        float b = gs;
        float a = 0.4F;
        if (mouseInSector) {
            slotSelected = seg;

            if (cadStack != null) {
                ICAD cad = (ICAD) cadStack.getItem();
                Color color = new Color(cad.getSpellColor(cadStack));
                r = color.getRed() / 255F;
                g = color.getGreen() / 255F;
                b = color.getBlue() / 255F;
            }
        }

        GlStateManager.color(r, g, b, a);
        GL11.glVertex2i(x, y);

        for (float i = degPer; i >= 0; i--) {
            float rad = (float) ((i + totalDeg) / 180F * Math.PI);
            double xp = x + Math.cos(rad) * radius;
            double yp = y + Math.sin(rad) * radius;
            if (i == (int) (degPer / 2))
                stringPositions.add(new int[] { seg, (int) xp, (int) yp, mouseInSector ? 'n' : 'r' });

            GL11.glVertex2d(xp, yp);
        }
        totalDeg += degPer;

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

        if (mouseInSector)
            radius -= highlight;
    }
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GlStateManager.enableTexture2D();

    for (int[] pos : stringPositions) {
        int slot = slots.get(pos[0]);
        int xp = pos[1];
        int yp = pos[2];
        char c = (char) pos[3];

        ItemStack stack = socketable.getBulletInSocket(socketableStack, slot);
        if (stack != null) {
            int xsp = xp - 4;
            int ysp = yp;
            String name = "\u00a7" + c + stack.getDisplayName();
            int width = fontRendererObj.getStringWidth(name);

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

            mc.getRenderItem().renderItemIntoGUI(stack, xdp - 8, ydp - 8);

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

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

            mod = 0.8;
            xdp = (int) ((xp - x) * mod + x);
            ydp = (int) ((yp - y) * mod + y);

            mc.renderEngine.bindTexture(signs[slot]);
            drawModalRectWithCustomSizedTexture(xdp - 8, ydp - 8, 0, 0, 16, 16, 16, 16);
        }
    }

    float stime = 5F;
    float fract = Math.min(stime, timeIn + partialTicks) / stime;
    float s = 3F * fract;
    GlStateManager.enableRescaleNormal();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    RenderHelper.enableGUIStandardItemLighting();

    if (controlledStacks != null && controlledStacks.length > 0) {
        int xs = width / 2 - 18 * controlledStacks.length / 2;
        int ys = height / 2;

        for (int i = 0; i < controlledStacks.length; i++) {
            float yoff = 25F + maxRadius;
            if (i == controlSlot)
                yoff += 5F;

            GlStateManager.translate(0, -yoff * fract, 0F);
            mc.getRenderItem().renderItemAndEffectIntoGUI(controlledStacks[i], xs + i * 18, ys);
            GlStateManager.translate(0, yoff * fract, 0F);
        }

    }

    if (socketableStack != null) {
        GlStateManager.scale(s, s, s);
        GlStateManager.translate(x / s - 8, y / s - 8, 0);
        mc.getRenderItem().renderItemAndEffectIntoGUI(socketableStack, 0, 0);
    }
    RenderHelper.disableStandardItemLighting();
    GlStateManager.disableBlend();
    GlStateManager.disableRescaleNormal();

    GlStateManager.popMatrix();
}