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:cn.weaponmod.api.client.render.RenderBulletWeapon.java

License:Open Source License

public void renderEquipped(ItemStack item, RenderBlocks render, EntityLivingBase entity) {
    Tessellator t = Tessellator.instance;

    int mode = 0;
    if (item.stackTagCompound != null)
        mode = item.getTagCompound().getInteger("mode");

    GL11.glPushMatrix();// w  ww  .  j  a  v a  2s  .c  o m

    InformationBullet inf = (InformationBullet) weaponType.getInformation(item, entity.worldObj);
    if (inf == null) {
        RenderUtils.renderItemIn2d(item, width);
        return;
    }

    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        boolean left = ItemControlHandler.getUsingTickLeft(player, false) == 0 ? true
                : ItemControlHandler.getUsingSide(player);
        boolean firstPerson = (entity == Minecraft.getMinecraft().thePlayer
                && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
                && Minecraft.getMinecraft().currentScreen == null;
        int mt = inf == null ? -1 : (left ? inf.muzzle_left : inf.muzzle_right);
        if (left ? inf.lastShooting_left : inf.lastShooting_right) {
            int dt = inf.getDeltaTick(left);
            float recoverTime = 0.5F * weaponType.upLiftRadius / weaponType.recoverRadius;
            if (dt < recoverTime) {
                float uplift = 2.0F * weaponType.upLiftRadius
                        * MathHelper.cos(mt * (float) Math.PI / recoverTime);
                GL11.glRotatef(uplift, 0.0F, 0.0F, 1.0F);
            }
        }

        if (mt > 0) {
            mt = 3 - mt;
            RenderBulletWeapon.renderMuzzleflashIn2d(t,
                    muzzleflash[mt < muzzleflash.length ? mt : muzzleflash.length - 1], tx, ty, tz);
        }

        if (firstPerson && inf.isReloading) {
            float rotation = weaponType.getRotationForReload(item);
            if (reloadAnimStyle == 0)
                GL11.glRotatef(upliftRatio * rotation * 75F, 0.0F, 1.0F, 0.0F);
            else if (reloadAnimStyle == 1) {
                GL11.glRotatef(upliftRatio * rotation * 17F, 0.0F, 0.0F, -1.0F);
                GL11.glRotatef(upliftRatio * rotation * 30F, 0.0F, -1.0F, 0.0F);
                GL11.glRotatef(upliftRatio * rotation * 14F, 1.0F, 0.0F, 0.0F);
            }
        }
    }
    RenderUtils.renderItemIn2d(item, width);
    GL11.glPopMatrix();
}

From source file:cn.weaponmod.api.client.render.RenderBulletWeapon.java

License:Open Source License

public static void renderMuzzleflashIn2d(Tessellator t, String texture, double tx, double ty, double tz) {

    Vec3 a1 = RenderUtils.newV3(1.2, -0.4, -0.5), a2 = RenderUtils.newV3(1.2, 0.4, -0.5),
            a3 = RenderUtils.newV3(1.2, 0.4, 0.3), a4 = RenderUtils.newV3(1.2, -0.4, 0.3);

    float u1 = 0.0F, v1 = 0.0F, u2 = 1.0F, v2 = 1.0F;

    t = Tessellator.instance;//from  ww  w  . j av  a 2s  .  c  o m
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(texture);

    GL11.glRotatef(45, 0.0F, 0.0F, 1.0F);
    GL11.glTranslated(tx, ty + 0.1F, tz + 0.1F);

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setColorRGBA_F(0.8F, .8F, .8F, 1.0F);
    t.setBrightness(15728880);
    addVertex(a1, u2, v2);
    addVertex(a2, u2, v1);
    addVertex(a3, u1, v1);
    addVertex(a4, u1, v2);
    t.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();

}

From source file:cn.weaponmod.api.client.render.RenderDualWieldWeapon.java

License:Open Source License

