Example usage for org.lwjgl.opengl GL11 glPopMatrix

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

Introduction

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

Prototype

public static native void glPopMatrix();

Source Link

Document

Pops the top entry off the current matrix stack, replacing the current matrix with the matrix that was the second entry in the stack.

Usage

From source file:com.bluepowermod.part.gate.GateTransparentLatch.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)// ww  w .j a  v  a2 s .  c om
public void renderTop(float frame) {

    if (mirrored) {
        GL11.glPushMatrix();
        GL11.glTranslated(0.5, 0, 0.5);
        GL11.glScaled(-1, 1, 1);
        GL11.glTranslated(-0.5, 0, -0.5);

        GL11.glDisable(GL11.GL_CULL_FACE);
    }

    renderTop("front", front());
    renderTop("left", mirrored ? right() : left());
    renderTop("back", back());
    renderTop("leftcenter", back().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(4 / 16D, 3D / 16D, -4 / 16D, 8D / 16D, back().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(4 / 16D, 3D / 16D, 1 / 16D, 8D / 16D,
            back().getInput() > 0 && front().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(1 / 16D, 3D / 16D, 1 / 16D, 8D / 16D,
            back().getInput() == 0 && front().getInput() == 0);
    RenderHelper.renderDigitalRedstoneTorch(-4 / 16D, 2D / 16D, 1 / 16D, 10D / 16D, front().getInput() > 0);
    RenderHelper.renderDigitalRedstoneTorch(2 / 16D, 2D / 16D, 6 / 16D, 10D / 16D, front().getInput() > 0);
    renderTop("right", mirrored ? left() : right());

    if (mirrored) {
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glPopMatrix();
    }
}

From source file:com.bluepowermod.part.gate.ic.IntegratedCircuit.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*  ww w .  jav a  2s .  c  o m*/
protected void renderTop(float frame) {

    renderTop("front", front());
    renderTop("left", left());
    renderTop("back", back());
    renderTop("right", right());
    Vec3d loc = new Vec3d(0, 0, 0);

    RenderHelper rh = RenderHelper.instance;
    rh.reset();
    RenderBlocks rb = RenderBlocks.getInstance();

    GL11.glPushMatrix();
    {
        GL11.glTranslated(0, 2 / 16D - 1 / 16D * (1.0 / getCircuitWidth()), 0);
        GL11.glNormal3d(0, 1, 0);
        int size = getCircuitWidth();
        double textureMaxUV = 0.5 * size;

        Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation(
                Refs.MODID + ":textures/blocks/gates/" + getTextureName() + "/checkerboard.png"));
        GL11.glBegin(GL11.GL_QUADS);
        {
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(BORDER_WIDTH, 0, BORDER_WIDTH, 0,
                    0);
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(BORDER_WIDTH, 0, 1 - BORDER_WIDTH,
                    0, textureMaxUV);
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(1 - BORDER_WIDTH, 0,
                    1 - BORDER_WIDTH, textureMaxUV, textureMaxUV);
            com.bluepowermod.client.render.RenderHelper.addVertexWithTexture(1 - BORDER_WIDTH, 0, BORDER_WIDTH,
                    textureMaxUV, 0);
        }
        GL11.glEnd();
    }
    GL11.glPopMatrix();

    GL11.glPushMatrix();
    {
        GL11.glTranslated(BORDER_WIDTH, 2 / 16D + 0.001D, BORDER_WIDTH);
        GL11.glScaled((1 - 2 * BORDER_WIDTH) / 1, 1, (1 - 2 * BORDER_WIDTH) / 1);

        GL11.glScaled(1.0 / getCircuitWidth(), 1.0 / getCircuitWidth(), 1.0 / getCircuitWidth());
        GL11.glTranslated(0, -2 / 16D, 0);
        for (GateBase[] gateArray : gates) {
            GL11.glPushMatrix();
            for (GateBase gate : gateArray) {
                if (gate != null) {
                    GL11.glPushMatrix();
                    gate.renderDynamic(loc, frame, 0);
                    GL11.glPopMatrix();

                    if (!isRenderingItem) {
                        // Static renderer
                        GL11.glPushMatrix();
                        {
                            Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
                            Tessellator.instance.startDrawingQuads();
                            gate.renderStatic(new Vec3i(gate), rh, rb, 0);
                            Tessellator.instance.draw();
                        }
                        GL11.glPopMatrix();
                    }

                    rh.reset();
                }
                GL11.glTranslated(0, 0, 1);
            }
            GL11.glPopMatrix();
            GL11.glTranslated(1, 0, 0);
        }
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.lamp.PartLamp.java

License:Open Source License

/**
 * @author Koen Beckers (K4Unl)//from w w  w . j a v a  2  s .c om
 */
@Override
@SideOnly(Side.CLIENT)
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    power = (byte) 255;

    RenderHelper rh = RenderHelper.instance;
    rh.setRenderCoords(null, 0, 0, 0);
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);

    Tessellator.instance.startDrawingQuads();
    renderStatic(new Vec3i(0, 0, 0), rh, RenderBlocks.getInstance(), 0);
    Tessellator.instance.draw();

    rh.reset();

    GL11.glPushMatrix();
    renderGlow(1);
    GL11.glPopMatrix();

    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);
}

From source file:com.bluepowermod.part.tube.Accelerator.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)/*  w  w w . j a  v a2 s. com*/
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();
    {
        GL11.glTranslated(0, -0.125, 0);

        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        rotation = ForgeDirection.UP;
        renderDynamic(new Vec3d(0, 0, 0), 0, 0);
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.tube.Accelerator.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//ww w.  j av  a 2 s  . co m
public void renderDynamic(Vec3d loc, double delta, int pass) {

    super.renderDynamic(loc, delta, pass);
    if (pass == 0) {
        Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
        Tessellator t = Tessellator.instance;

        GL11.glPushMatrix();
        GL11.glTranslatef((float) loc.getX() + 0.5F, (float) loc.getY() + 0.5F, (float) loc.getZ() + 0.5F);
        if (rotation == ForgeDirection.NORTH || rotation == ForgeDirection.SOUTH) {
            GL11.glRotated(90, 1, 0, 0);
        } else if (rotation == ForgeDirection.EAST || rotation == ForgeDirection.WEST) {
            GL11.glRotated(90, 0, 0, 1);
        }
        GL11.glTranslatef((float) -loc.getX() - 0.5F, (float) -loc.getY() - 0.5F, (float) -loc.getZ() - 0.5F);

        t.startDrawingQuads();

        t.setColorOpaque_F(1, 1, 1);
        t.addTranslation((float) loc.getX(), (float) loc.getY(), (float) loc.getZ());

        IIcon icon = isPowered() ? IconSupplier.acceleratorFrontPowered : IconSupplier.acceleratorFront;

        double minX = icon.getInterpolatedU(0);
        double maxX = icon.getInterpolatedU(16);
        double minY = icon.getInterpolatedV(0);
        double maxY = icon.getInterpolatedV(16);

        t.setNormal(0, -1, 0);
        t.addVertexWithUV(0, 4 / 16D, 0, maxX, maxY);// minY
        t.addVertexWithUV(1, 4 / 16D, 0, minX, maxY);
        t.addVertexWithUV(1, 4 / 16D, 1, minX, minY);
        t.addVertexWithUV(0, 4 / 16D, 1, maxX, minY);

        t.setNormal(0, 1, 1);
        t.addVertexWithUV(0, 12 / 16D, 0, maxX, maxY);// maxY
        t.addVertexWithUV(0, 12 / 16D, 1, minX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 1, minX, minY);
        t.addVertexWithUV(1, 12 / 16D, 0, maxX, minY);

        icon = isPowered() ? IconSupplier.acceleratorSidePowered : IconSupplier.acceleratorSide;

        minX = icon.getInterpolatedU(4);
        maxX = icon.getInterpolatedU(12);
        minY = icon.getInterpolatedV(0);
        maxY = icon.getInterpolatedV(16);

        t.setNormal(0, 0, 1);
        t.addVertexWithUV(0, 4 / 16D, 1, maxX, minY);// maxZ
        t.addVertexWithUV(1, 4 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 1, minX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 1, minX, minY);

        t.setNormal(0, 0, -1);
        t.addVertexWithUV(0, 4 / 16D, 0, minX, maxY);// minZ
        t.addVertexWithUV(0, 12 / 16D, 0, maxX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 0, maxX, minY);
        t.addVertexWithUV(1, 4 / 16D, 0, minX, minY);

        t.setNormal(-1, 0, 0);
        t.addVertexWithUV(0, 4 / 16D, 0, maxX, minY);// minX
        t.addVertexWithUV(0, 4 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 1, minX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 0, minX, minY);

        t.setNormal(1, 0, 0);
        t.addVertexWithUV(1, 4 / 16D, 0, maxX, maxY);// maxX
        t.addVertexWithUV(1, 12 / 16D, 0, minX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 1, minX, minY);
        t.addVertexWithUV(1, 4 / 16D, 1, maxX, minY);

        icon = IconSupplier.acceleratorInside;

        minX = icon.getInterpolatedU(4);
        maxX = icon.getInterpolatedU(12);
        minY = icon.getInterpolatedV(4);
        maxY = icon.getInterpolatedV(12);

        t.addVertexWithUV(0, 4 / 16D, 6 / 16D, minX, minY);// inside maxZ
        t.addVertexWithUV(1, 4 / 16D, 6 / 16D, maxX, maxY);
        t.addVertexWithUV(1, 12 / 16D, 6 / 16D, maxX, maxY);
        t.addVertexWithUV(0, 12 / 16D, 6 / 16D, minX, minY);

        t.addVertexWithUV(0, 4 / 16D, 10 / 16D, minX, maxY);// inside minZ
        t.addVertexWithUV(0, 12 / 16D, 10 / 16D, minX, minY);
        t.addVertexWithUV(1, 12 / 16D, 10 / 16D, maxX, minY);
        t.addVertexWithUV(1, 4 / 16D, 10 / 16D, maxX, maxY);

        t.addVertexWithUV(10 / 16D, 4 / 16D, 0, minX, minY);// inside minX
        t.addVertexWithUV(10 / 16D, 4 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(10 / 16D, 12 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(10 / 16D, 12 / 16D, 0, minX, minY);

        t.addVertexWithUV(6 / 16D, 4 / 16D, 0, minX, minY);// inside maxX
        t.addVertexWithUV(6 / 16D, 12 / 16D, 0, minX, maxY);
        t.addVertexWithUV(6 / 16D, 12 / 16D, 1, maxX, maxY);
        t.addVertexWithUV(6 / 16D, 4 / 16D, 1, maxX, minY);

        t.addTranslation((float) -loc.getX(), (float) -loc.getY(), (float) -loc.getZ());
        t.draw();
        GL11.glPopMatrix();
    }

}

From source file:com.bluepowermod.part.tube.MagTube.java

License:Open Source License

/**
 * Render method that works, and now should be buried under the ground so no-one looks at it
 *///from   w w  w. ja v a 2s  .  co m
@Override
@SideOnly(Side.CLIENT)
protected void renderSide() {

    Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    Tessellator t = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glTranslatef(0.5F, 0.5F, 0.5F);
    if (getParent() == null || getWorld() == null) {

    } else {
        if (connections[2]) {
            GL11.glRotated(90, 1, 0, 0);
        } else if (connections[4]) {
            GL11.glRotated(90, 0, 0, 1);
        }
    }
    GL11.glTranslatef(-0.5F, -0.5F, -0.5F);

    t.startDrawingQuads();

    double min = 2 / 16D;
    double max = 14 / 16D;
    double inMin = 12.001 / 16D;
    double inMax = 3.999 / 16D;

    IIcon icon = IconSupplier.magCoilSide;

    double minX = icon.getInterpolatedU(min * 16);
    double maxX = icon.getInterpolatedU(max * 16);
    double minY = icon.getInterpolatedV(min * 16);
    double maxY = icon.getInterpolatedV(max * 16);

    t.setNormal(0, 0, 1);
    t.addVertexWithUV(min, min, max, maxX, maxY);// maxZ
    t.addVertexWithUV(max, min, max, minX, maxY);
    t.addVertexWithUV(max, max, max, minX, minY);
    t.addVertexWithUV(min, max, max, maxX, minY);

    t.addVertexWithUV(min, min, inMax, maxX, maxY);// inside maxZ
    t.addVertexWithUV(max, min, inMax, minX, maxY);
    t.addVertexWithUV(max, max, inMax, minX, minY);
    t.addVertexWithUV(min, max, inMax, maxX, minY);

    t.setNormal(0, 0, -1);
    t.addVertexWithUV(min, min, min, minX, maxY);// minZ
    t.addVertexWithUV(min, max, min, minX, minY);
    t.addVertexWithUV(max, max, min, maxX, minY);
    t.addVertexWithUV(max, min, min, maxX, maxY);

    t.addVertexWithUV(min, min, inMin, maxX, maxY);// inside minZ
    t.addVertexWithUV(min, max, inMin, minX, minY);
    t.addVertexWithUV(max, max, inMin, minX, minY);
    t.addVertexWithUV(max, min, inMin, maxX, maxY);

    t.setNormal(-1, 0, 0);
    t.addVertexWithUV(min, min, min, maxX, maxY);// minX
    t.addVertexWithUV(min, min, max, minX, maxY);
    t.addVertexWithUV(min, max, max, minX, minY);
    t.addVertexWithUV(min, max, min, maxX, minY);

    t.addVertexWithUV(inMin, min, min, maxX, maxY);// inside minX
    t.addVertexWithUV(inMin, min, max, minX, maxY);
    t.addVertexWithUV(inMin, max, max, minX, minY);
    t.addVertexWithUV(inMin, max, min, maxX, minY);

    t.setNormal(1, 0, 0);
    t.addVertexWithUV(max, min, min, minX, minY);// maxX
    t.addVertexWithUV(max, max, min, minX, maxY);
    t.addVertexWithUV(max, max, max, maxX, maxY);
    t.addVertexWithUV(max, min, max, maxX, minY);

    t.addVertexWithUV(inMax, min, min, maxX, minY);// maxX
    t.addVertexWithUV(inMax, max, min, minX, maxY);
    t.addVertexWithUV(inMax, max, max, minX, maxY);
    t.addVertexWithUV(inMax, min, max, maxX, minY);

    icon = IconSupplier.magCoilFront;
    minX = icon.getInterpolatedU(min * 16);
    maxX = icon.getInterpolatedU(max * 16);
    minY = icon.getInterpolatedV(min * 16);
    maxY = icon.getInterpolatedV(max * 16);
    for (int i = 2; i < 16; i += 8) {
        t.setNormal(0, 1, 0);
        t.addVertexWithUV(min, 1 - i / 16D, min, maxX, maxY);// maxY
        t.addVertexWithUV(min, 1 - i / 16D, max, minX, maxY);
        t.addVertexWithUV(max, 1 - i / 16D, max, minX, minY);
        t.addVertexWithUV(max, 1 - i / 16D, min, maxX, minY);

        t.setNormal(0, -1, 0);
        t.addVertexWithUV(min, i / 16D, min, maxX, maxY);// minY
        t.addVertexWithUV(max, i / 16D, min, minX, maxY);
        t.addVertexWithUV(max, i / 16D, max, minX, minY);
        t.addVertexWithUV(min, i / 16D, max, maxX, minY);
    }
    t.draw();
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.tube.PneumaticTube.java

License:Open Source License

@Override
@SideOnly(Side.CLIENT)//  w  w w .j  ava2  s  .  c o m
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {

    GL11.glPushMatrix();
    GL11.glTranslated(0, -0.125D, 0);

    Tessellator t = Tessellator.instance;
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
    t.startDrawingQuads();

    connections[ForgeDirection.DOWN.ordinal()] = true;
    connections[ForgeDirection.UP.ordinal()] = true;

    RenderHelper renderer = RenderHelper.instance;
    renderer.fullReset();
    RenderBlocks rb = new RenderBlocks();

    renderStatic(new Vec3i(0, 0, 0), renderer, rb, 0);

    t.draw();
    renderSide();
    Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);

    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.tube.TubeLogic.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void renderDynamic(Vec3d pos, float partialTick) {

    GL11.glPushMatrix();/* w ww .ja va2  s  . com*/
    GL11.glTranslated(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5);
    for (TubeStack stack : tubeStacks) {
        stack.render(partialTick);
    }
    GL11.glPopMatrix();
}

From source file:com.bluepowermod.part.tube.TubeStack.java

License:Open Source License

@SideOnly(Side.CLIENT)
public void render(float partialTick) {
    if (renderMode == RenderMode.AUTO) {
        renderMode = Minecraft.getMinecraft().gameSettings.fancyGraphics ? RenderMode.NORMAL
                : RenderMode.REDUCED;//  w  ww . j  a  v  a  2 s  .c  om
    }
    final RenderMode finalRenderMode = renderMode;

    if (customRenderItem == null) {
        customRenderItem = new RenderItem() {

            @Override
            public boolean shouldBob() {

                return false;
            };

            @Override
            public byte getMiniBlockCount(ItemStack stack, byte original) {

                return finalRenderMode == RenderMode.REDUCED ? (byte) 1 : original;
            }
        };
        customRenderItem.setRenderManager(RenderManager.instance);

        renderedItem = new EntityItem(FMLClientHandler.instance().getWorldClient());
        renderedItem.hoverStart = 0.0F;
    }

    renderedItem.setEntityItemStack(stack);

    double renderProgress = (oldProgress + (progress - oldProgress) * partialTick) * 2 - 1;

    GL11.glPushMatrix();
    GL11.glTranslated(heading.offsetX * renderProgress * 0.5, heading.offsetY * renderProgress * 0.5,
            heading.offsetZ * renderProgress * 0.5);
    if (finalRenderMode != RenderMode.NONE) {
        GL11.glPushMatrix();
        if (stack.stackSize > 5) {
            GL11.glScaled(0.8, 0.8, 0.8);
        }
        if (!(stack.getItem() instanceof ItemBlock)) {
            GL11.glScaled(0.8, 0.8, 0.8);
            GL11.glTranslated(0, -0.15, 0);
        }

        customRenderItem.doRender(renderedItem, 0, 0, 0, 0, 0);
        GL11.glPopMatrix();
    } else {
        float size = 0.02F;
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glBegin(GL11.GL_QUADS);
        RenderHelper.drawColoredCube(new Vec3dCube(-size, -size, -size, size, size, size), 1, 1, 1, 1);
        GL11.glEnd();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    if (color != TubeColor.NONE) {

        float size = 0.2F;

        int colorInt = ItemDye.field_150922_c[color.ordinal()];
        float red = (colorInt >> 16) / 256F;
        float green = (colorInt >> 8 & 255) / 256F;
        float blue = (colorInt & 255) / 256F;

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor3f(red, green, blue);
        Minecraft.getMinecraft().renderEngine
                .bindTexture(new ResourceLocation(Refs.MODID, "textures/blocks/tubes/inside_color_border.png"));
        RenderHelper.drawTesselatedTexturedCube(new Vec3dCube(-size, -size, -size, size, size, size));
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_LIGHTING);
    }

    GL11.glPopMatrix();
}

From source file:com.breckinloggins.DrawUtils.java

License:Open Source License

public static void drawQuad(float x, float y, int size, float rotation) {
    int halfSize = size / 2;

    GL11.glPushMatrix();/*from w w  w .  j  av a  2s  .com*/
    {
        GL11.glTranslatef(x, y, 0);
        GL11.glRotatef(rotation, 0f, 0f, 1f);
        GL11.glTranslatef(-x, -y, 0);

        GL11.glBegin(GL11.GL_QUADS);
        {
            GL11.glVertex2f(x - halfSize, y - halfSize);
            GL11.glVertex2f(x + halfSize, y - halfSize);
            GL11.glVertex2f(x + halfSize, y + halfSize);
            GL11.glVertex2f(x - halfSize, y + halfSize);
        }
        GL11.glEnd();
    }
    GL11.glPopMatrix();
}