Example usage for org.lwjgl.opengl GL11 glPushAttrib

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

Introduction

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

Prototype

public static native void glPushAttrib(@NativeType("GLbitfield") int mask);

Source Link

Document

Takes a bitwise OR of symbolic constants indicating which groups of state variables to push onto the server attribute stack.

Usage

From source file:hellfirepvp.astralsorcery.client.render.tile.TESRTranslucentBlock.java

License:Open Source License

public static void renderTranslucentBlocks() {
    TextureHelper.refreshTextureBindState();
    TextureHelper.setActiveTextureToAtlasSprite();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/* w  w w  . j ava 2  s. c om*/
    RenderingUtils.removeStandartTranslationFromTESRMatrix(Minecraft.getMinecraft().getRenderPartialTicks());
    GlStateManager.color(1F, 1F, 1F, 1F);

    if (batchDList == -1) {
        batchBlocks();
        hash = hashBlocks();
        blocks.clear();
    } else {
        int currentHash = hashBlocks();
        if (hash != currentHash) {
            GLAllocation.deleteDisplayLists(batchDList);
            batchBlocks();
            hash = currentHash;
            blocks.clear();
        }
    }
    GL11.glEnable(GL11.GL_BLEND);
    Blending.ADDITIVEDARK.apply();
    GL11.glCallList(batchDList);
    blocks.clear();
    Blending.DEFAULT.apply();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.render.tile.TESRWell.java

License:Open Source License

@Override
public void renderTileEntityAt(TileWell te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    ItemStack catalyst = te.getInventoryHandler().getStackInSlot(0);
    if (!catalyst.isEmpty()) {
        EntityItem ei = new EntityItem(Minecraft.getMinecraft().world, 0, 0, 0, catalyst);
        ei.age = te.getTicksExisted();/*from  w w w.j  a v a 2s  .com*/
        ei.hoverStart = 0;
        Minecraft.getMinecraft().getRenderManager().doRenderEntity(ei, x + 0.5, y + 0.8, z + 0.5, 0,
                partialTicks, true);
    }
    if (te.getFluidAmount() > 0 && te.getHeldFluid() != null) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glEnable(GL11.GL_BLEND);
        Blending.DEFAULT.apply();
        GL11.glColor4f(1F, 1F, 1F, 1F);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        RenderHelper.disableStandardItemLighting();
        Vector3 offset = new Vector3(te).add(0.5D, 0.32D, 0.5D);
        offset.addY(te.getPercFilled() * 0.6);
        ResourceLocation still = te.getHeldFluid().getStill(te.getWorld(), te.getPos());
        TextureAtlasSprite tas = Minecraft.getMinecraft().getTextureMapBlocks()
                .getTextureExtry(still.toString());
        if (tas == null)
            Minecraft.getMinecraft().getTextureMapBlocks().getMissingSprite();

        TextureHelper.setActiveTextureToAtlasSprite();
        RenderingUtils.renderAngleRotatedTexturedRect(offset, Vector3.RotAxis.Y_AXIS.clone(),
                Math.toRadians(45), 0.54, tas.getMinU(), tas.getMinV(), tas.getMaxU() - tas.getMinU(),
                tas.getMaxV() - tas.getMinV(), partialTicks);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopAttrib();
        TextureHelper.refreshTextureBindState();
    }
}

From source file:hellfirepvp.astralsorcery.client.sky.RenderDefaultSkybox.java

License:Open Source License

@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();//from  w w w.j  ava2s  .c o  m
    renderDefaultSkybox(partialTicks);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.util.BlockArrayRenderHelper.java

License:Open Source License

