Example usage for org.lwjgl.opengl GL11 glDepthFunc

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

Introduction

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

Prototype

public static void glDepthFunc(@NativeType("GLenum") int func) 

Source Link

Document

Specifies the comparison that takes place during the depth buffer test (when GL11C#GL_DEPTH_TEST DEPTH_TEST is enabled).

Usage

From source file:lyonlancer5.pfsteel.client.render.RenderDarkShield.java

License:Open Source License

protected void renderDarkMain(EntityDarkShield shield, double x, double y, double z, float yaw, float pitch) {
    GL11.glDisable(GL11.GL_LIGHTING);// w  ww  .  j  a v  a  2  s .com

    GL11.glPushMatrix();
    GL11.glDisable(GL11.GL_CULL_FACE);
    if (RenderManager.instance.getDistanceToCamera(shield.posX, shield.posY, shield.posZ) < 36.0D) {
        GL11.glDepthFunc(GL11.GL_ALWAYS);
    } else {
        GL11.glDepthMask(false);
    }
    GL11.glTranslatef((float) x, (float) y, (float) z);
    GL11.glRotatef(-renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(renderManager.playerViewX, 1.0F, 0.0F, 0.0F);

    Tessellator tessellator = Tessellator.instance;
    GL11.glDepthMask(false);
    GL11.glEnable(GL11.GL_BLEND);

    GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR);
    GL11.glTranslatef(0.0F, 1.3F, 0.0F);
    this.bindTexture(darkTex);
    renderDark(tessellator, 12.0D, 12.0F, 0.0D, 1.0F, 0);
    GL11.glDisable(GL11.GL_BLEND);

    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glDepthMask(true);
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_LIGHTING);
}

From source file:matteroverdrive.client.render.entity.EntityRendererRougeAndroid.java

License:Open Source License

