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:forestry.apiculture.render.ParticleRenderer.java

License:Open Source License

private synchronized void render(float partialTicks) {
    Minecraft.getMinecraft().mcProfiler.startSection(name + "-render");

    float rotationX = ActiveRenderInfo.rotationX;
    float rotationZ = ActiveRenderInfo.rotationZ;
    float rotationYZ = ActiveRenderInfo.rotationYZ;
    float rotationXY = ActiveRenderInfo.rotationXY;
    float rotationXZ = ActiveRenderInfo.rotationXZ;

    EntityLivingBase player = Minecraft.getMinecraft().renderViewEntity;
    EntityFX.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
    EntityFX.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
    EntityFX.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;

    // bind the texture
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);

    // save the old gl state
    GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // gl states/settings for drawing
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glDepthMask(false);// w w w. jav a 2  s.  c  om
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.003921569F);

    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();

    for (EntityFX particle : particles) {
        tessellator.setBrightness(particle.getBrightnessForRender(partialTicks));

        particle.renderParticle(tessellator, partialTicks, rotationX, rotationXZ, rotationZ, rotationYZ,
                rotationXY);
    }

    tessellator.draw();

    // restore previous gl state
    GL11.glPopAttrib();

    Minecraft.getMinecraft().mcProfiler.endSection();
}

From source file:forestry.core.gui.GuiForestry.java

License:Open Source License

@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_LIGHTING);//from   w  w w  .j a  va  2s.com
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    ledgerManager.drawTooltips(mouseX, mouseY);

    InventoryPlayer playerInv = mc.thePlayer.inventory;

    if (playerInv.getItemStack() == null) {
        drawToolTips(widgetManager.widgets, mouseX, mouseY);
        drawToolTips(buttonList, mouseX, mouseY);
        drawToolTips(inventorySlots.inventorySlots, mouseX, mouseY);
    }

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

From source file:forestry.core.gui.GuiForestry.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bindTexture(textureFile);/*from  w w  w  .  ja va 2  s  .c  om*/
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

    int left = this.guiLeft;
    int top = this.guiTop;

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glTranslatef(left, top, 0.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240 / 1.0F, 240 / 1.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    drawWidgets();

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

    bindTexture(textureFile);
}

From source file:forestry.core.gui.GuiForestry.java

License:Open Source License

public void drawItemStack(ItemStack stack, int xPos, int yPos) {
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);//  www . j a  va  2s .co  m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderHelper.enableGUIStandardItemLighting();

    GL11.glTranslatef(0.0F, 0.0F, 32.0F);
    this.zLevel = 100.0F;
    itemRender.zLevel = 100.0F;
    FontRenderer font = null;
    if (stack != null) {
        font = stack.getItem().getFontRenderer(stack);
    }
    if (font == null) {
        font = fontRendererObj;
    }
    itemRender.renderItemAndEffectIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos);
    itemRender.renderItemOverlayIntoGUI(font, this.mc.getTextureManager(), stack, xPos, yPos);
    this.zLevel = 0.0F;
    itemRender.zLevel = 0.0F;

    RenderHelper.disableStandardItemLighting();
    GL11.glPopAttrib();
}

From source file:forestry.core.gui.widgets.TankWidget.java

License:Open Source License

@Override
public void draw(int startX, int startY) {
    StandardTank tank = getTank();/*w w w  .ja va 2  s .co  m*/
    if (tank == null) {
        return;
    }

    FluidStack contents = tank.getFluid();
    if (contents == null || contents.amount <= 0 || contents.getFluid() == null) {
        return;
    }
    IIcon liquidIcon = contents.getFluid().getIcon(contents);
    if (liquidIcon == null) {
        return;
    }
    int squaled = (contents.amount * height) / getTank().getCapacity();

    Proxies.common.bindTexture(SpriteSheet.BLOCKS);
    int start = 0;

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0F);
    while (true) {
        int x;

        if (squaled > 16) {
            x = 16;
            squaled -= 16;
        } else {
            x = squaled;
            squaled = 0;
        }

        manager.gui.drawTexturedModelRectFromIcon(startX + xPos, startY + yPos + height - x - start, liquidIcon,
                16, 16 - (16 - x));
        start = start + 16;

        if (x == 0 || squaled == 0) {
            break;
        }
    }

    Proxies.common.bindTexture(manager.gui.textureFile);
    manager.gui.drawTexturedModalRect(startX + xPos, startY + yPos, overlayTexX, overlayTexY, 16, 60);
    GL11.glPopAttrib();
}

