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.academy.energy.client.render.block.RenderPhaseGen.java

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float wtf) {
    TilePhaseGen gen = (TilePhaseGen) te;

    GL11.glPushMatrix();
    GL11.glTranslated(x + 0.5, y, z + 0.5);
    int tid = MathUtils.clampi(0, 4, (int) Math.round(4.0 * gen.getLiquidAmount() / gen.getTankSize()));
    RenderUtils.loadTexture(textures[tid]);
    model.renderAll();/*from   w  w w  .j  a  v a 2 s  .c o  m*/
    GL11.glPopMatrix();
}

From source file:cn.academy.energy.client.render.block.RenderWindGenMain.java

License:GNU General Public License

@Override
public void drawAtOrigin(TileEntity te) {
    TileWindGenMain gen = (TileWindGenMain) te;

    GL11.glPushMatrix();

    // draw body/*w  ww  .  j  a va  2  s  .c o  m*/
    RenderUtils.loadTexture(texBody);
    mdlBody.renderAll();

    // draw fan
    if (gen.isFanInstalled() && gen.noObstacle) {
        // update fan rotation
        long time = GameTimer.getTime();
        long dt = gen.lastFrame == -1 ? 0 : time - gen.lastFrame;
        gen.lastFrame = time;
        gen.lastRotation += gen.getSpinSpeed() * dt / 1000.0;

        GL11.glPushMatrix();
        GL11.glTranslated(0, 0.5, 0.82);
        GL11.glRotated(gen.lastRotation, 0, 0, -1);
        RenderUtils.loadTexture(texFan);
        mdlFan.renderAll();
        GL11.glPopMatrix();
    }

    GL11.glPopMatrix();
}

From source file:cn.academy.energy.client.render.tile.RenderMatrix.java

License:Open Source License

@Override
public void renderAtOrigin(TileEntity te) {
    TileMatrix tm = (TileMatrix) te;/*from w  w  w .  ja  va 2s  .  c  o  m*/
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(-1, 0, -1);
        double scale = 0.22;
        GL11.glScaled(scale, scale, scale);
        RenderUtils.loadTexture(tex);

        GL11.glDepthMask(true);
        model.renderPart("base");

        GL11.glPushMatrix();
        {
            GL11.glTranslated(0, 6.3, 0);
            drawCube(tm.isLoaded);
        }
        GL11.glPopMatrix();

        GL11.glDepthMask(false);

        RenderUtils.loadTexture(tex);
        model.renderPart("plate");

    }
    GL11.glPopMatrix();
}

From source file:cn.academy.energy.client.render.tile.RenderNode.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float w) {
    TileNode node = (TileNode) te;//  w  w  w .  j  a v a 2  s .c o m
    RenderUtils.loadTexture(TEX);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, z);

        for (int i = 0; i < 4; ++i) {
            GL11.glPushMatrix();
            GL11.glTranslated(offsets[i][0], 0, offsets[i][1]);
            GL11.glRotated(rots[i], 0, 1, 0);

            //original
            rect.setSize(1, 1);
            rect.map.set(0, 0, 32.0 / 34.0, 1);
            piece.draw();

            //energy bar
            GL11.glTranslated(-0.001, 4 / 32.0, 21.0 / 32.0);
            double cur = node.getEnergy() / node.getMaxEnergy();
            rect.map.set(32.0 / 34.0, 0, 2.0 / 34.0, cur * (15.0 / 32.0));
            rect.setSize(2.0 / 34.0, cur * (15.0 / 32.0));
            piece.draw();

            GL11.glPopMatrix();
        }
        rect.setSize(1, 1);

        RenderUtils.loadTexture(TEX_BTM);
        GL11.glPushMatrix();
        GL11.glTranslated(1, 0, 0);
        GL11.glRotated(90, 0, 0, 1);
        rect.map.set(0, 0, 1, 1);
        piece.draw();
        GL11.glPopMatrix();

        GL11.glPushMatrix();
        GL11.glTranslated(0, 1, 0);
        GL11.glRotated(-90, 0, 0, 1);
        piece.draw();
        GL11.glPopMatrix();

    }
    GL11.glPopMatrix();
}

