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:buildcraft.builders.urbanism.RenderBoxProvider.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    GL11.glPushMatrix();//www  . j a  v  a  2  s. c o m
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glPushMatrix();
    GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);
    GL11.glTranslated(x, y, z);

    if (tileentity instanceof IBoxesProvider) {
        for (Box b : ((IBoxesProvider) tileentity).getBoxes()) {
            if (b.isVisible) {
                RenderBox.doRender(TileEntityRendererDispatcher.instance.field_147553_e, getTexture(b.kind), b);
            }
        }
    } else if (tileentity instanceof IBoxProvider) {
        Box b = ((IBoxProvider) tileentity).getBox();

        if (b.isVisible) {
            RenderBox.doRender(TileEntityRendererDispatcher.instance.field_147553_e, getTexture(b.kind), b);
        }
    }

    GL11.glPopMatrix();

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

From source file:buildcraft.commander.GuiZonePlan.java

License:Minecraft Mod Public

@Override
protected void drawGuiContainerBackgroundLayer(float f, int x, int y) {
    super.drawGuiContainerBackgroundLayer(f, x, y);

    mapXMin = (width - getContainer().mapTexture.width) / 2;

    if (getContainer().mapTexture.height <= 200) {
        mapYMin = guiTop + 20;//from  w  w w  .j a  v a2s . com
    } else {
        mapYMin = (height - getContainer().mapTexture.height) / 2;
    }

    getContainer().mapTexture.drawMap(mapXMin, mapYMin, zLevel);

    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glEnable(GL11.GL_BLEND);

    currentSelection.drawMap(mapXMin, mapYMin, zLevel);

    GL11.glPopAttrib();

    newSelection.updateDynamicTexture();

    if (inSelection && selX2 != 0) {
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_BLEND);

        int x1 = selX1 < selX2 ? selX1 : selX2;
        int x2 = selX1 < selX2 ? selX2 : selX1;
        int y1 = selY1 < selY2 ? selY1 : selY2;
        int y2 = selY1 < selY2 ? selY2 : selY1;

        drawTexturedModalRect(x1, y1, 0, 0, x2 - x1 + 1, y2 - y1 + 1);
        GL11.glPopAttrib();
    }

    if (getContainer().mapTexture.height <= 200) {
        drawBackgroundSlots();

        bindTexture(texture);
        drawTexturedModalRect(guiLeft + colorSelected.x, guiTop + colorSelected.y, 0, 220, 16, 16);
        drawTexturedModalRect(guiLeft + 236, guiTop + 38, 16, 220, 8,
                (int) ((zonePlan.progress / (float) TileZonePlan.CRAFT_TIME) * 27));
    }
}

From source file:buildcraft.core.lib.engines.RenderEngine.java

License:Minecraft Mod Public

private void render(float progress, ForgeDirection orientation, ResourceLocation baseTexture,
        ResourceLocation chamberTexture, ResourceLocation trunkTexture, double x, double y, double z) {
    if (BuildCraftCore.render == RenderMode.NoDynamic) {
        return;/* ww  w  . j  av  a2  s  .  c om*/
    }

    GL11.glPushMatrix();
    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 = 7.99F - (progress - 0.5F) * 2F * 7.99F;
    } else {
        step = progress * 2F * 7.99F;
    }

    float translatefact = 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;
    }

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

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

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

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

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

    bindTexture(baseTexture);

    box.render(factor);

    GL11.glTranslatef(translate[0] * translatefact, translate[1] * translatefact, translate[2] * translatefact);
    movingBox.render(factor);
    GL11.glTranslatef(-translate[0] * translatefact, -translate[1] * translatefact,
            -translate[2] * translatefact);

    bindTexture(chamberTexture);

    float chamberf = 2F / 16F;
    int chamberc = ((int) step + 4) / 2;

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

    GL11.glTranslatef(-translate[0] * chamberf * chamberc, -translate[1] * chamberf * chamberc,
            -translate[2] * chamberf * chamberc);

    bindTexture(trunkTexture);

    trunk.render(factor);

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

From source file:buildcraft.core.lib.gui.AdvancedSlot.java

License:Minecraft Mod Public

public void drawSprite(int cornerX, int cornerY) {
    Minecraft mc = Minecraft.getMinecraft();

    if (drawBackround) {
        mc.renderEngine.bindTexture(TEXTURE_SLOT);
        gui.drawTexturedModalRect(cornerX + x - 1, cornerY + y - 1, 0, 0, 18, 18);
    }/* w  w w. j a v a 2  s .co m*/

    if (!isDefined()) {
        return;
    }

    if (getItemStack() != null) {
        drawStack(getItemStack());
    } else if (getIcon() != null) {
        mc.renderEngine.bindTexture(getTexture());
        //System.out.printf("Drawing advanced sprite %s (%d,%d) at %d %d\n", getIcon().getIconName(), getIcon().getOriginX(),getIcon().getOriginY(),cornerX + x, cornerY + y);

        GL11.glPushAttrib(GL11.GL_LIGHTING_BIT | GL11.GL_COLOR_BUFFER_BIT);

        GL11.glDisable(GL11.GL_LIGHTING); // Make sure that render states are reset, an ItemStack can derp them up.
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_BLEND);

        gui.drawTexturedModelRectFromIcon(cornerX + x, cornerY + y, getIcon(), 16, 16);

        GL11.glPopAttrib();
    }

}

