Example usage for org.lwjgl.opengl GL11 glPopAttrib

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

Introduction

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

Prototype

public static native void glPopAttrib();

Source Link

Document

Resets the values of those state variables that were saved with the last #glPushAttrib PushAttrib .

Usage

From source file:vazkii.botania.client.core.handler.BlockHighlightRenderHandler.java

License:Open Source License

@SubscribeEvent
public static void onWorldRenderLast(RenderWorldLastEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    RayTraceResult pos = mc.objectMouseOver;

    GlStateManager.pushMatrix();//from  w  w  w.j  a  v a 2s .  c  om
    GlStateManager.disableTexture2D();
    GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
    GlStateManager.disableLighting();
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    boundTile: {
        if (Botania.proxy.isClientPlayerWearingMonocle() && pos != null && pos.entityHit == null) {
            BlockPos bPos = pos.getBlockPos();

            ItemStack stackHeld = PlayerHelper.getFirstHeldItem(mc.thePlayer, ModItems.twigWand);
            if (stackHeld != null && ItemTwigWand.getBindMode(stackHeld)) {
                BlockPos coords = ItemTwigWand.getBoundTile(stackHeld);
                if (coords.getY() != -1)
                    bPos = coords;
            }

            TileEntity tile = mc.theWorld.getTileEntity(bPos);
            if (tile == null || !(tile instanceof ISubTileContainer))
                break boundTile;
            ISubTileContainer container = (ISubTileContainer) tile;
            SubTileEntity subtile = container.getSubTile();
            if (subtile == null)
                break boundTile;
            RadiusDescriptor descriptor = subtile.getRadius();
            if (descriptor == null)
                break boundTile;

            if (descriptor.isCircle())
                renderCircle(descriptor.getSubtileCoords(), descriptor.getCircleRadius());
            else
                renderRectangle(descriptor.getAABB(), true, null, (byte) 32);
        }
    }

    double offY = -1.0 / 16 + 0.005;
    for (Entity e : mc.theWorld.loadedEntityList)
        if (e instanceof EntityMagicLandmine) {
            BlockPos bpos = e.getPosition();
            AxisAlignedBB aabb = new AxisAlignedBB(bpos).offset(0, offY, 0).expand(2.5, 0, 2.5);

            float gs = (float) (Math.sin(ClientTickHandler.total / 20) + 1) * 0.2F + 0.6F;
            int r = (int) (105 * gs);
            int g = (int) (25 * gs);
            int b = (int) (145 * gs);
            Color color = new Color(r, g, b);

            int alpha = 32;
            if (e.ticksExisted < 8)
                alpha *= Math.min((e.ticksExisted + event.getPartialTicks()) / 8F, 1F);
            else if (e.ticksExisted > 47)
                alpha *= Math.min(1F - (e.ticksExisted - 47 + event.getPartialTicks()) / 8F, 1F);

            renderRectangle(aabb, false, color, (byte) alpha);
            offY += 0.001;
        }

    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
    GL11.glPopAttrib();
    GlStateManager.popMatrix();
}

From source file:vazkii.botania.client.core.handler.BoundTileRenderer.java

License:Open Source License

@SubscribeEvent
public static void onWorldRenderLast(RenderWorldLastEvent event) {
    GlStateManager.pushMatrix();//  w  ww  .  ja v a2s  . com
    GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
    GlStateManager.disableDepth();
    GlStateManager.disableTexture2D();
    GlStateManager.enableBlend();

    EntityPlayer player = Minecraft.getMinecraft().thePlayer;
    int color = Color.HSBtoRGB(ClientTickHandler.ticksInGame % 200 / 200F, 0.6F, 1F);

    if (player.getHeldItemMainhand() != null
            && player.getHeldItemMainhand().getItem() instanceof ICoordBoundItem) {
        BlockPos coords = ((ICoordBoundItem) player.getHeldItemMainhand().getItem())
                .getBinding(player.getHeldItemMainhand());
        if (coords != null)
            renderBlockOutlineAt(coords, color);
    }

    if (player.getHeldItemOffhand() != null
            && player.getHeldItemOffhand().getItem() instanceof ICoordBoundItem) {
        BlockPos coords = ((ICoordBoundItem) player.getHeldItemOffhand().getItem())
                .getBinding(player.getHeldItemOffhand());
        if (coords != null)
            renderBlockOutlineAt(coords, color);
    }

    IItemHandlerModifiable mainInv = (IItemHandlerModifiable) player
            .getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
    IItemHandlerModifiable baublesInv = BotaniaAPI.internalHandler.getBaublesInventoryWrapped(player);
    IItemHandler joined = baublesInv != null ? new CombinedInvWrapper(mainInv, baublesInv) : mainInv;

    for (int i = 0; i < joined.getSlots(); i++) {
        ItemStack stackInSlot = joined.getStackInSlot(i);

        if (stackInSlot != null && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) {
            IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot
                    .getItem();
            List<BlockPos> coordsList = provider.getWireframesToDraw(player, stackInSlot);
            if (coordsList != null)
                for (BlockPos coords : coordsList)
                    renderBlockOutlineAt(coords, color);

            BlockPos coords = provider.getSourceWireframe(player, stackInSlot);
            if (coords != null && coords.getY() > -1)
                renderBlockOutlineAt(coords, color, 5F);
        }
    }

    GlStateManager.enableDepth();
    GlStateManager.enableTexture2D();
    GlStateManager.disableBlend();
    GL11.glPopAttrib();
    GlStateManager.popMatrix();
}

