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:org.terasology.logic.world.Chunk.java

License:Apache License

public void executeOcclusionQuery() {
    GL11.glColorMask(false, false, false, false);
    GL11.glDepthMask(false);

    if (_activeMeshes != null) {
        for (int j = 0; j < VERTICAL_SEGMENTS; j++) {
            if (!isSubMeshEmpty(j)) {
                if (_queries[j] == 0) {
                    _queries[j] = GL15.glGenQueries();

                    GL15.glBeginQuery(GL15.GL_SAMPLES_PASSED, _queries[j]);
                    getSubMeshAABB(j).renderSolid();
                    GL15.glEndQuery(GL15.GL_SAMPLES_PASSED);
                }//w  w w . j a  v  a 2  s  . co  m
            }
        }
    }

    GL11.glColorMask(true, true, true, true);
    GL11.glDepthMask(true);
}

From source file:org.terasology.rendering.opengl.GraphicState.java

License:Apache License

/**
 * Sets the state for the rendering of objects or portions of objects having some degree of transparency.
 *
 * Generally speaking objects drawn with this state will have their color blended with the background
 * color, depending on their opacity. I.e. a 25% opaque foreground object will provide 25% of its
 * color while the background will provide the remaining 75%. The sum of the two RGBA vectors gets
 * written onto the output buffer./*w ww .  j  a  v  a 2s  . com*/
 *
 * Important note: this method disables writing to the Depth Buffer. This is why filters relying on
 * depth information (i.e. DoF) have problems with transparent objects: the depth of their pixels is
 * found to be that of the background. This is an unresolved (unresolv-able?) issue that would only
 * be reversed, not eliminated, by re-enabling writing to the Depth Buffer.
 */
public void preRenderSetupSimpleBlendMaterials() {
    buffers.sceneOpaque.bind();
    setRenderBufferMask(buffers.sceneOpaque, true, true, true);

    GL11.glEnable(GL_BLEND);
    GL11.glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // (*)
    GL11.glDepthMask(false);

    // (*) In this context SRC is Foreground. This effectively says:
    // Resulting RGB = ForegroundRGB * ForegroundAlpha + BackgroundRGB * (1 - ForegroundAlpha)
    // Which might still look complicated, but it's actually the most typical alpha-driven composite.
    // A neat tool to play with this settings can be found here: http://www.andersriggelsen.dk/glblendfunc.php
}

From source file:org.terasology.rendering.opengl.GraphicState.java

License:Apache License

/**
 * Resets the state after the rendering of semi-opaque/semi-transparent objects.
 *
 * See preRenderSetupSimpleBlendMaterials() for additional information.
 *///  ww w . ja  v a 2s  . c  om
public void postRenderCleanupSimpleBlendMaterials() {
    GL11.glDisable(GL_BLEND);
    GL11.glDepthMask(true);

    setRenderBufferMask(buffers.sceneOpaque, true, true, true); // TODO: review - this might be redundant.
    bindDisplay();
}

From source file:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public void glDepthMask(final boolean flag) {
    GL11.glDepthMask(flag);
}

From source file:playn.java.JavaGL20.java

License:Apache License

@Override
public void glDepthMask(boolean flag) {
    GL11.glDepthMask(flag);
}

From source file:processing.lwjgl.PLWJGL.java

License:Open Source License

public void depthMask(boolean mask) {
    GL11.glDepthMask(mask);
}

From source file:processing.opengl.PLWJGL.java

License:Open Source License

@Override
public void depthMask(boolean mask) {
    GL11.glDepthMask(mask);
}

From source file:RediscoveredMod.RenderRedDragon.java

License:Open Source License

/**
 * Renders the animation for when an enderdragon dies
 *///from w  ww .j  a v a 2  s .co  m
protected void renderDragonDying(EntityGoodDragon par1EntityGoodDragon, float par2) {
    super.renderEquippedItems(par1EntityGoodDragon, par2);
    Tessellator tessellator = Tessellator.instance;

    if (par1EntityGoodDragon.deathTicks > 0) {
        RenderHelper.disableStandardItemLighting();
        float f1 = ((float) par1EntityGoodDragon.deathTicks + par2) / 200.0F;
        float f2 = 0.0F;

        if (f1 > 0.8F) {
            f2 = (f1 - 0.8F) / 0.2F;
        }

        Random random = new Random(432L);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glShadeModel(GL11.GL_SMOOTH);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glDepthMask(false);
        GL11.glPushMatrix();
        GL11.glTranslatef(0.0F, -1.0F, -2.0F);

        for (int i = 0; (float) i < (f1 + f1 * f1) / 2.0F * 60.0F; ++i) {
            GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 0.0F, 1.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 1.0F, 0.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F, 0.0F, 1.0F, 0.0F);
            GL11.glRotatef(random.nextFloat() * 360.0F + f1 * 90.0F, 0.0F, 0.0F, 1.0F);
            tessellator.startDrawing(6);
            float f3 = random.nextFloat() * 20.0F + 5.0F + f2 * 10.0F;
            float f4 = random.nextFloat() * 2.0F + 1.0F + f2 * 2.0F;
            tessellator.setColorRGBA_I(16777215, (int) (255.0F * (1.0F - f2)));
            tessellator.addVertex(0.0D, 0.0D, 0.0D);
            tessellator.setColorRGBA_I(16711935, 0);
            tessellator.addVertex(-0.866D * (double) f4, (double) f3, (double) (-0.5F * f4));
            tessellator.addVertex(0.866D * (double) f4, (double) f3, (double) (-0.5F * f4));
            tessellator.addVertex(0.0D, (double) f3, (double) (1.0F * f4));
            tessellator.addVertex(-0.866D * (double) f4, (double) f3, (double) (-0.5F * f4));
            tessellator.draw();
        }

        GL11.glPopMatrix();
        GL11.glDepthMask(true);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glShadeModel(GL11.GL_FLAT);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        RenderHelper.enableStandardItemLighting();
    }
}