public void render3DGUI(double x, double y, float pTicks) {
    GuiScreen scr = Minecraft.getMinecraft().currentScreen;
    if (scr == null)
        return;//w  w  w .  j  a  va  2s.  c  o m

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();
    Minecraft mc = Minecraft.getMinecraft();
    double sc = new ScaledResolution(mc).getScaleFactor();
    GL11.glTranslated(x + 16D / sc, y + 16D / sc, 512);

    double mul = 10.5;

    double size = 2;
    double minSize = 0.5;

    Vec3i max = blocks.getMax();
    Vec3i min = blocks.getMin();

    double maxLength = 0;
    double pointDst = max.getX() - min.getX();
    if (pointDst > maxLength)
        maxLength = pointDst;
    pointDst = max.getY() - min.getY();
    if (pointDst > maxLength)
        maxLength = pointDst;
    pointDst = max.getZ() - min.getZ();
    if (pointDst > maxLength)
        maxLength = pointDst;
    maxLength -= 5;

    if (maxLength > 0) {
        size = (size - minSize) * (1D - (maxLength / 20D));
    }

    double dr = -5.75 * size;
    GL11.glTranslated(dr, dr, dr);
    GL11.glRotated(rotX, 1, 0, 0);
    GL11.glRotated(rotY, 0, 1, 0);
    GL11.glRotated(rotZ, 0, 0, 1);
    GL11.glTranslated(-dr, -dr, -dr);

    GL11.glScaled(-size * mul, -size * mul, -size * mul);

    BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
    VertexFormat blockFormat = DefaultVertexFormats.BLOCK;

    TextureHelper.setActiveTextureToAtlasSprite();
    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    vb.begin(GL11.GL_QUADS, blockFormat);
    for (Map.Entry<BlockPos, BakedBlockData> data : renderAccess.blockRenderData.entrySet()) {
        BlockPos offset = data.getKey();
        BakedBlockData renderData = data.getValue();
        if (renderData.type != Blocks.AIR) {
            brd.renderBlock(renderData.state, offset, renderAccess, vb);
        }
    }
    tes.draw();

    for (Map.Entry<BlockPos, BakedBlockData> data : renderAccess.blockRenderData.entrySet()) {
        BlockPos offset = data.getKey();
        BakedBlockData renderData = data.getValue();
        if (renderData.tileEntity != null && renderData.tesr != null) {
            renderData.tileEntity.setWorld(Minecraft.getMinecraft().world);
            renderData.tesr.renderTileEntityAt(renderData.tileEntity, offset.getX(), offset.getY(),
                    offset.getZ(), pTicks, 0);
        }
    }

    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.util.item.AstralTEISR.java

License:Open Source License

@Override
public void renderByItem(ItemStack itemStackIn) {
    if (ItemRenderRegistry.shouldHandleItemRendering(itemStackIn)) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        ItemRenderRegistry.renderItemStack(itemStackIn);
        GL11.glPopAttrib();/*from   ww  w . j a  va2s . c o  m*/
        return;
    }

    parent.renderByItem(itemStackIn);
}

From source file:hellfirepvp.astralsorcery.client.util.RenderConstellation.java

License:Open Source License

public static void renderConstellationIntoWorldFlat(IConstellation c, Color rC, Vector3 offsetPos, double scale,
        double lineBreadth, float br) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/*w  w  w. j  a v a2  s .c om*/
    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    double s = 1D / 31D * scale;

    GL11.glTranslated(-15.5D * s, 0, -15.5D * s);

    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    Blending.DEFAULT.apply();

    float fRed = ((float) rC.getRed()) / 255F;
    float fGreen = ((float) rC.getGreen()) / 255F;
    float fBlue = ((float) rC.getBlue()) / 255F;

    RenderAstralSkybox.TEX_CONNECTION.bind();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
    for (StarConnection sc : c.getStarConnections()) {
        float brightness = br;
        brightness *= 0.8;
        float fAlpha = brightness < 0 ? 0 : brightness;

        Vector3 offset = offsetPos.clone().addX(sc.from.x * s).addZ(sc.from.y * s);
        Vector3 dirU = new Vector3(sc.to.x, 0, sc.to.y).subtract(sc.from.x, 0, sc.from.y).multiply(s);
        Vector3 dirV = dirU.clone().crossProduct(new Vector3(0, 1, 0)).setY(0).normalize()
                .multiply(lineBreadth * s);
        Vector3 offsetRender = offset.subtract(dirV.clone().divide(2));

        Vector3 pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();

    }
    tes.draw();

    RenderAstralSkybox.TEX_STAR_1.bind();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
    for (StarLocation sl : c.getStars()) {
        float fAlpha = br < 0 ? 0 : br;

        Vector3 offsetRender = offsetPos.clone().add(sl.x * s - s, 0.005, sl.y * s - s);
        Vector3 dirU = new Vector3(s * 2, 0, 0);
        Vector3 dirV = new Vector3(0, 0, s * 2);

        Vector3 pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(1));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 0).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(1)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(0, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();
        pos = offsetRender.clone().add(dirU.clone().multiply(0)).add(dirV.clone().multiply(0));
        vb.pos(pos.getX(), pos.getY(), pos.getZ()).tex(1, 1).color(fRed, fGreen, fBlue, fAlpha).endVertex();
    }
    tes.draw();

    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.util.RenderingUtils.java

License:Open Source License