From source file:forestry.core.render.CrateRenderingHandler.java

License:Open Source License

private void render(ItemRenderType type, ItemStack stack) {
    GL11.glPushMatrix();/*from w  ww  . ja v  a  2 s  .c  om*/
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    IIcon crateTexture = stack.getIconIndex();
    renderItem.renderIcon(0, 0, crateTexture, 16, 16);

    ItemStack contained = getContainedFromCrate(stack);

    if (contained != null) {

        int meta = contained.getItemDamage();

        float scale = 0.5f;
        GL11.glScalef(scale, scale, 1);
        GL11.glTranslatef(6f, 8f, 0);
        if (type == ItemRenderType.ENTITY) {
            GL11.glTranslatef(0, 0, -0.1f);
        }

        if (contained.getItem() instanceof ItemBlock) {
            GL11.glScalef(16f, 16f, 1f);
            GL11.glTranslatef(1f, 1f, 0.1f);
            GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
            renderIn3D(contained);
        } else {
            for (int pass = 0; pass < contained.getItem().getRenderPasses(meta); ++pass) {
                IIcon containedTexture = contained.getItem().getIconFromDamageForRenderPass(meta, pass);
                if (containedTexture == null) {
                    continue;
                }

                if (renderItem.renderWithColor) {
                    int color = contained.getItem().getColorFromItemStack(contained, pass);
                    float c1 = (float) (color >> 16 & 255) / 255.0F;
                    float c2 = (float) (color >> 8 & 255) / 255.0F;
                    float c3 = (float) (color & 255) / 255.0F;

                    GL11.glColor4f(c1, c2, c3, 1.0F);
                }

                renderItem.renderIcon(0, 0, containedTexture, 16, 16);
            }
        }
    }

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

From source file:forestry.energy.render.RenderEngine.java

License:Open Source License

private void render(TemperatureState state, float progress, ForgeDirection orientation, double x, double y,
        double z) {

    GL11.glPushMatrix();/*from   w  w w  .  j a va  2s  .c o  m*/
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glColor3f(1, 1, 1);

    GL11.glTranslatef((float) x, (float) y, (float) z);

    float step;

    if (progress > 0.5) {
        step = 5.99F - (progress - 0.5F) * 2F * 5.99F;
    } else {
        step = progress * 2F * 5.99F;
    }

    float tfactor = step / 16;

    float[] angle = { 0, 0, 0 };
    float[] translate = { orientation.offsetX, orientation.offsetY, orientation.offsetZ };

    switch (orientation) {
    case EAST:
    case WEST:
    case DOWN:
        angle[2] = angleMap[orientation.ordinal()];
        break;
    case SOUTH:
    case NORTH:
    default:
        angle[0] = angleMap[orientation.ordinal()];
        break;
    }

    boiler.rotateAngleX = angle[0];
    boiler.rotateAngleY = angle[1];
    boiler.rotateAngleZ = angle[2];

    trunk.rotateAngleX = angle[0];
    trunk.rotateAngleY = angle[1];
    trunk.rotateAngleZ = angle[2];

    piston.rotateAngleX = angle[0];
    piston.rotateAngleY = angle[1];
    piston.rotateAngleZ = angle[2];

    extension.rotateAngleX = angle[0];
    extension.rotateAngleY = angle[1];
    extension.rotateAngleZ = angle[2];

    float factor = (float) (1.0 / 16.0);

    Proxies.common.bindTexture(textures[Textures.BASE.ordinal()]);
    boiler.render(factor);

    Proxies.common.bindTexture(textures[Textures.PISTON.ordinal()]);
    GL11.glTranslatef(translate[0] * tfactor, translate[1] * tfactor, translate[2] * tfactor);
    piston.render(factor);
    GL11.glTranslatef(-translate[0] * tfactor, -translate[1] * tfactor, -translate[2] * tfactor);

    ResourceLocation texture;

    switch (state) {
    case OVERHEATING:
        texture = textures[Textures.TRUNK_HIGHEST.ordinal()];
        break;
    case RUNNING_HOT:
        texture = textures[Textures.TRUNK_HIGHER.ordinal()];
        break;
    case OPERATING_TEMPERATURE:
        texture = textures[Textures.TRUNK_HIGH.ordinal()];
        break;
    case WARMED_UP:
        texture = textures[Textures.TRUNK_MEDIUM.ordinal()];
        break;
    case COOL:
    default:
        texture = textures[Textures.TRUNK_LOW.ordinal()];
        break;

    }
    Proxies.common.bindTexture(texture);
    trunk.render(factor);

    Proxies.common.bindTexture(textures[Textures.EXTENSION.ordinal()]);
    float chamberf = 2F / 16F;

    if (step > 0) {
        for (int i = 0; i <= step + 2; i += 2) {
            extension.render(factor);
            GL11.glTranslatef(translate[0] * chamberf, translate[1] * chamberf, translate[2] * chamberf);
        }
    }

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

From source file:forestry.farming.render.FarmItemRenderer.java

License:Open Source License

private void renderFarmBlock(RenderBlocks render, ItemStack item, float translateX, float translateY,
        float translateZ) {
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);/*from w  w w.  java  2  s .  co  m*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    Tessellator tessellator = Tessellator.instance;
    BlockFarm block = (BlockFarm) StackUtils.getBlock(item);
    if (block == null) {
        return;
    }

    block.setBlockBoundsForItemRender();
    render.setRenderBoundsFromBlock(block);

    EnumFarmBlock type = EnumFarmBlock.getFromCompound(item.getTagCompound());

    GL11.glTranslatef(translateX, translateY, translateZ);

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, -1F, 0.0F);
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 0, item.getItemDamage()));
    render.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(0, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 1.0F, 0.0F);
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 1, item.getItemDamage()));
    render.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(1, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, -1F);
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 2, item.getItemDamage()));
    render.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(2, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(0.0F, 0.0F, 1.0F);
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 3, item.getItemDamage()));
    render.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(3, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(-1F, 0.0F, 0.0F);
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 4, item.getItemDamage()));
    render.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(4, item.getItemDamage()));
    tessellator.draw();

    tessellator.startDrawingQuads();
    tessellator.setNormal(1.0F, 0.0F, 0.0F);
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D,
            block.getBlockTextureFromSideAndMetadata(type, 5, item.getItemDamage()));
    render.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getOverlayTextureForBlock(5, item.getItemDamage()));
    tessellator.draw();

    GL11.glTranslatef(0.5F, 0.5F, 0.5F);

    block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    GL11.glPopAttrib();
}

From source file:forestry.lepidopterology.render.ButterflyItemRenderer.java

License:Open Source License

private void renderButterflyItem(IButterfly butterfly, float translateX, float translateY, float translateZ) {
    float yaw = 1;
    float pitch = 1;

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);/*from   www  . java2s  .co m*/
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);

    GL11.glPushMatrix();

    if (RenderItem.renderInFrame) {
        //GL11.glScalef(-2.0f, 2.0f, 2.0f);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-90.0F, 1.0F, 0.0F, 0.0F);
        GL11.glScalef(1.1f, 1f, 1f);

        GL11.glTranslatef(0, -0.7f, 0.2f);

        entity.renderYawOffset = 0;
        entity.rotationYaw = 0;
        entity.rotationPitch = 0;
        entity.rotationYawHead = entity.rotationYaw;

        RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0f);

    } else {
        GL11.glTranslatef(translateX, translateY, translateZ);

        GL11.glScalef(-2.0f, 2.0f, 2.0f);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-((float) Math.atan((double) (pitch / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);

        entity.renderYawOffset = (float) Math.atan((double) (yaw / 40.0F)) * 20.0F;
        entity.rotationYaw = (float) Math.atan((double) (yaw / 40.0F)) * 40.0F;
        entity.rotationPitch = -((float) Math.atan((double) (pitch / 40.0F))) * 20.0F;
        entity.rotationYawHead = entity.rotationYaw;

        RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly));

    }

    GL11.glPopMatrix();

    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glPopAttrib();

}

From source file:forestry.lepidopterology.render.ButterflyItemRenderer.java

License:Open Source License

private void renderButterflyInInventory(IButterfly butterfly) {

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_LIGHTING);/*from w  w w. j  av a 2 s  .c  om*/
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    RenderHelper.enableStandardItemLighting();
    GL11.glPushMatrix();

    GL11.glTranslatef(0f, -0.75f, 0f);
    GL11.glScalef(-2.0f, 2.0f, 2.0f);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(-35.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(1.1f, 1f, 1f);

    entity.renderYawOffset = 0;
    entity.rotationYaw = 0;
    entity.rotationPitch = 0;
    entity.rotationYawHead = entity.rotationYaw;

    RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, getWingYaw(butterfly));

    GL11.glPopMatrix();
    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glPopAttrib();

}