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:buildcraft.robotics.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderItem(ItemStack stack) {
    float renderScale = 0.5f;
    GL11.glPushMatrix();/*ww w .j  a  v  a2s.c o  m*/
    GL11.glTranslatef(0, 0.28F, 0);
    GL11.glScalef(renderScale, renderScale, renderScale);
    dummyEntityItem.setEntityItemStack(stack);
    customRenderItem.doRender(dummyEntityItem, 0, 0, 0, 0, 0);

    GL11.glPopMatrix();
}

From source file:buildcraft.robotics.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderWearable(EntityRobot entity, TextureManager textureManager, ItemStack wearable) {
    if (wearable.getItem() instanceof IRobotOverlayItem) {
        ((IRobotOverlayItem) wearable.getItem()).renderRobotOverlay(wearable, textureManager);
    } else if (wearable.getItem() instanceof ItemArmor) {
        GL11.glPushMatrix();/* w  w  w .j a  v  a 2  s  . c o  m*/
        GL11.glScalef(1.0125F, 1.0125F, 1.0125F);
        GL11.glTranslatef(0.0f, -0.25f, 0.0f);
        GL11.glRotatef(180F, 0, 0, 1);

        int color = wearable.getItem().getColorFromItemStack(wearable, 0);
        if (color != 16777215) {
            GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT);
            GL11.glColor3ub((byte) (color >> 16), (byte) ((color >> 8) & 255), (byte) (color & 255));
        }

        textureManager.bindTexture(RenderBiped.getArmorResource(entity, wearable, 0, null));
        ModelBiped armorModel = ForgeHooksClient.getArmorModel(entity, wearable, 0, null);
        if (armorModel != null) {
            armorModel.render(entity, 0, 0, 0, -90f, 0, 1 / 16F);

            if (color != 16777215) {
                GL11.glPopAttrib();
            }
        } else {
            GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
            helmetBox.render(1 / 16F);

            if (color != 16777215) {
                this.bindTexture(RenderBiped.getArmorResource(entity, wearable, 0, "overlay"));
                helmetBox.render(1 / 16F);
                GL11.glPopAttrib();
            }
        }

        GL11.glPopMatrix();
    } else if (wearable.getItem() instanceof ItemSkull) {
        doRenderSkull(wearable);
    }
}

From source file:buildcraft.robotics.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderSkull(ItemStack wearable) {
    GL11.glPushMatrix();/*  w  w  w  .ja  v a2s .c  om*/
    GL11.glScalef(1.0125F, 1.0125F, 1.0125F);
    GameProfile gameProfile = null;
    if (wearable.hasTagCompound()) {
        NBTTagCompound nbt = wearable.getTagCompound();
        if (nbt.hasKey("Name")) {
            gameProfile = gameProfileCache.get(nbt.getString("Name"));
        } else if (nbt.hasKey("SkullOwner", NBT.TAG_COMPOUND)) {
            gameProfile = NBTUtil.func_152459_a(nbt.getCompoundTag("SkullOwner"));
            nbt.setString("Name", gameProfile.getName());
            gameProfileCache.put(gameProfile.getName(), gameProfile);
        }
    }

    TileEntitySkullRenderer.field_147536_b.func_152674_a(-0.5F, -0.25F, -0.5F, 1, -90.0F,
            wearable.getItemDamage(), gameProfile);
    if (gameProfile != null) {
        GL11.glTranslatef(0.0f, -0.25f, 0.0f);
        GL11.glRotatef(180F, 0, 0, 1);
        GL11.glRotatef(-90.0f, 0.0f, 1.0f, 0.0f);
        skullOverlayBox.render(1 / 16f);
    }
    GL11.glPopMatrix();
}

From source file:buildcraft.robotics.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderRobot(float factor, TextureManager texManager, float storagePercent, boolean isAsleep) {
    box.render(factor);/*w  ww .  ja  v  a  2  s . c  om*/

    if (!isAsleep) {
        float lastBrightnessX = OpenGlHelper.lastBrightnessX;
        float lastBrightnessY = OpenGlHelper.lastBrightnessY;

        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);

        GL11.glColor4f(1.0F, 1.0F, 1.0F, storagePercent);
        texManager.bindTexture(overlay_red);
        box.render(factor);

        GL11.glDisable(GL11.GL_BLEND);

        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        texManager.bindTexture(overlay_cyan);
        box.render(factor);

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

        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lastBrightnessX, lastBrightnessY);
    }

}

From source file:buildcraft.robots.render.RenderRobot.java

License:Minecraft Mod Public