public static void renderStackTooltip(int x, int y, List<Tuple<ItemStack, String>> tooltipData, Color color,
        Color colorFade, Color strColor, FontRenderer fr, RenderItem ri) {
    TextureHelper.setActiveTextureToAtlasSprite();

    if (!tooltipData.isEmpty()) {
        int esWidth = 0;
        for (Tuple<ItemStack, String> toolTip : tooltipData) {
            int width = fr.getStringWidth(toolTip.value) + 17;
            if (width > esWidth)
                esWidth = width;/* w  ww.  ja  v  a 2s  . co  m*/
        }
        ScaledResolution sr = new ScaledResolution(Minecraft.getMinecraft());
        if (x + 15 + esWidth > sr.getScaledWidth()) {
            x -= esWidth + 24;
        }
        int pX = x + 12;
        int pY = y - 12;
        int sumLineHeight = 8;
        if (tooltipData.size() > 1)
            sumLineHeight += 2 + (tooltipData.size() - 1) * 17;
        float z = 300F;

        GL11.glDisable(GL11.GL_DEPTH_TEST);
        drawGradientRect(pX - 3, pY - 4, z, pX + esWidth + 3, pY - 3, color, colorFade);
        drawGradientRect(pX - 3, pY + sumLineHeight + 3, z, pX + esWidth + 3, pY + sumLineHeight + 4, color,
                colorFade);
        drawGradientRect(pX - 3, pY - 3, z, pX + esWidth + 3, pY + sumLineHeight + 3, color, colorFade);
        drawGradientRect(pX - 4, pY - 3, z, pX - 3, pY + sumLineHeight + 3, color, colorFade);
        drawGradientRect(pX + esWidth + 3, pY - 3, z, pX + esWidth + 4, pY + sumLineHeight + 3, color,
                colorFade);

        int rgb = color.getRGB();
        int col = (rgb & 0x00FFFFFF) | rgb & 0xFF000000;
        Color colOp = new Color(col);
        drawGradientRect(pX - 3, pY - 3 + 1, z, pX - 3 + 1, pY + sumLineHeight + 3 - 1, color, colOp);
        drawGradientRect(pX + esWidth + 2, pY - 3 + 1, z, pX + esWidth + 3, pY + sumLineHeight + 3 - 1, color,
                colOp);
        drawGradientRect(pX - 3, pY - 3, z, pX + esWidth + 3, pY - 3 + 1, colOp, colOp);
        drawGradientRect(pX - 3, pY + sumLineHeight + 2, z, pX + esWidth + 3, pY + sumLineHeight + 3, color,
                color);

        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        for (Tuple<ItemStack, String> stackDesc : tooltipData) {
            fr.drawString(stackDesc.value, pX + 17, pY, strColor.getRGB());
            GlStateManager.color(1F, 1F, 1F, 1F);
            GL11.glPushMatrix();
            RenderHelper.enableGUIStandardItemLighting();
            ri.renderItemAndEffectIntoGUI(stackDesc.key, pX - 1, pY - 5);

            GL11.glEnable(GL11.GL_BLEND);
            Blending.DEFAULT.apply();

            GL11.glPopMatrix();
            pY += 17;
        }
        GL11.glPopAttrib();
        GlStateManager.color(1F, 1F, 1F, 1F);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }

    GlStateManager.enableAlpha();
    GlStateManager.color(1F, 1F, 1F, 1F);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    TextureHelper.refreshTextureBindState();
}

From source file:hellfirepvp.astralsorcery.client.util.UIGateway.java

License:Open Source License

public void renderIntoWorld(float pticks) {
    if (Minecraft.getMinecraft().player == null)
        return;//from   w  ww.  j  a va2 s  .co  m

    double dst = new Vector3(origin).distance(new Vector3(Minecraft.getMinecraft().player));
    if (dst > 3)
        return;
    float alpha = 1F - ((float) (dst / 2D));
    alpha = MathHelper.clamp(alpha, 0F, 1F);
    Color c = new Color(0xF0BD00);
    float red = c.getRed() / 255F;
    float green = c.getGreen() / 255F;
    float blue = c.getBlue() / 255F;

    long seed = 0xA781B4F01C771923L;
    seed |= ((long) origin.getBlockX()) << 48;
    seed |= ((long) origin.getBlockY()) << 24;
    seed |= ((long) origin.getBlockZ());
    Random rand = new Random(seed);

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    Blending.DEFAULT.apply();
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glColor4f(1F, 1F, 1F, 1F);
    RenderAstralSkybox.TEX_STAR_1.bind();

    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();
    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR);
    for (int i = 0; i < 300; i++) {
        Vector3 dir = Vector3.random(rand).normalize().multiply(radius);
        float a = RenderConstellation.conCFlicker(ClientScheduler.getClientTick(), pticks, rand.nextInt(7) + 6);
        a *= alpha;
        RenderingUtils.renderFacingFullQuadVB(vb, origin.getX() + dir.getX(), origin.getY() + dir.getY(),
                origin.getZ() + dir.getZ(), pticks, 0.07F, 0, 1F, 1F, 1F, a);
    }
    for (GatewayEntry entry : gatewayEntries) {
        float a = RenderConstellation.conCFlicker(ClientScheduler.getClientTick(), pticks, rand.nextInt(7) + 6);
        a = 0.4F + (0.6F * a);
        a = (a * alpha);
        RenderingUtils.renderFacingFullQuadVB(vb, origin.getX() + entry.relativePos.getX(),
                origin.getY() + entry.relativePos.getY(), origin.getZ() + entry.relativePos.getZ(), pticks,
                0.16F, 0, red, green, blue, a);
    }
    RenderingUtils.sortVertexData(vb);
    tes.draw();
    TextureHelper.refreshTextureBindState();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.common.item.wand.ItemArchitectWand.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*from  w ww.j  a  va  2 s .c om*/
