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

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

Introduction

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

Prototype

int GL_BLEND

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

Click Source Link

Usage

From source file:de.r2soft.empires.client.maps.hex.R2HexMapRenderer.java

License:Apache License

/** Invalidates batch and flushes all resources */
private void invalidate() {
    logger.info("Invalidating batch resources!");
    Gdx.gl.glEnable(GL20.GL_BLEND);
    batch.flush();/*w w w  .j  a  va2 s . co  m*/
    batch.dispose();
    batch = new SpriteBatch();
}

From source file:de.r2soft.empires.client.screens.gameplay.HexMapScreen.java

License:Open Source License

@Override
public void render(float delta) {
    // TODO: Move this into the game core?
    Gdx.gl20.glEnable(GL20.GL_BLEND);
    shapeRenderer.setProjectionMatrix(uiCam.combined);
    shapeRenderer.begin(ShapeType.Filled);
    shapeRenderer.setColor(0, 0, 0, 0.75f);
    shapeRenderer.rect(Values.HEX_MAP_BASE_OFFSET.x, Values.HEX_MAP_BASE_OFFSET.y, Values.HEX_MAP_BASE_SIZE.x,
            Values.HEX_MAP_BASE_SIZE.y);
    shapeRenderer.end();/*from ww  w  .  j  ava  2  s  .c  o m*/

    /** Sets up map view */
    Gdx.gl.glViewport(Values.HEX_MAP_BASE_OFFSET.x, Values.HEX_MAP_BASE_OFFSET.y, Values.HEX_MAP_BASE_SIZE.x,
            Values.HEX_MAP_BASE_SIZE.y);

    mapCam.update();
    mapCamController.update();
    r2HexRenderer.setView(mapCam);
    r2HexRenderer.checkDebugRendering();
    r2HexRenderer.render();

    /** Sets up stage view */
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    uiCam.update();

    shapeRenderer.begin(ShapeType.Line);
    shapeRenderer.setColor(1, 1, 1, 0.5f);
    /** Draws debug frame around map view */
    shapeRenderer.rect(Values.HEX_MAP_BASE_OFFSET.x, Values.HEX_MAP_BASE_OFFSET.y, Values.HEX_MAP_BASE_SIZE.x,
            Values.HEX_MAP_BASE_SIZE.y);
    shapeRenderer.end();

    stage.act();
    stage.draw();
}

From source file:de.r2soft.empires.client.screens.gameplay.SolMapScreen.java

License:Open Source License

@Override
public void render(float arg0) {
    Gdx.gl20.glEnable(GL20.GL_BLEND);

    /* Background colour drop for map */
    shapeRenderer.setProjectionMatrix(uiCam.combined);
    shapeRenderer.begin(ShapeType.Filled);
    shapeRenderer.setColor(0, 0, 0, 0.75f);
    shapeRenderer.rect(Values.HEX_MAP_BASE_OFFSET.x, Values.HEX_MAP_BASE_OFFSET.y, Values.HEX_MAP_BASE_SIZE.x,
            Values.HEX_MAP_BASE_SIZE.y);
    shapeRenderer.end();//from  w ww .  jav a2s  .  c o  m

    Gdx.gl.glViewport(Values.SOL_MAP_BASE_OFFSET.x, Values.SOL_MAP_BASE_OFFSET.y, Values.SOL_MAP_BASE_SIZE.x,
            Values.SOL_MAP_BASE_SIZE.y);
    mapCam.update();
    solRenderer.setView(mapCam);
    solRenderer.render();

    /** Sets up stage view */
    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    uiCam.update();

    /* Draws debug frame around map view */
    shapeRenderer.begin(ShapeType.Line);
    shapeRenderer.setColor(1, 1, 1, 0.5f);
    shapeRenderer.rect(Values.SOL_MAP_BASE_OFFSET.x, Values.SOL_MAP_BASE_OFFSET.y, Values.SOL_MAP_BASE_SIZE.x,
            Values.SOL_MAP_BASE_SIZE.y);
    shapeRenderer.end();

    stage.act();
    stage.draw();
}

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

License:Apache License

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

    GL20 gl = Gdx.gl20;/*from  www  .  j a  v  a  2 s  .  c  om*/
    gl.glClearColor(1, 1, 1, 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);

    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  w w.ja  v a2 s  .  c om*/
    }

    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);
    }
}

From source file:es.eucm.ead.editor.components.EditorImageActor.java

License:Open Source License

