Example usage for org.lwjgl.opengl GL11 GL_KEEP

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

Introduction

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

Prototype

int GL_KEEP

To view the source code for org.lwjgl.opengl GL11 GL_KEEP.

Click Source Link

Document

StencilOp

Usage

From source file:blusunrize.immersiveengineering.client.render.TileRenderBottlingMachine.java

@Override
public void render(TileEntityBottlingMachine te, double x, double y, double z, float partialTicks,
        int destroyStage, float alpha) {
    if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
        return;/*  ww  w .  j a va 2s.  c  o  m*/

    //Grab model + correct eextended state
    final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
    BlockPos blockPos = te.getPos();
    IBlockState state = getWorld().getBlockState(blockPos);
    if (state.getBlock() != IEContent.blockMetalMultiblock)
        return;
    state = state.getBlock().getActualState(state, getWorld(), blockPos);
    state = state.withProperty(IEProperties.DYNAMICRENDER, true);
    IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);

    //Initialize Tesselator and BufferBuilder
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder worldRenderer = tessellator.getBuffer();
    //Outer GL Wrapping, initial translation
    GlStateManager.pushMatrix();
    GlStateManager.translate(x + .5, y + .5, z + .5);
    if (te.mirrored)
        GlStateManager.scale(te.facing.getXOffset() == 0 ? -1 : 1, 1, te.facing.getZOffset() == 0 ? -1 : 1);

    //Item Displacement
    float[][] itemDisplays = new float[te.bottlingProcessQueue.size()][];
    //Animations
    float lift = 0;

    for (int i = 0; i < itemDisplays.length; i++) {
        BottlingProcess process = te.bottlingProcessQueue.get(i);
        if (process == null || process.processTick == process.maxProcessTick)
            continue;

        //+partialTicks
        float processTimer = ((float) process.processTick) / process.maxProcessTick * 120;

        float itemX = -1.5f;//-1;
        float itemY = -.15625f;// -.34375f;
        float itemZ = 1;//-.9375f;
        float itemFill = 0;//ClientUtils.mc().player.ticksExisted%100; //0f;

        if (processTimer <= 35)//slide
        {
            itemX += processTimer / 35f * 1.5;
        } else if (processTimer <= 85)//slide
        {
            itemX = 0;
            if (processTimer <= 55)
                lift = (processTimer - 35) / 20f * .125f;
            else if (processTimer <= 65) {
                lift = .125f;
                itemFill = (processTimer - 55) / 10f;
            } else {
                lift = (85 - processTimer) / 20f * .125f;
                itemFill = 1;
            }
            itemY += lift;
            lift += .0625;
        } else {
            itemX = (processTimer - 85) / 35f * 1.5f;
            itemFill = 1;
        }
        itemDisplays[i] = new float[] { processTimer, itemX, itemY, itemZ, itemFill };

    }

    ClientUtils.bindAtlas();
    GlStateManager.pushMatrix();

    GlStateManager.translate(0, lift, 0);
    renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "lift");
    GlStateManager.translate(0, -lift, 0);

    RenderHelper.enableStandardItemLighting();
    GlStateManager.popMatrix();

    switch (te.facing) {
    case NORTH:
        break;
    case SOUTH:
        GlStateManager.rotate(180, 0, 1, 0);
        break;
    case WEST:
        GlStateManager.rotate(90, 0, 1, 0);
        break;
    case EAST:
        GlStateManager.rotate(-90, 0, 1, 0);
        break;
    }

    float scale = .0625f;
    FluidStack fs = te.tanks[0].getFluid();
    if (fs != null) {
        GlStateManager.pushMatrix();
        float level = fs.amount / (float) te.tanks[0].getCapacity();
        GlStateManager.translate(-.21875, .376, 1.21875);
        GlStateManager.scale(scale, scale, scale);
        float h = level * 9;
        ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);
        GlStateManager.rotate(90, 0, 1, 0);
        ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);
        GlStateManager.rotate(90, 0, 1, 0);
        GlStateManager.translate(-7, 0, 7);
        ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);
        GlStateManager.rotate(90, 0, 1, 0);
        ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, h);

        GlStateManager.rotate(90, 1, 0, 0);
        ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, 7);
        GlStateManager.translate(0, 0, -h);
        ClientUtils.drawRepeatedFluidSprite(fs, 0, 0, 7, 7);

        GlStateManager.scale(1 / scale, 1 / scale, 1 / scale);
        GlStateManager.translate(0, -1, -1);
        GlStateManager.popMatrix();
    }

    //DRAW ITEMS HERE
    for (int i = 0; i < itemDisplays.length; i++)
        if (itemDisplays[i] != null) {
            BottlingProcess process = te.bottlingProcessQueue.get(i);
            if (process == null)
                continue;

            ItemStack display = itemDisplays[i][4] == 0 || process.items.get(1).isEmpty() ? process.items.get(0)
                    : process.items.get(1);
            scale = .4375f;

            GlStateManager.translate(itemDisplays[i][1], itemDisplays[i][2], itemDisplays[i][3]);
            GlStateManager.scale(scale, scale, scale);

            if (itemDisplays[i][4] == 0)
                ClientUtils.mc().getRenderItem().renderItem(process.items.get(0),
                        ItemCameraTransforms.TransformType.FIXED);
            else if (itemDisplays[i][4] == 1 || !ClientProxy.stencilBufferEnabled)
                ClientUtils.mc().getRenderItem().renderItem(display, ItemCameraTransforms.TransformType.FIXED);
            else {
                float h0 = -.5f;
                float h1 = h0 + itemDisplays[i][4];

                BufferBuilder worldrenderer = tessellator.getBuffer();

                //TODO move to GlStateManager if that ever gets the stencil functions
                GL11.glEnable(GL11.GL_STENCIL_TEST);

                GlStateManager.colorMask(false, false, false, false);
                GlStateManager.depthMask(false);

                GL11.glStencilFunc(GL11.GL_NEVER, 1, 0xFF);
                GL11.glStencilOp(GL11.GL_REPLACE, GL11.GL_KEEP, GL11.GL_KEEP);

                GL11.glStencilMask(0xFF);
                GlStateManager.clear(GL11.GL_STENCIL_BUFFER_BIT);

                GlStateManager.rotate(90.0F - ClientUtils.mc().getRenderManager().playerViewY, 0.0F, 1.0F,
                        0.0F);

                GlStateManager.disableTexture2D();
                worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
                ClientUtils.renderBox(worldrenderer, -.5, h0, -.5, .5, h1, .5);
                tessellator.draw();
                GlStateManager.enableTexture2D();

                GlStateManager.rotate(-(90.0F - ClientUtils.mc().getRenderManager().playerViewY), 0.0F, 1.0F,
                        0.0F);

                GlStateManager.colorMask(true, true, true, true);
                GlStateManager.depthMask(true);

                GL11.glStencilMask(0x00);

                GL11.glStencilFunc(GL11.GL_EQUAL, 0, 0xFF);
                ClientUtils.mc().getRenderItem().renderItem(process.items.get(0),
                        ItemCameraTransforms.TransformType.FIXED);

                GL11.glStencilFunc(GL11.GL_EQUAL, 1, 0xFF);
                ClientUtils.mc().getRenderItem().renderItem(display, ItemCameraTransforms.TransformType.FIXED);

                GL11.glDisable(GL11.GL_STENCIL_TEST);
            }

            GlStateManager.scale(1 / scale, 1 / scale, 1 / scale);
            GlStateManager.translate(-itemDisplays[i][1], -itemDisplays[i][2], -itemDisplays[i][3]);
        }
    GlStateManager.popMatrix();
}

