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.liutils.util.RenderUtils.java

License:Open Source License

public static void renderOverlay_Inv(ResourceLocation src) {
    GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);/*from ww w.  ja v  a 2s.c o  m*/
    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 = Minecraft.getSystemTime() % 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 = Minecraft.getSystemTime() % 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.util.RenderUtils.java

License:Open Source License

public static void renderSimpleOverlay_Inv(ResourceLocation src) {
    //GL11.glDepthFunc(GL11.GL_EQUAL);
    GL11.glDisable(GL11.GL_LIGHTING);/*w w  w  . j  av  a2  s  .  com*/
    RenderUtils.loadTexture(src);
    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.glEnable(GL11.GL_LIGHTING);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
}

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

License:Open Source License

private static void applyFunction(final int depthFunc, final ZBufferStateRecord record) {
    if (depthFunc != record.depthFunc || !record.isValid()) {
        GL11.glDepthFunc(depthFunc);
        record.depthFunc = depthFunc;/*from   w w w  . j  a v a2 s. c om*/
    }
}

From source file:com.auroraengine.opengl.GLWindow.java

License:Open Source License

/**
 * Currently serves as a simple test for implementing some GL settings.
 *
 * @throws GLException/*  w w w .ja v  a  2s. c  om*/
 */
public static void updateGL() throws GLException {
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.5f);
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

public void glDepthFunc(int func) {
    GL11.glDepthFunc(func);
}

From source file:com.badlogic.gdx.backends.lwjgl.LwjglGL10.java

License:Apache License

public final void glDepthFunc(int func) {
    GL11.glDepthFunc(func);
}

From source file:com.builtbroken.atomic.content.items.cell.RendererItemCell.java

protected void renderFluid(ItemRenderType type, ItemStack item) {
    final FluidStack fluidStack = ((ItemFluidCell) item.getItem()).getFluid(item);
    if (fluidStack != null) {
        final Fluid fluid = fluidStack.getFluid();

        if (fluid != null) {
            final IIcon maskIcon = ASItems.itemFluidCell.getIconFromDamage(-1);
            final IIcon subIcon = fluid.getFlowingIcon() != null ? fluid.getFlowingIcon() : fluid.getIcon();

            if (maskIcon != null && subIcon != null) {
                GL11.glEnable(GL11.GL_BLEND);
                GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL11.glDisable(GL11.GL_CULL_FACE);
                Tessellator tessellator = Tessellator.instance;

                //Render mask TODO change mask verts to show fill %
                bindItemTexture(item.getItem());
                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, 1);
                generatedGeometry(maskIcon, type, 10, 0.001);
                tessellator.draw();//  ww w  .  ja  v  a2s .  c o  m

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, -1); //TODO don't think is needed for inventory
                generatedGeometry(maskIcon, type, -0.0635, -0.0635);
                tessellator.draw();

                //Render fluid
                bindFluidTexture(fluid);

                GL11.glDepthFunc(GL11.GL_EQUAL);
                GL11.glDepthMask(false);

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, 1);
                generatedGeometry(subIcon, type, 10, 0.001);
                tessellator.draw();

                tessellator.startDrawingQuads();
                tessellator.setNormal(0, 0, -1); //TODO don't think is needed for inventory
                generatedGeometry(subIcon, type, -0.0635, -0.0635);
                tessellator.draw();

                GL11.glDisable(GL11.GL_BLEND);
                GL11.glDepthMask(true);
                GL11.glDepthFunc(GL11.GL_LEQUAL);
                GL11.glEnable(GL11.GL_CULL_FACE);
                GL11.glColor4f(1, 1, 1, 1);
            }
        }
    }
}

From source file:com.darkona.adventurebackpack.client.render.CopygirlRenderUtils.java

License:Open Source License

public static void renderItemIn3d(ItemStack stack) {
    TextureManager textureManager = Minecraft.getMinecraft().getTextureManager();
    // Not sure why but this can be null when the world loads.
    if (textureManager == null) {
        return;//  w  ww. ja  va  2s .  c  om
    }
    Item item = stack.getItem();

    GL11.glPushMatrix();

    Tessellator tessellator = Tessellator.instance;
    GL11.glEnable(GL12.GL_RESCALE_NORMAL);
    GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
    GL11.glTranslatef(-0.5F, -0.5F, 1 / 32.0F);

    int passes = item.getRenderPasses(stack.getItemDamage());
    for (int pass = 0; pass < passes; pass++) {
        textureManager.bindTexture(((stack.getItemSpriteNumber() == 0) ? TextureMap.locationBlocksTexture
                : TextureMap.locationItemsTexture));
        IIcon icon = item.getIcon(stack, pass);
        if (icon != null) {
            float minU = icon.getMinU();
            float maxU = icon.getMaxU();
            float minV = icon.getMinV();
            float maxV = icon.getMaxV();
            CopygirlRenderUtils.setColorFromInt(item.getColorFromItemStack(stack, pass));
            ItemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(),
                    icon.getIconHeight(), 0.0625F);
        }
    }

    if (stack.hasEffect(0)) {
        GL11.glDepthFunc(GL11.GL_EQUAL);
        GL11.glDisable(GL11.GL_LIGHTING);
        textureManager.bindTexture(glint);
        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 = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
        GL11.glTranslatef(f9, 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, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glPushMatrix();
        GL11.glScalef(f8, f8, f8);
        f9 = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
        GL11.glTranslatef(-f9, 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, 256, 256, 0.0625F);
        GL11.glPopMatrix();
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
    }

    GL11.glDisable(GL12.GL_RESCALE_NORMAL);

    GL11.glPopMatrix();
}

