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:cn.academy.core.client.render.SkillRenderManager.java

License:Open Source License

public static void renderThirdPerson(EntityLivingBase ent, ItemStack stack, ItemRenderType type) {
    if (type == ItemRenderType.EQUIPPED_FIRST_PERSON || !(ent instanceof EntityPlayer))
        return;//from   ww w . j  a  va  2  s.com
    EntityPlayer player = (EntityPlayer) ent;
    Item item = stack.getItem();
    Block block = Block.getBlockFromItem(stack.getItem());
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    {

        GL11.glColor4d(1, 0.6, 0.6, 0.55);

        if (stack.getItemSpriteNumber() == 0 && item instanceof ItemBlock) { //block render routine
            GL11.glTranslated(0, 0, 1.5);
            GL11.glScalef(2F, 2F, 2F);
            GL11.glRotated(45, 1, 0, 1);
            GL11.glRotated(45, 0, 1, 0);
            GL11.glRotated(180, 1, 0, 0);
        } else if (item.isFull3D()) {
            GL11.glTranslated(0.1, 0.8, -.4);
            GL11.glScalef(.8F, .8F, .8F);
            GL11.glRotated(45, 0, 0, -1);
        } else {
            GL11.glTranslated(-.3, 1.2, -.6);
            GL11.glRotatef(90, 1, 0, 0);
            GL11.glScalef(1.5F, 1.5F, 1.5F);
        }

        traverseHandRender(player, HandRenderType.EQUIPPED);

    }
    GL11.glPopMatrix();
}

From source file:cn.academy.core.client.render.SkillRenderManager.java

License:Open Source License

public static void renderFirstPerson() {
    //System.out.println("rfp");
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_BLEND);// w  w  w  .  j  ava  2s  .c  o m
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glPushMatrix();
    {
        GL11.glTranslated(0.28, -0.55, -.9);
        GL11.glColor4d(1, 0.6, 0.6, 0.55);
        GL11.glScalef(0.66F, 0.66F, 0.66F);
        GL11.glRotatef(20, 1, 0, 0);

        //RenderUtils.loadTexture(ACClientProps.TEX_ARC_SHELL[0]);
        //RenderUtils.drawCube(1, 1, 1, false);
        traverseHandRender(Minecraft.getMinecraft().thePlayer, HandRenderType.FIRSTPERSON);
        //rpe.renderHandEffect(Minecraft.getMinecraft().thePlayer, null, HandRenderType.FIRSTPERSON);

    }
    GL11.glPopMatrix();
}

From source file:cn.academy.crafting.client.render.item.RendererMatterUnit.java

License:GNU General Public License

@Override
public void renderItem(ItemRenderType type, ItemStack stack, Object... data) {
    ItemMatterUnit item = ModuleCrafting.matterUnit;
    GL11.glColor4d(1, 1, 1, 1);//from www.j  a  v  a  2s  .  c  o  m
    if (type != ItemRenderType.INVENTORY) {
        GL11.glPushMatrix();
        {
            if (type == ItemRenderType.ENTITY)
                GL11.glTranslated(-.5, -0.1, 0);

            RenderUtils.drawEquippedItem(stack, 0.0625f);

            GL11.glColorMask(false, false, false, false);
            RenderUtils.drawEquippedItem(0.0626f, texMask, texMask);
            GL11.glColorMask(true, true, true, true);

            GL11.glDepthFunc(GL11.GL_EQUAL);
            MatterMaterial mat = item.getMaterial(stack);
            RenderUtils.drawEquippedItemOverlay(0.0626f, mat.texture);
            GL11.glDepthFunc(GL11.GL_LEQUAL);
        }
        GL11.glPopMatrix();
    } else {
        ShaderMask shader = ShaderMask.instance;
        float du = -(GameTimer.getAbsTime() % 10000L) / 1e4f, dv = (GameTimer.getAbsTime() % 10000L) / 1e4f;

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

        RenderUtils.renderItemInventory(stack);

        shader.start(texMask);
        RenderUtils.loadTexture(item.getMaterial(stack).texture);

        GL11.glBegin(GL11.GL_QUADS);

        GL11.glTexCoord2f(0 + du, 0 + dv);
        shader.maskTexCoord(0, 0);
        GL11.glVertex2f(0, 0);

        GL11.glTexCoord2f(0 + du, 1 + dv);
        shader.maskTexCoord(0, 1);
        GL11.glVertex2f(0, 16);

        GL11.glTexCoord2f(1 + du, 1 + dv);
        shader.maskTexCoord(1, 1);
        GL11.glVertex2f(16, 16);

        GL11.glTexCoord2f(1 + du, 0 + dv);
        shader.maskTexCoord(1, 0);
        GL11.glVertex2f(16, 0);

        GL11.glEnd();

        shader.end();

        GL11.glDisable(GL11.GL_BLEND);
    }
}

From source file:cn.lambdalib.cgui.gui.CGui.java

License:MIT License

