Example usage for com.badlogic.gdx.graphics GL20 GL_DEPTH_TEST

List of usage examples for com.badlogic.gdx.graphics GL20 GL_DEPTH_TEST

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics GL20 GL_DEPTH_TEST.

Prototype

int GL_DEPTH_TEST

To view the source code for com.badlogic.gdx.graphics GL20 GL_DEPTH_TEST.

Click Source Link

Usage

From source file:com.lyeeedar.Roguelike3D.Graphics.Screens.AbstractScreen.java

License:Open Source License

@Override
public void render(float delta) {

    update(delta);//from  w w w.  ja va  2s . c om
    stage.act(delta);

    Gdx.graphics.getGL20().glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    Gdx.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    Gdx.graphics.getGL20().glEnable(GL20.GL_CULL_FACE);
    Gdx.graphics.getGL20().glCullFace(GL20.GL_BACK);

    Gdx.graphics.getGL20().glEnable(GL20.GL_DEPTH_TEST);
    Gdx.graphics.getGL20().glDepthMask(true);

    drawModels(delta);

    Gdx.graphics.getGL20().glDisable(GL20.GL_CULL_FACE);

    drawTransparent(delta);

    Gdx.graphics.getGL20().glDisable(GL20.GL_DEPTH_TEST);

    drawOrthogonals(delta);

    fps.log();

}

From source file:com.perfectplay.org.SkyBox.java

License:Open Source License

public void render(PerspectiveCamera camera) {
    invView.set(camera.view);//w w  w  .jav a 2 s . c  o m

    // Remove translation
    invView.val[Matrix4.M03] = 0;
    invView.val[Matrix4.M13] = 0;
    invView.val[Matrix4.M23] = 0;

    invView.inv().tra();

    mvp.set(camera.projection);
    mvp.mul(invView);

    Gdx.gl.glEnable(GL20.GL_CULL_FACE);
    Gdx.gl.glCullFace(GL20.GL_FRONT);
    Gdx.gl.glFrontFace(GL20.GL_CCW);

    Gdx.gl20.glDisable(GL20.GL_BLEND);
    Gdx.gl20.glDisable(GL20.GL_DEPTH_TEST);
    Gdx.gl20.glDepthMask(false);

    Gdx.gl20.glActiveTexture(GL20.GL_TEXTURE0);
    Gdx.gl20.glBindTexture(GL20.GL_TEXTURE_CUBE_MAP, g_cubeTexture);

    program.begin();

    program.setUniformMatrix("u_mvpMatrix", mvp);
    program.setUniformi("s_cubemap", 0);

    cube.render(program, GL20.GL_TRIANGLE_STRIP);

    program.end();

    Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
    Gdx.gl.glDepthMask(true);
}

From source file:org.ah.gcode.preview.GCodePreview.java

License:Open Source License

@Override
public void render() {
    if (loadingAssets && assetManager.update()) {
        finishedLoading();/*from   ww  w  .  j  av a2s  . c o  m*/
    }

    if (loadingAssets) {
    } else {
        if (parsingGCode) {
            parseGCode();
        } else if (preparingMeshes) {
            prepareMesh();
        } else {
        }
    }
    camera.update();
    Vector3 lightDirection = new Vector3(camera.direction).nor();
    directionalLight.set(lightColor, lightDirection);

    // Magic rendering initialisation
    Gdx.gl.glDisable(GL20.GL_CULL_FACE);
    Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
    //        Gdx.gl.glEnable(GL20.GL_BLEND);
    //        Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));

    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    if (instances.size() > 0) {
        modelBatch.begin(camera);
        for (ModelInstance instance : instances) {
            modelBatch.render(instance, environment);
        }

        // gCodeModel.render(modelBatch, environment);
        modelBatch.end();
    }
    if (controller != null) {
        controller.render(camera, environment);
    }

    spriteBatch.begin();
    spriteBatch.setProjectionMatrix(spriteFontCamera.combined);
    spriteBatch.enableBlending();
    window.render(spriteBatch);
    spriteBatch.end();
}

From source file:postprocessing.PostProcessor.java

License:Apache License

/** Stops capturing the scene and apply the effect chain, if there is one. If the specified output framebuffer is NULL, then the
 * rendering will be performed to screen. */
public void render(FrameBuffer dest) {
    captureEnd();//from  w  ww.j a v a 2s .com

    if (!hasCaptured) {
        return;
    }

    // Array<PostProcessorEffect> items = manager.items;
    Array<PostProcessorEffect> items = enabledEffects;

    int count = items.size;
    if (count > 0) {

        Gdx.gl.glDisable(GL20.GL_CULL_FACE);
        Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);

        // render effects chain, [0,n-1]
        if (count > 1) {
            for (int i = 0; i < count - 1; i++) {
                PostProcessorEffect e = items.get(i);
                composite.capture();
                {
                    e.render(composite.getSourceBuffer(), composite.getResultBuffer());
                }
            }

            // complete
            composite.end();
        }

        if (listener != null && dest == null) {
            listener.beforeRenderToScreen();
        }

        // render with null dest (to screen)
        items.get(count - 1).render(composite.getResultBuffer(), dest);

        // ensure default texture unit #0 is active
        Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0);
    } else {
        Gdx.app.log("PostProcessor", "No post-processor effects enabled, aborting render");
    }
}

From source file:ta.firegreen.creation.creator.java

License:Apache License

@Override
public void create() {
    batch = new SpriteBatch();
    rendu = new ImmediateModeRenderer20(false, true, 0);
    renduTexture = new ImmediateModeRenderer20(false, true, 1);
    configF = new ConfigurationFrame(this);
    cam = new PerspectiveCamera(95, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    Gdx.gl20.glEnable(GL20.GL_TEXTURE_2D);
    Gdx.gl20.glEnable(GL20.GL_DEPTH_TEST);
    Gdx.gl20.glEnable(GL20.GL_BLEND);// w ww  . j a  v  a  2  s  .c  o  m
    Gdx.gl20.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    shape = new ShapeRenderer();
    cam.near = 1;
    cam.far = 100;
    cam.direction.set(0, 1, 0);
    cam.position.set(posX, posY, posZ);
    cam.lookAt(cibleX, cibleY, cibleZ);
    cam.update();
    configF.setVisible(true);
    trianglesSelected = new MeshTA();

}

From source file:tilo.Tilo.java

License:Open Source License

public void create() {
    int width = 800;
    int height = 600;
    Tilo.width = width;/* w  w w.j  a  v  a 2s .  c o  m*/
    Tilo.height = height;

    script = new lua();

    // LOAD PLUGINS
    g.plugin_load();
    script.put("graphics", g);
    script.put("timer", t);
    script.put("window", w);
    script.put("math", m);
    script.put("input", i);
    script.put("audio", a);

    if (getPlatform().equalsIgnoreCase("desktop")) {
        width = 800;
        height = 600;

        Tilo.width = width;
        Tilo.height = height;

        boolean fullscreen = false;
        Gdx.graphics.setDisplayMode(width, height, fullscreen);
    }
    assets = new AssetManager();
    Gdx.input.setInputProcessor(this);

    // LOAD SCRIPT
    FileHandle main = file("main.lua");

    if (main.exists()) {
        script.eval(main.readString());
    } else {
        error(TAG, E_RESOURCE + main.name());
        quit();
    }

    // Enable non power of two textures.
    FileTextureData.copyToPOT = true;

    // Set OpenGL features
    Gdx.gl.glDisable(GL20.GL_CULL_FACE);
    Gdx.gl.glDisable(GL20.GL_DITHER);
    Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

    script.invoke("tilo", "load", assets);
    ready = true;
}