protected void drawCollider(Batch batch) {
    if (getCollider() != null) {
        batch.end();//from ww  w  .  ja  va 2  s. c o  m
        Gdx.gl.glEnable(GL20.GL_BLEND);
        Gdx.gl.glBlendFunc(GL20.GL_ONE, GL20.GL_DST_COLOR);
        Gdx.gl.glBlendEquation(GL20.GL_FUNC_SUBTRACT);
        shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
        shapeRenderer.setTransformMatrix(batch.getTransformMatrix());
        shapeRenderer.begin(ShapeType.Line);
        shapeRenderer.setColor(Color.WHITE);
        for (Polygon polygon : getCollider()) {
            float[] vertices = polygon.getVertices();
            shapeRenderer.polygon(vertices);
        }
        shapeRenderer.end();
        Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD);
        Gdx.gl.glDisable(GL20.GL_BLEND);
        batch.begin();
    }
}

From source file:es.eucm.ead.editor.view.widgets.groupeditor.GroupEditor.java

License:Open Source License

@Override
protected void drawChildren(Batch batch, float parentAlpha) {
    if (background != null) {
        background.draw(batch, 0, 0, getWidth(), getHeight());
    }/* w ww .j  av a2 s.c  om*/
    super.drawChildren(batch, parentAlpha);
    if (selection.getWidth() != 0 && selection.getHeight() != 0) {
        batch.end();
        Gdx.gl.glEnable(GL20.GL_BLEND);
        Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
        shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
        shapeRenderer.setTransformMatrix(batch.getTransformMatrix());
        drawSelectionRectangle();
        Gdx.gl.glDisable(GL20.GL_BLEND);
        batch.begin();
    }
}

From source file:es.eucm.ead.editor.view.widgets.groupeditor.Grouper.java

License:Open Source License

@Override
protected void drawChildren(Batch batch, float parentAlpha) {
    batch.end();//from  ww w . j  a va  2s . c om
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_ONE, GL20.GL_DST_COLOR);
    Gdx.gl.glBlendEquation(GL20.GL_FUNC_SUBTRACT);
    shapeRenderer.setColor(Color.WHITE);
    shapeRenderer.begin(ShapeType.Line);
    super.drawChildren(batch, parentAlpha);
    shapeRenderer.end();
    Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD);
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
}

From source file:es.eucm.ead.editor.view.widgets.groupeditor.Handles.java

License:Open Source License

@Override
protected void drawChildren(Batch batch, float parentAlpha) {
    batch.end();/* w w  w  . j  a v a  2s  .  co m*/
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_ONE, GL20.GL_DST_COLOR);
    Gdx.gl.glBlendEquation(GL20.GL_FUNC_SUBTRACT);
    shapeRenderer.setProjectionMatrix(batch.getProjectionMatrix());
    shapeRenderer.setTransformMatrix(batch.getTransformMatrix());
    shapeRenderer.begin(ShapeType.Line);
    shapeRenderer.setColor(Color.WHITE);
    shapeRenderer.line(handles[0].getX(), handles[0].getY(), handles[2].getX(), handles[2].getY());
    shapeRenderer.line(handles[0].getX(), handles[0].getY(), handles[6].getX(), handles[6].getY());
    shapeRenderer.line(handles[2].getX(), handles[2].getY(), handles[8].getX(), handles[8].getY());
    shapeRenderer.line(handles[8].getX(), handles[8].getY(), handles[6].getX(), handles[6].getY());
    shapeRenderer.end();
    super.drawChildren(batch, parentAlpha);
    Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD);
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
}

From source file:es.eucm.eadmockup.prototypes.camera.postprocessing.effects.Bloom.java

License:Apache License

@Override
public void render(final FrameBuffer src, final FrameBuffer dest) {
    Texture texsrc = src.getColorBufferTexture();

    boolean blendingWasEnabled = PostProcessor.isStateEnabled(GL20.GL_BLEND);
    Gdx.gl.glDisable(GL20.GL_BLEND);//w  w  w .ja  v a 2s  .  c o m

    pingPongBuffer.begin();
    {
        // threshold / high-pass filter
        // only areas with pixels >= threshold are blit to smaller fbo
        threshold.setInput(texsrc).setOutput(pingPongBuffer.getSourceBuffer()).render();

        // blur pass
        blur.render(pingPongBuffer);
    }
    pingPongBuffer.end();

    if (blending || blendingWasEnabled) {
        Gdx.gl.glEnable(GL20.GL_BLEND);
    }

    if (blending) {
        Gdx.gl.glBlendFunc(sfactor, dfactor);
    }

    restoreViewport(dest);

    // mix original scene and blurred threshold, modulate via
    // set(Base|Bloom)(Saturation|Intensity)
    combine.setOutput(dest).setInput(texsrc, pingPongBuffer.getResultTexture()).render();
}