From source file:com.gameminers.ethereal.architect.ModelCanvas.java

License:Open Source License

@Override
protected void paintGL() {
    try {/*from  w  w w  .  ja  v a 2s . c  om*/
        if (getWidth() != current_width || getHeight() != current_height) {
            current_width = getWidth();
            current_height = getHeight();
            GL11.glViewport(0, 0, current_width, current_height);
        }
        GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f);
        GL11.glClearDepth(1.0);
        GL11.glColor3f(1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, zoom);
        GL11.glRotatef(angle, 0f, 1f, 0f);
        GL11.glRotatef(tilt, 1f, 0f, 0f);
        GL11.glTranslatef(-16, -16, -16);
        if (lit) {
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        if (textured) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        if (model != null) {
            if (model.isAmbientOcclusionEnabled()) {
                GL11.glShadeModel(GL11.GL_SMOOTH);
            } else {
                GL11.glShadeModel(GL11.GL_FLAT);
            }
            for (ModelElement ele : model.getElements()) {
                GL11.glPushMatrix();
                if (ele.isShade()) {
                    GL11.glEnable(GL11.GL_LIGHTING);
                } else {
                    GL11.glDisable(GL11.GL_LIGHTING);
                }
                float fromX = ele.getFrom()[0];
                float fromY = ele.getFrom()[1];
                float fromZ = ele.getFrom()[2];
                float toX = ele.getTo()[0];
                float toY = ele.getTo()[1];
                float toZ = ele.getTo()[2];

                float fX = (fromX > toX ? fromX : toX);
                float fY = (fromY > toY ? fromY : toY);
                float fZ = (fromZ > toZ ? fromZ : toZ);
                float tX = (fromX > toX ? toX : fromX);
                float tY = (fromY > toY ? toY : fromY);
                float tZ = (fromZ > toZ ? toZ : fromZ);

                GL11.glTranslatef(fX, fY, fZ);
                float scaleX = tX - fX;
                float scaleY = tY - fY;
                float scaleZ = tZ - fZ;
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glNormal3f(0, 0, -1f);
                for (int i = 0; i < vertices.length / 3; i++) {
                    int faceIdx = i / 4;
                    ModelFace face;
                    switch (faceIdx) {
                    case 0:
                        face = ele.getFaces().getNorth();
                        break;
                    case 1:
                        face = ele.getFaces().getSouth();
                        break;
                    case 2:
                        face = ele.getFaces().getUp();
                        break;
                    case 3:
                        face = ele.getFaces().getDown();
                        break;
                    case 4:
                        face = ele.getFaces().getWest();
                        break;
                    case 5:
                        face = ele.getFaces().getEast();
                        break;
                    default:
                        face = null;
                        break;
                    }
                    int idx = i * 3;
                    float vX = vertices[idx] * scaleX;
                    float vY = vertices[idx + 1] * scaleY;
                    float vZ = vertices[idx + 2] * scaleZ;
                    /*float u;
                    float v;
                    GL11.glTexCoord2f(u, v);*/
                    GL11.glVertex3f(vX, vY, vZ);
                }
                GL11.glEnd();
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
        swapBuffers();
        repaint();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.github.kajdreef.mazerunnermvn.Launcher.java

/**
 * Initialize the display.//from w  w w.j a  v  a  2 s  .  c  om
 */
public void initDisplayLWJGL() {
    PixelFormat pixelFormat = new PixelFormat();
    ContextAttribs contextAtrributes = new ContextAttribs(3, 2).withForwardCompatible(true)
            .withProfileCore(true);

    try {
        Display.setDisplayMode(new DisplayMode(WIDTH, HEIGHT));
        Display.setTitle("MazeRunner");
        Display.create(pixelFormat, contextAtrributes);
    } catch (LWJGLException e) {
        e.printStackTrace();
        System.exit(-1);
    }

    GL11.glClearColor(0.4f, 0.6f, 0.9f, 0f);
    GL11.glViewport(0, 0, WIDTH, HEIGHT);

    // Enable depth test so the objects are rendered in the right way.
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glDepthMask(true);

    GL11.glEnable(GL11.GL_CULL_FACE);
}