Example usage for org.lwjgl.opengl GL11 glDepthMask

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

Introduction

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

Prototype

public static void glDepthMask(@NativeType("GLboolean") boolean flag) 

Source Link

Document

Masks the writing of depth values to the depth buffer.

Usage

From source file:ccm.placeableTools.client.ToolRenderer.java

License:Open Source License

private void renderSign(double x, double y, double z, float tickTime, int facing, String[] signText, int meta) {
    GL11.glPushMatrix();/*from   w w  w. j a va 2 s  .co m*/
    float f1 = 0.6666667F;
    float f2 = 0.0F;

    switch (facing) {
    case 0:
    case 8:
        f2 = -90f;
        break;
    case 1:
    case 7:
        f2 = 90f;
        break;
    case 2:
    case 5:
        f2 = 180f;
    }

    if (meta >= 2) {
        GL11.glTranslated(0, -1.2, 0);
    }

    GL11.glTranslatef((float) x + 0.5F, (float) y + 0.75F * f1, (float) z + 0.5F);
    GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F);

    GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
    GL11.glTranslatef(0f, 0.8F, 0.5f);
    MODEL_SIGN.signStick.showModel = false;

    if (facing > 4) {
        if (meta >= 2)
            GL11.glTranslated(-0.6, 0, 0);
        //GL11.glTranslated(b ? -0.4 : -0.6, 0, 0);

        if (meta == 2 && facing == 7)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 3 && facing == 8)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 4 && facing == 6)
            GL11.glTranslated(1.2, 0, 0);
        else if (meta == 5 && facing == 5)
            GL11.glTranslated(1.2, 0, 0);
    }

    this.bindTexture(SIGN_TEXTURE);
    GL11.glPushMatrix();
    GL11.glScalef(f1, -f1, -f1);
    MODEL_SIGN.renderSign();
    GL11.glPopMatrix();
    FontRenderer fontrenderer = this.getFontRenderer();
    f2 = 0.016666668F * f1;
    GL11.glTranslatef(0.0F, 0.5F * f1, 0.07F * f1);
    GL11.glScalef(f2, -f2, f2);
    GL11.glNormal3f(0.0F, 0.0F, -1.0F * f2);
    GL11.glDepthMask(false);
    byte b0 = 0;

    for (int j = 0; j < signText.length; ++j) {
        GL11.glPushMatrix();
        String s = signText[j];
        int width = fontrenderer.getStringWidth(s);
        if (width > 95) {
            float f = 1f - ((width) * 0.0015f);
            GL11.glScalef(f, f, f);
        }
        fontrenderer.drawString(s, -width / 2, j * 10 - signText.length * 5, b0);
        GL11.glPopMatrix();
    }

    GL11.glDepthMask(true);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:chb.mods.mffs.client.TECapacitorRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
    if (tileEntity instanceof TileEntityCapacitor) {
        TileEntityCapacitor topview = (TileEntityCapacitor) tileEntity;
        GL11.glPushMatrix();/*from w ww .j a  v a 2s. c o  m*/
        GL11.glPolygonOffset(-10, -10);
        GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
        int side = topview.getSide();
        float dx = 1F / 16;
        float dz = 1F / 16;
        float displayWidth = 1 - 2F / 16;
        float displayHeight = 1 - 2F / 16;
        GL11.glTranslatef((float) x, (float) y, (float) z);
        switch (side) {
        case 1:

            break;
        case 0:
            GL11.glTranslatef(1, 1, 0);
            GL11.glRotatef(180, 1, 0, 0);
            GL11.glRotatef(180, 0, 1, 0);

            break;
        case 3:
            GL11.glTranslatef(0, 1, 0);
            GL11.glRotatef(0, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        case 2:
            GL11.glTranslatef(1, 1, 1);
            GL11.glRotatef(180, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        case 5:
            GL11.glTranslatef(0, 1, 1);
            GL11.glRotatef(90, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        case 4:
            GL11.glTranslatef(1, 1, 0);
            GL11.glRotatef(-90, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        }
        GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
        GL11.glRotatef(-90, 1, 0, 0);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        FontRenderer fontRenderer = this.getFontRenderer();
        int maxWidth = 1;
        String header = "MFFS Capacitor";
        maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth);
        maxWidth += 4;
        int lineHeight = fontRenderer.FONT_HEIGHT + 2;
        int requiredHeight = lineHeight * 1;
        float scaleX = displayWidth / maxWidth;
        float scaleY = displayHeight / requiredHeight;
        float scale = Math.min(scaleX, scaleY);
        GL11.glScalef(scale, -scale, scale);
        GL11.glDepthMask(false);
        int offsetX;
        int offsetY;
        int realHeight = (int) Math.floor(displayHeight / scale);
        int realWidth = (int) Math.floor(displayWidth / scale);

        if (scaleX < scaleY) {
            offsetX = 2;
            offsetY = (realHeight - requiredHeight) / 2;
        } else {
            offsetX = (realWidth - maxWidth) / 2 + 2;
            offsetY = 0;
        }
        GL11.glDisable(GL11.GL_LIGHTING);
        fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight,
                1);
        fontRenderer.drawString("capacity: ", offsetX - realWidth / 2,
                1 + offsetY - realHeight / 2 + 0 * lineHeight, 1);
        fontRenderer.drawString(String.valueOf(topview.getCapacity()).concat(" % "),
                offsetX + realWidth / 2 - offsetX
                        - fontRenderer.getStringWidth(String.valueOf(topview.getCapacity()).concat(" % ")),
                offsetY - realHeight / 2 - 0 * lineHeight, 1);
        fontRenderer.drawString("range: ", offsetX - realWidth / 2,
                1 + offsetY - realHeight / 2 + 1 * lineHeight, 1);
        fontRenderer.drawString(String.valueOf(topview.getTransmitRange()),
                offsetX + realWidth / 2 - offsetX
                        - fontRenderer.getStringWidth(String.valueOf(topview.getTransmitRange())),
                offsetY - realHeight / 2 + 1 * lineHeight, 1);
        fontRenderer.drawString("linked device: ", offsetX - realWidth / 2,
                1 + offsetY - realHeight / 2 + 2 * lineHeight, 1);
        fontRenderer.drawString(String.valueOf(topview.getLinketProjektor()),
                offsetX + realWidth / 2 - offsetX
                        - fontRenderer.getStringWidth(String.valueOf(topview.getLinketProjektor())),
                offsetY - realHeight / 2 + 2 * lineHeight, 1);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthMask(true);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
        GL11.glPopMatrix();
    }
}

From source file:chb.mods.mffs.client.TEExtractorRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float f) {
    if (tileEntity instanceof TileEntityExtractor) {
        TileEntityExtractor topview = (TileEntityExtractor) tileEntity;
        GL11.glPushMatrix();/*from www.  j  a  v  a 2s.co m*/
        GL11.glPolygonOffset(-10, -10);
        GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
        int side = topview.getSide();
        float dx = 1F / 16;
        float dz = 1F / 16;
        float displayWidth = 1 - 2F / 16;
        float displayHeight = 1 - 2F / 16;
        GL11.glTranslatef((float) x, (float) y, (float) z);
        switch (side) {
        case 1:

            break;
        case 0:
            GL11.glTranslatef(1, 1, 0);
            GL11.glRotatef(180, 1, 0, 0);
            GL11.glRotatef(180, 0, 1, 0);

            break;
        case 3:
            GL11.glTranslatef(0, 1, 0);
            GL11.glRotatef(0, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        case 2:
            GL11.glTranslatef(1, 1, 1);
            GL11.glRotatef(180, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        case 5:
            GL11.glTranslatef(0, 1, 1);
            GL11.glRotatef(90, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        case 4:
            GL11.glTranslatef(1, 1, 0);
            GL11.glRotatef(-90, 0, 1, 0);
            GL11.glRotatef(90, 1, 0, 0);

            break;
        }
        GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2);
        GL11.glRotatef(-90, 1, 0, 0);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        FontRenderer fontRenderer = this.getFontRenderer();
        int maxWidth = 1;
        String header = "MFFS Extractor";
        maxWidth = Math.max(fontRenderer.getStringWidth(header), maxWidth);
        maxWidth += 4;
        int lineHeight = fontRenderer.FONT_HEIGHT + 2;
        int requiredHeight = lineHeight * 1;
        float scaleX = displayWidth / maxWidth;
        float scaleY = displayHeight / requiredHeight;
        float scale = Math.min(scaleX, scaleY);
        GL11.glScalef(scale, -scale, scale);
        GL11.glDepthMask(false);
        int offsetX;
        int offsetY;
        int realHeight = (int) Math.floor(displayHeight / scale);
        int realWidth = (int) Math.floor(displayWidth / scale);

        if (scaleX < scaleY) {
            offsetX = 2;
            offsetY = (realHeight - requiredHeight) / 2;
        } else {
            offsetX = (realWidth - maxWidth) / 2 + 2;
            offsetY = 0;
        }
        GL11.glDisable(GL11.GL_LIGHTING);
        fontRenderer.drawString(header, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -2 * lineHeight,
                1);
        fontRenderer.drawString("WE:", offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + -0 * lineHeight,
                1);
        fontRenderer.drawString(String.valueOf(topview.getWorkdone()).concat(" % "),
                offsetX + realWidth / 2 - offsetX
                        - fontRenderer.getStringWidth(String.valueOf(topview.getWorkdone()).concat(" % ")),
                offsetY - realHeight / 2 - 0 * lineHeight, 1);
        fontRenderer.drawString("WC left:", offsetX - realWidth / 2,
                1 + offsetY - realHeight / 2 + 1 * lineHeight, 1);
        fontRenderer.drawString(String.valueOf(topview.getWorkCylce()),
                offsetX + realWidth / 2 - offsetX
                        - fontRenderer.getStringWidth(String.valueOf(topview.getWorkCylce())),
                offsetY - realHeight / 2 + 1 * lineHeight, 1);
        fontRenderer.drawString("FE Cap:", offsetX - realWidth / 2,
                1 + offsetY - realHeight / 2 + 2 * lineHeight, 1);
        fontRenderer.drawString(String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k"),
                offsetX + realWidth / 2 - offsetX
                        - fontRenderer.getStringWidth(
                                String.valueOf(topview.getForceEnergybuffer() / 1000).concat("k")),
                offsetY - realHeight / 2 + 2 * lineHeight, 1);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthMask(true);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
        GL11.glPopMatrix();
    }
}

From source file:chessMod.client.ChessModDrawBlockHighlightHandler.java

License:LGPL

public static void highlightTile(EntityPlayer player, double x, double y, double z, float partialTicks) {

    x += 0.5D;//from w ww  .  j  a va  2 s.co  m
    y += 0.5D;
    z += 0.5D;
    double iPX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks;
    double iPY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks;
    double iPZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks;

    float xScale = 1.0F;
    float yScale = 1;
    float zScale = 1.0F;
    float xShift = 0.0F;
    float yShift = 0.01F;
    float zShift = 0.0F;

    GL11.glDepthMask(false);
    GL11.glDisable(GL11.GL_CULL_FACE);

    for (int i = 4; i < 5; i++) {
        ForgeDirection forgeDir = ForgeDirection.getOrientation(i);
        int zCorrection = i == 2 ? -1 : 1;
        GL11.glPushMatrix();
        GL11.glTranslated(-iPX + x + xShift, -iPY + y + yShift, -iPZ + z + zShift);
        GL11.glScalef(1F * xScale, 1F * yScale, 1F * zScale);
        GL11.glRotatef(90, forgeDir.offsetX, forgeDir.offsetY, forgeDir.offsetZ);
        GL11.glTranslated(0, 0, 0.5f * zCorrection);
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        drawQuad(-0.5F, -0.5F, 1F, 1F, 0F);
        GL11.glPopMatrix();
    }

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(true);
}

From source file:cn.academy.ability.electro.client.render.skill.ChargePlaneEffect.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override//from w  w w  .j  av a 2 s  .co  m
public void renderHud(EntityPlayer player, ScaledResolution sr, long time) {
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(false);
    //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    {
        GL11.glColor4d(1, 1, 1, 0.4);
        double w = sr.getScaledWidth_double(), h = sr.getScaledHeight_double();
        if (lct == 0 || time - lct > 200) {
            lct = time;
            seq.rebuild();
        }
        for (int i = 0; i < 4; ++i) {
            RenderUtils.loadTexture(TEXS[seq.get(i)]);
            HudUtils.drawRect(w * pts[i][0], h * pts[i][1], sizes[i] * w, sizes[i] * w);
        }
        RenderUtils.bindIdentity();
    }
    GL11.glPopMatrix();
    GL11.glDepthMask(true);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
}

From source file:cn.academy.ability.electro.client.render.skill.RailgunPlaneEffect.java

License:Open Source License

@SideOnly(Side.CLIENT)
@Override/*from w  w  w. java2s  .co m*/
public void renderHandEffect(EntityPlayer player, HandRenderType type, long dt) {
    if (type == HandRenderType.EQUIPPED)
        return;
    if (dt < DELAY)
        return;
    dt -= DELAY;

    double tz = dt * dt / 3e4;
    double TRANS_TIME = ANIM_LEN * 0.2;
    double alpha = (dt < TRANS_TIME ? dt / TRANS_TIME
            : (dt > ANIM_LEN - TRANS_TIME ? (ANIM_LEN - dt) / TRANS_TIME : 1));

    //Draw a screen-filling blackout
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_CULL_FACE);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glLoadIdentity();
    GLU.gluOrtho2D(0, 255, 0, 255);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glDepthMask(false);
    GL11.glLoadIdentity();
    {
        GL11.glTranslated(0, 0, 0);
        GL11.glColor4d(0, 0, 0, 0.2 * alpha);
        HudUtils.setZLevel(1);
        HudUtils.drawModalRect(0, 0, 255, 255);
        HudUtils.setZLevel(-90);
    }
    GL11.glDepthMask(true);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPopMatrix();

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

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glMatrixMode(GL11.GL_MODELVIEW); //Restore the matrix

    //Draw the real effect

    GL11.glColor4d(1, 1, 1, alpha * 0.6);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.0f);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(-.4, 0.85 + tz * 0.37, tz);
        GL11.glRotated(-20.4, 1, 0, 0);

        drawSingleSide(7);

        //         GL11.glPushMatrix(); {
        //            GL11.glTranslated(-2.3, 0, 0);
        //            drawSingleSide(7);
        //         } GL11.glPopMatrix();
    }
    GL11.glPopMatrix();

    GL11.glDisable(GL11.GL_ALPHA_TEST);
}