@Override
public void doRender(EntityLivingBase p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_,
        float p_76986_8_, float p_76986_9_) {
    if (hologram) {
        GL11.glPushMatrix();// w  ww .  j ava  2 s . c  om
        GL11.glDisable(GL11.GL_CULL_FACE);
        this.mainModel.onGround = this.renderSwingProgress(p_76986_1_, p_76986_9_);

        if (this.renderPassModel != null) {
            this.renderPassModel.onGround = this.mainModel.onGround;
        }

        this.mainModel.isRiding = p_76986_1_.isRiding();

        if (this.renderPassModel != null) {
            this.renderPassModel.isRiding = this.mainModel.isRiding;
        }

        this.mainModel.isChild = p_76986_1_.isChild();

        if (this.renderPassModel != null) {
            this.renderPassModel.isChild = this.mainModel.isChild;
        }

        this.renderLivingAt(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_);

        try {
            float f2 = 0;
            float f3 = 0;
            float f4;

            f4 = this.handleRotationFloat(p_76986_1_, p_76986_9_);
            this.rotateCorpse(p_76986_1_, f4, f2, p_76986_9_);
            float f5 = 0.0625F;
            GL11.glEnable(GL12.GL_RESCALE_NORMAL);
            GL11.glScalef(-1.0F, -1.0F, 1.0F);
            this.preRenderCallback(p_76986_1_, p_76986_9_);
            GL11.glTranslatef(0.0F, -24.0F * f5 - 0.0078125F, 0.0F);
            float f6 = p_76986_1_.prevLimbSwingAmount
                    + (p_76986_1_.limbSwingAmount - p_76986_1_.prevLimbSwingAmount) * p_76986_9_;
            float f7 = p_76986_1_.limbSwing - p_76986_1_.limbSwingAmount * (1.0F - p_76986_9_);

            if (p_76986_1_.isChild()) {
                f7 *= 3.0F;
            }

            if (f6 > 1.0F) {
                f6 = 1.0F;
            }

            GL11.glEnable(GL11.GL_ALPHA_TEST);
            this.mainModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
            this.renderModel(p_76986_1_, f7, f6, f4, f3 - f2, p_76986_1_.rotationPitch, f5);
            int j;
            float f8;
            float f9;
            float f10;

            for (int i = 0; i < 4; ++i) {
                j = this.shouldRenderPass(p_76986_1_, i, p_76986_9_);

                if (j > 0) {
                    this.renderPassModel.setLivingAnimations(p_76986_1_, f7, f6, p_76986_9_);
                    this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, p_76986_1_.rotationPitch, f5);

                    if ((j & 240) == 16) {
                        this.func_82408_c(p_76986_1_, i, p_76986_9_);
                        this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2, p_76986_1_.rotationPitch,
                                f5);
                    }

                    if ((j & 15) == 15) {
                        f8 = (float) p_76986_1_.ticksExisted + p_76986_9_;
                        //this.bindTexture(RES_ITEM_GLINT);
                        GL11.glEnable(GL11.GL_BLEND);
                        f9 = 0.5F;
                        GL11.glColor4f(f9, f9, f9, 1.0F);
                        GL11.glDepthFunc(GL11.GL_EQUAL);
                        GL11.glDepthMask(false);

                        for (int k = 0; k < 2; ++k) {
                            GL11.glDisable(GL11.GL_LIGHTING);
                            f10 = 0.76F;
                            GL11.glColor4f(0.5F * f10, 0.25F * f10, 0.8F * f10, 1.0F);
                            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
                            GL11.glMatrixMode(GL11.GL_TEXTURE);
                            GL11.glLoadIdentity();
                            float f11 = f8 * (0.001F + (float) k * 0.003F) * 20.0F;
                            float f12 = 0.33333334F;
                            GL11.glScalef(f12, f12, f12);
                            GL11.glRotatef(30.0F - (float) k * 60.0F, 0.0F, 0.0F, 1.0F);
                            GL11.glTranslatef(0.0F, f11, 0.0F);
                            GL11.glMatrixMode(GL11.GL_MODELVIEW);
                            this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2,
                                    p_76986_1_.rotationPitch, f5);
                        }

                        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                        GL11.glMatrixMode(GL11.GL_TEXTURE);
                        GL11.glDepthMask(true);
                        GL11.glLoadIdentity();
                        GL11.glMatrixMode(GL11.GL_MODELVIEW);
                        GL11.glEnable(GL11.GL_LIGHTING);
                        GL11.glDisable(GL11.GL_BLEND);
                        GL11.glDepthFunc(GL11.GL_LEQUAL);
                    }

                    GL11.glDisable(GL11.GL_BLEND);
                    GL11.glEnable(GL11.GL_ALPHA_TEST);
                }
            }

            GL11.glDepthMask(true);
            this.renderEquippedItems(p_76986_1_, p_76986_9_);
            float f14 = p_76986_1_.getBrightness(p_76986_9_);
            j = this.getColorMultiplier(p_76986_1_, f14, p_76986_9_);
            OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);

            if ((j >> 24 & 255) > 0 || p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) {
                GL11.glDisable(GL11.GL_TEXTURE_2D);
                GL11.glDisable(GL11.GL_ALPHA_TEST);
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL11.glDepthFunc(GL11.GL_EQUAL);

                if (p_76986_1_.hurtTime > 0 || p_76986_1_.deathTime > 0) {
                    GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F);
                    this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, p_76986_1_.rotationPitch, f5);

                    for (int l = 0; l < 4; ++l) {
                        if (this.inheritRenderPass(p_76986_1_, l, p_76986_9_) >= 0) {
                            GL11.glColor4f(f14, 0.0F, 0.0F, 0.4F);
                            this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2,
                                    p_76986_1_.rotationPitch, f5);
                        }
                    }
                }

                if ((j >> 24 & 255) > 0) {
                    f8 = (float) (j >> 16 & 255) / 255.0F;
                    f9 = (float) (j >> 8 & 255) / 255.0F;
                    float f15 = (float) (j & 255) / 255.0F;
                    f10 = (float) (j >> 24 & 255) / 255.0F;
                    GL11.glColor4f(f8, f9, f15, f10);
                    this.mainModel.render(p_76986_1_, f7, f6, f4, f3 - f2, p_76986_1_.rotationPitch, f5);

                    for (int i1 = 0; i1 < 4; ++i1) {
                        if (this.inheritRenderPass(p_76986_1_, i1, p_76986_9_) >= 0) {
                            GL11.glColor4f(f8, f9, f15, f10);
                            this.renderPassModel.render(p_76986_1_, f7, f6, f4, f3 - f2,
                                    p_76986_1_.rotationPitch, f5);
                        }
                    }
                }

                GL11.glDepthFunc(GL11.GL_LEQUAL);
                GL11.glDisable(GL11.GL_BLEND);
                GL11.glEnable(GL11.GL_ALPHA_TEST);
                GL11.glEnable(GL11.GL_TEXTURE_2D);
            }

            GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        } catch (Exception exception) {

        }

        OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glPopMatrix();
        this.passSpecialRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_);
    } else {
        super.doRender(p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_);
    }
}