From source file:vazkii.botania.client.core.handler.MultiblockRenderHandler.java

License:Open Source License

private static void renderPlayerLook(EntityPlayer player, RayTraceResult src) {
    if (currentMultiblock != null && dimension == player.worldObj.provider.getDimension()) {
        BlockPos anchorPos = anchor != null ? anchor : src.getBlockPos();

        GlStateManager.pushMatrix();/*from   w  ww  .  j a  v  a2s.c  o  m*/
        GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
        GlStateManager.enableBlend();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.disableLighting();
        rendering = true;
        Multiblock mb = anchor != null ? currentMultiblock.getForFacing(angle)
                : currentMultiblock.getForEntity(player);
        boolean didAny = false;

        blockAccess.update(player.worldObj, mb, anchorPos);

        ShaderHelper.useShader(ShaderHelper.alpha, shader -> {
            int alpha = ARBShaderObjects.glGetUniformLocationARB(shader, "alpha");
            ARBShaderObjects.glUniform1fARB(alpha, 0.4F);
        });

        for (MultiblockComponent comp : mb.getComponents()) {
            if (renderComponentInWorld(player.worldObj, mb, comp, anchorPos))
                didAny = true;
        }

        ShaderHelper.releaseShader();

        rendering = false;
        GL11.glPopAttrib();
        GlStateManager.popMatrix();

        if (!didAny) {
            setMultiblock(null);
            player.addChatComponentMessage(new TextComponentTranslation("botaniamisc.structureComplete")
                    .setStyle(new Style().setColor(TextFormatting.GREEN)));
        }
    }
}

From source file:vazkii.botania.client.core.handler.RedStringRenderer.java

License:Open Source License

public static void renderAll() {
    if (!redStringTiles.isEmpty()) {
        GlStateManager.pushMatrix();//from w  w  w . ja  va  2  s . com
        GlStateManager.disableTexture2D();
        GlStateManager.enableBlend();
        GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
        GlStateManager.disableLighting();
        GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GlStateManager.color(1F, 0F, 0F, sizeAlpha);

        TileRedString tile;
        while ((tile = redStringTiles.poll()) != null)
            renderTile(tile);

        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
        GL11.glPopAttrib();
        GlStateManager.popMatrix();

    }
}

From source file:vazkii.botania.client.core.handler.TooltipAdditionDisplayHandler.java

License:Open Source License

private static void drawTerraPick(ItemStack stack, int mouseX, int mouseY, int width, int height,
        FontRenderer font) {//from w  w w . j  a  v  a  2 s  .co  m
    int level = ItemTerraPick.getLevel(stack);
    int max = ItemTerraPick.LEVELS[Math.min(ItemTerraPick.LEVELS.length - 1, level + 1)];
    boolean ss = level >= ItemTerraPick.LEVELS.length - 1;
    int curr = ItemTerraPick.getMana_(stack);
    float percent = level == 0 ? 0F : (float) curr / (float) max;
    int rainbowWidth = Math.min(width - (ss ? 0 : 1), (int) (width * percent));
    float huePer = width == 0 ? 0F : 1F / width;
    float hueOff = (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) * 0.01F;

    GlStateManager.disableDepth();
    Gui.drawRect(mouseX - 1, mouseY - height - 1, mouseX + width + 1, mouseY, 0xFF000000);
    for (int i = 0; i < rainbowWidth; i++)
        Gui.drawRect(mouseX + i, mouseY - height, mouseX + i + 1, mouseY,
                Color.HSBtoRGB(hueOff + huePer * i, 1F, 1F));
    Gui.drawRect(mouseX + rainbowWidth, mouseY - height, mouseX + width, mouseY, 0xFF555555);

    String rank = I18n.format("botania.rank" + level).replaceAll("&", "\u00a7");

    GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
    GlStateManager.disableLighting();
    font.drawStringWithShadow(rank, mouseX, mouseY - 12, 0xFFFFFF);
    if (!ss) {
        rank = I18n.format("botania.rank" + (level + 1)).replaceAll("&", "\u00a7");
        font.drawStringWithShadow(rank, mouseX + width - font.getStringWidth(rank), mouseY - 12, 0xFFFFFF);
    }
    GlStateManager.enableLighting();
    GlStateManager.enableDepth();
    GL11.glPopAttrib();
}

