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.lambdalib.template.client.render.block.RenderTileEntityModel.java

License:MIT License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float f) {
    GL11.glPushMatrix();
    {/*w ww. ja v  a  2  s. c o m*/
        GL11.glTranslated(d0 + .5, d1 + yOffset, d2 + .5);
        if (reverse) {
            GL11.glScaled(-scale, -scale, scale);
        } else {
            GL11.glScaled(scale, scale, scale);
        }
        RenderUtils.loadTexture(texture);
        model.render(tileentity, 0F, 0F);
    }
    GL11.glPopMatrix();
}

From source file:cn.lambdalib.template.client.render.entity.RenderCrossedProjectile.java

License:MIT License

@Override
public void doRender(Entity entity, double par2, double par4, double par6, float par8, float par9) {
    Motion3D motion = new Motion3D(entity);
    Tessellator t = Tessellator.instance;

    GL11.glPushMatrix();
    {/*  ww w . j a v a2 s.c om*/
        Vec3 v1 = newV3(0, HEIGHT, 0), v2 = newV3(0, -HEIGHT, 0), v3 = newV3(LENGTH, -HEIGHT, 0),
                v4 = newV3(LENGTH, HEIGHT, 0), v5 = newV3(0, 0, -HEIGHT), v6 = newV3(0, 0, HEIGHT),
                v7 = newV3(LENGTH, 0, HEIGHT), v8 = newV3(LENGTH, 0, -HEIGHT);

        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

        if (renderTexture) {
            bindTexture(TEXTURE_PATH);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glColor3f(colorR, colorG, colorB);
        }
        if (ignoreLight) {
            GL11.glDisable(GL11.GL_LIGHTING);
            OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240f, 240f);
        }

        GL11.glTranslatef((float) par2, (float) par4, (float) par6);

        GL11.glRotatef(90 + entity.rotationYaw, 0.0F, -1.0F, 0.0F); // ?
        GL11.glRotatef(-entity.rotationPitch, 0.0F, 0.0F, 1.0F); // 

        if (this.playerViewOptm) {
            boolean firstPerson = Minecraft.getMinecraft().gameSettings.thirdPersonView == 0;
            if (firstPerson) {
                GL11.glTranslated(fpOffsetX, fpOffsetY, fpOffsetZ);
            } else {
                GL11.glTranslated(tpOffsetX, tpOffsetY, tpOffsetZ);
            }
        }

        t.startDrawingQuads();
        if (ignoreLight)
            t.setBrightness(15728880);

        RenderUtils.addVertex(v1, 0, 0);
        RenderUtils.addVertex(v2, 0, 1);
        RenderUtils.addVertex(v3, 1, 1);
        RenderUtils.addVertex(v4, 1, 0);

        RenderUtils.addVertex(v5, 0, 0);
        RenderUtils.addVertex(v6, 0, 1);
        RenderUtils.addVertex(v7, 1, 1);
        RenderUtils.addVertex(v8, 1, 0);

        t.draw();

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

From source file:cn.lambdalib.template.client.render.entity.RenderIcon.java

License:MIT License

@Override
public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) {
    GL11.glEnable(GL11.GL_BLEND);//from www  .j  a v a2s .  c o  m
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glDisable(GL11.GL_CULL_FACE);
    if (!hasLight)
        GL11.glDisable(GL11.GL_LIGHTING);
    //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glAlphaFunc(GL11.GL_GREATER, minTolerateAlpha);
    GL11.glPushMatrix();
    {
        GL11.glTranslatef((float) par2, (float) par4, (float) par6);
        GL11.glScalef(size, size, size);
        postTranslate(par1Entity);
        if (icon != null)
            RenderUtils.loadTexture(icon);

        Tessellator t = Tessellator.instance;
        this.func_77026_a(par1Entity, t);

    }
    GL11.glPopMatrix();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_CULL_FACE);
}

From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java

License:MIT License

