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:org.minetweak.world.characters.Player.java

License:Apache License

@Override
public void render() {
    GL11.glEnable(GL11.GL_DEPTH_TEST);//from w  ww  .  j  a va  2 s. c o  m
    GL11.glDepthFunc(GL11.GL_LEQUAL);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);

    if (_aimedBlockPosition.y() != -1) {
        GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glDisable(GL11.GL_TEXTURE_2D);

        _aimedBlockAABB.render(0.0f, 0.0f, 0.0f, 0.1f);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
    }

    if (_selectedItem != null) {
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_CULL_FACE);

        _body.transformToRightHand();

        /* Prepare the light buffer */
        Chunk c = Game.getInstance().getWorld().getChunkManager().getChunkContaining(
                MathHelper.floor(_position.x()), MathHelper.floor(_position.y()) + 1,
                MathHelper.floor(_position.z()), false, false, false);
        if (c != null) {
            c.getLightBuffer().setReferencePoint(MathHelper.floor(_position.x()),
                    MathHelper.floor(_position.y()) + 1, MathHelper.floor(_position.z()));

            /* Render the object, with the lightbuffer */
            _selectedItem.renderHoldableObject(c.getLightBuffer());
        }

        GL11.glEnable(GL11.GL_CULL_FACE);
        GL11.glPopMatrix();
    }
    GL11.glDisable(GL11.GL_DEPTH_TEST);
}

From source file:org.mkdev.ai.langton3d.core.App.java

License:GNU General Public License

private boolean initGL() {
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();//  w  w w .  ja v a2  s. c  o  m

    GLU.gluPerspective(FOV, ((float) targetWidth) / ((float) targetHeight), 0.1f, 100.0f);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    GL11.glShadeModel(GL11.GL_SMOOTH);

    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_FASTEST);

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

    setupLights();
    setupFog(Settings.FOG_DENSITY, Settings.FOG_START, Settings.FOG_END);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    return true;
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void drawSky(float[] view_xyz) {
    GL11.glDisable(GL11.GL_LIGHTING);/* w w w . j  av  a 2s . c  o m*/
    if (use_textures) {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        sky_texture.bind(false);
    } else {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glColor3f(0f, 0.5f, 1.0f);
    }

    // make sure sky depth is as far back as possible
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glDepthRange(1, 1);

    final float ssize = 1000.0f;

    float x = ssize * sky_scale;
    float y = view_xyz[1] + sky_height;

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glNormal3f(0, -1, 0);
    GL11.glTexCoord2f(x + offset, -x + offset);
    GL11.glVertex3f(ssize + view_xyz[0], y, -ssize + view_xyz[2]);
    GL11.glTexCoord2f(x + offset, x + offset);
    GL11.glVertex3f(ssize + view_xyz[0], y, ssize + view_xyz[2]);
    GL11.glTexCoord2f(-x + offset, x + offset);
    GL11.glVertex3f(-ssize + view_xyz[0], y, ssize + view_xyz[2]);
    GL11.glTexCoord2f(-x + offset, -x + offset);
    GL11.glVertex3f(-ssize + view_xyz[0], y, -ssize + view_xyz[2]);
    GL11.glEnd();

    offset = offset + 0.002f;
    if (offset > 1)
        offset -= 1;

    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glDepthRange(0, 1);
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void drawGround() {
    GL11.glDisable(GL11.GL_LIGHTING);/*from   w w  w  .ja v a 2  s  .c o m*/
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);
    // GL11.glDepthRange (1,1);

    if (use_textures) {
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        ground_texture.bind(false);
    } else {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glColor3f(GROUND_R, GROUND_G, GROUND_B);
    }

    // ground fog seems to cause problems with TNT2 under windows
    /*
    GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1};
    GL11.glEnable (GL_FOG);
    GL11.glFogi (GL_FOG_MODE, GL_EXP2);
    GL11.glFogfv (GL_FOG_COLOR, fogColor);
    GL11.glFogf (GL_FOG_DENSITY, 0.05f);
    GL11.glHint (GL_FOG_HINT, GL_NICEST); // GL_DONT_CARE);
    GL11.glFogf (GL_FOG_START, 1.0);
    GL11.glFogf (GL_FOG_END, 5.0);
     */

    final float gsize = 100.0f;
    final float offset = 0; // -0.001f; ... polygon offsetting doesn't work well

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glNormal3f(0, 1, 0);

    GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz);
    GL11.glVertex3f(-gsize, offset, gsize);
    GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, gsize * ground_scale + ground_ofsz);
    GL11.glVertex3f(gsize, offset, gsize);
    GL11.glTexCoord2f(gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz);
    GL11.glVertex3f(gsize, offset, -gsize);
    GL11.glTexCoord2f(-gsize * ground_scale + ground_ofsx, -gsize * ground_scale + ground_ofsz);
    GL11.glVertex3f(-gsize, offset, -gsize);
    GL11.glEnd();

    GL11.glDisable(GL11.GL_FOG);
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void drawPyramidGrid() {
    // setup stuff
    GL11.glEnable(GL11.GL_LIGHTING);//from w ww . j  a  v  a  2 s  .c  o  m
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);

    // draw the pyramid grid
    for (int i = -1; i <= 1; i++) {
        for (int j = -1; j <= 1; j++) {
            GL11.glPushMatrix();
            GL11.glTranslatef(i, 0, j);
            if (i == 1 && j == 0)
                setColor(1, 0, 0, 1);
            else if (i == 0 && j == 1)
                setColor(0, 0, 1, 1);
            else
                setColor(1, 1, 0, 1);
            final float k = 0.03f;
            GL11.glBegin(GL11.GL_TRIANGLE_FAN);
            GL11.glNormal3f(0, 1, -1);
            GL11.glVertex3f(0, k, 0);
            GL11.glVertex3f(-k, 0, -k);
            GL11.glVertex3f(k, 0, -k);
            GL11.glNormal3f(1, 1, 0);
            GL11.glVertex3f(k, 0, k);
            GL11.glNormal3f(0, 1, 1);
            GL11.glVertex3f(-k, 0, k);
            GL11.glNormal3f(-1, 1, 0);
            GL11.glVertex3f(-k, 0, -k);
            GL11.glEnd();
            GL11.glPopMatrix();
        }
    }
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

