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.kegare.caveworld.client.renderer.RenderMiningPickaxe.java

License:Minecraft Mod Public

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    FontRenderer renderer = item.getItem().getFontRenderer(item);

    if (renderer == null) {
        renderer = mc.fontRenderer;/*from w ww .  ja  v a  2s  . c  o  m*/
    }

    itemRender.renderItemIntoGUI(renderer, mc.getTextureManager(), item, 0, 0, true);

    Item base = ((ItemMiningPickaxe) item.getItem()).getBaseTool(item);

    if (base != CaveItems.mining_pickaxe) {
        GL11.glPushMatrix();
        GL11.glTranslatef(-9.0F, 14.0F, -9.0F);
        GL11.glScalef(0.6F, 0.6F, 0.6F);
        GL11.glRotatef(-90.0F, 0.0F, 0.0F, 1.0F);
        itemRender.renderItemIntoGUI(renderer, mc.getTextureManager(), new ItemStack(base), 0,
                item.isItemDamaged() ? 13 : 16, true);
        GL11.glPopMatrix();
    }

    String refined = Roman.toRoman(((ItemMiningPickaxe) item.getItem()).getRefined(item));

    if (!Strings.isNullOrEmpty(refined)) {
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPushMatrix();
        GL11.glTranslatef(5.0F, 5.0F, 5.0F);
        GL11.glScalef(0.8F, 0.8F, 0.8F);
        renderer.drawStringWithShadow(refined, 16 - renderer.getStringWidth(refined) - 2,
                item.isItemDamaged() ? 3 : 6, 0xEEEEEE);
        GL11.glPopMatrix();
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
    }
}

From source file:com.kegare.caveworld.handler.CaveEventHooks.java

License:Minecraft Mod Public

@SideOnly(Side.CLIENT)
@SubscribeEvent/* www.j  a va 2s  .c o  m*/
public void onRenderTick(RenderTickEvent event) {
    if (event.phase != Phase.END) {
        return;
    }

    Minecraft mc = FMLClientHandler.instance().getClient();
    ScaledResolution resolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);

    if (mc.thePlayer != null) {
        ItemStack current = mc.thePlayer.getCurrentEquippedItem();

        if (current != null && current.getItem() != null && current.getItem() instanceof ItemMiningPickaxe) {
            ItemMiningPickaxe item = (ItemMiningPickaxe) current.getItem();

            if (item.highlightTicks > 0) {
                GL11.glPushMatrix();
                GL11.glEnable(GL11.GL_BLEND);
                OpenGlHelper.glBlendFunc(770, 771, 1, 0);
                mc.fontRenderer.drawStringWithShadow(item.getModeInfomation(current), 18,
                        resolution.getScaledHeight() - 20, 0xEEEEEE);
                GL11.glDisable(GL11.GL_BLEND);
                GL11.glPopMatrix();

                --item.highlightTicks;
            } else {
                int highlight = ObfuscationReflectionHelper.getPrivateValue(GuiIngame.class, mc.ingameGUI,
                        "remainingHighlightTicks", "field_92017_k");

                if (highlight == 40) {
                    item.highlightTicks = 800;
                }
            }
        }
    }
}

From source file:com.kegare.caveworld.util.CaveUtils.java

License:Minecraft Mod Public

@SideOnly(Side.CLIENT)
public static boolean renderItemStack(Minecraft mc, ItemStack itemstack, int x, int y, boolean overlay,
        String txt) {/*from w  w w  . j  a  v  a 2 s . c om*/
    GL11.glColor3f(1.0F, 1.0F, 1.0F);

    boolean isLightingEnabled = GL11.glIsEnabled(GL11.GL_LIGHTING);
    boolean rc = false;

    if (itemstack != null && itemstack.getItem() != null) {
        Block block = Block.getBlockFromItem(itemstack.getItem());

        if (GameRegistry.findUniqueIdentifierFor(block).modId.equals("EnderIO")
                && !block.renderAsNormalBlock()) {
            return false;
        }

        rc = true;
        boolean isRescaleNormalEnabled = GL11.glIsEnabled(GL12.GL_RESCALE_NORMAL);
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, 0.0F, 32.0F);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glEnable(GL11.GL_LIGHTING);
        short short1 = 240;
        short short2 = 240;
        RenderHelper.enableGUIStandardItemLighting();
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, short1 / 1.0F, short2 / 1.0F);
        RenderItem itemRender = RenderItem.getInstance();

        itemRender.zLevel += 100.0F;
        boolean rendered;

        try {
            rendered = ForgeHooksClient.renderInventoryItem(RenderBlocks.getInstance(), mc.getTextureManager(),
                    itemstack, itemRender.renderWithColor, itemRender.zLevel, x, y);
        } catch (Throwable e) {
            rendered = false;
        }

        if (!rendered) {
            try {
                itemRender.renderItemIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y, true);
            } catch (Throwable e) {
            }
        }

        if (overlay) {
            try {
                itemRender.renderItemOverlayIntoGUI(mc.fontRenderer, mc.getTextureManager(), itemstack, x, y,
                        txt);
            } catch (Throwable e) {
            }
        }

        itemRender.zLevel -= 100.0F;

        GL11.glPopMatrix();

        if (isRescaleNormalEnabled) {
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        } else {
            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        }
    }

    if (isLightingEnabled) {
        GL11.glEnable(GL11.GL_LIGHTING);
    } else {
        GL11.glDisable(GL11.GL_LIGHTING);
    }

    return rc;
}

