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.TESRAttunementAltar.java

License:Open Source License

@Override
public void renderTileEntityAt(TileAttunementAltar te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/*from   w w w  .j a v a 2  s  .  c o  m*/

    GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
    GL11.glScaled(0.0625, 0.0625, 0.0625);
    GL11.glRotated(180, 1, 0, 0);

    GlStateManager.pushMatrix();
    GlStateManager.rotate(165.0F, 1.0F, 0.0F, 0.0F);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();

    texModelAttunementAltar.bind();
    modelAttunementAltar.renderBase();
    GL11.glPopMatrix();

    float startY = -1.5F;
    float endY = -0.5F;
    float tickPartY = (endY - startY) / ((float) TileAttunementAltar.MAX_START_ANIMATION_TICK);

    float prevPosY = endY + (te.prevActivationTick * tickPartY);
    float posY = endY + (te.activationTick * tickPartY);
    double framePosY = RenderingUtils.interpolate(prevPosY, posY, partialTicks);

    double generalAnimationTick = ClientScheduler.getClientTick() / 4D;
    if (te.animate) {
        if (te.tesrLocked) {
            te.tesrLocked = false;
        }
    } else {
        if (te.tesrLocked) {
            generalAnimationTick = 7.25D;
        } else {
            if (Math.abs(
                    (generalAnimationTick % TileAttunementAltar.MAX_START_ANIMATION_SPIN) - 7.25D) <= 0.3125) {
                generalAnimationTick = 7.25D;
                te.tesrLocked = true;
            }
        }
    }

    float spinDur = TileAttunementAltar.MAX_START_ANIMATION_SPIN;

    for (int i = 1; i < 9; i++) {
        float incrementer = (spinDur / 8) * i;

        double aFrame = generalAnimationTick + incrementer;
        double prevAFrame = generalAnimationTick + incrementer - 1;
        double renderFrame = RenderingUtils.interpolate(prevAFrame, aFrame, 0);

        double partRenderFrame = (renderFrame % spinDur) / spinDur;
        float normalized = (float) (partRenderFrame * 2F * Math.PI);

        float xOffset = MathHelper.cos(normalized);
        float zOffset = MathHelper.sin(normalized);

        GL11.glPushMatrix();
        GL11.glTranslated(x + 0.5, y + framePosY, z + 0.5);
        GL11.glScaled(0.0625, 0.0625, 0.0625);
        GL11.glRotated(180, 1, 0, 0);

        modelAttunementAltar.renderHovering(xOffset, zOffset,
                (float) RenderingUtils.interpolate(
                        ((float) te.prevActivationTick) / TileAttunementAltar.MAX_START_ANIMATION_TICK,
                        ((float) te.activationTick) / TileAttunementAltar.MAX_START_ANIMATION_TICK,
                        partialTicks));

        GL11.glPopMatrix();
    }

    RenderHelper.disableStandardItemLighting();

    GL11.glPopAttrib();
}

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

License:Open Source License