@Override
//   void dsDrawFrame (int width, int height, dsFunctions *fn, int pause)
void dsDrawFrame(int width, int height, dsFunctions fn, boolean pause) {
    if (current_state < 1)
        dsDebug("internal error");
    current_state = 2;// www.  ja  v  a  2 s .  c  om

    // setup stuff
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_LIGHT0);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
    GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glCullFace(GL11.GL_BACK);
    GL11.glFrontFace(GL11.GL_CCW);

    // setup viewport
    GL11.glViewport(0, 0, width, height);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    final float vnear = 0.1f;
    final float vfar = 100.0f;
    final float k = 0.8f; // view scale, 1 = +/- 45 degrees
    if (width >= height) {
        float k2 = (float) height / (float) width;
        GL11.glFrustum(-vnear * k, vnear * k, -vnear * k * k2, vnear * k * k2, vnear, vfar);
    } else {
        float k2 = (float) width / (float) height;
        GL11.glFrustum(-vnear * k * k2, vnear * k * k2, -vnear * k, vnear * k, vnear, vfar);
    }

    // setup lights. it makes a difference whether this is done in the
    // GL_PROJECTION matrix mode (lights are scene relative) or the
    // GL_MODELVIEW matrix mode (lights are camera relative, bad!).
    //      static GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 };
    //      static GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 };
    //      static GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, light_ambient);
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_DIFFUSE, light_diffuse);
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_SPECULAR, light_specular);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);

    // clear the window
    GL11.glClearColor(0.5f, 0.5f, 0.5f, 0);
    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    // snapshot camera position (in MS Windows it is changed by the GUI thread)
    float[] view2_xyz = view_xyz.clone();
    float[] view2_rxyz = view_rxyz.clone();
    //      memcpy (view2_xyz,view_xyz);//,sizeof(float)*3);
    //      memcpy (view2_hpr,view_hpr);//,sizeof(float)*3);

    // go to GL_MODELVIEW matrix mode and set the camera
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    setCamera(view2_xyz[0], view2_xyz[1], view2_xyz[2], view2_rxyz[0], view2_rxyz[1], view2_rxyz[2]);

    // set the light position (for some reason we have to do this in model view.
    //      static GLfloat light_position[] = { LIGHTX, LIGHTY, 1.0, 0.0 };
    GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, light_position);

    // draw the background (ground, sky etc)
    drawSky(view2_xyz);
    drawGround();

    // draw the little markers on the ground
    drawPyramidGrid();

    // leave openGL in a known state - flat shaded white, no textures
    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthFunc(GL11.GL_LESS);
    GL11.glColor3f(1, 1, 1);
    setColor(1, 1, 1, 1);

    // draw the rest of the objects. set drawing state first.
    color[0] = 1;
    color[1] = 1;
    color[2] = 1;
    color[3] = 1;
    tnum = DS_TEXTURE_NUMBER.DS_NONE;
    //if (fn.step) 
    fn.step(pause);
}

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