From source file:cn.academy.energy.client.render.tile.RenderSolarGen.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float u) {
    GL11.glPushMatrix();
    GL11.glTranslated(x + .5, y, z + .5);
    double scale = 0.018;
    GL11.glScaled(scale, scale, scale);/*  w w  w.  ja va 2 s.  co m*/
    RenderUtils.loadTexture(tex);
    model.renderAll();
    GL11.glPopMatrix();
}

From source file:cn.academy.knowledge.client.ui.LifeRecordUI.java

License:Open Source License

private void drawHoveringText(Knowledge l, double mx, double my) {
    final double SIZE_NAME = 48, SIZE_DESC = 44;
    final double W_MARGIN = 20, H_MARGIN = 10;

    GL11.glPushMatrix();

    GL11.glTranslated(mx + 60, my + 5, 1);

    Font font = Font.font;

    double len = Math.max(font.strLen(l.getName(), SIZE_NAME), font.strLen(l.getDesc(), SIZE_DESC));

    double x = -W_MARGIN, y = -H_MARGIN, w = len + 2 * W_MARGIN, h = 46 + SIZE_DESC + 2 * H_MARGIN;

    HudUtils.pushZLevel();/*from   w  w  w  .  ja va2 s .c  o m*/
    HudUtils.zLevel = 0;

    temp.fromHexColor(0xb4343434);
    temp.bind();
    HudUtils.colorRect(x, y, w, h);

    temp.fromHexColor(0xa49d9d9d);
    temp.bind();
    HudUtils.drawRectOutline(x, y, w, h, 2);

    HudUtils.popZLevel();

    font.draw(l.getName(), 0, 0, SIZE_NAME, 0xdcdcdc);
    font.draw(l.getDesc(), 0, 46, SIZE_DESC, 0xb7dcdcdc);

    GL11.glColor4d(1, 1, 1, 1);

    GL11.glPopMatrix();
}

From source file:cn.academy.misc.client.render.RendererCoin.java

License:Open Source License

@Override
public void doRender(Entity var1, double x, double y, double z, float var8, float var9) {
    EntityThrowingCoin etc = (EntityThrowingCoin) var1;
    EntityPlayer player = etc.player;//www . j ava2s.  c om
    boolean fp = player == Minecraft.getMinecraft().thePlayer
            && Minecraft.getMinecraft().gameSettings.thirdPersonView == 0;
    double dt = Minecraft.getSystemTime() - etc.getEntityData().getLong("startTime");
    if (etc.isSync)
        return;
    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, z);
        if (fp) {
            GL11.glRotated(player.rotationYaw, 0, -1, 0);
        } else
            GL11.glRotated(player.renderYawOffset, 0, -1, 0);
        GL11.glTranslated(-0.63, -0.60, 0.30);
        float scale = 0.3F;
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslated(0.5, 0.5, 0);
        GL11.glRotated(dt * 2, etc.axis.xCoord, etc.axis.yCoord, etc.axis.zCoord);
        GL11.glTranslated(-0.5, -0.5, 0);
        RenderUtils.renderItemIn2d(0.0625, ACClientProps.TEX_COIN_FRONT, ACClientProps.TEX_COIN_BACK);
    }
    GL11.glPopMatrix();
}

From source file:cn.academy.misc.client.render.RendererMagHook.java

License:Open Source License

@Override
public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    EntityMagHook hook = (EntityMagHook) ent;
    IModelCustom realModel = model;/*  w w w.  jav  a2  s  .c  o  m*/
    if (hook.isHit) {
        realModel = model_open;
        hook.preRender();
        x = hook.posX - RenderManager.renderPosX;
        y = hook.posY - RenderManager.renderPosY;
        z = hook.posZ - RenderManager.renderPosZ;
    }

    GL11.glPushMatrix();
    RenderUtils.loadTexture(ACClientProps.TEX_MDL_MAGHOOK);
    GL11.glTranslated(x, y, z);
    GL11.glRotated(-hook.rotationYaw + 90, 0, 1, 0);
    GL11.glRotated(hook.rotationPitch - 90, 0, 0, 1);
    double scale = 0.0054;
    GL11.glScaled(scale, scale, scale);
    realModel.renderAll();
    GL11.glPopMatrix();
}