From source file:cn.academy.ability.electro.client.render.skill.SRSmallCharge.java

License:Open Source License

@Override
public void draw() {
    GL11.glDisable(GL11.GL_CULL_FACE);/*from  www.ja v  a2s.com*/
    GL11.glDepthMask(false);
    GL11.glPushMatrix();
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glColor4d(1, 1, 1, 0.7);

    GL11.glTranslated(0, 0.9, 0.2);
    GL11.glRotated(120, 1, 0, 0);
    GL11.glScaled(0.5, 0.5, 0.5);
    //RenderUtils.drawCube(1, 1, 2);
    for (ArcObject arc : arcs) {
        arc.draw();
    }

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

From source file:cn.academy.core.client.component.Glow.java

License:GNU General Public License

public Glow() {
    super("Glow");

    listen(FrameEvent.class, (w, event) -> {
        if (!writeDepth)
            GL11.glDepthMask(false);
        GL11.glPushMatrix();/*from  w  w w  .ja v a 2 s .  co  m*/
        GL11.glTranslated(0, 0, zLevel);
        ACRenderingHelper.drawGlow(0, 0, w.transform.width, w.transform.height, glowSize, color);
        GL11.glPopMatrix();
        GL11.glDepthMask(true);
    });
}

From source file:cn.academy.core.client.gui.dev.PageMain.java

License:Open Source License

private void drawPlayer() {
    EntityPlayer player = dev.user;//from w ww.  j a  va  2s .co m
    RenderUtils.loadTexture(RenderUtils.STEVE_TEXTURE);
    float x = 100, y = 100, scale = 2.1F;
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glPushMatrix();
    {
        GL11.glTranslatef(183, 58, 100F);
        GL11.glScalef((-scale), scale, scale);
        GL11.glRotated(-25, 1, 0, 0);
        RenderHelper.enableStandardItemLighting();
        GL11.glRotatef(Minecraft.getSystemTime() / 100F, 0F, 1F, 0F); //Rotate around Y
        model.render(player, 0, 0, 0, 0, 0, 1F);
    }
    GL11.glPopMatrix();
    RenderHelper.disableStandardItemLighting();
    GL11.glDisable(GL12.GL_RESCALE_NORMAL);
    OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    GL11.glDepthFunc(GL11.GL_ALWAYS);
}

From source file:cn.academy.crafting.client.render.block.RenderImagPhaseLiquid.java

License:GNU General Public License

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float w) {

    if (!(te.getBlockType() instanceof BlockFluidClassic))
        return;//from  w  ww . j ava2  s. c  o m

    BlockFluidClassic liq = (BlockFluidClassic) te.getBlockType();
    double distSq = Minecraft.getMinecraft().thePlayer.getDistanceSq(te.xCoord + .5, te.yCoord + .5,
            te.zCoord + .5);
    double alpha = 1 / (1 + 0.2 * Math.pow(distSq, 0.5));

    if (alpha < 1E-1)
        return;

    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.glDepthMask(false);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_CULL_FACE);

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

    RenderHelper.disableStandardItemLighting();
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.defaultTexUnit, 240f, 240f);
    double ht = 1.2 * Math.sqrt(rbf.getFluidHeightForRender(te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord,
            (BlockFluidBase) te.getBlockType()));

    GL11.glEnable(GL11.GL_BLEND);
    drawLayer(0, -0.3 * ht, 0.3, 0.2, 0.7);
    drawLayer(1, 0.35 * ht, 0.3, 0.05, 0.7);
    if (ht > 0.5)
        drawLayer(2, 0.7 * ht, 0.1, 0.25, 0.7);

    RenderHelper.enableStandardItemLighting();
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);

    GL11.glPopMatrix();
}