Example usage for com.badlogic.gdx.graphics GL10 GL_DEPTH_BUFFER_BIT

List of usage examples for com.badlogic.gdx.graphics GL10 GL_DEPTH_BUFFER_BIT

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL10 GL_DEPTH_BUFFER_BIT.

Prototype

int GL_DEPTH_BUFFER_BIT

To view the source code for com.badlogic.gdx.graphics GL10 GL_DEPTH_BUFFER_BIT.

Click Source Link

Usage

From source file:airfoil.Main.java

License:Open Source License

@Override
public void render() {
    if (this.alive) {
        GLCommon gl = Gdx.gl;/*w w  w  .  j a  va 2s .  co  m*/
        gl.glViewport(0, 0, this.width, this.height);
        gl.glClearColor(ColorClear.r, ColorClear.g, ColorClear.b, ColorClear.a);
        gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
        gl.glEnable(GL20.GL_DEPTH_TEST);
        gl.glDepthFunc(GL20.GL_LESS);

        /*
         */

        this.renderMeshLines(this.database.getMesh(this.geometry));

    }
}

From source file:application.concretion.GameScreenController.java

License:Open Source License

@Override
public void render() {
    //   log.log();
    // Clean the screen
    Gdx.gl.glClearColor(1, 1, 1, 1);/*from  w  ww .j  a  v a  2 s  .  com*/
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT | GL10.GL_STENCIL_BUFFER_BIT);

    // Update and draw the screen
    currentScreen.update(Gdx.graphics.getDeltaTime());
    currentScreen.draw(Gdx.graphics.getDeltaTime());

    // Check if the current screen is done and set the next screen if return
    // null means that is not done
    nextScreen = currentScreen.nextScreen();
    if (nextScreen != null) {
        // Dispose the resources of the current screen
        currentScreen.dispose();
        // Set the next screen
        currentScreen = nextScreen;
    }
}

From source file:com.badlogic.gdx.graphics.g3d.test.KeyframedModelViewer.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    cam.update();/*  w w w  .  j  ava  2  s  . com*/
    cam.apply(Gdx.gl10);

    drawAxes();

    if (hasNormals) {
        Gdx.gl.glEnable(GL10.GL_LIGHTING);
        Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL);
        Gdx.gl.glEnable(GL10.GL_LIGHT0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);
    }

    if (texture != null) {
        Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
        texture.bind();
    }

    angle += 45 * Gdx.graphics.getDeltaTime();
    animTime += Gdx.graphics.getDeltaTime();
    if (animTime >= anim.totalDuration) {
        animTime = 0;
    }

    model.setAnimation(anim.name, animTime, false);
    for (int i = 0; i < 20; i++) {
        Gdx.gl10.glPushMatrix();
        Gdx.gl10.glTranslatef(0, 0, -100 + i * 10);
        model.render();
        Gdx.gl10.glPopMatrix();
    }

    if (texture != null) {
        Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
    }

    if (hasNormals) {
        Gdx.gl.glDisable(GL10.GL_LIGHTING);
    }

    batch.begin();
    font.setColor(Color.RED);
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30);
    batch.end();
}

From source file:com.badlogic.gdx.graphics.g3d.test.MD2Viewer.java

@Override
public void render() {
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    cam.update();//from   w ww  .  j a  v a2 s. c  o m
    cam.apply(Gdx.gl10);

    angle += 45 * Gdx.graphics.getDeltaTime();
    Gdx.gl10.glRotatef(angle, 0, 1, 0);

    Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
    texture.bind();

    model.subMeshes[0].mesh.setVertices(model.subMeshes[0].animations.get("all").keyframes[0].vertices);
    model.subMeshes[0].mesh.render(GL10.GL_TRIANGLES);
}