From source file:cn.academy.misc.client.render.RendererRayBase.java

License:Open Source License

@Override
 public final void doRender(Entity var1, double x, double y, double z, float h, float a) {

     long time = Minecraft.getSystemTime();
     T er = (T) var1;
     if (!er.isLoaded()) {
         return;//from  www . java 2 s  .  com
     }
     er.beforeRender();
     x = er.posX - RenderManager.renderPosX;
     y = er.posY - RenderManager.renderPosY;
     z = er.posZ - RenderManager.renderPosZ;

     EntityPlayer clientPlayer = Minecraft.getMinecraft().thePlayer;
     boolean firstPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView == 0
             && clientPlayer.equals(er.getSpawner());

     double len = er.getDisplayRayLen();

     //System.out.println(firstPerson);
     if (er.doesFollowSpawner()) {
         //Pos injection, for better viewing effect
         x = 0;
         y = 0;
         z = 0;
     }

     GL11.glDisable(GL11.GL_ALPHA_TEST);
     GL11.glEnable(GL11.GL_BLEND);
     GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
     GL11.glDisable(GL11.GL_CULL_FACE);
     if (disableLight)
         GL11.glDisable(GL11.GL_LIGHTING);
     GL11.glPushMatrix();
     {
         GL11.glTranslated(x, y, z);
         GL11.glRotated(er.rotationYaw, 0, -1, 0);
         GL11.glRotated(er.rotationPitch, 1, 0, 0);
         GL11.glColor4d(1, 1, 1, alpha * er.getAlpha());

         if (firstPerson) {
             if (er.isNearPlayer())
                 transformFirstPerson(er, x, y, z);
         } else {
             if (er.isNearPlayer())
                 transformThirdPerson(er, x, y, z);
             optimizeView(er, x, y, z);
         }

         if (disableLight) {
             OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
             Tessellator.instance.setBrightness(15728880);
         }
         drawAtOrigin(er, len, firstPerson);
     }
     GL11.glPopMatrix();
     GL11.glEnable(GL11.GL_ALPHA_TEST);
     GL11.glEnable(GL11.GL_LIGHTING);
     GL11.glEnable(GL11.GL_CULL_FACE);
 }

From source file:cn.academy.misc.client.render.RendererRayBlended.java

License:Open Source License

@Override
protected void drawAtOrigin(T ent, double len, boolean w) {
    double width = w ? widthFp : widthTp;

    double forw = width * ratio;
    if (len < 2 * forw)
        len = 2 * forw; //Change to safe range

    GL11.glPushMatrix();
    {//from   www.java  2s  .co  m

        GL11.glTranslated(0, -width * 0.5, 0);

        RenderUtils.loadTexture(blendTex);
        //Beginning blend
        GL11.glPushMatrix();
        rect.map.set(0, 0, 1, 1);
        rect.setSize(forw, width);
        drawer.draw();
        GL11.glPopMatrix();

        //Ending blend
        //         GL11.glPushMatrix();
        //         GL11.glTranslated(0, 0, len);
        //         GL11.glScaled(1, 1, -1);
        //         rect.map.set(0, 0, 1, 1);
        //         drawer.draw();
        //         GL11.glPopMatrix();

        RenderUtils.loadTexture(tex);
        //Real ray
        RenderUtils.loadTexture(tex);
        GL11.glTranslated(0, 0, forw);
        len = len - forw;
        rect.map.set(0, 0, len * ratio, 1);
        rect.setSize(len, width);
        drawer.draw();

    }
    GL11.glPopMatrix();
}