Example usage for org.lwjgl.opengl GL11 glPushMatrix

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

Introduction

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

Prototype

public static native void glPushMatrix();

Source Link

Document

Pushes the current matrix stack down by one, duplicating the current matrix in both the top of the stack and the entry below it.

Usage

From source file:cn.lambdacraft.crafting.client.renderer.RenderWire.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
    TileWire wire = (TileWire) tileentity;
    Tessellator t = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glTranslated(d0 + 0.5, d1 + 0.5, d2 + 0.5);
    renderWireBox(t, -1, wire.renderSides);
    for (int i = 0; i < 6; i++) {
        if (wire.renderSides[i])
            renderWireBox(t, i, wire.renderSides);
    }// ww  w . jav  a2  s.  c o m
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.crafting.client.renderer.RenderWire.java

License:Open Source License

private void renderWireBox(Tessellator t, int side, boolean[] theArray) {
    ForgeDirection[] dirs = ForgeDirection.values();
    Vec3 v1 = RenderUtils.newV3(-WIDTH, -WIDTH, -WIDTH), v2 = RenderUtils.newV3(WIDTH, -WIDTH, -WIDTH),
            v3 = RenderUtils.newV3(WIDTH, -WIDTH, WIDTH), v4 = RenderUtils.newV3(-WIDTH, -WIDTH, WIDTH),
            v5 = RenderUtils.newV3(-WIDTH, WIDTH, -WIDTH), v6 = RenderUtils.newV3(WIDTH, WIDTH, -WIDTH),
            v7 = RenderUtils.newV3(WIDTH, WIDTH, WIDTH), v8 = RenderUtils.newV3(-WIDTH, WIDTH, WIDTH);
    GL11.glPushMatrix();
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    float dx = 0.0F, dy = 0.0F, dz = 0.0F;
    switch (side) {
    case 0:/*w  w w  . jav a2 s.  co  m*/
        dy = -1;
        break;
    case 1:
        dy = 1;
        break;
    case 4:
        dx = -1;
        break;
    case 5:
        dx = 1;
        break;
    case 2:
        dz = -1;
        break;
    case 3:
        dz = 1;
        break;
    }
    float offset = (0.5F + WIDTH) / 2F;
    GL11.glTranslatef(dx * offset, dy * offset, dz * offset);
    if (side != -1) {
        float scale = 2F;
        GL11.glScalef(Math.abs(dx == 0.0F ? 1 : dx * scale), Math.abs(dy == 0.0F ? 1 : dy * scale),
                Math.abs(dz == 0.0F ? 1 : dz * scale));
    }
    int a = 0;
    for (int i = 0; i < theArray.length; i++)
        if (theArray[i])
            a++;
    for (int i = 0; i < 6; i++) {
        if (!doesRenderSide(side, i, theArray))
            continue;
        Vec3 vec1 = null, vec2 = null, vec3 = null, vec4 = null;
        dx = 0.0F;
        dy = 0.0F;
        dz = 0.0F;
        switch (i) {
        case 0:
            vec1 = v4;
            vec2 = v3;
            vec3 = v2;
            vec4 = v1;
            dy = -1.0F;
            break;
        case 1:
            vec1 = v5;
            vec2 = v6;
            vec3 = v7;
            vec4 = v8;
            dy = 1.0F;
            break;
        case 4:
            vec1 = v1;
            vec2 = v5;
            vec3 = v8;
            vec4 = v4;
            dx = -1.0F;
            break;
        case 5:
            vec1 = v2;
            vec2 = v3;
            vec3 = v7;
            vec4 = v6;
            dx = 1.0F;
            break;
        case 2:
            vec1 = v1;
            vec2 = v2;
            vec3 = v6;
            vec4 = v5;
            dz = -1.0F;
            break;
        case 3:
            vec1 = v4;
            vec2 = v8;
            vec3 = v7;
            vec4 = v3;
            dz = 1.0F;
            break;
        }
        GL11.glPushMatrix();
        if (side == -1) {
            if (a == 1 && theArray[dirs[i].getOpposite().ordinal()])
                RenderUtils.loadTexture(ClientProps.WIRE_MAIN_PATH);
            else
                RenderUtils.loadTexture(ClientProps.WIRE_SIDE_PATH);
        } else {
            RenderUtils.loadTexture(ClientProps.WIRE_SIDE_PATH2);
        }

        t.startDrawingQuads();
        t.setNormal(dx, dy, dz);
        RenderUtils.addVertex(vec4, 0.0, 1.0);
        RenderUtils.addVertex(vec3, 1.0, 1.0);
        RenderUtils.addVertex(vec2, 1.0, 0.0);
        RenderUtils.addVertex(vec1, 0.0, 0.0);
        t.draw();
        GL11.glPopMatrix();
    }
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.deathmatch.client.HEVRenderingUtils.java

License:Open Source License

public static void drawPlayerHud(EntityPlayer player, ScaledResolution resolution, float partialTickTime) {

    int k = resolution.getScaledWidth();
    int l = resolution.getScaledHeight();
    int i2 = k / 2 - 91;
    int k2 = l - 32 + 3;
    Minecraft mc = Minecraft.getMinecraft();
    TextureManager engine = mc.renderEngine;
    GL11.glEnable(GL11.GL_BLEND);// w  w w  .ja va  2  s  . c o  m
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.6F);
    engine.bindTexture(ClientProps.HEV_HUD_PATH);

    GL11.glPushMatrix();

    double scale = 0.00026 * mc.displayWidth + 0.3;

    float xOffset, yOffset;
    xOffset = 10;
    yOffset = l - 20;
    GL11.glTranslatef(xOffset, yOffset, 0.0F);

    GL11.glScaled(scale, scale, 1.0);
    //Health Section
    HudUtils.setTextureResolution(TEX_WIDTH, TEX_HEIGHT);

    GL11.glColor4f(0.7F, 0.7F, 0.7F, 0.6F);
    HudUtils.drawTexturedModalRect(0, 0, 64, 64, 24, 24, 64, 64);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.6F);
    int h = (int) (player.getHealth() * 16 / 20);
    HudUtils.drawTexturedModalRect(0, 24 - (int) (h * 1.5), 192, 128 - 4 * h, 24, (int) (1.5 * h), 64, 4 * h);
    if (player.getHealth() <= 5)
        GL11.glColor4f(0.9F, 0.1F, 0.1F, 0.6F);
    drawNumberAt((byte) (player.getHealth() * 5), 18, 0);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.9F);

    //Armor Section
    GL11.glColor4f(0.7F, 0.7F, 0.7F, 0.6F);
    HudUtils.drawTexturedModalRect(70, 0, 0, 64, 24, 24, 64, 64);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.6F);
    h = player.getTotalArmorValue() * 16 / 20;
    if (h > 16)
        h = 16;
    HudUtils.drawTexturedModalRect(70, 24 - (int) (h * 1.5), 128, 128 - 4 * h, 24, (int) (h * 1.5), 64, 4 * h);

    drawNumberAt(player.getTotalArmorValue() * 5, 70 + 12, 0);

    GL11.glPopMatrix();

    //Other section
    drawArmorTip(player, engine, k, l);
    if (LCClientPlayer.drawArmorTip)
        drawWeaponTip(player, engine, k, l);

    engine.bindTexture(engine.getResourceLocation(1));
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.7F);
}