From source file:com.badlogic.gdx.graphics.g3d.test.QbobViewer.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0, 0, 0, 1);//  w ww  .  j a va  2s.  c  o m
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

    cam.update();
    cam.apply(Gdx.gl10);

    Gdx.gl.glEnable(GL10.GL_CULL_FACE);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0);
    Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
    diffuse.bind();
    diffuse.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE1);
    Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);

    lightMaps[0].bind();
    lightMaps[0].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();

    model[0].render();
    lightMaps[1].bind();
    lightMaps[1].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();

    model[1].render();
    lightMaps[2].bind();
    lightMaps[2].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();

    model[2].render();
    lightMaps[3].bind();
    lightMaps[3].setFilter(TextureFilter.MipMapNearestNearest, TextureFilter.Linear);
    setCombiners();
    model[3].render();

    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE1);
    Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
    Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0);
    Gdx.gl.glDisable(GL10.GL_CULL_FACE);
    Gdx.gl11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

    Gdx.gl.glDisable(GL10.GL_BLEND);

    animTime += Gdx.graphics.getDeltaTime();
    if (animTime > anim.totalDuration - anim.frameDuration)
        animTime = 0;
    animModel.setAnimation(anim.name, animTime, true);

    Gdx.gl10.glPushMatrix();
    Gdx.gl10.glTranslatef(cam.position.x, cam.position.y, 6);
    animModel.render();
    Gdx.gl10.glPopMatrix();

    Gdx.gl.glDisable(GL10.GL_DEPTH_TEST);
    batch.begin();
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 10, 20);
    batch.end();

    fps.log();
}

From source file:com.badlogic.gdx.graphics.g3d.test.SkeletonModelViewer.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    cam.update();//from w  w w  . j a va  2s .  co m
    cam.apply(Gdx.gl10);

    drawAxes();

    if (hasNormals) {
        Gdx.gl.glEnable(GL10.GL_LIGHTING);
        Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL);
        Gdx.gl.glEnable(GL10.GL_LIGHT0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);
    }

    if (texture != null) {
        Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
        Gdx.gl.glEnable(GL10.GL_BLEND);
        Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    }

    angle += 45 * Gdx.graphics.getDeltaTime();
    Gdx.gl10.glRotatef(angle, 0, 1, 0);
    animTime += Gdx.graphics.getDeltaTime() / 10;
    if (animTime > anim.totalDuration) {
        animTime = 0;
    }
    model.setAnimation(anim.name, animTime, false);
    model.render();

    if (texture != null) {
        Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
    }

    if (hasNormals) {
        Gdx.gl.glDisable(GL10.GL_LIGHTING);
    }

    batch.begin();
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30);
    batch.end();
}

From source file:com.badlogic.gdx.graphics.g3d.test.StillModelViewer.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1.0f);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);

    cam.update();//from w w  w .ja  v a 2 s  .  c o m
    cam.apply(Gdx.gl10);

    drawAxes();

    if (hasNormals) {
        Gdx.gl.glEnable(GL10.GL_LIGHTING);
        Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL);
        Gdx.gl.glEnable(GL10.GL_LIGHT0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
        Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);
    }

    if (textures != null) {
        for (int i = 0; i < textures.length; i++) {
            Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0 + i);
            Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
            textures[i].bind();
            if (i > 0) {
                switch (i) {
                case 1:
                    setCombiners(GL11.GL_ADD_SIGNED);
                    break;
                case 2:
                    setCombiners(GL10.GL_MODULATE);
                    break;
                default:
                    setCombiners(GL10.GL_MODULATE);
                }
            }
        }
    }

    angle += 45 * Gdx.graphics.getDeltaTime();
    Gdx.gl10.glRotatef(angle, 0, 1, 0);
    model.render();

    if (textures != null) {
        for (int i = 0; i < textures.length; i++) {
            Gdx.gl.glActiveTexture(GL10.GL_TEXTURE0 + i);
            Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
        }
    }

    if (hasNormals) {
        Gdx.gl.glDisable(GL10.GL_LIGHTING);
    }

    batch.begin();
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30);
    batch.end();

    fps.log();
}

From source file:com.badlogic.gdx.graphics.g3d.test.StillModelViewerGL20.java

License:Apache License

@Override
public void render() {

    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl.glEnable(GL10.GL_CULL_FACE);/*from ww  w  . ja  va 2 s  .co  m*/

    instance.getTransform().rotate(0, 1, -0.1f, 35 * Gdx.graphics.getDeltaTime());
    instance2.getTransform().rotate(0, 1, 0.1f, -15 * Gdx.graphics.getDeltaTime());

    cam.update();

    protoRenderer.begin();
    protoRenderer.draw(model, instance);
    protoRenderer.draw(model, instance2);
    protoRenderer.end();

    batch.begin();
    font.draw(batch, "fps: " + Gdx.graphics.getFramesPerSecond(), 20, 30);
    batch.end();

    fps.log();
}