@Override
public void renderEquipped(ItemStack item, RenderBlocks render, EntityLivingBase entity, ItemRenderType type) {

    GL11.glPushMatrix();//  w w  w  . j ava 2  s. c  o m

    super.doRenderEquipped(item, render, entity, false, type);

    boolean firstPerson = (entity == Minecraft.getMinecraft().thePlayer
            && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
            && Minecraft.getMinecraft().currentScreen == null;

    GL11.glTranslatef(0.0F, 0.0F, firstPerson ? -1.7F : 0.8F);
    GL11.glScalef(1.0F, 1.0F, -1.0F);

    GL11.glDisable(GL11.GL_CULL_FACE);
    super.doRenderEquipped(item, render, entity, true, type);
    GL11.glEnable(GL11.GL_CULL_FACE);

    GL11.glPopMatrix();

}

From source file:cn.weaponmod.api.client.render.RenderDualWieldWeapon.java

License:Open Source License

@Override
public void renderInventory() {
    GL11.glPushMatrix();/*w w  w . java  2  s  . com*/
    GL11.glTranslatef(-1.5F, -3F, -6.0F);
    super.renderInventory();

    GL11.glTranslatef(3.0F, 3.0F, 6.0F);
    GL11.glRotatef(20, 0.0F, 1.0F, 0.0F);
    super.renderInventory();
    GL11.glPopMatrix();
}

From source file:cn.weaponmod.api.client.render.RendererBulletWeapon.java

License:Open Source License

public static void renderMuzzleflashIn2d(Tessellator t, ResourceLocation texture, double tx, double ty,
        double tz, float size) {
    Vec3 a1 = RenderUtils.newV3(1.2, -0.4, -0.5), a2 = RenderUtils.newV3(1.2, 0.4, -0.5),
            a3 = RenderUtils.newV3(1.2, 0.4, 0.3), a4 = RenderUtils.newV3(1.2, -0.4, 0.3);

    float u1 = 0.0F, v1 = 0.0F, u2 = 1.0F, v2 = 1.0F;

    t = Tessellator.instance;/* w w w .  jav a2s  . c  o  m*/
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(texture);

    GL11.glRotatef(45, 0.0F, 0.0F, 1.0F);
    GL11.glTranslated(tx, ty + 0.1F, tz + 0.1F);
    GL11.glScalef(size, size, size);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setBrightness(15728880);
    addVertex(a1, u2, v2);
    addVertex(a2, u2, v1);
    addVertex(a3, u1, v1);
    addVertex(a4, u1, v2);
    t.draw();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
}

From source file:cn.weaponmod.api.client.render.RendererBulletWeapon.java

License:Open Source License

@Override
protected void renderWeapon(ItemStack stack, EntityPlayer pl, ItemRenderType type) {
    Tessellator t = Tessellator.instance;

    GL11.glPushMatrix();/*from w w w  . ja v  a2 s. c om*/
    RenderUtils.renderItemIn2d(stack, width);
    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.PartedModel.java

License:Open Source License

public void renderAll(String exception) {
    GL11.glPushMatrix();//  www  . ja  va  2 s .c o m
    {
        transformAll.doTransform();
        for (String s : transformData.keySet()) {
            if (!s.equals(exception))
                renderPart(s);
            //System.out.println("render part " + s);
        }
    }
    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.PartedModel.java

License:Open Source License

/**
 * Render the part at the origin, then peform the following transform sequence:
 * move to pivot->scale->rotate->transform->move back from pivot
 * @throws NullPointerException if no such model part
 * @param name The part name//from  w  ww  .j  a  v  a  2  s  . c  om
 */
public void renderPart(String name) {
    CompTransform t = transformData.get(name);
    GL11.glPushMatrix();

    t.doTransform();
    renderAtCenter(name);

    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.RendererWeapon.java

License:Open Source License

private void handleHeldRender(RenderInfo info, boolean firstPerson) {
    GL11.glPushMatrix();/*w  ww .  j  a va 2  s.  co m*/
    model.pushTransformState();
    {

        if (firstPerson) {
            doFirstPersonTansform();
            fpTransform.doTransform();
        } else {
            doThirdPersonTransform();
            tpTransform.doTransform();
        }
        stdTransform.doTransform();
        doFixedTransform();

        info.renderAll(model, firstPerson, 0);

        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPushMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        info.renderAll(model, firstPerson, 1);
        GL11.glMatrixMode(GL11.GL_TEXTURE);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPopMatrix();

        GL11.glDisable(GL11.GL_CULL_FACE);

        RenderUtils.loadTexture(texture);
        model.renderAll();
        GL11.glEnable(GL11.GL_CULL_FACE);
    }
    model.popTransformState();
    GL11.glPopMatrix();
}

From source file:cn.weaponry.api.client.render.RendererWeapon.java

License:Open Source License

private void handleSimpleRender(ItemStack stack) {
    GL11.glPushMatrix();//from w w  w.  java  2 s.c o m
    {
        stdTransform.doTransform();
        doFixedTransform();
        RenderUtils.loadTexture(texture);
        model.renderAll();
    }
    GL11.glPopMatrix();
}