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.gui.GuiTelescope.java

License:Open Source License

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/*from  ww w .j  av a  2  s .c  o  m*/
    drawWHRect(textureGrid);
    TextureHelper.refreshTextureBindState();

    zLevel -= 5;
    drawCellsWithEffects(partialTicks);
    zLevel += 5;

    drawRotationArrows(partialTicks);

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

From source file:hellfirepvp.astralsorcery.client.gui.GuiTelescope.java

License:Open Source License

private void drawCellsWithEffects(float partialTicks) {
    WorldSkyHandler handle = ConstellationSkyHandler.getInstance().getWorldHandler(guiOwner.getWorld());
    int lastTracked = handle == null ? 5 : handle.lastRecordedDay;
    Random r = new Random(guiOwner.getWorld().getSeed() * 31 + lastTracked * 31 + rotation.ordinal());
    World world = Minecraft.getMinecraft().world;
    boolean canSeeSky = canTelescopeSeeSky(world);

    /*if(handle != null) {
    LinkedList<IConstellation> active = handle.getSortedActiveConstellations();
    PlayerProgress prog = ResearchManager.clientProgress;
    Iterator<IConstellation> iterator = active.iterator();
    while (iterator.hasNext()) {/*ww w .  ja  va 2  s . c  om*/
        IConstellation c = iterator.next();
        if(!(c instanceof IWeakConstellation)) {
            iterator.remove();
            continue;
        }
        if(!c.canDiscover(prog)) {
            iterator.remove();
            continue;
        }
        if(handle.getCurrentDistribution((IWeakConstellation) c, (f) -> f) <= 0.5F) {
            iterator.remove();
        }
    }
    if(active.size() <= 8) {
        active.toArray(constellations);
    } else {
        active.subList(0, 8).toArray(constellations);
    }
    }*/

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

    drawGridBackground(partialTicks, canSeeSky);

    if (handle != null && canSeeSky) {
        zLevel += 1;
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glEnable(GL11.GL_BLEND);
        Blending.DEFAULT.apply();

        RenderAstralSkybox.TEX_STAR_1.bind();
        float starSize = 2.5F;
        for (int i = 0; i < 72 + r.nextInt(144); i++) {
            float innerOffsetX = starSize + r.nextInt(MathHelper.floor(guiWidth - starSize));
            float innerOffsetY = starSize + r.nextInt(MathHelper.floor(guiHeight - starSize));
            float brightness = 0.3F + (RenderConstellation.stdFlicker(ClientScheduler.getClientTick(),
                    partialTicks, 10 + r.nextInt(20))) * 0.6F;
            brightness *= Minecraft.getMinecraft().world.getStarBrightness(1.0F) * 2;
            GL11.glColor4f(brightness, brightness, brightness, brightness);
            drawRectDetailed(guiLeft + innerOffsetX - starSize, guiTop + innerOffsetY - starSize, starSize * 2,
                    starSize * 2);
            GL11.glColor4f(1, 1, 1, 1);
        }
        zLevel -= 1;

        RotationConstellationInformation info = currentInformation.informationMap.get(rotation);
        if (info != null) {
            currentInformation.informationMap.get(rotation).informations.clear();
            for (Map.Entry<Point, IConstellation> entry : info.constellations.entrySet()) {

                float widthHeight = SkyConstellationDistribution.constellationWH;

                Point offset = entry.getKey();

                Map<StarLocation, Rectangle> rectangles = RenderConstellation.renderConstellationIntoGUI(
                        entry.getValue(), offset.x + guiLeft, offset.y + guiTop, zLevel, ((int) widthHeight),
                        ((int) widthHeight), 2.5, new RenderConstellation.BrightnessFunction() {
                            @Override
                            public float getBrightness() {
                                return RenderConstellation.conCFlicker(ClientScheduler.getClientTick(),
                                        partialTicks, 5 + r.nextInt(15));
                            }
                        }, ResearchManager.clientProgress
                                .hasConstellationDiscovered(entry.getValue().getUnlocalizedName()),
                        true);

                currentInformation.informationMap.get(rotation).informations
                        .add(new ConstellationInformation(rectangles, entry.getValue()));
            }
        }

        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopAttrib();
    }

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

    zLevel += 2;
    drawDrawnLines(r, partialTicks);
    zLevel -= 2;

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.gui.GuiTelescope.java

License:Open Source License