From source file:com.badlogic.gdx.graphics.g3d.test.Viewer.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    Gdx.gl.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl.glEnable(GL10.GL_TEXTURE_2D);
    Gdx.gl.glEnable(GL10.GL_LIGHTING);/*from   w ww . j  ava 2  s.co  m*/
    Gdx.gl.glEnable(GL10.GL_COLOR_MATERIAL);

    cam.update();
    cam.apply(Gdx.gl10);

    Gdx.gl.glEnable(GL10.GL_LIGHT0);
    Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightColor, 0);
    Gdx.gl10.glLightfv(GL10.GL_LIGHT0, GL10.GL_POSITION, lightPosition, 0);

    angle += 45 * Gdx.graphics.getDeltaTime();
    long processingTime = 0;
    for (int i = 0; i < NUM_INSTANCES; i++) {
        // Gdx.gl10.glPushMatrix();
        // Gdx.gl10.glTranslatef(0, 0, i * -50);
        // Gdx.gl10.glRotatef(angle, 0, 1, 0);
        model.setAnimation(animation, time, true);
        model.render();

        // Gdx.gl10.glPopMatrix();
    }

    Gdx.gl.glDisable(GL10.GL_LIGHTING);
    Gdx.gl.glDisable(GL10.GL_DEPTH_TEST);
    Gdx.gl.glDisable(GL10.GL_TEXTURE_2D);
    renderSkeleton();

    Gdx.app.log("Skinning", "took: " + processingTime / 1000000000.0f + " secs");

    batch.begin();
    font.draw(batch, "Touch to switch Animation, Animation: " + animation + ", FPS: "
            + Gdx.graphics.getFramesPerSecond(), 10, 30);
    batch.end();

    if (Gdx.input.justTouched()) {
        currAnimIdx++;
        if (currAnimIdx == animNames.size())
            currAnimIdx = 0;
        animation = animNames.get(currAnimIdx);
        time = 0;
    }

    time += Gdx.graphics.getDeltaTime() / 10;
    if (time > model.skeleton.animations.get(animation).totalDuration) {
        time = 0;
    }
}

From source file:com.badlogic.gdx.physics.bullet.demo.screens.SimulationScreen.java

@Override
public final void render(float graphicsDelta) {
    // Physics/*from   w  w w .  j a  v  a  2 s .co  m*/
    hookRenderPrePhysics(graphicsDelta);
    final float physicsDelta = stepPhysics();
    hookRenderPostPhysics(graphicsDelta, physicsDelta);

    // Clear frame and enable model styles
    Gdx.gl10.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
    hookRenderPostClear(graphicsDelta, physicsDelta);

    // Apply perspective player camera
    perspectiveCamera.apply(Gdx.gl10);

    Gdx.gl10.glEnable(GL10.GL_DITHER);
    Gdx.gl10.glEnable(GL10.GL_DEPTH_TEST);
    Gdx.gl10.glEnable(GL10.GL_CULL_FACE);
    Gdx.gl10.glEnable(GL10.GL_BLEND);
    Gdx.gl10.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);

    // Position lights so lighting calculations for objects are correct
    positionLights(graphicsDelta, physicsDelta);

    renderDynamicsWorld();

    hookRenderScene(graphicsDelta, physicsDelta);

    // Apply orthographic OSD camera
    osdCamera.apply(Gdx.gl10);

    // Disable face culling so we draw everything
    Gdx.gl10.glDisable(GL10.GL_CULL_FACE);

    // Render OSD
    disableLights();
    osdSpriteBatch.begin();
    osdFont.setColor(1, 1, 1, 1f);
    osdFont.draw(osdSpriteBatch, getOSDText(), 10, 10 + osdFont.getCapHeight());
    osdSpriteBatch.end();
    hookRenderOSD(graphicsDelta, physicsDelta);
}