From source file:com.ardor3d.scene.state.lwjgl.LwjglStencilStateUtil.java

License:Open Source License

private static int getGLStencilOp(final StencilOperation operation, final ContextCapabilities caps) {
    switch (operation) {
    case Keep:// w  ww  . j  av  a2s .  c o  m
        return GL11.GL_KEEP;
    case DecrementWrap:
        if (caps.isStencilWrapSupported()) {
            return EXTStencilWrap.GL_DECR_WRAP_EXT;
        }
        // FALLS THROUGH
    case Decrement:
        return GL11.GL_DECR;
    case IncrementWrap:
        if (caps.isStencilWrapSupported()) {
            return EXTStencilWrap.GL_INCR_WRAP_EXT;
        }
        // FALLS THROUGH
    case Increment:
        return GL11.GL_INCR;
    case Invert:
        return GL11.GL_INVERT;
    case Replace:
        return GL11.GL_REPLACE;
    case Zero:
        return GL11.GL_ZERO;
    }
    throw new IllegalArgumentException("unknown operation: " + operation);
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

public InspectorCanvas(Composite parent, int style, GLData data) {
    super(parent, style, data);
    setCurrent();//from   w ww .j a v  a 2s.  com

    // Clear the canvas.
    GL11.glClearColor(CLEAR_COLOR[0], CLEAR_COLOR[1], CLEAR_COLOR[2], CLEAR_COLOR[3]);
    GL11.glClearDepth(1.0f);
    GL11.glLineWidth(1.0f);
    GL11.glPointSize(1.0f);

    GL11.glShadeModel(GL11.GL_FLAT);

    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
    GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);

    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.01f);

    GL11.glEnable(GL11.GL_STENCIL_TEST);
    GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0xf);
    GL11.glStencilOp(GL11.GL_INCR, GL11.GL_KEEP, GL11.GL_INCR);

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

    reset();

    mTransform = new Matrix4f();
    mTransform.setIdentity();

    addListener(SWT.Resize, this);
    addListener(SWT.Paint, this);
    addMouseListener(this);
    addMouseWheelListener(this);
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawOverdraw(int level) {
    GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT);

    GL11.glStencilFunc(level == 5 ? GL11.GL_LEQUAL : GL11.GL_EQUAL, level, 0xf);
    GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);

    GL11.glTranslatef(mNode.bounds.x, -mNode.bounds.y, 0.0f);

    if (level == 2) {
        loadColor(ColorType.OVERDRAW_BLUE);
    } else if (level == 3) {
        loadColor(ColorType.OVERDRAW_GREEN);
    } else if (level == 4) {
        loadColor(ColorType.OVERDRAW_RED_LOW);
    } else if (level > 4) {
        loadColor(ColorType.OVERDRAW_RED_HIGH);
    }//w  w  w. java2  s .co  m

    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(0.0f, 0.0f, 0.0f);
    GL11.glVertex3f(mNode.bounds.width, 0.0f, 0.0f);
    GL11.glVertex3f(mNode.bounds.width, -mNode.bounds.height, 0.0f);
    GL11.glVertex3f(0.0f, -mNode.bounds.height, 0.0f);
    GL11.glEnd();

    GL11.glPopAttrib();
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