From source file:cn.lambdacraft.deathmatch.client.HEVRenderingUtils.java

License:Open Source License

public static void drawCrosshair(ItemStack stack, int k, int l) {
    String xhairPath = null;/*from  w  w w. j  av a  2 s . c om*/
    TextureManager engine = Minecraft.getMinecraft().renderEngine;
    int h = 12;
    if (stack != null) {
        if (stack.getItem() instanceof ISpecialCrosshair) {
            h = ((ISpecialCrosshair) stack.getItem()).getHalfWidth();
            int i = ((ISpecialCrosshair) stack.getItem()).getCrosshairID(stack);
            if (i >= 0)
                xhairPath = ClientProps.xhair_path + "xhair" + i + ".png";
        } else
            xhairPath = ClientProps.getCrosshairPath(stack.getItem().getUnlocalizedName(stack));

        if (xhairPath == null)
            xhairPath = ClientProps.DEFAULT_XHAIR_PATH;
    } else {
        xhairPath = ClientProps.DEFAULT_XHAIR_PATH;
    }
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    int par1 = k / 2 - h, par2 = l / 2 - h;
    RenderUtils.loadTexture(xhairPath);
    Tessellator t = Tessellator.instance;
    t.startDrawingQuads();
    t.setColorRGBA(ClientProps.xHairR, ClientProps.xHairG, ClientProps.xHairB, 255);
    t.addVertexWithUV(par1 + 0, par2 + 2 * h, -90, 0, 1);
    t.addVertexWithUV(par1 + 2 * h, par2 + 2 * h, -90, 1, 1);
    t.addVertexWithUV(par1 + 2 * h, par2 + 0, -90, 1, 0);
    t.addVertexWithUV(par1 + 0, par2 + 0, -90, 0, 0);
    t.draw();

    //TODO: maybe buggy here
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 0.5F, 0.0F, 0.7F);
    GL11.glPopMatrix();
    engine.bindTexture(Gui.icons);
}