From source file:com.kegare.frozenland.client.renderer.FrozenlandSkyRenderer.java

License:Minecraft Mod Public

public FrozenlandSkyRenderer() {
    this.starGLCallList = GLAllocation.generateDisplayLists(3);
    GL11.glPushMatrix();// w  ww  .ja  v a  2 s  . c o m
    GL11.glNewList(starGLCallList, GL11.GL_COMPILE);
    renderStars();
    GL11.glEndList();
    GL11.glPopMatrix();
}

From source file:com.kegare.frozenland.client.renderer.FrozenlandSkyRenderer.java

License:Minecraft Mod Public

@Override
public void render(float ticks, WorldClient world, Minecraft mc) {
    GL11.glPushMatrix();//from w  w w . ja v  a2 s  . c o m
    GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(world.getCelestialAngle(ticks) * 360.0F, 1.0F, 0.0F, 0.0F);
    float color = world.getStarBrightness(ticks) * (1.0F - world.getRainStrength(ticks));

    if (color > 0.0F) {
        GL11.glColor4f(color, color, color, color);
        GL11.glCallList(starGLCallList);
    }

    GL11.glPopMatrix();
}

From source file:com.kegare.frozenland.client.renderer.RenderIceball.java

License:Minecraft Mod Public

@Override
public void doRender(Entity entity, double posX, double posY, double posZ, float yaw, float ticks) {
    IIcon icon = Items.snowball.getIconFromDamage(0);

    if (icon != null) {
        GL11.glPushMatrix();//  ww  w  . j  a v a  2 s  . c  o m
        GL11.glTranslatef((float) posX, (float) posY, (float) posZ);
        GL11.glEnable(GL12.GL_RESCALE_NORMAL);
        GL11.glScalef(0.5F, 0.5F, 0.5F);
        bindEntityTexture(entity);
        Tessellator tessellator = Tessellator.instance;
        int i = 0x95CBE7;
        float r = (i >> 16 & 255) / 255.0F;
        float g = (i >> 8 & 255) / 255.0F;
        float b = (i & 255) / 255.0F;
        GL11.glColor3f(r, g, b);
        GL11.glPushMatrix();
        doRender(tessellator, icon);
        GL11.glPopMatrix();
        GL11.glColor3f(1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        GL11.glPopMatrix();
    }
}

From source file:com.kodehawa.gui.api.components.ModuleGui.java

License:Open Source License

public void makeKeybindsFrame() {
    Frame kFrame = new Frame(CheatBase.instance, 250, 10, 120, 20, 0xff550055, 0xaa000000, "Keybinds") {
        @Override/* w ww.  j av a  2 s.co m*/
        public void update() {
            this.draw();
            this.children.clear();
            for (Mod m : CheatBase.instance.mmanager.mods) {
                Label l = new Label(m.name + " - " + Keyboard.getKeyName(m.keyBind), 0xffffff);
                l.setParent(this, (x) + 3, (y) - 21);
                addChild(l);
            }
        }

        @Override
        public void draw() {
            // TODO Auto-generated method stub

            if (color2 > -1) {
                ModGuiUtils.drawRect(x, y, x + width, y + oldHeight, color);
                ModGuiUtils.drawRect(x, y, x + width, y + oldHeight, (int) (color * 1.1));
            } else {
                ModGuiUtils.drawGradientRect(x, y, x + width, y + oldHeight, color, color2);
                ModGuiUtils.drawRect(x, y + oldHeight, x + width, y + height, color2);
            }

            /**
             * Minimize button
             */
            ModGuiUtils.drawFilledCircle((x + width) - 8, y + 7, 2.5, 0xff00dd66);
            if (minimized) {
                ModGuiUtils.drawFilledCircle((x + width) - 8, y + 7, 2.5, 0xaa000000);
            }

            if (pinnable) {
                ModGuiUtils.drawFilledCircle((x + width) - 16, y + 7, 2.5, 0xff72a9dc);
                if (pinned) {
                    ModGuiUtils.drawFilledCircle((x + width) - 16, y + 7, 2.5, 0xaa000000);
                }
            }

            ModGuiUtils.drawHorizontalLine(this.x + 2, (this.x + this.width) - 2, (this.y + this.oldHeight) - 6,
                    2, 0xff550055);

            CheatBase.instance.minecraft.fontRenderer.drawString(this.text, this.x + 3, this.y + 3, 0xff87b5ff);

            if (minimized) {
                this.height = oldHeight;

            } else {
                this.height = (int) (oldHeight + ((oldHeight * this.children.size()) / 1.4) + 5) / 2;
            }
            if (!minimized) {
                GL11.glPushMatrix();
                GL11.glScaled(0.5, 0.5, 0.5);
                for (Item e : children) {
                    e.x = ((this.x) + 3) * 2;
                    int offset = oldHeight;
                    offset /= 8;
                    offset += 4;
                    e.y = ((this.y) + (offset * (this.children.indexOf(e) + 1)) + 15) * 2;

                    e.update();

                }
                GL11.glScaled(1, 1, 1);
                GL11.glPopMatrix();
            }
        }
    };

    kFrame.setPinnable(false);
    addFrame(kFrame);
}

From source file:com.kodehawa.gui.api.components.ModuleGui.java

License:Open Source License

public void makeInfoFrame() {
    final Frame iFrame = new Frame(CheatBase.instance, 250, 30, 120, 20, 0xff550055, 0xaa000000,
            "Player Info") {
        @Override/*from w w  w .j  ava  2  s. c o  m*/
        public void update() {
            this.draw();
            String dim = "Overworld";
            String dir = "NORTH";
            int d = mc.thePlayer.dimension;

            if (d == -1) {
                dim = "Nether";
            }
            if (d == 0) {
                dim = "Overworld";
            }
            if (d == 1) {
                dim = "The End";
            }

            int var24 = MathHelper.floor_double(((mc.thePlayer.rotationYaw * 4.0F) / 360.0F) + 0.5D) & 3;
            dir = Direction.directions[var24];
            try {
                children.clear();
                //addChild( new Label( "User: " + CheatBase.instance.minecraft.thePlayer.username, 0xffffff ) );
                addChild(new Label("FPS: " + mc.debugFPS, 0xffffff));
                addChild(new Label("X: " + (int) CheatBase.instance.minecraft.thePlayer.posX, 0xffffff));
                addChild(new Label("Y: " + (int) CheatBase.instance.minecraft.thePlayer.posY, 0xffffff));
                addChild(new Label("Z: " + (int) CheatBase.instance.minecraft.thePlayer.posZ, 0xffffff));
                addChild(new Label("Dimension: " + dim, 0xffffff));
                //addChild( new Label( "Facing " + dir, 0xffffff ) );

                addChild(new Label("", 0xffffff));
            } catch (Exception e) {
                e.printStackTrace();
            }

        }

        @Override
        public void draw() {
            // TODO Auto-generated method stub

            if (color2 > -1) {
                ModGuiUtils.drawRect(x, y, x + width, y + oldHeight, color);
                ModGuiUtils.drawRect(x, y, x + width, y + oldHeight, (int) (color * 1.1));
            } else {
                ModGuiUtils.drawGradientRect(x, y, x + width, y + oldHeight, color, color2);
                ModGuiUtils.drawRect(x, y + oldHeight, x + width, y + height, color2);
            }

            /**
             * Minimize button
             */
            ModGuiUtils.drawFilledCircle((x + width) - 8, y + 7, 2.5, 0xff00dd66);
            if (minimized) {
                ModGuiUtils.drawFilledCircle((x + width) - 8, y + 7, 2.5, 0xaa000000);
            }

            if (pinnable) {
                ModGuiUtils.drawFilledCircle((x + width) - 16, y + 7, 2.5, 0xff72a9dc);
                if (pinned) {
                    ModGuiUtils.drawFilledCircle((x + width) - 16, y + 7, 2.5, 0xaa000000);
                }
            }

            ModGuiUtils.drawHorizontalLine(this.x + 2, (this.x + this.width) - 2, (this.y + this.oldHeight) - 6,
                    2, 0xff550055);

            CheatBase.instance.minecraft.fontRenderer.drawString(this.text, this.x + 3, this.y + 3, 0xff87b5ff);
            // TTFRenderer.drawTTFString( Colony.guiFont, this.text, x + 2,
            // y, 0x87b5ff );

            if (minimized) {
                this.height = oldHeight;
            } else {
                this.height = (int) (oldHeight + ((oldHeight * this.children.size()) / 1.4) + 5) / 2;
            }
            if (!minimized) {
                GL11.glPushMatrix();
                GL11.glScaled(0.5, 0.5, 0.5);
                for (Item e : children) {
                    e.x = ((this.x) + 3) * 2;
                    int offset = oldHeight;
                    offset /= 8;
                    offset += 4;
                    e.y = ((this.y) + (offset * (this.children.indexOf(e) + 1)) + 15) * 2;

                    e.update();

                }
                GL11.glScaled(1, 1, 1);
                GL11.glPopMatrix();
            }
        }
    };
    iFrame.setPinnable(false);
    addFrame(iFrame);
}

From source file:com.kodehawa.gui.api.components.ModuleGui.java

License:Open Source License

public void makeTestFrame() {
    Frame tFrame = new Frame(CheatBase.instance, 130, 30, 120, 20, 0xff550000, 0xaa000055, "Console") {
        @Override/*from w  w  w .  j  av  a2 s .co m*/
        public void update() {
            this.draw();
            if (this.children.size() > 10) {
                this.removeLater(this.children.get(1));
            }
        }

        @Override
        public void draw() {
            // TODO Auto-generated method stub

            if (color2 > -1) {
                ModGuiUtils.drawRect(x, y, x + width, y + oldHeight, color);
                ModGuiUtils.drawRect(x, y, x + width, y + oldHeight, (int) (color * 1.1));
            } else {
                ModGuiUtils.drawGradientRect(x, y, x + width, y + oldHeight, color, color2);
                ModGuiUtils.drawRect(x, y + oldHeight, x + width, y + height, color2);
            }

            /**
             * Minimize button
             */
            ModGuiUtils.drawFilledCircle((x + width) - 8, y + 7, 2.5, 0xff00dd66);
            if (minimized) {
                ModGuiUtils.drawFilledCircle((x + width) - 8, y + 7, 2.5, 0xaa000000);
            }

            if (pinnable) {
                ModGuiUtils.drawFilledCircle((x + width) - 16, y + 7, 2.5, 0xff72a9dc);
                if (pinned) {
                    ModGuiUtils.drawFilledCircle((x + width) - 16, y + 7, 2.5, 0xaa000000);
                }
            }

            ModGuiUtils.drawHorizontalLine(this.x + 2, (this.x + this.width) - 2, (this.y + this.oldHeight) - 6,
                    2, 0xff550055);

            CheatBase.instance.minecraft.fontRenderer.drawString(this.text, this.x + 3, this.y + 3, 0xff87b5ff);

            // TTFRenderer.drawTTFString( Colony.guiFont, this.text, x + 2,
            // y,
            // 0x87b5ff );

            if (minimized) {
                this.height = oldHeight;

            } else {
                GL11.glPushMatrix();
                GL11.glScaled(0.5, 0.5, 0.5);
                CheatBase.instance.minecraft.fontRenderer.drawString("Type \'clear\' to clear history. ",
                        (this.x * 2) + 6, ((this.y + this.oldHeight) * 2) - 4, 0xffffff);
                GL11.glScaled(1, 1, 1);
                GL11.glPopMatrix();
                int diff = 0;
                if (this.children.size() > 0) {
                    diff = this.children.size() * 2;
                }
                this.height = (int) ((oldHeight + ((oldHeight * this.children.size()) / 1.4) + 5 + diff) / 1.1);
            }
            if (!minimized) {
                for (Item e : children) {
                    e.x = (this.x) + 3;
                    int offset = oldHeight;
                    offset /= 2;
                    offset += 4;
                    e.y = (this.y) + (offset * (this.children.indexOf(e) + 1)) + 10;
                    e.update();
                }
            }
        }
    };

    tFrame.addChild(new TextArea("", tFrame.x, tFrame.y + (tFrame.children.size() * 12), 100, 10, 0x77770077));

    addFrame(tFrame);
}