From source file:buildcraft.core.lib.gui.GuiAdvancedInterface.java

License:Minecraft Mod Public

protected void drawBackgroundSlots(int mouseX, int mouseY) {
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glPushMatrix();/*from  www. j a  va2  s . co m*/
    GL11.glPushAttrib(GL11.GL_TRANSFORM_BIT);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    int i1 = 240;
    int k1 = 240;
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, i1 / 1.0F, k1 / 1.0F);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    if (slots != null) {
        for (AdvancedSlot slot : slots) {
            if (slot != null) {
                slot.drawSprite(guiLeft, guiTop);
                drawSlotHighlight(slot, mouseX, mouseY);
            }
        }
    }

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

From source file:buildcraft.core.render.RenderBuilder.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    super.renderTileEntityAt(tileentity, x, y, z, f);

    TileAbstractBuilder builder = (TileAbstractBuilder) tileentity;

    if (builder != null) {
        GL11.glPushMatrix();/* w  w  w .j  a v a2 s.c  o  m*/
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslated(x, y, z);
        GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);

        if (builder.getPathLaser() != null) {
            for (LaserData laser : builder.getPathLaser()) {
                if (laser != null) {
                    GL11.glPushMatrix();
                    RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser,
                            EntityLaser.LASER_TEXTURES[4]);
                    GL11.glPopMatrix();
                }
            }
        }

        //GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopAttrib();
        GL11.glPopMatrix();

        renderItems.render(tileentity, x, y, z);
    }
}

From source file:buildcraft.core.render.RenderLaser.java

License:Minecraft Mod Public

private void doRender(EntityLaser laser, double x, double y, double z, float f, float f1) {
    if (!laser.isVisible() || laser.getTexture() == null) {
        return;// w w  w . j  a va  2  s .c om
    }

    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
    GL11.glDisable(GL11.GL_LIGHTING);

    Position offset = laser.renderOffset();
    GL11.glTranslated(x + offset.x, y + offset.y, z + offset.z);

    // FIXME: WARNING! not using getBox (laser) will kill laser movement.
    // we can use some other method for the animation though.
    doRenderLaser(renderManager.renderEngine, laser.data, laser.getTexture());

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

From source file:buildcraft.core.render.RenderPathMarker.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TilePathMarker marker, double x, double y, double z, float f, int arg) {
    if (marker != null) {
        GL11.glPushMatrix();/*from   w w w.  ja v a  2  s. co  m*/
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);

        GL11.glTranslated(x, y, z);
        GL11.glTranslated(-marker.getPos().getX(), -marker.getPos().getY(), -marker.getPos().getZ());

        for (LaserData laser : marker.lasers) {
            if (laser != null) {
                GL11.glPushMatrix();
                RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.worldObj,
                        Minecraft.getMinecraft().renderEngine, laser, EntityLaser.LASER_BLUE);
                GL11.glPopMatrix();
            }
        }

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

From source file:buildcraft.energy.render.RenderEnergyEmitter.java

License:Minecraft Mod Public

public void renderTileEntityAt2(TileEntity tileentity, double x, double y, double z, float f) {

    if (BuildCraftCore.render == RenderMode.NoDynamic) {
        return;//w ww.ja  v a 2  s  . c o m
    }

    GL11.glPushMatrix();
    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;

    float[] angle = { 0, 0, 0 };

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

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

    //bindTexture(EntityLaser.LASER_TEXTURES[3]);
    bindTexture(CHAMBER_TEXTURE);

    box.render(factor);

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

From source file:buildcraft.energy.render.RenderEnergyEmitter.java

License:Minecraft Mod Public

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
    TileEnergyEmitter emitter = (TileEnergyEmitter) tileentity;

    if (emitter != null) {
        GL11.glPushMatrix();/*from   w  w  w  .j  a v a  2s .co m*/
        GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        GL11.glTranslated(x, y, z);

        for (Target t : emitter.targets.values()) {
            GL11.glPushMatrix();
            GL11.glTranslated(0.5F, 0.5F, 0.5F);
            RenderLaser.doRenderLaserWave(TileEntityRendererDispatcher.instance.field_147553_e, t.data,
                    EntityLaser.LASER_TEXTURES[3]);
            GL11.glPopMatrix();
        }

        //GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
    }
}