From source file:matteroverdrive.gui.android.AndroidHudMinimap.java

License:Open Source License

private void beginMask() {
    glPushMatrix();/*from  w w  w  .j  a  v a2  s . c  o  m*/
    glClear(GL_DEPTH_BUFFER_BIT);
    glClearDepth(1f);
    GL11.glDepthFunc(GL11.GL_LESS);
    glEnable(GL_DEPTH_TEST);
    glDepthMask(true);
    glColorMask(false, false, false, false);
    glDisable(GL_TEXTURE_2D);
    glTranslated(0, 0, 1);
    RenderUtils.drawCircle(RADIUS, 32);
    glEnable(GL_TEXTURE_2D);

    glDepthMask(false);
    glColorMask(true, true, true, true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_GREATER);
    glPopMatrix();
}

From source file:matteroverdrive.gui.pages.PageGuideEntries.java

License:Open Source License

@Override
public void drawBackground(int mouseX, int mouseY, float gameTicks) {
    //begin depth masking by clearing depth buffer
    //and enabling depth masking. this is where the mask will be drawn
    glClear(GL_DEPTH_BUFFER_BIT);//from  w  w w  .  ja v  a  2s . c o  m
    glClearDepth(1f);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    glDepthMask(true);
    glColorMask(false, false, false, false);
    glDisable(GL_TEXTURE_2D);
    //draws an invisible square mask that will sit on top of everything
    RenderUtils.drawPlane(posX, posY, 200, sizeX, sizeY);
    glEnable(GL_TEXTURE_2D);

    //disable the drawing of the mask and start the drawing of the masked elements
    //while still having the depth test active
    glDepthMask(false);
    glColorMask(true, true, true, true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_GREATER);
    gui.bindTexture(this.background);
    double aspect = (double) sizeY / (double) sizeX;
    glEnable(GL_BLEND);
    glDisable(GL_ALPHA_TEST);
    glColor4d(1, 1, 1, 0.1);
    RenderUtils.drawPlaneWithUV(posX, posY, 0, sizeX, sizeY, 0.5 - scrollX * 0.001,
            0.5 - (double) scrollY * 0.0003, 0.5, 0.5 * aspect);
    RenderUtils.drawPlaneWithUV(posX, posY, 0, sizeX, sizeY, 0.2 - scrollX * 0.001,
            0.2 - (double) scrollY * 0.0005, 0.3, 0.3 * aspect);
    glEnable(GL_ALPHA_TEST);
    super.drawBackground(mouseX, mouseY, gameTicks);

    if (orderButtonElement.getSelectedState() > 1) {
        for (Map.Entry<String, Bounds> group : groups.entrySet()) {
            getFontRenderer().setUnicodeFlag(true);
            Bounds b = group.getValue();
            RenderUtils.applyColor(Reference.COLOR_MATTER);
            groupBackground.render(14 + b.getMinX(), 14 + b.getMinY(), b.getWidth(), b.getHeight());
            String groupName = MOStringHelper
                    .translateToLocal(String.format("guide.group.%s.name", group.getKey()));
            int groupNameWidth = getFontRenderer().getStringWidth(groupName);
            getFontRenderer().drawString(groupName,
                    14 + scrollX + b.getMinX() + b.getWidth() / 2 - groupNameWidth / 2, 10 + b.getMinY(),
                    Reference.COLOR_MATTER.getColor());
            getFontRenderer().setUnicodeFlag(false);
        }
    }

    //reset the depth check function to prevent the masking of other elements as well as the depth testing
    glDepthFunc(GL_LEQUAL);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
}