public void renderInventory() {

    GL11.glDisable(GL11.GL_CULL_FACE);/*from   w w  w.j a  v  a 2s . com*/
    GL11.glPushMatrix();
    {

        RenderUtils.loadTexture(texturePath);

        GL11.glTranslated(8.0F + invOffset.x, 8.0F + invOffset.y, 0.0F);
        GL11.glScaled(16F * invScale, 16F * invScale, 16F * invScale);
        float rotation = 145F;
        if (inventorySpin)
            rotation = GameTimer.getAbsTime() / 100F;
        GL11.glRotatef(rotation, 0, 1, 0);
        this.doRotation(invRotation);
        GL11.glScalef(-1F, -1F, 1F);

        renderAtStdPosition();

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

From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java

License:MIT License

public void renderEntityItem(RenderBlocks render, EntityItem ent) {
    GL11.glPushMatrix();
    {/*from  w  w w  .j av a  2 s .  c  o m*/
        RenderUtils.loadTexture(texturePath);
        this.doRotation(entityItemRotation);
        this.doTransformation(entityItemOffset);
        GL11.glScaled(entityItemScale, entityItemScale, entityItemScale);
        renderAtStdPosition();
    }
    GL11.glPopMatrix();
}

From source file:cn.lambdalib.template.client.render.item.RenderModelItem.java

License:MIT License

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

    if (item.stackTagCompound == null)
        item.stackTagCompound = new NBTTagCompound();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    {/*  w  w w . j  av a 2 s.co  m*/
        RenderUtils.loadTexture(texturePath);
        float sc2 = 0.0625F;
        GL11.glRotatef(40F, 0, 0, 1);
        if (type == ItemRenderType.EQUIPPED)
            this.doTransformation(thirdPersonOffset);
        this.doTransformation(equipOffset);
        this.doRotation(equipRotation);
        GL11.glRotatef(90, 0, -1, 0);
        GL11.glScaled(equipScale, equipScale, equipScale);
        if (type == ItemRenderType.EQUIPPED)
            GL11.glScaled(thirdPersonScale, thirdPersonScale, thirdPersonScale);
        renderAtStdPosition(getModelAttribute(item, entity));
    }
    GL11.glPopMatrix();

}

From source file:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

private static void drawEquippedItem(double w, ResourceLocation front, ResourceLocation back, double u1,
        double v1, double u2, double v2, boolean faceOnly) {
    Vec3 a1 = vec(0, 0, w), a2 = vec(1, 0, w), a3 = vec(1, 1, w), a4 = vec(0, 1, w), a5 = vec(0, 0, -w),
            a6 = vec(1, 0, -w), a7 = vec(1, 1, -w), a8 = vec(0, 1, -w);

    Minecraft mc = Minecraft.getMinecraft();

    GL11.glPushMatrix();

    RenderUtils.loadTexture(back);/*from   w w  w .  j  a  v  a  2s .  co m*/
    t.startDrawingQuads();
    t.setNormal(0.0F, 0.0F, 1.0F);
    addVertex(a1, u2, v2);
    addVertex(a2, u1, v2);
    addVertex(a3, u1, v1);
    addVertex(a4, u2, v1);
    t.draw();

    RenderUtils.loadTexture(front);
    t.startDrawingQuads();
    t.setNormal(0.0F, 0.0F, -1.0F);
    addVertex(a8, u2, v1);
    addVertex(a7, u1, v1);
    addVertex(a6, u1, v2);
    addVertex(a5, u2, v2);
    t.draw();

    int var7;
    float var8;
    double var9;
    float var10;

    /*
     * Gets the width/16 of the currently bound texture, used to fix the
     * side rendering issues on textures != 16
     */
    int tileSize = 32;
    float tx = 1.0f / (32 * tileSize);
    float tz = 1.0f / tileSize;

    if (!faceOnly) {
        t.startDrawingQuads();
        t.setNormal(-1.0F, 0.0F, 0.0F);
        for (var7 = 0; var7 < tileSize; ++var7) {
            var8 = (float) var7 / tileSize;
            var9 = u2 - (u2 - u1) * var8 - tx;
            var10 = 1.0F * var8;
            t.addVertexWithUV(var10, 0.0D, -w, var9, v2);
            t.addVertexWithUV(var10, 0.0D, w, var9, v2);
            t.addVertexWithUV(var10, 1.0D, w, var9, v1);
            t.addVertexWithUV(var10, 1.0D, -w, var9, v1);

            t.addVertexWithUV(var10, 1.0D, w, var9, v1);
            t.addVertexWithUV(var10, 0.0D, w, var9, v2);
            t.addVertexWithUV(var10, 0.0D, -w, var9, v2);
            t.addVertexWithUV(var10, 1.0D, -w, var9, v1);
        }
        t.draw();
    }

    GL11.glPopMatrix();
}

From source file:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void renderOverlayEquip(ResourceLocation src) {
    //Setup/*from   w w w .java2s  . c  o m*/
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    //Push texture mat
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F); //xOffset loops between 0.0 and 8.0
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();

    //Second pass
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F; //Loop between 0 and 8, longer loop
    GL11.glTranslatef(-f9, 0.0F, 0.0F); //Still xOffset
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //However, different rotation!
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();
    //Pop texture mat
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void renderOverlayInv(ResourceLocation src) {
    GL11.glDepthFunc(GL11.GL_EQUAL);//from  w  ww. j a va 2 s  .c o m
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    //GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F);
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F;
    GL11.glTranslatef(-f9, 0.0F, 0.0F);
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void drawBlackout() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glDisable(GL11.GL_CULL_FACE);//from ww w.j ava 2s  . c  om
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(1, 0, 1, 0);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();

    GL11.glColor4d(0, 0, 0, 0.7);
    GL11.glTranslated(0, 0, 0);
    HudUtils.colorRect(0, 0, 1, 1);

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPopMatrix();

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

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
}