Example usage for org.lwjgl.opengl GL11 glStencilOp

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

Introduction

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

Prototype

public static void glStencilOp(@NativeType("GLenum") int sfail, @NativeType("GLenum") int dpfail,
        @NativeType("GLenum") int dppass) 

Source Link

Document

Indicates what happens to the stored stencil value if this or certain subsequent tests fail or pass.

Usage

From source file:matteroverdrive.util.RenderUtils.java

License:Open Source License

public static void drawStencil(int xMin, int yMin, int xMax, int yMax, int mask) {
    GL11.glDisable(GL_TEXTURE_2D);//from   ww w.j  av a2 s  .  c  o m
    GL11.glStencilFunc(GL_ALWAYS, mask, mask);
    GL11.glStencilOp(0, 0, GL_REPLACE);
    GL11.glStencilMask(1);
    GL11.glColorMask(false, false, false, false);
    GL11.glDepthMask(false);
    Tessellator.instance.startDrawingQuads();
    Tessellator.instance.addVertex((double) xMin, (double) yMax, 0.0D);
    Tessellator.instance.addVertex((double) xMax, (double) yMax, 0.0D);
    Tessellator.instance.addVertex((double) xMax, (double) yMin, 0.0D);
    Tessellator.instance.addVertex((double) xMin, (double) yMin, 0.0D);
    Tessellator.instance.draw();
    GL11.glEnable(GL_TEXTURE_2D);
    GL11.glStencilFunc(GL_EQUAL, mask, mask);
    GL11.glStencilMask(0);
    GL11.glColorMask(true, true, true, true);
    GL11.glDepthMask(true);
}

From source file:org.oscim.gdx.LwjglGL20.java

License:Apache License

public void stencilOp(int fail, int zfail, int zpass) {
    GL11.glStencilOp(fail, zfail, zpass);
}

From source file:org.spoutcraft.api.gui.renderer.GuiRendererFBO.java

License:MIT License

@Override
public void setClip(int x, int y, int width, int height) {
    super.setClip(x, y, width, height);
    GL11.glColorMask(false, false, false, false);
    GL11.glDepthMask(false);//  w w  w  .  j a v  a 2s.c  o m
    GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
    GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
    GL11.glStencilMask(0xFF);
    clearClip();
    //Actually fill stencil area
    RenderUtil.drawRect(x, y, width, height, Color.WHITE);

    GL11.glColorMask(true, true, true, true);
    GL11.glDepthMask(true);
    GL11.glStencilMask(0x00);
    GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
}

From source file:playn.java.JavaGL20.java

License:Apache License

@Override
public void glStencilOp(int fail, int zfail, int zpass) {
    GL11.glStencilOp(fail, zfail, zpass);
}

From source file:processing.lwjgl.PLWJGL.java

License:Open Source License

public void stencilOp(int sfail, int dpfail, int dppass) {
    GL11.glStencilOp(sfail, dpfail, dppass);
}

From source file:processing.opengl.PLWJGL.java

License:Open Source License

@Override
public void stencilOp(int sfail, int dpfail, int dppass) {
    GL11.glStencilOp(sfail, dpfail, dppass);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glStencilOp(int a, int b, int c) {
    GL11.glStencilOp(a, b, c);
}

From source file:vazkii.botania.client.core.helper.RenderHelper.java

License:Open Source License

public static void renderProgressPie(int x, int y, float progress, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GlStateManager.colorMask(false, false, false, false);
    GlStateManager.depthMask(false);//from www.  j a va  2  s  .  c o  m
    GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
    GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
    GL11.glStencilMask(0xFF);
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    mc.renderEngine.bindTexture(new ResourceLocation(LibResources.GUI_MANA_HUD));
    int r = 10;
    int centerX = x + 8;
    int centerY = y + 8;
    int degs = (int) (360 * progress);
    float a = 0.5F + 0.2F
            * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10)
                    * 0.5F + 0.5F);

    GlStateManager.disableLighting();
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.depthMask(true);
    GL11.glStencilMask(0x00);
    GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);

    VertexBuffer buf = Tessellator.getInstance().getBuffer();
    buf.begin(GL11.GL_TRIANGLE_FAN, DefaultVertexFormats.POSITION_COLOR);
    buf.pos(centerX, centerY, 0).color(0, 0.5F, 0.5F, a).endVertex();

    for (int i = degs; i > 0; i--) {
        double rad = (i - 90) / 180F * Math.PI;
        buf.pos(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r, 0).color(0F, 1F, 0.5F, a).endVertex();
    }

    buf.pos(centerX, centerY, 0).color(0F, 1F, 0.5F, a).endVertex();
    Tessellator.getInstance().draw();

    GlStateManager.disableBlend();
    GlStateManager.enableTexture2D();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_STENCIL_TEST);
}

From source file:vazkii.psi.client.core.helper.PsiRenderHelper.java

public static void renderProgressPie(int x, int y, float progress, ItemStack stack) {
    Minecraft mc = Minecraft.getMinecraft();
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    GlStateManager.clear(GL11.GL_DEPTH_BUFFER_BIT);
    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GlStateManager.colorMask(false, false, false, false);
    GlStateManager.depthMask(false);/*from   ww w .  j  a  va  2s.  c  om*/
    GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
    GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);
    GL11.glStencilMask(0xFF);
    mc.getRenderItem().renderItemAndEffectIntoGUI(stack, x, y);

    int r = 10;
    int centerX = x + 8;
    int centerY = y + 8;
    int degs = (int) (360 * progress);
    float a = 0.5F + 0.2F
            * ((float) Math.cos((double) (ClientTickHandler.ticksInGame + ClientTickHandler.partialTicks) / 10)
                    * 0.5F + 0.5F);

    GlStateManager.disableLighting();
    GlStateManager.disableTexture2D();
    GlStateManager.shadeModel(GL11.GL_SMOOTH);
    GlStateManager.enableBlend();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GlStateManager.colorMask(true, true, true, true);
    GlStateManager.depthMask(true);
    GL11.glStencilMask(0x00);
    GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GlStateManager.color(0F, 0.5F, 0.5F, a);
    GL11.glVertex2i(centerX, centerY);
    GlStateManager.color(0F, 1F, 0.5F, a);
    for (int i = degs; i > 0; i--) {
        double rad = (i - 90) / 180F * Math.PI;
        GL11.glVertex2d(centerX + Math.cos(rad) * r, centerY + Math.sin(rad) * r);
    }
    GL11.glVertex2i(centerX, centerY);
    GL11.glEnd();
    GlStateManager.disableBlend();
    GlStateManager.enableTexture2D();
    GlStateManager.shadeModel(GL11.GL_FLAT);
    GL11.glDisable(GL11.GL_STENCIL_TEST);
}

From source file:zsawyer.mods.stereoscopic3d.renderers.StencilingRenderer.java

License:Open Source License

protected synchronized void reinit() {
    reinitPending = true;//from   www .  j a va  2 s  .c om

    if (!Display.isDirty()) {
        int width = mc.displayWidth;
        int height = mc.displayHeight;

        savePreviousState();
        initStencilState();

        setupView(width, height);

        prepareStencilBuffer();

        drawStencilPattern(width, height);

        // disabling changes in stencil buffer
        GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
        GL11.glFlush();

        recoverPreviousState();

        reinitPending = false;
    }
}