License:Apache License

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

From source file:org.spoutcraft.client.gui.MCRenderDelegate.java

License:Open Source License

public void render(GenericItemWidget item) {
    GL11.glDepthFunc(515);
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_DEPTH_TEST);//from   ww w  .j  a va2  s. c  o  m
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) item.getScreenX(), (float) item.getScreenY(), 0);
    if (item.getAnchor() == WidgetAnchor.SCALE) {
        GL11.glScalef((float) (item.getScreen().getWidth() / 427f),
                (float) (item.getScreen().getHeight() / 240f), 1);
    }
    GL11.glScaled(item.getWidth() / 16D, item.getHeight() / 16D, 1);
    int id = item.getTypeId();
    int data = item.getData();
    if (MaterialData.getCustomItem(id) != null) {
        int temp = id;
        id = 318;
        data = temp;
    }
    GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
    renderer.renderItemIntoGUI(SpoutClient.getHandle().fontRenderer, SpoutClient.getHandle().renderEngine,
            new net.minecraft.src.ItemStack(id, 1, data), 0, 0);
    GL11.glPopMatrix();
    GL11.glScaled(16D / item.getWidth(), 16D / item.getHeight(), 1);
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    RenderHelper.disableStandardItemLighting();
}

From source file:org.spoutcraft.client.gui.MCRenderDelegate.java

License:Open Source License

public void render(GenericSlot genericSlot) {
    if (!genericSlot.isVisible()) {
        return;/*w w w  .j  a v  a 2  s  . c o  m*/
    }
    ItemStack item = genericSlot.getItem();

    GL11.glDepthFunc(515);
    RenderHelper.enableGUIStandardItemLighting();
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_COLOR_MATERIAL);
    GL11.glPushMatrix();
    GL11.glTranslatef((float) genericSlot.getScreenX(), (float) genericSlot.getScreenY(), 0);
    if (genericSlot.getAnchor() == WidgetAnchor.SCALE) {
        GL11.glScalef((float) (genericSlot.getScreen().getWidth() / 427f),
                (float) (genericSlot.getScreen().getHeight() / 240f), 1);
    }
    GL11.glScaled(genericSlot.getWidth() / 16D, genericSlot.getHeight() / 16D, 1);

    if (item.getTypeId() != 0) {
        GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
        int id = item.getTypeId();
        int data = item.getDurability();
        if (MaterialData.getCustomItem(id) != null) {
            int temp = id;
            id = 318;
            data = temp;
        }
        renderer.renderItemIntoGUI(SpoutClient.getHandle().fontRenderer, SpoutClient.getHandle().renderEngine,
                new net.minecraft.src.ItemStack(id, item.getAmount(), data), 0, 0);
        renderer.renderItemOverlayIntoGUI(SpoutClient.getHandle().fontRenderer,
                SpoutClient.getHandle().renderEngine,
                new net.minecraft.src.ItemStack(id, item.getAmount(), data), 0, 0);
    }
    GL11.glEnable(GL11.GL_LIGHTING);
    RenderHelper.disableStandardItemLighting();
    if (isHovering(genericSlot))
        RenderUtil.drawRectangle(0, 0, 16, 16, 0x88ffffff);
    GL11.glPopMatrix();
}

From source file:org.terasology.rendering.dag.tasks.SetDepthFunctionTask.java

License:Apache License

@Override
public void execute() {
    GL11.glDepthFunc(depthFunction);
}