@Override
public void renderTileEntityAt(TileCelestialCrystals te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();//  w w  w.j a va 2s  . c  o m
    RenderHelper.disableStandardItemLighting();
    GL11.glTranslated(x + 0.5, y + 0.1, z + 0.5);
    float size = 0.2F;
    GL11.glScalef(size, size, size);

    int r = 0x59A51481;
    BlockPos at = te.getPos();
    r ^= at.getX();
    r ^= at.getY();
    r ^= at.getZ();
    r = Math.abs(r);
    r = rotMapping[r % rotMapping.length];
    GL11.glRotated(r, 0, 1, 0);

    renderCelestialCrystals(te.getGrowth());
    RenderHelper.enableStandardItemLighting();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

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

License:Open Source License

@Override
public void renderTileEntityAt(TileCollectorCrystal te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    BlockCollectorCrystalBase.CollectorCrystalType type = te.getType();
    long sBase = 1553015L;
    sBase ^= (long) te.getPos().getX();
    sBase ^= (long) te.getPos().getY();
    sBase ^= (long) te.getPos().getZ();
    Color c = type == null ? BlockCollectorCrystalBase.CollectorCrystalType.ROCK_CRYSTAL.displayColor
            : type.displayColor;// ww w.  j  ava  2s  . c om
    if (te.isEnhanced()) {
        RenderingUtils.renderLightRayEffects(x + 0.5, y + 0.5, z + 0.5, c, sBase,
                ClientScheduler.getClientTick(), 20, 1.4F, 50, 25);
        RenderingUtils.renderLightRayEffects(x + 0.5, y + 0.5, z + 0.5, Color.WHITE, sBase,
                ClientScheduler.getClientTick(), 40, 2, 15, 15);
    } else {
        RenderingUtils.renderLightRayEffects(x + 0.5, y + 0.5, z + 0.5, c, sBase,
                ClientScheduler.getClientTick(), 20, 50, 25);
    }

    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y, z + 0.5);
    renderCrystal(type == BlockCollectorCrystalBase.CollectorCrystalType.CELESTIAL_CRYSTAL, true);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

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

License:Open Source License

@Override
public void renderTileEntityAt(TileGrindstone te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GlStateManager.pushMatrix();//www. j av a 2 s.  c o m
    GlStateManager.translate(x + 0.5, y + 1.65, z + 0.5);
    GlStateManager.rotate(180, 1, 0, 0);
    GlStateManager.scale(0.067, 0.067, 0.067);

    GlStateManager.pushMatrix();
    GlStateManager.rotate(-30.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(165.0F, 1.0F, 0.0F, 0.0F);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();

    renderModel(te, 1);
    GlStateManager.popMatrix();
    GL11.glPopAttrib();

    ItemStack grind = te.getGrindingItem();
    if (!grind.isEmpty()) {
        TextureHelper.refreshTextureBindState();
        TextureHelper.setActiveTextureToAtlasSprite();
        if (grind.getItem() instanceof IGrindable) {
            IGrindable grindable = (IGrindable) grind.getItem();
            GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
            GL11.glPushMatrix();
            GL11.glTranslated(x, y, z);
            grindable.applyClientGrindstoneTransforms();
            RenderHelper.enableStandardItemLighting();
            Minecraft.getMinecraft().getRenderItem().renderItem(grind,
                    ItemCameraTransforms.TransformType.GROUND);
            RenderHelper.disableStandardItemLighting();
            GL11.glPopMatrix();
            GL11.glPopAttrib();
        }
        if (SwordSharpenHelper.isSharpenableItem(grind)) {
            GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
            GL11.glPushMatrix();
            GL11.glTranslated(x, y, z);
            IGrindable.applyDefaultGrindstoneTransforms();
            RenderHelper.enableStandardItemLighting();
            Minecraft.getMinecraft().getRenderItem().renderItem(grind,
                    ItemCameraTransforms.TransformType.GROUND);
            RenderHelper.disableStandardItemLighting();
            GL11.glPopMatrix();
            GL11.glPopAttrib();
        }
    }
}

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

License:Open Source License

@Override
public void renderTileEntityAt(TileCrystalLens te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    List<BlockPos> linked = te.getLinkedPositions();
    float yaw = 0; //Degree
    float pitch = 0; //Degree
    if (!linked.isEmpty() && linked.size() == 1) {
        BlockPos to = linked.get(0);//w  w w.j a  va 2 s . com
        BlockPos from = te.getTrPos();
        Vector3 dir = new Vector3(to).subtract(new Vector3(from));

        pitch = (float) Math.atan2(dir.getY(), Math.sqrt(dir.getX() * dir.getX() + dir.getZ() * dir.getZ()));

        yaw = (float) Math.atan2(dir.getX(), dir.getZ());

        yaw = 180F + (float) Math.toDegrees(-yaw);
        pitch = (float) Math.toDegrees(pitch);
    }
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

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

    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y + 1.335, z + 0.5);
    GL11.glScaled(0.055, 0.055, 0.055);
    GL11.glRotated(180, 1, 0, 0);
    GL11.glRotated(yaw % 360, 0, 1, 0);
    renderHandle(yaw, pitch);
    if (te.getLensColor() != null) {
        GL11.glRotated(180, 0, 1, 0);
        Color c = te.getLensColor().wrappedColor;
        GL11.glColor4f(c.getRed() / 255F, c.getGreen() / 255F, c.getBlue() / 255F, 1F);
        renderColoredLens(yaw, -pitch);
        GL11.glColor4f(1F, 1F, 1F, 1F);
    }
    TextureHelper.refreshTextureBindState();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

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

License:Open Source License

public static void renderColoredPrismsLast() {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();// w ww.j  a  v  a  2 s .c  om
    RenderingUtils.removeStandartTranslationFromTESRMatrix(Minecraft.getMinecraft().getRenderPartialTicks());

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

    for (TileCrystalPrismLens prism : coloredPositions) {
        Color c = prism.getLensColor().wrappedColor;
        GL11.glPushMatrix();
        BlockPos pos = prism.getPos();

        GL11.glTranslated(pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5);
        GL11.glScaled(0.0625, 0.0625, 0.0625);
        GL11.glRotated(180, 1, 0, 0);

        GL11.glColor4f(c.getRed() / 255F, c.getGreen() / 255F, c.getBlue() / 255F, 1F);
        renderColoredPrism();
        GL11.glColor4f(1F, 1F, 1F, 1F);

        GL11.glPopMatrix();
    }

    coloredPositions.clear();

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

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

License:Open Source License

@Override
public void renderTileEntityAt(TileCrystalPrismLens te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();//ww w  . ja  v a 2 s. c om

    if (te.getLinkedPositions().size() > 0) {
        long sBase = 0x5911539513145924L;
        sBase ^= (long) te.getPos().getX();
        sBase ^= (long) te.getPos().getY();
        sBase ^= (long) te.getPos().getZ();
        RenderingUtils.renderLightRayEffects(x + 0.5, y + 0.6, z + 0.5,
                BlockCollectorCrystal.CollectorCrystalType.ROCK_CRYSTAL.displayColor, sBase,
                ClientScheduler.getClientTick(), 9, 50, 25);
    }

    GL11.glTranslated(x + 0.5, y + 0.20, z + 0.5);

    GL11.glScaled(0.6, 0.6, 0.6);
    GL11.glEnable(GL11.GL_BLEND);
    Blending.DEFAULT.apply();
    TESRCollectorCrystal.renderCrystal(false, true);
    RenderHelper.disableStandardItemLighting();
    if (te.getLensColor() != null) {
        coloredPositions.add(te);
        /*GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
        GL11.glScaled(0.0625, 0.0625, 0.0625);
        GL11.glRotated(180, 1, 0, 0);
        GL11.glEnable(GL11.GL_BLEND);
        Blending.DEFAULT.applyServer();
        Color c = te.getLensColor().wrappedColor;
        GL11.glColor4f(c.getRed() / 255F, c.getGreen() / 255F, c.getBlue() / 255F, 1F);
        renderColoredPrism();
        GL11.glColor4f(1F, 1F, 1F, 1F);*/
    }
    TextureHelper.refreshTextureBindState();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

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

License:Open Source License

@Override
public void renderTileEntityAt(TileRitualPedestal te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    renderCrystalStack(te, x, y, z);/*from  w w w.j  av  a2s  . c  o  m*/

    if (te.shouldDoAdditionalEffects()) {
        renderEffects(te);

        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_ALPHA_TEST);

        IConstellation c = te.getDisplayConstellation();
        if (c != null) {
            float alphaDaytime = ConstellationSkyHandler.getInstance()
                    .getCurrentDaytimeDistribution(te.getWorld());
            alphaDaytime *= 0.8F;

            int max = 5000;
            int t = (int) (ClientScheduler.getClientTick() % max);
            float halfAge = max / 2F;
            float tr = 1F - (Math.abs(halfAge - t) / halfAge);
            tr *= 2;

            int tick = te.getEffectWorkTick();
            float percRunning = ((float) tick / (float) TileRitualPedestal.MAX_EFFECT_TICK);

            RenderingUtils.removeStandartTranslationFromTESRMatrix(partialTicks);

            float br = 0.6F * (alphaDaytime * percRunning);

            RenderConstellation.renderConstellationIntoWorldFlat(c, c.getRenderColor(),
                    new Vector3(te).add(0.5, 0.04, 0.5), 3 + tr, 2, 0.1F + br);
        }

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

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

License:Open Source License

private void renderCrystalStack(TileRitualPedestal te, double x, double y, double z) {
    ItemStack i = te.getInventoryHandler().getStackInSlot(0);
    if (!i.isEmpty()) {
        Item it = i.getItem();//w  w w .  ja v a 2s.  c om
        if (it instanceof ItemTunedCrystalBase) {
            GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
            GL11.glPushMatrix();
            boolean celestial = it instanceof ItemTunedCelestialCrystal;
            Color c = celestial ? BlockCollectorCrystalBase.CollectorCrystalType.CELESTIAL_CRYSTAL.displayColor
                    : BlockCollectorCrystalBase.CollectorCrystalType.ROCK_CRYSTAL.displayColor;
            long sBase = 1553015L;
            sBase ^= (long) te.getPos().getX();
            sBase ^= (long) te.getPos().getY();
            sBase ^= (long) te.getPos().getZ();
            RenderingUtils.renderLightRayEffects(x + 0.5, y + 1.3, z + 0.5, c, sBase,
                    ClientScheduler.getClientTick(), 20, 50, 25);

            GL11.glTranslated(x + 0.5, y + 1, z + 0.5);
            GL11.glScaled(0.6, 0.6, 0.6);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            TESRCollectorCrystal.renderCrystal(celestial, true);

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

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

License:Open Source License

@Override
public void renderTileEntityAt(TileTelescope te, double x, double y, double z, float partialTicks,
        int destroyStage) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GlStateManager.pushMatrix();/*from  w  w  w. j a v  a2s.  com*/
    GlStateManager.translate(x + 0.5, y + 1.28, z + 0.5);
    GlStateManager.rotate(180, 1, 0, 0);
    GlStateManager.rotate(180, 0, 1, 0);
    GlStateManager.rotate(te.getRotation().ordinal() * 45, 0, 1, 0);
    GlStateManager.scale(0.053, 0.053, 0.053);

    GlStateManager.pushMatrix();
    GlStateManager.rotate((te.getRotation().ordinal()) * 45 + 152.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(165.0F, 1.0F, 0.0F, 0.0F);
    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();

    renderModel(te, 1);
    GlStateManager.popMatrix();
    GL11.glPopAttrib();
}