private void drawGridBackground(float partialTicks, boolean canSeeSky) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    Blending.PREALPHA.apply();//from   w  w  w.ja  v a2s .  c om
    World renderWorld = Minecraft.getMinecraft().world;
    int rgbFrom, rgbTo;
    if (canSeeSky) {
        float starBr = renderWorld.getStarBrightness(partialTicks) * 2;
        float rain = renderWorld.getRainStrength(partialTicks);
        rgbFrom = RenderingUtils.clampToColorWithMultiplier(calcRGBFromWithRain(starBr, rain), 1F).getRGB();
        rgbTo = RenderingUtils.clampToColorWithMultiplier(calcRGBToWithRain(starBr, rain), 1F).getRGB();
    } else {
        rgbFrom = 0x000000;
        rgbTo = 0x000000;
    }
    int alphaMask = 0xFF000000; //100% opacity.
    RenderingUtils.drawGradientRect(guiLeft + 4, guiTop + 4, zLevel, guiLeft + guiWidth - 4,
            guiTop + guiHeight - 4, new Color(alphaMask | rgbFrom), new Color(alphaMask | rgbTo));
    Blending.DEFAULT.apply();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.gui.journal.GuiJournalPages.java

License:Open Source License

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/*from   w ww  .j  a v a2  s  .c  o  m*/
    GL11.glEnable(GL11.GL_BLEND);
    if (origin != null) {
        drawDefault(textureResBlank);
    } else {
        drawWHRect(textureResBlank);
    }
    TextureHelper.refreshTextureBindState();

    zLevel += 100;
    int pageOffsetY = 20;
    if (currentPageOffset == 0) {
        /*texUnderline.bind();
        GL11.glPushMatrix();
        GL11.glTranslated(guiLeft + 20, guiTop + 15, zLevel);
        drawTexturedRectAtCurrentPos(175, 6);
        GL11.glPopMatrix();*/

        TextureHelper.refreshTextureBindState();
        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        String name = I18n.format(unlocTitle);
        double width = fontRenderer.getStringWidth(name);
        GL11.glTranslated(guiLeft + 117, guiTop + 22, 0);
        GL11.glScaled(1.3, 1.3, 1.3);
        GL11.glTranslated(-(width / 2), 0, 0);
        fontRenderer.drawString(name, 0, 0, 0x00DDDDDD);//Color.LIGHT_GRAY.getRGB());
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glPopMatrix();

        texUnderline.bind();
        GL11.glPushMatrix();
        GL11.glTranslated(guiLeft + 30, guiTop + 35, zLevel);
        drawTexturedRectAtCurrentPos(175, 6);
        GL11.glPopMatrix();
        pageOffsetY = 50;
        TextureHelper.refreshTextureBindState();
    }

    int index = currentPageOffset * 2;
    if (pages.size() > index) {
        GL11.glPushMatrix();
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        IGuiRenderablePage page = pages.get(index);
        page.render(guiLeft + 30, guiTop + pageOffsetY, partialTicks, zLevel, mouseX, mouseY);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
        TextureHelper.refreshTextureBindState();
    }
    index = index + 1;
    if (pages.size() > index) {
        GL11.glPushMatrix();
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        IGuiRenderablePage page = pages.get(index);
        page.render(guiLeft + 220, guiTop + 20, partialTicks, zLevel, mouseX, mouseY);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
        TextureHelper.refreshTextureBindState();
    }
    index = currentPageOffset * 2;
    if (pages.size() > index) {
        GL11.glPushMatrix();
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        IGuiRenderablePage page = pages.get(index);
        page.postRender(guiLeft + 30, guiTop + pageOffsetY, partialTicks, zLevel, mouseX, mouseY);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
        TextureHelper.refreshTextureBindState();
    }
    index = index + 1;
    if (pages.size() > index) {
        GL11.glPushMatrix();
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        IGuiRenderablePage page = pages.get(index);
        page.postRender(guiLeft + 220, guiTop + 20, partialTicks, zLevel, mouseX, mouseY);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
        TextureHelper.refreshTextureBindState();
    }
    drawBackArrow(partialTicks);
    drawNavArrows(partialTicks);
    TextureHelper.refreshTextureBindState();
    zLevel -= 100;

    GL11.glColor4f(1F, 1F, 1F, 1F);
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

From source file:hellfirepvp.astralsorcery.client.gui.journal.GuiProgressionClusterRenderer.java

License:Open Source License