From source file:matteroverdrive.gui.pages.PageGuideEntries.java

License:Open Source License

@Override
public void drawForeground(int mouseX, int mouseY) {
    glClear(GL_DEPTH_BUFFER_BIT);/*  w ww . j a v a2s.  c o m*/
    glClearDepth(1f);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    glDepthMask(true);
    glColorMask(false, false, false, false);
    glDisable(GL_TEXTURE_2D);
    RenderUtils.drawPlane(posX, posY, 400, sizeX, sizeY);
    glEnable(GL_TEXTURE_2D);

    glDepthMask(false);
    glColorMask(true, true, true, true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_GREATER);
    super.drawForeground(mouseX, mouseY);
    glDepthFunc(GL_LEQUAL);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    glDepthMask(false);
}

From source file:matteroverdrive.util.RenderUtils.java

License:Open Source License

public static void beginDrawingDepthMask() {
    glClear(GL_DEPTH_BUFFER_BIT);/*w w w  . j  a  v  a 2  s.  c  o  m*/
    glClearDepth(1f);
    GL11.glDepthFunc(GL11.GL_LESS);
    glEnable(GL_DEPTH_TEST);
    glDepthMask(true);
    glColorMask(false, false, false, false);
    glDisable(GL_TEXTURE_2D);
}

From source file:matteroverdrive.util.RenderUtils.java

License:Open Source License

public static void beginDepthMasking() {
    glEnable(GL_TEXTURE_2D);//from   w ww  . j av a 2  s .  co m
    glDepthMask(false);
    glColorMask(true, true, true, true);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_GREATER);
}

From source file:me.sunchiro.game.engine.gl.Graphic.java

License:Open Source License

public void createWindow(int width, int height, String name) {
    this.width = width;
    this.height = height;
    glfwSetErrorCallback(errorCallback = Callbacks.errorCallbackPrint(System.err));
    if (glfwInit() != GL11.GL_TRUE)
        throw new IllegalStateException("Unable to initialize GLFW");
    glfwDefaultWindowHints(); // optional, the current window hints are
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
    glfwWindowHint(GLFW_VISIBLE, GL11.GL_FALSE); // the window will stay
    // hidden/*from www .  j a va2s  .  c o m*/
    glfwWindowHint(GLFW_RESIZABLE, GL11.GL_TRUE); // the window will be
    // resizable
    window = glfwCreateWindow(width, height, name, NULL, NULL);
    if (window == NULL)
        throw new RuntimeException("Failed to create the GLFW window");
    // glfwSetKeyCallback(window,this.keyCallback = keyCallback);
    glfwSetWindowSizeCallback(window, resizeCallback());
    ByteBuffer vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());
    glfwSetWindowPos(window, (vidmode.asIntBuffer().get(0) - width) / 2,
            (vidmode.asIntBuffer().get(1) - height) / 2);
    glfwMakeContextCurrent(window);
    Graphic.instance = this;
    glfwSwapInterval(1);
    GL.createCapabilities();
    setCapabilities();

    glfwShowWindow(window);

    // Setup an XNA like background color
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);

    GL11.glClearColor(bgColor.x, bgColor.y, bgColor.z, 0);
    // Map the internal OpenGL coordinate system to the entire screen
    GL11.glViewport(0, 0, width, height);
    matBuff = BufferUtils.createFloatBuffer(16);
    vaoId = GL30.glGenVertexArrays();
    vboiId = GL15.glGenBuffers();
    vboId = GL15.glGenBuffers();
    tid_charmap = texManager.loadTexture("textures/charmap.png", GL13.GL_TEXTURE0);
    shader.setupShader();
    // testQuad();

}