public void refresh() {
    if (mShowOverdraw) {
        GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT);
        GL11.glStencilFunc(GL11.GL_ALWAYS, 0x1, 0xf);
        GL11.glStencilOp(GL11.GL_INCR, GL11.GL_KEEP, GL11.GL_INCR);
    }//from  w ww .ja v a2s.  c  o m

    // Do the actual paint.
    doPaint();

    if (mShowOverdraw) {
        GL11.glPopAttrib();
    }
}

From source file:com.sriramramani.droid.inspector.ui.InspectorCanvas.java

License:Mozilla Public License

private void drawHierarchy(Node node) {
    if (node == null || node.bounds.width == 0 || node.bounds.height == 0 || !node.isShowing()
            || !node.isVisible()) {//w  w w  .  j a  v a2  s .  co m
        return;
    }

    // Give a 3d depth.
    GL11.glPushMatrix();

    final float depth = node.depth * mDepth;

    // Node's translation.
    GL11.glTranslatef(node.bounds.x, -node.bounds.y, depth);

    final Drawable background = node.getBackground();
    final Drawable content = node.getContent();
    final boolean hasBackground = node.isBackgroundShown && (background.displayListId != -1);
    final boolean hasContent = node.isContentShown && (content.displayListId != -1);

    if (mIsPicking) {
        GL11.glColor4f(node.pickColor[0], node.pickColor[1], node.pickColor[2], node.pickColor[3]);

        drawFrontFace(node, 0.0f, GL11.GL_FILL);

        // Draw the depth, only if we show in actual mode.
        // If not, if we are splitting content, draw a layer for it.
        if (mShowDepth) {
            drawDepth(node, -mDepth, GL11.GL_FILL);
        } else if (mSplitContent && hasBackground && hasContent) {
            drawFrontFace(node, -mDepth / 2.0f, GL11.GL_FILL);
        }
    } else {
        if (!mIsOrtho && mShowDepth) {
            GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT);
            GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);
            drawDepthCube(node, depth);
            GL11.glPopAttrib();
        }

        if (hasBackground && hasContent) {
            // Both background and content are available.
            // Draw background at a depth if needed.
            if (mSplitContent)
                GL11.glTranslatef(0.0f, 0.0f, -mDepth / 2.0f);

            GL11.glCallList(background.displayListId);

            if (mSplitContent)
                GL11.glTranslatef(0.0f, 0.0f, mDepth / 2.0f);

            GL11.glCallList(content.displayListId);
        } else if (hasBackground) {
            GL11.glCallList(background.displayListId);
        } else if (hasContent) {
            GL11.glCallList(content.displayListId);
        }

        // Stencil shouldn't know about bounds.
        GL11.glPushAttrib(GL11.GL_STENCIL_BUFFER_BIT | GL11.GL_LINE_BIT);
        GL11.glStencilOp(GL11.GL_KEEP, GL11.GL_KEEP, GL11.GL_KEEP);

        // Show bounds.
        if (!mIsOrtho && mShowDepth) {
            loadColor(ColorType.BOUNDS_NORMAL);
        } else {
            if (node.isSelected) {
                GL11.glLineWidth(2.0f);
                loadColor(ColorType.BOUNDS_SELECTION);
            } else {
                loadColor(ColorType.BOUNDS_NORMAL);
            }
        }

        if (node.isSelected || !mIsOrtho || mShowBounds) {
            drawFrontFace(node, 0.0f, GL11.GL_LINE);
        }

        // Show a bounding box for split content in perspective mode.
        if (!mIsOrtho && !mShowDepth && mSplitContent && hasBackground && hasContent) {
            drawFrontFace(node, -mDepth / 2.0f, GL11.GL_LINE);
        }

        GL11.glPopAttrib();
    }

    for (Node child : node.children) {
        drawHierarchy(child);
    }

    GL11.glPopMatrix();
}

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);/*from w  ww .j a v  a 2 s .co 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: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 v a2s . co 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  w  w  w  .  j  a  va2s .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;//  w ww .  ja v  a2s .c  o  m

    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;
    }
}