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.vanilla.meltdowner.client.render.RenderMdShield.java

License:GNU General Public License

@Override
public void doRender(Entity _entity, double x, double y, double z, float a, float b) {
    if (RenderUtils.isInShadowPass()) {
        return;//w  w w . j  a  v  a 2s. com
    }

    long time = GameTimer.getTime();
    EntityMdShield entity = (EntityMdShield) _entity;

    // Calculate rotation
    long dt;
    if (entity.lastRender == 0)
        dt = 0;
    else
        dt = time - entity.lastRender;

    float rotationSpeed = MathUtils.lerpf(0.8f, 2f, Math.min(entity.ticksExisted / 30.0f, 1f));
    entity.rotation += rotationSpeed * dt;
    if (entity.rotation >= 360f)
        entity.rotation -= 360f;

    ShaderSimple.instance().useProgram();
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.05f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();

    GL11.glTranslated(x, y, z);
    GL11.glRotatef(-entity.rotationYaw, 0, 1, 0);
    GL11.glRotatef(entity.rotationPitch, 1, 0, 0);
    GL11.glRotatef(entity.rotation, 0, 0, 1);

    float size = EntityMdShield.SIZE * MathUtils.lerpf(0.2f, 1f, Math.min(entity.ticksExisted / 15.0f, 1f));
    float alpha = Math.min(entity.ticksExisted / 6.0f, 1.0f);

    GL11.glScalef(size, size, 1);

    RenderUtils.loadTexture(texture);
    mesh.draw(ShaderSimple.instance());

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.1f);
    GL20.glUseProgram(0);

    entity.lastRender = time;
}

From source file:cn.academy.vanilla.teleporter.client.MarkRender.java

License:GNU General Public License