From source file:cn.lambdacraft.mob.client.renderer.RenderAlienSlave.java

License:Open Source License

@Override
public void doRender(Entity entity, double x, double y, double z, float par8, float par9) {
    GL11.glPushMatrix();
    EntityAlienSlave slave = (EntityAlienSlave) entity;
    Tessellator t = Tessellator.instance;
    if (slave.isCharging) {
        for (Vec3 vec : slave.electrolyze_left) {
            renderElectro(slave, vec, t, x, y, z, true);
        }//  w w w . ja v a2  s . c o  m

        for (Vec3 vec : slave.electrolyze_right) {
            renderElectro(slave, vec, t, x, y, z, false);
        }
    }
    if (entity.hurtResistantTime > 10)
        GL11.glColor4f(1.0F, 0.3F, 0.3F, 1.0F);
    super.doRender(entity, x, y, z, par8, par9);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.mob.client.renderer.RenderAlienSlave.java

License:Open Source License

private void renderElectro(EntityAlienSlave ent, Vec3 vec3, Tessellator t, double x, double y, double z,
        boolean isLeft) {
    double dx = vec3.xCoord, dy = vec3.yCoord, dz = vec3.zCoord;
    double tx = 0.0, ty = 1.2, tz = 0.0;
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);//from   w  w w  .j ava  2s. c om
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.loadTexture(ClientProps.VORTIGAUNT_RAY_PATH[rand.nextInt(3)]);

    Vec3 v1 = RenderUtils.newV3(tx - WIDTH, ty, tz), v2 = RenderUtils.newV3(tx + WIDTH, ty, tz),
            v3 = RenderUtils.newV3(tx, ty - WIDTH, tz), v4 = RenderUtils.newV3(tx, ty + WIDTH, tz);
    double d = Math.sqrt(dx * dx + dy * dy + dz * dz) * 1.3;

    GL11.glTranslated(x, y, z);

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setBrightness(15728880);
    t.setColorRGBA_F(0.1F, 0.9F, 0.1F, 0.7F);
    RenderUtils.addVertex(v1, 0, 0);
    RenderUtils.addVertex(v2, 1, 0);
    RenderUtils.addVertex(v2.addVector(dx, dy, dz), 1, d);
    RenderUtils.addVertex(v1.addVector(dx, dy, dz), 0, d);

    RenderUtils.addVertex(v3, 0, 0);
    RenderUtils.addVertex(v4, 1, 0);
    RenderUtils.addVertex(v4.addVector(dx, dy, dz), 1, d);
    RenderUtils.addVertex(v3.addVector(dx, dy, dz), 0, d);
    t.draw();

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

}