From source file:rheel.ac.client.gui.GuiPeriodicBook.java

License:Open Source License

public void drawPeriodicTableItem(int x, int y, float scale, PeriodicItem item) {
    if (item != null) {
        GL11.glPushMatrix();//  w ww  .java2 s  .c om
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

        this.mc.getTextureManager().bindTexture(TextureLoader.getGUITexture("PeriodicBook_Icons.png"));

        for (int i = 0; i < item.getIcons().length; i++) {
            PeriodicIcon icon = item.getIcons()[i];

            if (!PeriodicPlayer.getInstance(this.player).getTable().isIconDiscovered(item, icon)
                    && !this.fullBook) {
                icon = PeriodicIcon.ICON_UNKNOWN;
            }

            final int iconX = x + 1 + (int) (i * 13 / scale);
            final int iconY = y + 1;
            this.drawIcon(iconX, iconY, icon.getTexCoordX(), icon.getTexCoordY(), scale);

            final List<String> overlayText = new ArrayList<String>();
            overlayText.add(icon.getMouseOverText());

            for (final String s : icon.getMouseOverSubText()) {
                overlayText.add(EnumChatFormatting.YELLOW + s);
            }

            this.overlays.put(new Rectangle(iconX, iconY, (int) (12 / scale), (int) ((12 + scale) / scale)),
                    overlayText);
        }

        GL11.glPushMatrix();

        String symbol = item.getSymbol();

        if (!item.isRandom() && !PeriodicPlayer.getInstance(this.player).getTable().isSymbolDiscovered(item)
                && !this.fullBook) {
            symbol = "?";
        }

        float xAdd = (51 - this.fontRenderer.getStringWidth(symbol) / (4 / scale)) / 2 / scale;
        float yAdd = (55 - this.fontRenderer.FONT_HEIGHT / (4 / scale)) / 2 / scale;

        GL11.glScalef(4 / scale, 4 / scale, 4 / scale);
        this.fontRenderer.drawString(symbol,
                (int) ((x + xAdd) / (4 / scale)) - (symbol.length() == 1 ? 0 : 3)
                        - (scale == 1 ? 2 : scale == 2 ? 1 : scale == 4 ? -1 : 0),
                (int) ((y + yAdd) / (4 / scale)) + 1, 0x404040);

        GL11.glPopMatrix();

        final List<String> nameOverlay = new ArrayList<String>();
        String name = item.getName();
        nameOverlay.add(item.getName());

        PeriodicItem clickItem = item;
        PeriodicPlayer player = PeriodicPlayer.getInstance(this.player);
        if (!item.isRandom() && !player.getTable().isStructureDiscovered(item)) {
            item = this.rndItems[item.getPeriod()][player.getTable().getGroupForItem(item)];
        }

        this.overlays.put(new Rectangle(x, y + (int) (16 / scale), (int) (54 / scale), (int) (51 / scale)),
                nameOverlay);
        this.clicks.put(new Rectangle(x, y + (int) (16 / scale), (int) (54 / scale), (int) (51 / scale)),
                new GuiPeriodicPage(this.player, item, this.fullBook));
        this.itemRects.add(new Rectangle(x, y, (int) (54 / scale), (int) (66 / scale)));

        this.mc.getTextureManager().bindTexture(TextureLoader.getGUITexture("PeriodicBook_Icons.png"));

        if (item.isComplex() && (PeriodicPlayer.getInstance(this.player).getTable().isSymbolDiscovered(item)
                || this.fullBook)) {
            GL11.glPushMatrix();
            GL11.glDisable(GL11.GL_DEPTH_TEST);
            GL11.glDepthMask(false);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glDisable(GL11.GL_ALPHA_TEST);

            this.drawComplex(x + 1, y + (int) (18 / scale), 0, 20, scale);
            GL11.glPopMatrix();
        }

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

From source file:rheel.ac.client.gui.GuiResearch.java

License:Open Source License

private void drawStacks(Minecraft mc, int x, int y, boolean remote, int mouseX, int mouseY) {
    if (this.dragged != null) {
        GL11.glPushMatrix();//  www  . j  a  va  2  s  . c  o  m
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glDepthMask(false);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        mc.getTextureManager().bindTexture(TextureLoader.getGUITexture("Research.png"));

        this.drawTexturedModalRect(mouseX - 12, mouseY - 12, 22, 131, 24, 24);

        GL11.glPopMatrix();

        this.drawItemStack(new StackWithPos(this.dragged, mouseX - 8 - x - 100, mouseY - 8 - y - 46), mc,
                remote, x, y);
    }

    for (final StackWithPos stack : this.entity.getItems()) {
        if (remote) {
            if (stack != null) {
                final StackWithPos swp = new StackWithPos(stack.item, stack.x + 100, stack.y + 46);
                this.drawItemStack(swp, mc, remote, x, y);
            }
        } else {
            this.drawItemStack(stack, mc, remote, x, y);

        }
    }
}