@Override
public void doRender(Entity ent, double x, double y, double z, float var8, float var9) {
    if (RenderUtils.isInShadowPass())
        return;//  w  w w . j  a v  a 2  s.  com

    EntityTPMarking mark = (EntityTPMarking) ent;
    if (!mark.firstUpdated())
        return;

    int texID = (int) ((mark.ticksExisted / 2.5) % tex.length);

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

    GL11.glPushMatrix();
    {
        GL11.glTranslated(x, y, z);

        GL11.glRotated(-mark.rotationYaw, 0, 1, 0);
        GL11.glScaled(-1, -1, 1);
        ShaderSimple.instance().useProgram();
        RenderUtils.loadTexture(tex[texID]);

        if (!mark.available) {
            GL11.glColor4d(1, 0.2, 0.2, 1);
        } else {
            GL11.glColor4d(1, 1, 1, 1);
        }

        model.draw();
        GL20.glUseProgram(0);
    }
    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:cn.academy.vanilla.teleporter.client.RenderMarker.java

License:GNU General Public License

@Override
public void doRender(Entity ent, double x, double y, double z, float a, float b) {
    EntityMarker marker = (EntityMarker) ent;
    if (!marker.firstUpdated())
        return;//from   ww w  .j  a v a  2  s .  com

    Entity targ = marker.target;
    float width, height;
    if (targ != null) {
        width = targ.width;
        height = targ.height;
    } else {
        width = marker.width;
        height = marker.height;
    }

    ShaderNotex.instance().useProgram();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    if (marker.ignoreDepth)
        GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();

    GL11.glTranslated(x - width / 2, y + 0.05 * Math.sin(GameTimer.getAbsTime() / 400.0), z - width / 2);
    marker.color.bind();
    renderMark(width, height);

    GL11.glPopMatrix();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL20.glUseProgram(0);
}

From source file:cn.academy.vanilla.teleporter.client.RenderMarker.java

License:GNU General Public License

protected void renderMark(float width, float height) {
    for (int i = 0; i < 8; ++i) {
        GL11.glPushMatrix();

        boolean rev = i < 4;
        double sx = width * mulArray[i][0], sy = height * mulArray[i][1], sz = width * mulArray[i][2];
        final double len = 0.2 * width;
        GL11.glTranslated(sx, sy, sz);// ww w  .  j av  a2s  .co  m
        GL11.glRotated(rotArray[i], 0, 1, 0);
        GL11.glLineWidth(3f);
        t.startDrawing(GL11.GL_LINES);
        t.setBrightness(15728880);
        t.addVertex(0, 0, 0);
        t.addVertex(0, rev ? len : -len, 0);
        t.addVertex(0, 0, 0);
        t.addVertex(len, 0, 0);
        t.addVertex(0, 0, 0);
        t.addVertex(0, 0, len);
        t.draw();

        GL11.glPopMatrix();
    }
}

From source file:cn.lambdacraft.crafting.block.crafter.GuiElectricCrafter.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);// w w  w.  ja va  2  s. com
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    RenderUtils.loadTexture(ClientProps.GUI_ELCRAFTER_PATH);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    int height = tileEntity.heatForRendering * 46 / tileEntity.maxHeat;
    if (height > 0) {
        drawTexturedModalRect(x + 138, y + 63 - height, 181, 0, 6, height);
    }
    height = tileEntity.currentEnergy * 46 / TileElCrafter.MAX_STORAGE;
    if (height > 0) {
        drawTexturedModalRect(x + 116, y + 63 - height, 174, 0, 6, height);
    }
    if (tileEntity.isCrafting && tileEntity.currentRecipe != null) {
        if (tileEntity.heatRequired > 0) {
            height = tileEntity.heatRequired * 46 / tileEntity.maxHeat;
            drawTexturedModalRect(x + 136, y + 63 - height, 207, 1, 6, 3);
        }
    }

    this.drawElements(i, j);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.crafting.client.gui.GuiBatBox.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    mc.renderEngine.bindTexture(ClientProps.GUI_BATBOX_PATH);
    GL11.glEnable(GL11.GL_BLEND);/* ww w.j  a  va2s .c om*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);

    if (te.currentEnergy > 0) {
        int len = te.currentEnergy * 68 / te.maxStorage;
        this.drawTexturedModalRect(x + 53, y + 38, 173, 10, len, 7);
    }

    this.drawElements();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.crafting.client.gui.GuiElectricCrafter.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);//w  ww  . j  av a  2  s . c om
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bindTexture(ClientProps.GUI_ELCRAFTER_PATH);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    int height = tileEntity.heatForRendering * 46 / tileEntity.maxHeat;
    if (height > 0) {
        drawTexturedModalRect(x + 138, y + 63 - height, 181, 0, 6, height);
    }
    height = tileEntity.currentEnergy * 46 / TileElCrafter.MAX_STORAGE;
    if (height > 0) {
        drawTexturedModalRect(x + 116, y + 63 - height, 174, 0, 6, height);
    }
    if (tileEntity.isCrafting && tileEntity.currentRecipe != null) {
        if (tileEntity.heatRequired > 0) {
            height = tileEntity.heatRequired * 46 / tileEntity.maxHeat;
            drawTexturedModalRect(x + 136, y + 63 - height, 207, 1, 6, 3);
        }
    }
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.crafting.client.gui.GuiGenFire.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);//from   w  ww. j  a  v  a2s  .c o m
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bindTexture(ClientProps.GUI_GENFIRE_PATH);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    int len = 0;
    if (te.maxBurnTime > 0) {
        len = te.tickLeft * 39 / te.maxBurnTime;
        this.drawTexturedModalRect(x + 109, y + 52, 173, 0, len, 3);
    }
    len = te.currentEnergy * 50 / te.maxStorage;
    if (len > 0)
        this.drawTexturedModalRect(x + 75, y + 65 - len, 173, 55 - len, 14, len);
    this.drawElements();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.crafting.client.gui.GuiGenLava.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);/*  ww  w.  jav a2 s. com*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bindTexture(ClientProps.GUI_GENLAVA_PATH);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    int len = 0;
    len = te.bucketCnt * 47 / te.maxStorage;
    len += Math.round(2.35F * te.currentEnergy / TileGeneratorLava.ENERGY_PER_BUCKET);
    this.drawTexturedModalRect(x + 91, y + 65 - len, 173, 59 - len, 6, len);
    this.drawElements();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}

From source file:cn.lambdacraft.crafting.client.gui.GuiGenSolar.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);/*from w  ww. j a  v a2s  .com*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    bindTexture(ClientProps.GUI_GENSOLAR_PATH);
    int x = (width - xSize) / 2;
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    int len = 0;
    len = te.currentEnergy * 48 / te.maxStorage;
    if (len > 0)
        this.drawTexturedModalRect(x + 24, y + 52, 174, 70, len, 7);
    if (te.worldObj.isDaytime()) {
        this.drawTexturedModalRect(x + 13, y + 19, 173, 0, 60, 30);
        this.drawTexturedModalRect(x + 86, y + 44, 186, 9, 5, 5);
    } else {
        this.drawTexturedModalRect(x + 13, y + 19, 173, 34, 60, 30);
        this.drawTexturedModalRect(x + 86, y + 44, 186, 44, 5, 5);
    }
    this.drawElements();
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glPopMatrix();
}