From source file:cn.lambdacraft.mob.client.renderer.RenderBarnacle.java

License:Open Source License

@Override
public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9) {
    EntityBarnacle barnacle = (EntityBarnacle) entity;
    Tessellator t = Tessellator.instance;
    GL11.glPushMatrix();
    Minecraft.getMinecraft().renderEngine.bindTexture(ClientProps.BARNACLE_PATH);
    GL11.glTranslatef((float) par2, (float) par4 + 2 * entity.height, (float) par6);
    GL11.glScalef(-1.0F, -1.0F, 1.0F);/*from ww w  .j av  a 2 s  .  c om*/
    GL11.glTranslatef(0.0F, 1.5F, 0.0F);
    if (barnacle.getHealth() <= 0)
        GL11.glRotatef(barnacle.deathTime * 6.5F, 1.0F, 0.0F, -1.0F);
    GL11.glTranslatef(0.0F, -1.5F, 0.0F);
    if (barnacle.hurtResistantTime > 10)
        GL11.glColor3f(1.0F, 0.5F, 0.5F);

    this.model.render(entity, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

    if (barnacle.getHealth() > 0) {
        //Barnacle Tentacle Render
        double length = barnacle.tentacleLength;
        double h1 = 0.5, h2 = length + 1.0;
        Vec3 v1 = RenderUtils.newV3(-WIDTH, h1, -WIDTH), v2 = RenderUtils.newV3(-WIDTH, h1, WIDTH),
                v3 = RenderUtils.newV3(WIDTH, h1, WIDTH), v4 = RenderUtils.newV3(WIDTH, h1, -WIDTH);
        Vec3 v5 = RenderUtils.newV3(-WIDTH, h1, -WIDTH), v6 = RenderUtils.newV3(-WIDTH, h2, WIDTH),
                v7 = RenderUtils.newV3(WIDTH, h2, WIDTH), v8 = RenderUtils.newV3(WIDTH, h2, -WIDTH);
        Minecraft.getMinecraft().renderEngine.bindTexture(ClientProps.BARNACLE_TENTACLE_PATH);

        t.startDrawingQuads();
        RenderUtils.addVertex(v1, 0.0, 0.0);
        RenderUtils.addVertex(v5, 0.0, length);
        RenderUtils.addVertex(v6, 1.0, length);
        RenderUtils.addVertex(v2, 1.0, 0.0);

        RenderUtils.addVertex(v2, 0.0, 0.0);
        RenderUtils.addVertex(v6, 0.0, length);
        RenderUtils.addVertex(v7, 1.0, length);
        RenderUtils.addVertex(v3, 1.0, 0.0);

        RenderUtils.addVertex(v3, 0.0, 0.0);
        RenderUtils.addVertex(v7, 0.0, length);
        RenderUtils.addVertex(v8, 1.0, length);
        RenderUtils.addVertex(v4, 1.0, 0.0);

        RenderUtils.addVertex(v4, 0.0, 0.0);
        RenderUtils.addVertex(v8, 0.0, length);
        RenderUtils.addVertex(v5, 1.0, length);
        RenderUtils.addVertex(v1, 1.0, 0.0);

        RenderUtils.addVertex(v8, 0.0, 0.0);
        RenderUtils.addVertex(v7, 0.0, 0.1);
        RenderUtils.addVertex(v6, 0.1, 0.1);
        RenderUtils.addVertex(v5, 0.1, 0.0);
        t.draw();
    }
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.mob.client.renderer.RenderHoundeye.java

License:Open Source License

@Override
public void func_110827_b(EntityLiving ent, double par2, double par4, double par6, float par8, float par9) {
    GL11.glPushMatrix();
    float yOffset = ent.prevLimbSwingAmount + (ent.limbSwingAmount - ent.prevLimbSwingAmount) * par9;
    float xOffset = 0.0F, zOffset = 0.0F;
    if (((EntityHoundeye) ent).isCharging) {
        xOffset = rand.nextFloat() * 0.3F;
        zOffset = rand.nextFloat() * 0.3F;
        yOffset += rand.nextFloat() * 0.3F;
    }/*from w w  w.  j a  va  2 s  .c o  m*/
    if (yOffset > 1.0F)
        yOffset = 1.0F;
    yOffset *= 0.2F;
    GL11.glTranslatef(xOffset, yOffset, zOffset);
    super.func_110827_b(ent, par2, par4, par6, par8, par9);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.mob.client.renderer.RenderSentryRay.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
    this.doRender(tile, x, y, z, f);
    TileSentryRay ray = (TileSentryRay) tile, ray2 = ray.linkedBlock;
    double width = 0.015;
    if (ray2 != null) {
        Vec3 v = ray2.getRayOffset();//from   w  w w.  j  ava 2 s.c  om
        Vec3 va = ray.getRayOffset();
        double x1 = x + ray2.xCoord + v.xCoord - ray.xCoord, y1 = y + ray2.yCoord + v.yCoord - ray.yCoord,
                z1 = z + ray2.zCoord + v.zCoord - ray.zCoord;
        x += va.xCoord;
        y += va.yCoord;
        z += va.zCoord;
        Vec3 v1 = getVec3(0, 0, -width).addVector(x, y, z), v2 = getVec3(0, 0, width).addVector(x, y, z),
                v3 = getVec3(0, 0, width).addVector(x1, y1, z1),
                v4 = getVec3(0, 0, -width).addVector(x1, y1, z1);

        Vec3 v5 = getVec3(-width, 0, 0).addVector(x, y, z), v6 = getVec3(width, 0, 0).addVector(x, y, z),
                v7 = getVec3(width, 0, 0).addVector(x1, y1, z1),
                v8 = getVec3(-width, 0, 0).addVector(x1, y1, z1);

        Vec3 v9 = getVec3(0, -width, 0).addVector(x, y, z), v10 = getVec3(0, width, 0).addVector(x, y, z),
                v11 = getVec3(0, width, 0).addVector(x1, y1, z1),
                v12 = getVec3(0, -width, 0).addVector(x1, y1, z1);
        double dist = ray.getDistanceFrom(ray2.xCoord, ray2.yCoord, ray2.zCoord);
        GL11.glPushMatrix();
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        Tessellator t = Tessellator.instance;

        t.startDrawingQuads();
        t.setColorRGBA_F(1.0F, 0.2F, 0.2F, 0.65F);
        t.setBrightness(512);
        RenderUtils.addVertex(v1, 0, 0);
        RenderUtils.addVertex(v2, 0, 1);
        RenderUtils.addVertex(v3, dist, 1);
        RenderUtils.addVertex(v4, dist, 0);

        RenderUtils.addVertex(v5, 0, 0);
        RenderUtils.addVertex(v6, 0, 1);
        RenderUtils.addVertex(v7, dist, 1);
        RenderUtils.addVertex(v8, dist, 0);
        RenderUtils.addVertex(v9, 0, 0);
        RenderUtils.addVertex(v10, 0, 1);
        RenderUtils.addVertex(v11, dist, 1);
        RenderUtils.addVertex(v12, dist, 0);

        t.draw();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
    }
}

From source file:cn.lambdacraft.mob.client.renderer.RenderShockwave.java

License:Open Source License

protected void renderWave(Tessellator t, double x, double y, double z, float radius) {
    GL11.glPushMatrix();

    GL11.glTranslated(x, y, z);//from w ww  .  ja  va2  s .  c  om
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    t.startDrawingQuads();
    t.setColorRGBA(255, 255, 255, 128);
    t.setBrightness(15728880);

    t.addVertexWithUV(-radius, 0.0, -radius, 0.0, 0.0);
    t.addVertexWithUV(-radius, 0.0, radius, 0.0, 1.0);
    t.addVertexWithUV(radius, 0.0, radius, 1.0, 1.0);
    t.addVertexWithUV(radius, 0.0, -radius, 1.0, 0.0);

    t.draw();

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
}