public void onRenderInHandHUD(ItemStack lastCacheInstance, float fadeAlpha, float pTicks) {
    ItemStack blockStackStored = getStoredStateAsStack(lastCacheInstance);
    if (blockStackStored.isEmpty())
        return;

    int amtFound = 0;
    if (Mods.BOTANIA.isPresent()) {
        amtFound = ModIntegrationBotania.getItemCount(Minecraft.getMinecraft().player, lastCacheInstance,
                ItemUtils.createBlockState(blockStackStored));
    } else {
        Collection<ItemStack> stacks = ItemUtils.scanInventoryForMatching(
                new InvWrapper(Minecraft.getMinecraft().player.inventory), blockStackStored, false);
        for (ItemStack stack : stacks) {
            amtFound += stack.getCount();
        }
    }

    int height = 26;
    int width = 26;
    int offsetX = 30;
    int offsetY = 15;

    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    Blending.DEFAULT.apply();
    ClientRenderEventHandler.texHUDItemFrame.bind();

    GL11.glColor4f(1F, 1F, 1F, fadeAlpha * 0.9F);
    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();

    vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
    vb.pos(offsetX, offsetY + height, 10).tex(0, 1).endVertex();
    vb.pos(offsetX + width, offsetY + height, 10).tex(1, 1).endVertex();
    vb.pos(offsetX + width, offsetY, 10).tex(1, 0).endVertex();
    vb.pos(offsetX, offsetY, 10).tex(0, 0).endVertex();
    tes.draw();

    TextureHelper.refreshTextureBindState();
    TextureHelper.setActiveTextureToAtlasSprite();

    RenderHelper.enableGUIStandardItemLighting();
    RenderItem ri = Minecraft.getMinecraft().getRenderItem();
    ri.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().player, blockStackStored, offsetX + 5, offsetY + 5);
    RenderHelper.disableStandardItemLighting();
    GlStateManager.enableAlpha(); //Because Mc item rendering..

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glTranslated(offsetX + 14, offsetY + 16, 0);
    String amtString = String.valueOf(amtFound);
    if (amtFound == -1) {
        amtString = "";
    }
    GL11.glTranslated(-Minecraft.getMinecraft().fontRenderer.getStringWidth(amtString) / 3, 0, 0);
    GL11.glScaled(0.7, 0.7, 0.7);
    if (amtString.length() > 3) {
        GL11.glScaled(0.9, 0.9, 0.9);
    }
    int c = 0x00DDDDDD;
    Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(amtString, 0, 0, c);
    GlStateManager.color(1F, 1F, 1F, 1F);
    TextureHelper.refreshTextureBindState();

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.common.item.wand.ItemArchitectWand.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//  ww w  . java  2  s  .  co m
public void onRenderWhileInHand(ItemStack stack, EnumHand hand, float pTicks) {
    IBlockState stored = getStoredState(stack);
    if (stored == null || stored.getBlock().equals(Blocks.AIR))
        return;

    Deque<BlockPos> placeable = filterBlocksToPlace(Minecraft.getMinecraft().player,
            Minecraft.getMinecraft().world, architectRange);
    if (!placeable.isEmpty()) {
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glPushMatrix();
        boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_BLEND);
        Blending.ADDITIVEDARK.apply();
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        RenderingUtils.removeStandartTranslationFromTESRMatrix(pTicks);
        World w = Minecraft.getMinecraft().world;

        Tessellator tes = Tessellator.getInstance();
        VertexBuffer vb = tes.getBuffer();
        vb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
        for (BlockPos pos : placeable) {
            Minecraft.getMinecraft().getBlockRendererDispatcher().renderBlock(stored, pos, w, vb);
        }
        vb.sortVertexData((float) TileEntityRendererDispatcher.staticPlayerX,
                (float) TileEntityRendererDispatcher.staticPlayerY,
                (float) TileEntityRendererDispatcher.staticPlayerZ);
        tes.draw();
        Blending.DEFAULT.apply();
        if (!blend) {
            GL11.glDisable(GL11.GL_BLEND);
        }
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glPopMatrix();
        GL11.glPopAttrib();
    }
}