private void renderNodeToGUI(ResearchNode node, double lowerPosX, double lowerPosY, float zLevel) {
    double scaledLeft = this.mousePointScaled.getScaledPosX() - partSizeHandler.widthToBorder;
    double scaledTop = this.mousePointScaled.getScaledPosY() - partSizeHandler.heightToBorder;
    double xAdd = lowerPosX - scaledLeft;
    double yAdd = lowerPosY - scaledTop;
    double offsetX = renderOffsetX + xAdd;
    double offsetY = renderOffsetY + yAdd;

    GL11.glPushMatrix();/*from  w  w w . j a  v a  2 s .c  om*/
    GL11.glDepthMask(true);
    GL11.glEnable(GL11.GL_BLEND);

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

    /*if(node.isSpecial()) {
    frameWooden.bind();
    } else {
    frameBlank.bind();
    }*/
    frameWooden.bind();

    double zoomedWH = partSizeHandler.getZoomedWHNode();

    if (partSizeHandler.getScalingFactor() >= 0.7) {
        clickableNodes.put(new Rectangle(MathHelper.floor(offsetX), MathHelper.floor(offsetY),
                MathHelper.floor(zoomedWH), MathHelper.floor(zoomedWH)), node);
    }

    drawResearchItemBackground(zoomedWH, xAdd, yAdd, zLevel);
    TextureHelper.refreshTextureBindState();
    GL11.glPopMatrix();

    GL11.glPushMatrix();
    GL11.glTranslated(offsetX, offsetY, 0);

    RenderItem ri = Minecraft.getMinecraft().getRenderItem();
    Tessellator t = Tessellator.getInstance();
    VertexBuffer vb = t.getBuffer();
    switch (node.getRenderType()) {
    case ITEMSTACK:
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        RenderHelper.enableGUIStandardItemLighting();
        GL11.glPushMatrix();
        GL11.glScaled(partSizeHandler.getScalingFactor(), partSizeHandler.getScalingFactor(),
                partSizeHandler.getScalingFactor());
        GL11.glTranslated(3, 3, 3);
        GL11.glScaled(0.75, 0.75, 0.75);
        GL11.glColor4f(renderLoopBrFactor, renderLoopBrFactor, renderLoopBrFactor, renderLoopBrFactor);
        float oldZ = ri.zLevel;
        ri.zLevel = zLevel - 5;
        ri.renderItemIntoGUI(node.getRenderItemStack(ClientScheduler.getClientTick()), 0, 0);
        ri.zLevel = oldZ;
        GL11.glColor4f(1F, 1F, 1F, 1F);
        GL11.glPopMatrix();
        RenderHelper.disableStandardItemLighting();
        GL11.glPopAttrib();
        break;
    case TEXTURE:
        GlStateManager.disableAlpha();
        GlStateManager.color(renderLoopBrFactor, renderLoopBrFactor, renderLoopBrFactor, renderLoopBrFactor);
        BindableResource tex = node.getTexture().resolve();
        tex.bind();
        vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        vb.pos(0, zoomedWH - 1, zLevel).tex(0, 1).endVertex();
        vb.pos(zoomedWH - 1, zoomedWH - 1, zLevel).tex(1, 1).endVertex();
        vb.pos(zoomedWH - 1, 0, zLevel).tex(1, 0).endVertex();
        vb.pos(0, 0, zLevel).tex(0, 0).endVertex();
        t.draw();
        GlStateManager.color(1F, 1F, 1F, 1F);
        TextureHelper.refreshTextureBindState();
        GlStateManager.enableAlpha();
        break;
    case TEXTURE_SPRITE:
        GlStateManager.disableAlpha();
        GL11.glDisable(GL11.GL_ALPHA_TEST);

        GlStateManager.color(renderLoopBrFactor, renderLoopBrFactor, renderLoopBrFactor, renderLoopBrFactor);
        SpriteSheetResource res = node.getSpriteTexture().resolveSprite();
        res.getResource().bind();
        Tuple<Double, Double> uvTexture = res.getUVOffset(ClientScheduler.getClientTick());
        vb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
        vb.pos(0, zoomedWH, zLevel).tex(uvTexture.key, uvTexture.value + res.getVLength()).endVertex();
        vb.pos(zoomedWH, zoomedWH, zLevel)
                .tex(uvTexture.key + res.getULength(), uvTexture.value + res.getVLength()).endVertex();
        vb.pos(zoomedWH, 0, zLevel).tex(uvTexture.key + res.getULength(), uvTexture.value).endVertex();
        vb.pos(0, 0, zLevel).tex(uvTexture.key, uvTexture.value).endVertex();
        t.draw();
        GlStateManager.color(1F, 1F, 1F, 1F);
        TextureHelper.refreshTextureBindState();
        GlStateManager.enableAlpha();
        break;
    }
    GL11.glPopMatrix();
}

