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.mob.client.renderer.RenderTurret.java

License:Open Source License

@Override
public void doRender(Entity entity, double par2, double par4, double par6, float par8, float f1) {
    EntitySentry turret = (EntitySentry) entity;
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);//ww w.  j a v  a 2  s .com
    RenderUtils.loadTexture(ClientProps.TURRET_PATH);
    super.doRender(entity, par2, par4, par6, par8, f1);
    GL11.glTranslatef((float) par2, (float) par4 + turret.height - turret.deathTime * 0.06F, (float) par6);
    GL11.glScalef(-1.0F, -1.0F, 1.0F);
    if (turret.hurtResistantTime > 15)
        GL11.glColor3f(1.0F, 0.3F, 0.3F);
    GL11.glRotatef(turret.deathTime * 3, 1.0F, 0.2F, -1.0F);
    GL11.glRotatef(180.0F - turret.rotationYawHead, 0.0F, 1.0F, 0.0F);
    model.renderTop(entity, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();
}

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

License:Open Source License

@Override
public void doRender(Entity entity, double d0, double d1, double d2, float f, float f1) {
    EntityVortigauntRay ray = (EntityVortigauntRay) entity;

    Tessellator tessellator = Tessellator.instance;

    GL11.glPushMatrix();

    double dx = ray.destX - ray.startX;
    double dy = ray.destY - ray.startY;
    double dz = ray.destZ - ray.startZ;
    double d = Math.sqrt(dx * dx + dy * dy + dz * dz);
    float angle = ray.ticksExisted;
    double tx = 0.0, tz = 0.0;
    double ty = -0.63;

    Vec3 v1 = RenderUtils.newV3(0, 0, -WIDTH), v2 = RenderUtils.newV3(0, 0, WIDTH),

            v5 = RenderUtils.newV3(0, WIDTH, 0), v6 = RenderUtils.newV3(0, -WIDTH, 0);

    // Translations and rotations
    GL11.glDisable(GL11.GL_LIGHTING);//from ww w. j a  v a 2 s  .c o  m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    GL11.glTranslatef((float) d0, (float) d1, (float) d2);
    // GL11.glRotatef(angle, 1.0F, 0, 0);
    int rand = RenderUtils.rand.nextInt(3);
    Minecraft.getMinecraft().renderEngine.bindTexture(ClientProps.VORTIGAUNT_RAY_PATH[rand]);

    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
    tessellator.startDrawingQuads();
    tessellator.setBrightness(15728880);
    tessellator.setColorRGBA(50, 200, 50, 200);

    RenderUtils.addVertex(v1.addVector(tx, ty, tz), 0, 0);
    RenderUtils.addVertex(v2.addVector(tx, ty, tz), 1, 0);
    RenderUtils.addVertex(v2.addVector(dx, dy, dz), 1, d);
    RenderUtils.addVertex(v1.addVector(dx, dy, dz), 0, d);

    RenderUtils.addVertex(v5.addVector(tx, ty, tz), 0, d);
    RenderUtils.addVertex(v6.addVector(tx, ty, tz), 1, d);
    RenderUtils.addVertex(v6.addVector(dx, dy, dz), 1, 0);
    RenderUtils.addVertex(v5.addVector(dx, dy, dz), 0, 0);

    tessellator.draw();

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

From source file:cn.lambdacraft.terrain.client.model.ModelXenAmethyst.java

License:Open Source License

@Override
public void render(TileEntity is, double x, double y, double z, float f1, float scale, float f) {
    GL11.glPushMatrix();
    //      GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
    GL11.glTranslated(x + 0.5, y + 1.6, z + 0.5);
    GL11.glScalef(-1.0F, -1.0F, 1.0F);/*  w w  w.j  a  v  a2 s.  co m*/
    RenderUtils.loadTexture(ClientProps.AMETHYST_PATH);
    Shape1.render(scale);
    Shape2.render(scale);
    Shape3.render(scale);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.terrain.client.model.ModelXenLight.java

License:Open Source License

@Override
public void render(TileEntity is, double x, double y, double z, float f1, float scale, float f) {
    TileEntityXenLight tile = (TileEntityXenLight) is;
    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5);
    GL11.glScalef(-1.0F, -1.0F, 1.0F);//from   w  ww . j  a  v  a 2s . co  m
    RenderUtils.loadTexture(ClientProps.XENLIGHT_PATH);
    Shape1.render(scale);
    //~
    GL11.glRotated(12.5 * MathHelper.sin(tile.ticksExisted * 0.07F), 0.1, 1, -0.1);
    if (tile.isLighting) {
        if (tile.tickSinceChange < 15)
            GL11.glTranslatef(0.0F, 0.0166F * (15 - tile.tickSinceChange), 0.0F);
    } else {
        if (tile.tickSinceChange < 5)
            GL11.glTranslatef(0.0F, 0.05F * tile.tickSinceChange, 0.0F);
        else
            GL11.glTranslatef(0.0F, 0.25F, 0.0F);
    }
    Shape2.render(scale);
    Shape3.render(scale);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.terrain.client.renderer.RenderTileXenAmethyst.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
    TileEntityXenAmethyst amethyst = (TileEntityXenAmethyst) tileentity;
    GL11.glPushMatrix();
    if (amethyst.ticksSinceLastAtack < 10) {
        renderRay(amethyst, Tessellator.instance, d0, d1, d2);
    }/*w w w.j ava2  s  .  com*/
    super.renderTileEntityAt(tileentity, d0, d1, d2, f);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.terrain.client.renderer.RenderTileXenAmethyst.java

License:Open Source License

/**
 * Render the Amethyst ray/*from   w w w  .  j  a v  a  2 s  .c om*/
 * @param ent
 * @param t
 * @param x
 * @param y
 * @param z
 */
private void renderRay(TileEntityXenAmethyst ent, Tessellator t, double x, double y, double z) {
    double dx = ent.lastxCoord, dy = ent.lastyCoord, dz = ent.lastzCoord;
    //       double tx = 0.0, ty = 0.4, tz = 0.0;
    double tx = 0.5, ty = 0.2, tz = 0.5;
    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);
    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[rng.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.663F, 0.263F, 1.0F, 0.65F);
    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.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();

}

From source file:cn.lambdalib.cgui.gui.CGui.java

License:MIT License

private void drawTraverse(double mx, double my, Widget cur, WidgetContainer set, Widget top) {
    try {/*from  w w w  .ja  v  a 2  s .  c  om*/
        if (cur != null && cur.isVisible()) {
            GL11.glPushMatrix();
            GL11.glTranslated(cur.x, cur.y, 0);

            GL11.glDepthFunc(GL11.GL_LEQUAL);
            GL11.glScaled(cur.scale, cur.scale, 1);
            GL11.glTranslated(-cur.transform.pivotX, -cur.transform.pivotY, 0);

            GL11.glColor4d(1, 1, 1, 1); //Force restore color for any widget
            cur.post(new FrameEvent((mx - cur.x) / cur.scale, (my - cur.y) / cur.scale, cur == top));
            GL11.glPopMatrix();
        }
    } catch (Exception e) {
        LambdaLib.log.error("Error occured handling widget draw. instance class: " + cur.getClass().getName()
                + ", name: " + cur.getName());
        e.printStackTrace();
    }

    if (cur == null || cur.isVisible()) {
        Iterator<Widget> iter = set.iterator();
        while (iter.hasNext()) {
            Widget wn = iter.next();
            drawTraverse(mx, my, wn, wn, top);
        }
    }
}

From source file:cn.lambdalib.cgui.gui.CGuiScreen.java

License:MIT License

@Override
public void drawScreen(int mx, int my, float w) {
    gui.resize(width, height);/*from www .jav  a 2 s. co  m*/
    if (drawBack)
        this.drawDefaultBackground();
    GL11.glPushMatrix();
    {
        gui.draw(mx, my);
    }
    GL11.glPopMatrix();
}

From source file:cn.lambdalib.multiblock.RenderBlockMulti.java

License:MIT License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
    if (!(te.getBlockType() instanceof BlockMulti))
        return;// w ww.  j  ava2  s .  co m

    BlockMulti bm = (BlockMulti) te.getBlockType();
    InfoBlockMulti inf = ((IMultiTile) te).getBlockInfo();

    if (inf == null || !inf.isLoaded() || inf.subID != 0)
        return;
    GL11.glPushMatrix();
    double[] off = bm.getPivotOffset(inf);
    double[] off2 = bm.rotCenters[inf.dir.ordinal()];
    GL11.glTranslated(x + off[0] + off2[0], y + 0 + off2[1], z + off[1] + off2[2]);
    // GL11.glTranslated(x, y, z);
    GL11.glRotated(bm.getRotation(inf), 0, 1, 0);
    drawAtOrigin(te);
    GL11.glPopMatrix();
}

From source file:cn.lambdalib.particle.RenderParticle.java

License:MIT License

@Override
public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    if (RenderUtils.isInShadowPass())
        return;/*from  w  w w .j  ava  2  s.c  om*/

    Particle ish = (Particle) ent;
    if (!ish.updated)
        return;

    ish.updateSprite(sprite);

    GL11.glAlphaFunc(GL11.GL_GREATER, 0.05f);
    GL11.glPushMatrix();

    if (ish.needViewOptimize()) {
        GL11.glTranslated(0, -0.2, 0);
    }

    GL11.glTranslated(x, y, z);
    if (ish.customRotation) {
        GL11.glRotatef(ish.rotationYaw, 0, 1, 0);
        GL11.glRotatef(ish.rotationPitch, 0, 0, 1);
    } else {
        GL11.glRotatef(180F - this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
        GL11.glRotatef(-this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
    }

    sprite.draw();

    GL11.glPopMatrix();
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.1f);
}