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

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

Introduction

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

Prototype

public void glEnable(int cap);

Source Link

Usage

From source file:com.badlogic.invaders.Renderer.java

License:Apache License

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();/*from   w  w w  .  j  av a  2 s. c o m*/
    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;
}

From source file:com.cyphercove.dayinspace.shared.FullScreenFader.java

License:Apache License

public void render(float deltaTime) {
    if (!on && alpha == 0)
        return; //nothing to draw or update

    alpha += (on ? 1 : -1) * deltaTime / fadeTime;
    alpha = Math.max(0, Math.min(1, alpha));

    GL20 gl = Gdx.gl20;
    gl.glEnable(GL20.GL_BLEND);
    gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    color.a = Interpolation.fade.apply(alpha);

    shader.begin();//  w  w  w.  j  a v a  2  s .  co  m
    shader.setUniformf(u_color, color);
    mesh.render(shader, GL20.GL_TRIANGLE_FAN);
    shader.end();

}

From source file:com.cyphercove.lwptools.core.FullScreenFader.java

License:Apache License

public void render(float deltaTime) {
    if (elapsed >= fadeTime)
        return;//  w  w  w . jav  a 2 s .co m

    if (delay > 0) {
        delay -= deltaTime;
    }

    GL20 gl = Gdx.gl20;
    gl.glEnable(GL20.GL_BLEND);
    gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    color.a = delay > 0 ? 1f : 1f - Interpolation.fade.apply(elapsed / fadeTime);

    if (shader == null)
        createShader();
    shader.begin();
    shader.setUniformf(u_color, color);
    mesh.render(shader, GL20.GL_TRIANGLE_FAN);

    shader.end();

    if (delay <= 0)
        elapsed += deltaTime;
}

From source file:com.github.fauu.helix.core.Renderer.java

License:Open Source License

public void render(Camera camera, Array<RenderableProvider> renderableProviders, Array<Decal> decals) {
    final GL20 gl = Gdx.graphics.getGL20();

    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    gl.glClearColor(0.1f, 0.1f, 0.1f, 1);
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    gl.glEnable(GL20.GL_BLEND);
    gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    if (decalBatch == null) {
        defaultCameraGroupStrategy = new CameraGroupStrategy(camera);
        waterCameraGroupStrategy = new CameraGroupStrategy(waterCamera);

        decalBatch = new DecalBatch(defaultCameraGroupStrategy);
    }//  www.j  a  v  a 2  s.  co  m

    //waterCamera.moveTo(new Vector2(13, 19));
    /* Render objects to framebuffer */
    fb.begin();
    gl.glClearColor(0, 0, 0, 0);
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    gl.glEnable(GL20.GL_BLEND);
    gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    renderContext.begin();
    modelBatch.begin(waterCamera);
    for (int i = 1; i < renderableProviders.size - 1; i++) {
        modelBatch.render(renderableProviders.get(i));
    }
    modelBatch.end();
    renderContext.end();

    decalBatch.setGroupStrategy(waterCameraGroupStrategy);
    if (decals != null) {
        decals.first().rotateX(50);
        decalBatch.add(decals.first());
        decalBatch.flush();
        decals.first().rotateX(-50);
    }

    //    Vector3 waterPos = waterCamera.project(new Vector3(8, 0, 19));
    //    reflectionPixmap = ScreenUtils.getFrameBufferPixmap((int) waterPos.x, (int) waterPos.y, 348, 261);
    //    reflectionPixmap = ScreenUtils.getFrameBufferPixmap(0, 0, 800, 600);

    fb.end();

    //    if (reflectionTexture == null) {
    //      reflectionTexture = new Texture(reflectionPixmap);
    //    } else {
    //      reflectionTexture.draw(reflectionPixmap, 0, 0);
    //    }

    ((WaterData) ((ModelInstance) renderableProviders
            .get(renderableProviders.size - 1)).userData).reflectionTexture = fb.getColorBufferTexture();

    /* Render objects and terrain to the screen */
    renderContext.begin();
    modelBatch.begin(camera);
    modelBatch.render(renderableProviders);
    modelBatch.end();
    renderContext.end();
    decalBatch.setGroupStrategy(defaultCameraGroupStrategy);
    if (decals != null) {
        decalBatch.add(decals.first());
    }
    decalBatch.flush();

    spriteBatch.begin();
    spriteBatch.enableBlending();
    spriteBatch.draw(fb.getColorBufferTexture(), 0, 0, 800, 600);
    spriteBatch.end();

}

From source file:dorkbox.tweenengine.demo.Launcher.java

License:Apache License

public void render() {
    tweenManager.update(Gdx.graphics.getDeltaTime());

    GL20 gl = Gdx.gl20;
    gl.glClearColor(1, 1, 1, 1);/*from   w w  w  .j av a  2s . c o  m*/
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    gl.glEnable(GL20.GL_BLEND);
    gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    int w = Gdx.graphics.getWidth();
    int h = Gdx.graphics.getHeight();

    if (selectedTile == null) {
        batch.getProjectionMatrix().setToOrtho2D(0, 0, w, h);
        batch.begin();
        batch.disableBlending();
        background.draw(batch);
        batch.end();

        batch.setProjectionMatrix(camera.combined);
        batch.begin();
        batch.enableBlending();
        for (int i = 0; i < tiles.size(); i++) {
            tiles.get(i).draw(batch);
        }
        batch.end();

        batch.getProjectionMatrix().setToOrtho2D(0, 0, w, h);

        batch.begin();
        batch.disableBlending();
        title.draw(batch);
        titleLeft.draw(batch);
        titleRight.draw(batch);
        batch.enableBlending();

        if (veil.getColor().a > 0.1f) {
            veil.draw(batch);
        }
        batch.end();

    } else {
        selectedTile.getTest().render();
    }
}

From source file:dorkbox.tweenengine.demo.SplashScreen.java

License:Apache License

public void render() {
    tweenManager.update(Gdx.graphics.getDeltaTime());

    if (gdx.getRotation() > 360 * 15 - 20) {
        gdx.setRegion(gdxTex);/*from w  ww  . ja  v  a 2s.c o  m*/
    }

    GL20 gl = Gdx.gl20;
    gl.glClearColor(0, 0, 0, 1);
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    gl.glEnable(GL20.GL_BLEND);
    gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    strip.draw(batch);
    universal.draw(batch);
    tween.draw(batch);
    engine.draw(batch);
    logo.draw(batch);
    powered.draw(batch);
    gdx.draw(batch);

    if (veil.getColor().a > 0.1f) {
        veil.draw(batch);
    }
    batch.end();

    if (finishedAnimation) {
        callback.onEvent(null);
    }
}