From source file:hellfirepvp.astralsorcery.client.gui.journal.GuiScreenJournal.java

License:Open Source License

public void drawDefault(BindableResource background) {
    GL11.glPushMatrix();/*  ww w . j  a  va2  s  . com*/
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    Point mouse = getCurrentMousePoint();

    zLevel += 100; //To ensure that it over-renders items conflicting with the shell.
    drawWHRect(background);
    drawBookmarks(zLevel, mouse);
    zLevel -= 100;

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

From source file:hellfirepvp.astralsorcery.client.gui.journal.page.IGuiRenderablePage.java

License:Open Source License

default public Rectangle drawItemStack(ItemStack stack, int offsetX, int offsetY, float zLevel,
        FontRenderer fontRenderer, RenderItem ri) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/*from   ww  w.  j  av  a  2s .  c  o m*/

    float zIR = ri.zLevel;
    ri.zLevel = zLevel;
    RenderHelper.enableGUIStandardItemLighting();

    ri.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().player, stack, offsetX, offsetY);
    ri.renderItemOverlayIntoGUI(fontRenderer, stack, offsetX, offsetY, null);

    RenderHelper.disableStandardItemLighting();
    GlStateManager.enableAlpha(); //Because Mc item rendering..
    ri.zLevel = zIR;
    TextureHelper.refreshTextureBindState();
    TextureHelper.setActiveTextureToAtlasSprite();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
    return new Rectangle(offsetX, offsetY, 16, 16);
}

From source file:hellfirepvp.astralsorcery.client.gui.journal.page.IGuiRenderablePage.java

License:Open Source License

default public void drawInfoStarSingle(float offsetX, float offsetY, float zLevel, float widthHeight,
        double deg) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();//from   w  w w .j  ava2 s  .com

    resStar.bind();
    Vector3 offset = new Vector3(-widthHeight / 2D, -widthHeight / 2D, 0).rotate(deg, Vector3.RotAxis.Z_AXIS);
    Vector3 uv01 = new Vector3(-widthHeight / 2D, widthHeight / 2D, 0).rotate(deg, Vector3.RotAxis.Z_AXIS);
    Vector3 uv11 = new Vector3(widthHeight / 2D, widthHeight / 2D, 0).rotate(deg, Vector3.RotAxis.Z_AXIS);
    Vector3 uv10 = new Vector3(widthHeight / 2D, -widthHeight / 2D, 0).rotate(deg, Vector3.RotAxis.Z_AXIS);

    Tessellator tes = Tessellator.getInstance();
    VertexBuffer vb = tes.getBuffer();
    vb.begin(7, DefaultVertexFormats.POSITION_TEX);
    vb.pos(offsetX + uv01.getX(), offsetY + uv01.getY(), zLevel).tex(0, 1).endVertex();
    vb.pos(offsetX + uv11.getX(), offsetY + uv11.getY(), zLevel).tex(1, 1).endVertex();
    vb.pos(offsetX + uv10.getX(), offsetY + uv10.getY(), zLevel).tex(1, 0).endVertex();
    vb.pos(offsetX + offset.getX(), offsetY + offset.getY(), zLevel).tex(0, 0).endVertex();
    tes.draw();

    TextureHelper.refreshTextureBindState();
    TextureHelper.setActiveTextureToAtlasSprite();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

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

License:Open Source License

private void renderT3Additions(TileAltar te, double x, double y, double z, double jump) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();/*from  w  w  w.j  a  v  a 2  s . c  om*/
    GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
    GL11.glRotated(180, 1, 0, 0);
    GL11.glScaled(0.0625, 0.0625, 0.0625);
    RenderHelper.disableStandardItemLighting();

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

    texAltar3.bind();
    modelAltar3.render(null, (float) jump, 0, 0, 0, 0, 1F);
    RenderHelper.disableStandardItemLighting();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}

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

License:Open Source License

private void renderT2Additions(TileAltar te, double x, double y, double z, double jump) {
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
    GL11.glPushMatrix();// w  ww.jav  a 2 s  .c om
    GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
    GL11.glRotated(180, 1, 0, 0);
    GL11.glScaled(0.0625, 0.0625, 0.0625);
    RenderHelper.disableStandardItemLighting();

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

    texAltar2.bind();
    modelAltar2.render(null, (float) jump, 0, 0, 0, 0, 1F);
    RenderHelper.disableStandardItemLighting();
    GL11.glPopMatrix();
    GL11.glPopAttrib();
}