Java Code Examples for com.badlogic.gdx.graphics.GL20#glEnable()

The following examples show how to use com.badlogic.gdx.graphics.GL20#glEnable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Renderer.java    From VuforiaLibGDX with MIT License 5 votes vote down vote up
public void render(Display display, float delta) {
    GL20 gl = Gdx.gl;

    gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    TrackableResult[] results = null;

    if (vuforiaRenderer != null && vuforiaRenderer.isActive()) {
        //render camera background and find targets
        results = vuforiaRenderer.onDrawFrame();
    }

    gl.glEnable(GL20.GL_DEPTH_TEST);
    gl.glEnable(GL20.GL_CULL_FACE);


    double FOV = 1.0;
    if (vuforiaRenderer != null) {
        FOV = Math.toDegrees(vuforiaRenderer.getFieldOfViewRadians());
    }
    setProjectionAndCamera(display, results, (float) FOV);
    modelBatch.begin(camera);

    gl.glDepthMask(true);
    modelBatch.render(display.modelInstance, lights);

    modelBatch.end();

    gl.glDisable(GL20.GL_CULL_FACE);
    gl.glDisable(GL20.GL_DEPTH_TEST);
    gl.glDisable(GL20.GL_BLEND);
}
 
Example 2
Source File: Renderer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
public void render (Simulation simulation, float delta) {
	// We explicitly require GL10, otherwise we could've used the GLCommon
	// interface via Gdx.gl
	GL20 gl = Gdx.gl;
	gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
	renderBackground();
	gl.glEnable(GL20.GL_DEPTH_TEST);
	gl.glEnable(GL20.GL_CULL_FACE);
	setProjectionAndCamera(simulation.ship);

	modelBatch.begin(camera);
	modelBatch.render(simulation.explosions);
	if (!simulation.ship.isExploding) modelBatch.render(simulation.ship, lights);
	modelBatch.render(simulation.invaders, lights);
	modelBatch.render(simulation.blocks);
	modelBatch.render(simulation.shots);
	modelBatch.end();

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

	spriteBatch.setProjectionMatrix(viewMatrix);
	spriteBatch.begin();
	if (simulation.ship.lives != lastLives || simulation.score != lastScore || simulation.wave != lastWave) {
		status = "lives: " + simulation.ship.lives + " wave: " + simulation.wave + " score: " + simulation.score;
		lastLives = simulation.ship.lives;
		lastScore = simulation.score;
		lastWave = simulation.wave;
	}
	spriteBatch.enableBlending();
	font.draw(spriteBatch, status, 0, 320);
	spriteBatch.end();

	invaderAngle += delta * 90;
	if (invaderAngle > 360) invaderAngle -= 360;
}