private void doRender(EntityRobot robot, double x, double y, double z) {
    GL11.glPushMatrix();//from   w  w  w  .ja  v  a 2s .c o  m
    GL11.glTranslated(x, y, z);

    if (robot.getStackInSlot(0) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(-0.125F, 0, -0.125F);
        doRenderItem(robot.getStackInSlot(0));
        GL11.glPopMatrix();
    }

    if (robot.getStackInSlot(1) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(+0.125F, 0, -0.125F);
        doRenderItem(robot.getStackInSlot(1));
        GL11.glPopMatrix();
    }

    if (robot.getStackInSlot(2) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(+0.125F, 0, +0.125F);
        doRenderItem(robot.getStackInSlot(2));
        GL11.glPopMatrix();
    }

    if (robot.getStackInSlot(3) != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(-0.125F, 0, +0.125F);
        doRenderItem(robot.getStackInSlot(3));
        GL11.glPopMatrix();
    }

    if (robot.itemInUse != null) {
        GL11.glPushMatrix();

        GL11.glRotatef((float) (-robot.itemAngle1 / (2 * Math.PI) * 360) + 180, 0, 1, 0);
        GL11.glRotatef((float) (robot.itemAngle2 / (2 * Math.PI) * 360), 0, 0, 1);

        if (robot.itemActive) {
            long newDate = new Date().getTime();
            robot.itemActiveStage = (robot.itemActiveStage + (newDate - robot.lastUpdateTime) / 10) % 45;
            GL11.glRotatef(robot.itemActiveStage, 0, 0, 1);
            robot.lastUpdateTime = newDate;
        }

        GL11.glTranslatef(-0.4F, 0, 0);
        GL11.glRotatef(-45F + 180F, 0, 1, 0);
        GL11.glScalef(0.8F, 0.8F, 0.8F);

        ItemStack itemstack1 = robot.itemInUse;

        if (itemstack1.getItem().requiresMultipleRenderPasses()) {
            for (int k = 0; k < itemstack1.getItem().getRenderPasses(itemstack1.getItemDamage()); ++k) {
                RenderUtils.setGLColorFromInt(itemstack1.getItem().getColorFromItemStack(itemstack1, k));
                this.renderManager.itemRenderer.renderItem(robot, itemstack1, k);
            }
        } else {
            RenderUtils.setGLColorFromInt(itemstack1.getItem().getColorFromItemStack(itemstack1, 0));
            this.renderManager.itemRenderer.renderItem(robot, itemstack1, 0);
        }

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

    if (robot.laser.isVisible) {
        robot.laser.head.x = robot.posX;
        robot.laser.head.y = robot.posY;
        robot.laser.head.z = robot.posZ;

        RenderLaser.doRenderLaser(renderManager.renderEngine, robot.laser, EntityLaser.LASER_TEXTURES[1]);
    }

    if (robot.getTexture() != null) {
        renderManager.renderEngine.bindTexture(robot.getTexture());
        doRenderRobot(1F / 16F, renderManager.renderEngine);
    }

    GL11.glPopMatrix();
}

From source file:buildcraft.robots.render.RenderRobot.java

License:Minecraft Mod Public

@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
    if (RenderManager.instance == null || RenderManager.instance.renderEngine == null) {
        return;// w  ww. j  ava2 s  .c o m
    }

    GL11.glPushMatrix();

    if (item.getItem() == BuildCraftSilicon.robotItem) {
        ItemRobot robot = (ItemRobot) item.getItem();
        RenderManager.instance.renderEngine.bindTexture(robot.getTextureRobot(item));
    }

    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
        GL11.glTranslated(0.0, 1.0, 0.7);
    } else if (type == ItemRenderType.ENTITY) {
        GL11.glScaled(0.6, 0.6, 0.6);
    } else if (type == ItemRenderType.INVENTORY) {
        GL11.glScaled(1.5, 1.5, 1.5);
    }

    doRenderRobot(1F / 16F, RenderManager.instance.renderEngine);

    GL11.glPopMatrix();
}

From source file:buildcraft.robots.render.RenderRobot.java

License:Minecraft Mod Public

private void doRenderRobot(float factor, TextureManager texManager) {
    box.render(factor);//from   w w w.j  a  va  2  s .  c  o m

    GL11.glPushMatrix();
    texManager.bindTexture(overlay);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE);
    GL11.glDepthMask(true);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 61680, 0);
    box.render(factor);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glPopMatrix();
}

From source file:buildcraft.silicon.render.RenderLaserBlock.java

License:Minecraft Mod Public

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

    if (laser != null) {
        GL11.glPushMatrix();/*www  .  ja  va 2  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);

        GL11.glPushMatrix();
        RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser.laser,
                laser.getTexture());
        GL11.glPopMatrix();

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

From source file:buildcraft.silicon.render.RenderLaserTile.java

License:Minecraft Mod Public

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

    if (laser != null) {
        GL11.glPushMatrix();/*from  w  w w. j a  v  a  2s.c o m*/
        GL11.glTranslated(x, y, z);
        GL11.glTranslated(-tileentity.xCoord, -tileentity.yCoord, -tileentity.zCoord);

        GL11.glPushMatrix();
        RenderLaser.doRenderLaser(TileEntityRendererDispatcher.instance.field_147553_e, laser.laser,
                laser.getTexture());
        GL11.glPopMatrix();

        GL11.glPopMatrix();
    }
}

From source file:buildcraft.transport.client.render.PipeRendererTESR.java

License:Minecraft Mod Public

private static void renderWire(TileGenericPipe pipe, double x, double y, double z) {
    PipeWireKey key = new PipeWireKey(pipe.renderState);

    RenderHelper.disableStandardItemLighting();
    TileEntityRendererDispatcher.instance.renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

    GL11.glPushMatrix();/*from   w  w w. j  a va2 s  .  c  o m*/
    GL11.glTranslated(x, y, z);

    PipeModelCacheWire.cacheAll.renderDisplayList(key);
    GL11.glPopMatrix();

    RenderHelper.enableStandardItemLighting();
}