From source file:me.ukl.api.gui.renderer.GuiRendererDepth.java

License:MIT License

@Override
public void setClip(int x, int y, int width, int height) {
    super.setClip(x, y, width, height);
    GL11.glDepthMask(true); //Write to depth
    clearClip();/* w  ww  .  j a va 2s .  co m*/
    GL11.glDepthFunc(GL11.GL_ALWAYS);
    GL11.glColorMask(false, false, false, false);

    RenderUtil.drawRect(x, y, width, height, Color.WHITE);

    GL11.glDepthMask(false);//No more writing to depth
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glColorMask(true, true, true, true);
    //        addClip(x, y, width, height);
}

From source file:mods.railcraft.client.render.RenderTankCartItem.java

License:Open Source License

private void renderIn3D(ItemStack stack) {
    GL11.glPushMatrix();//w ww.  j  a va2  s  . c o m
    Tessellator tessellator = Tessellator.instance;

    int meta = stack.getItemDamage();
    for (int pass = 0; pass < stack.getItem().getRenderPasses(meta); ++pass) {
        IIcon icon = stack.getItem().getIconFromDamageForRenderPass(meta, pass);
        if (icon == null)
            continue;
        int color = stack.getItem().getColorFromItemStack(stack, pass);
        float c1 = (float) (color >> 16 & 255) / 255.0F;
        float c2 = (float) (color >> 8 & 255) / 255.0F;
        float c3 = (float) (color & 255) / 255.0F;

        if (renderItem.renderWithColor)
            GL11.glColor4f(c1, c2, c3, 1.0F);

        float minU = icon.getMinU();
        float maxU = icon.getMaxU();
        float minV = icon.getMinV();
        float maxV = icon.getMaxV();

        if (stack.getItemSpriteNumber() == 0)
            RenderManager.instance.renderEngine.bindTexture(BLOCK_TEXTURE);
        else
            RenderManager.instance.renderEngine.bindTexture(ITEM_TEXTURE);

        ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(),
                icon.getIconHeight(), RenderTools.PIXEL);

        if (stack.hasEffect(pass)) {
            GL11.glDepthFunc(GL11.GL_EQUAL);
            GL11.glDisable(GL11.GL_LIGHTING);
            RenderManager.instance.renderEngine.bindTexture(GLINT_TEXTURE);
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
            float f13 = 0.76F;
            GL11.glColor4f(0.5F * f13, 0.25F * f13, 0.8F * f13, 1.0F);
            GL11.glMatrixMode(GL11.GL_TEXTURE);
            GL11.glPushMatrix();
            float f14 = 0.125F;
            GL11.glScalef(f14, f14, f14);
            float f15 = (float) (Minecraft.getSystemTime() % 3000L) / 3000.0F * 8.0F;
            GL11.glTranslatef(f15, 0.0F, 0.0F);
            GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, RenderTools.PIXEL);
            GL11.glPopMatrix();
            GL11.glPushMatrix();
            GL11.glScalef(f14, f14, f14);
            f15 = (float) (Minecraft.getSystemTime() % 4873L) / 4873.0F * 8.0F;
            GL11.glTranslatef(-f15, 0.0F, 0.0F);
            GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
            ItemRenderer.renderItemIn2D(tessellator, 0.0F, 0.0F, 1.0F, 1.0F, 255, 255, RenderTools.PIXEL);
            GL11.glPopMatrix();
            GL11.glMatrixMode(GL11.GL_MODELVIEW);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
    }

    GL11.glPopMatrix();
}