From source file:vazkii.botania.client.fx.ParticleRenderDispatcher.java

License:Creative Commons License

public static void dispatch() {
    Tessellator tessellator = Tessellator.getInstance();

    Profiler profiler = Minecraft.getMinecraft().mcProfiler;

    GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
    GlStateManager.depthMask(false);// w  ww .  ja  va  2 s . c  om
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GlStateManager.alphaFunc(GL11.GL_GREATER, 0.003921569F);
    GlStateManager.disableLighting();

    profiler.startSection("sparkle");
    FXSparkle.dispatchQueuedRenders(tessellator);
    profiler.endStartSection("wisp");
    FXWisp.dispatchQueuedRenders(tessellator);
    profiler.endSection();

    GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1F);
    GlStateManager.disableBlend();
    GlStateManager.depthMask(true);
    GL11.glPopAttrib();
}

From source file:vazkii.botania.client.model.ModelHourglass.java

License:Open Source License

public void render(float fract1, float fract2, boolean flip, int color) {
    if (flip) {//from  w  w  w.  j  av a 2  s  . c om
        float fract3 = fract1;
        fract1 = fract2;
        fract2 = fract3;
    }

    float f = 1F / 16F;
    ring.render(f);
    base1.render(f);
    base2.render(f);
    Color c = new Color(color);
    GL11.glColor3ub((byte) c.getRed(), (byte) c.getGreen(), (byte) c.getBlue());

    GL11.glPushAttrib(GL11.GL_TRANSFORM_BIT);
    GlStateManager.disableRescaleNormal();
    GlStateManager.enableNormalize();

    if (fract1 > 0) {
        GlStateManager.pushMatrix();
        if (flip)
            GlStateManager.translate(-2.5F * f, 1.0F * f, -2.5F * f);
        else {
            GlStateManager.rotate(180F, 0F, 0F, 1F);
            GlStateManager.translate(-2.5F * f, -6.0F * f, -2.5F * f);
        }

        GlStateManager.scale(1F, fract1, 1F);
        sand1.render(f);
        GlStateManager.popMatrix();
    }

    if (fract2 > 0) {
        GlStateManager.pushMatrix();
        if (flip)
            GlStateManager.translate(-2.5F * f, -6.0F * f, -2.5F * f);
        else {
            GlStateManager.rotate(180F, 0F, 0F, 1F);
            GlStateManager.translate(-2.5F * f, 1.0F * f, -2.5F * f);
        }

        GlStateManager.scale(1F, fract2, 1F);

        sand2.render(f);
        GlStateManager.popMatrix();
    }

    GL11.glPopAttrib();

    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    glass1.render(f);
    glass2.render(f);
}

From source file:zeldaswordskills.client.gui.GuiBuffBar.java

License:Open Source License

@SubscribeEvent
public void onRenderExperienceBar(RenderGameOverlayEvent.Post event) {
    if (!shouldDisplay || event.type != ElementType.EXPERIENCE) {
        return;//from www  .  ja  va 2 s  .  c  om
    }

    int xPos = Config.isBuffBarLeft() ? 2 : event.resolution.getScaledWidth() - (ICON_SPACING + 2);
    int yPos = 2;
    int offset = 0;
    int increment = Config.isBuffBarHorizontal() && !Config.isBuffBarLeft() ? -ICON_SPACING : ICON_SPACING;
    Collection<BuffBase> collection = ZSSEntityInfo.get(mc.thePlayer).getActiveBuffsMap().values();
    if (!collection.isEmpty()) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_LIGHTING);
        // alpha test and blend needed due to vanilla or Forge rendering bug
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_BLEND);
        mc.getTextureManager().bindTexture(textures);
        for (Iterator<BuffBase> iterator = ZSSEntityInfo.get(mc.thePlayer).getActiveBuffsMap().values()
                .iterator(); iterator.hasNext(); offset = increment) {
            BuffBase buff = iterator.next();
            int index = buff.getIconIndex();
            xPos += (Config.isBuffBarHorizontal() ? offset : 0);
            yPos += (Config.isBuffBarHorizontal() ? 0 : offset);
            drawTexturedModalRect(xPos, yPos, index % ICONS_PER_ROW * ICON_SIZE,
                    index / ICONS_PER_ROW * ICON_SIZE, ICON_SIZE, ICON_SIZE);
            if (buff.displayArrow()) {
                drawTexturedModalRect(xPos, yPos, buff.isDebuff() ? ICON_SIZE : 0, 0, ICON_SIZE, ICON_SIZE);
            }
        }
        GL11.glPopAttrib();
    }
}