private void drawTraverse(double mx, double my, Widget cur, WidgetContainer set, Widget top) {
    try {//w  w  w. j  a  v  a 2s . c  o  m
        if (cur != null && cur.isVisible()) {
            GL11.glPushMatrix();
            GL11.glTranslated(cur.x, cur.y, 0);

            GL11.glDepthFunc(GL11.GL_LEQUAL);
            GL11.glScaled(cur.scale, cur.scale, 1);
            GL11.glTranslated(-cur.transform.pivotX, -cur.transform.pivotY, 0);

            GL11.glColor4d(1, 1, 1, 1); //Force restore color for any widget
            cur.post(new FrameEvent((mx - cur.x) / cur.scale, (my - cur.y) / cur.scale, cur == top));
            GL11.glPopMatrix();
        }
    } catch (Exception e) {
        LambdaLib.log.error("Error occured handling widget draw. instance class: " + cur.getClass().getName()
                + ", name: " + cur.getName());
        e.printStackTrace();
    }

    if (cur == null || cur.isVisible()) {
        Iterator<Widget> iter = set.iterator();
        while (iter.hasNext()) {
            Widget wn = iter.next();
            drawTraverse(mx, my, wn, wn, top);
        }
    }
}

From source file:cn.lambdalib.util.client.auxgui.AuxGuiHandler.java

License:MIT License

@SubscribeEvent
public void drawHudEvent(RenderGameOverlayEvent event) {
    GL11.glDepthFunc(GL11.GL_ALWAYS);
    GL11.glDepthMask(false);//from   ww w.j  a  v a  2s  .c  o  m
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    RenderUtils.pushTextureState();

    if (event.type == ElementType.EXPERIENCE) {
        Iterator<AuxGui> iter = auxGuiList.iterator();
        startIterating();
        while (iter.hasNext()) {
            AuxGui gui = iter.next();
            if (!gui.isDisposed()) {
                if (!gui.lastFrameActive)
                    gui.lastActivateTime = GameTimer.getTime();
                gui.draw(event.resolution);
                gui.lastFrameActive = true;
            }
        }
        endIterating();
    }

    RenderUtils.popTextureState();
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void renderOverlayEquip(ResourceLocation src) {
    //Setup/* www. j a  va 2 s  . co m*/
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    //Push texture mat
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F); //xOffset loops between 0.0 and 8.0
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();

    //Second pass
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F; //Loop between 0 and 8, longer loop
    GL11.glTranslatef(-f9, 0.0F, 0.0F); //Still xOffset
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //However, different rotation!
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();
    //Pop texture mat
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.lambdalib.util.client.RenderUtils.java

License:MIT License

public static void renderOverlayInv(ResourceLocation src) {
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);/*from w  w  w.  j a va  2s .c  om*/
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    //GL11.glColor4f(0.5F * f7, 0.25F * f7, 0.8F * f7, 1.0F);
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = GameTimer.getAbsTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F);
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = GameTimer.getAbsTime() % 4873L / 4873.0F * 8.0F;
    GL11.glTranslatef(-f9, 0.0F, 0.0F);
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
    t.startDrawingQuads();
    t.addVertexWithUV(0.0, 0.0, 0.0, 0.0, 0.0);
    t.addVertexWithUV(0.0, 16.0, 0.0, 0.0, 1.0);
    t.addVertexWithUV(16.0, 16.0, 0.0, 1.0, 1.0);
    t.addVertexWithUV(16.0, 0.0, 0.0, 1.0, 0.0);
    t.draw();
    GL11.glPopMatrix();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.liutils.api.gui.LIGui.java

License:Open Source License

/**
 * Go down the hierarchy tree and draw each widget node.
 *///  ww  w  .j av a2  s. c  o m
public void draw(double mx, double my) {
    frameUpdate();
    updateMouse(mx, my);
    iterating = true;
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    GL11.glDepthFunc(GL11.GL_ALWAYS);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glDepthMask(false);
    drawTraverse(mx, my, null, this, getTopNode(mx, my));
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    iterating = false;
}

From source file:cn.liutils.core.event.LIClientEvents.java

License:Open Source License

@SubscribeEvent
public void drawHudEvent(RenderGameOverlayEvent event) {
    GL11.glDepthFunc(GL11.GL_ALWAYS);
    GL11.glDepthMask(false);/*from  www. j  a v a  2  s  . c  om*/
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    if (event.type == ElementType.CROSSHAIRS) {
        for (AuxGui gui : auxGuiList) {
            if (gui.isOpen())
                gui.draw(event.resolution);
        }
    }
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthMask(true);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

From source file:cn.liutils.util.RenderUtils.java

License:Open Source License

public static void renderOverlay_Equip(ResourceLocation src) {
    //Setup/*from  w w  w  . jav  a 2 s  .  co m*/
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);
    loadTexture(src);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
    float f7 = 0.76F;
    GL11.glMatrixMode(GL11.GL_TEXTURE);
    //Push texture mat
    GL11.glPushMatrix();
    float f8 = 0.125F;
    GL11.glScalef(f8, f8, f8);
    float f9 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
    GL11.glTranslatef(f9, 0.0F, 0.0F); //xOffset loops between 0.0 and 8.0
    GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();

    //Second pass
    GL11.glPushMatrix();
    GL11.glScalef(f8, f8, f8);
    f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F; //Loop between 0 and 8, longer loop
    GL11.glTranslatef(-f9, 0.0F, 0.0F); //Still xOffset
    GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F); //However, different rotation!
    ItemRenderer.renderItemIn2D(t, 0.0F, 0.0F, 1.0F, 1.0F, 256, 256, 0.0625F);
    GL11.glPopMatrix();
    //Pop texture mat
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}