From source file:zeldaswordskills.client.gui.GuiMusicBase.java

License:Open Source License

@Override
public void drawScreen(int mouseX, int mouseY, float f) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.getTextureManager().bindTexture(getTexture());
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glDisable(GL11.GL_LIGHTING);//  w  w  w  . j  ava 2s .c  o m
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    RenderHelperQ.drawTexturedRect(guiLeft, guiTop, 0, 0, xSize, ySize, fullX, fullY);
    GL11.glPopAttrib();
    int i1 = (melody.size() > MAX_NOTES ? ((melody.size() - 1) / MAX_NOTES) * MAX_NOTES : 0);
    for (int i = 0; (i + i1) < melody.size(); ++i) {
        SongNote note = melody.get(i + i1);
        // j is factor of how far down the screen note should be drawn
        int j = SongNote.Note.values().length - (note.note.ordinal() + 1)
                + (SongNote.Note.values().length * (2 - note.getOctave()));
        int dy = 6 + (INT_Y * j);
        int dx = 46 + (NOTE_SIZE + 8) * i;
        // draw supplementary line(s) under staff and behind note
        if (j > 10) { // j goes from 0-13, not 1-14
            int dy2 = (10 + INT_Y * 11);
            // given the control scheme, this loop is not really necessary as it's not possible to reach the low A note
            for (int n = 0; n < ((j - 9) / 2); ++n) {
                // each line segment is 16x5 pixels, using first line in .png file at 8,15
                RenderHelperQ.drawTexturedRect(guiLeft + (dx - 2), guiTop + dy2 + (n * 2 * INT_Y), 8, 15, 16, 5,
                        fullX, fullY);
            }
        }
        RenderHelperQ.drawTexturedRect(guiLeft + dx, guiTop + dy, xSize,
                PlayableNote.getOrdinalFromNote(note) * NOTE_SIZE, NOTE_SIZE, NOTE_SIZE, fullX, fullY);
        // draw additional sharp / flat if applicable
        if (note.isSharp() || note.isFlat()) {
            RenderHelperQ.drawTexturedRect(guiLeft + dx + NOTE_SIZE - 2, guiTop + dy, xSize + NOTE_SIZE,
                    (note.isSharp() ? 0 : 5), 5, 5, fullX, fullY);
        }
    }
    if (song != null) {
        String s = song.getDisplayName();
        fontRendererObj.drawString(s, guiLeft + (xSize / 2) - (fontRendererObj.getStringWidth(s) / 2),
                guiTop + 3, 0xFFFFFF);
    }
    super.drawScreen(mouseX, mouseY, f);
}

From source file:zeldaswordskills.client.gui.GuiSkills.java

License:Open Source License

@Override
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
    if (needsScrollBar()) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glEnable(GL11.GL_BLEND);/*from w  w  w.  j av  a2 s  . c o m*/
        mc.renderEngine.bindTexture(texture);
        RenderHelperQ.drawTexturedRect(259, 55, 282, 0, 3, 5, 285, 180);
        RenderHelperQ.drawTexturedRect(259, 150, 282, 5, 3, 5, 285, 180);
        RenderHelperQ.drawTexturedRect(260, 61, 283, 17, 1, 88, 285, 180);
        RenderHelperQ.drawTexturedRect(259, 61 + (int) (scrollY * 81), 282, 10, 3, 7, 285, 180);
        GL11.glPopAttrib();
    }
    String s = (currentSkill != null ? currentSkill.getDisplayName().toUpperCase()
            : StatCollector.translateToLocal("skill.zss.gui.description"));
    isUnicode = fontRendererObj.getUnicodeFlag();
    fontRendererObj.setUnicodeFlag(true);
    fontRendererObj.drawString(s, 158, 38, 4210752);
    if (currentSkill != null) {
        s = currentSkill.getLevelDisplay(false);
        fontRendererObj.drawString(s, 262 - fontRendererObj.getStringWidth(s), 38, 4210752);
    }
    refreshDescription();
    textY = 38 + (fontRendererObj.FONT_HEIGHT * 2);
    int start = (needsScrollBar() ? (int) (scrollY * (numLines - MAX_LINES)) : 0);
    for (int i = start; i < desc.size() && i < (MAX_LINES + start); ++i) {
        fontRendererObj.drawString(desc.get(i), 158, textY, 4210752);
        textY += fontRendererObj.FONT_HEIGHT;
    }
    fontRendererObj.setUnicodeFlag(isUnicode);
}