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:net.team2xh.environment.widgets.graphs.BarChart.java

@Override
public void render(ShapeRenderer renderer, Batch batch) {

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

    renderer.setAutoShapeType(true);//w  w  w .j a  v a  2 s .c o m
    renderer.begin();
    {
        //Gdx.gl.glLineWidth(1.0f);
        renderer.translate(getX(), getY(), 0);

        renderer.set(ShapeType.Line);
        renderer.setColor(Color.GRAY);
        renderer.rect(0, 0, getWidth(), getHeight());

        // TODO: Grid

        renderer.set(ShapeType.Line);
        renderer.setColor(Color.WHITE);
        if (showAxis) {
            // Vertical
            renderer.line(yAxisMargin, xAxisMargin, yAxisMargin, getHeight() - padding);
            // Horizontal
            renderer.line(yAxisMargin, xAxisMargin, getWidth() - padding, xAxisMargin);
        }

        // Bars
        renderer.translate(0, 0, -1);
        int i = 1;
        for (Map.Entry<String, Number> e : data) {
            float length = maxLength * (e.getValue().floatValue() / maxValue);
            Colors c = colors[color];
            renderer.set(ShapeType.Filled);
            renderer.setColor(c.transparent());
            if (horizontal) {
                renderer.rect(yAxisMargin, getHeight() - (i + 1) * padding - i * thickness, length, thickness);
            } else {
                renderer.rect(yAxisMargin + i * padding + (i - 1) * thickness, xAxisMargin, thickness, length);
            }
            renderer.set(ShapeType.Line);
            renderer.setColor(c.color());
            if (horizontal) {
                renderer.rect(yAxisMargin, getHeight() - (i + 1) * padding - i * thickness,
                        maxLength * (e.getValue().floatValue() / maxValue), thickness);
            } else {
                renderer.rect(yAxisMargin + i * padding + (i - 1) * thickness, xAxisMargin, thickness, length);
            }
            ++i;
            nextColor();
        }
        renderer.translate(0, 0, +1);

        renderer.translate(-getX(), -getY(), 0);
    }
    renderer.end();

    batch.begin();
    {
        int i = 0;
        for (Map.Entry<String, Number> e : data) {
            if (horizontal) {
                font.draw(batch, e.getKey(), getX() + yAxisMargin - padding - font.getBounds(e.getKey()).width,
                        getY() + getHeight() + font.getCapHeight() / 2
                                - (xAxisMargin + 2 * padding + i * (thickness + padding)));
                // TODO: Values axis    
            }
            // TODO: Vertical
            ++i;
        }
    }
    batch.end();

    Gdx.gl.glDisable(GL20.GL_BLEND);

}

From source file:org.anism.lotw.LOTW.java

License:Open Source License

@Override
public void create() {
    dpi = Gdx.graphics.getDensity();/*from  w  w w.j  a v  a2 s.  c  om*/

    if (actionResolver.getSignedInGPGS()) {
    } else {
        actionResolver.loginGPGS();
    }

    G = new Glob(this);
    G.clear();
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    buttonWidth = Math.min(G.width / 4 - 8 * dpi, 196 * dpi);
    settingsButtonHeight = Math.min((G.height - 96 * dpi) / 4 - 8 * dpi, 88 * dpi);
    /*
    Texture upTexture = new Texture(Gdx.files.internal("images/sphere-lightgrey-24.png"));
    Texture downTexture = new Texture(Gdx.files.internal("images/sphere-greylight-24.png"));
    NinePatch buttonPatchUp = new NinePatch(upTexture, 11, 11, 11, 11);
    NinePatch buttonPatchDown = new NinePatch(downTexture, 11, 11, 11, 11);
    */

    //intro = new Stage();
    settings = new Stage();
    colorSettings = new Stage();
    controlSettings = new Stage();
    modeSettings = new Stage();
    loginSettings = new Stage();
    bottomSettings = new Stage();

    about = new TouchStage();
    instructions = new TouchStage();
    statistics = new TouchStage();
    game = new TouchStage() {
        @Override
        public void draw() {
            G.tick(true, true);
            G.input(true);
            G.clear();
            G.draw();
            super.act();
            super.draw();
            Gdx.gl.glEnable(GL20.GL_BLEND);
        }
    };
    over = new TouchStage();

    initEverything();

    setStage(instructions);
}

From source file:org.anism.lotw.LOTW.java

License:Open Source License

@Override
public void render() {
    float dt = Gdx.graphics.getDeltaTime();
    if (current != game) {
        G.clear();/*from  w w  w  . j a va 2s.  c om*/
        Gdx.gl.glEnable(GL20.GL_BLEND);
        G.input(false);
        G.sb.begin();
        G.settings.drawStars();
        G.sb.end();
        Gdx.gl.glEnable(GL20.GL_BLEND);
        //G.glider.draw(new Color(0, 0, 0, .5f));
        if (current != settings && current != statistics && current != colorSettings
                && current != controlSettings && current != modeSettings && current != loginSettings
                && current != bottomSettings) {
            G.tick(false, true);
            G.glider.draw();
        } else {
            G.tick(false, false);
        }
    }
    current.act(dt);
    current.draw();
    G.changeSeason();

    /*
    G.tick();
    G.clear();
    G.draw();
    G.clean();
    Gdx.gl.glEnable(GL20.GL_BLEND);
    */
}

From source file: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 ww  . j a  va2s  . c o m

    pingPongBuffer.begin();
    {
        // BLOOM_THRESHOLD / high-pass filter
        // only areas with pixels >= BLOOM_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) {
        // TODO support for Gdx.gl.glBlendFuncSeparate(sfactor, dfactor, GL20.GL_ONE, GL20.GL_ONE );
        Gdx.gl.glBlendFunc(sfactor, dfactor);
    }

    restoreViewport(dest);

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

From source file:postprocessing.effects.LensFlare2.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);//from  w  ww .  j a va 2 s .co m

    pingPongBuffer.begin();
    {
        // apply bias
        bias.setInput(texsrc).setOutput(pingPongBuffer.getSourceBuffer()).render();

        lens.setInput(pingPongBuffer.getSourceBuffer()).setOutput(pingPongBuffer.getResultBuffer()).render();

        pingPongBuffer.set(pingPongBuffer.getResultBuffer(), pingPongBuffer.getSourceBuffer());

        // 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 BLOOM_THRESHOLD, modulate via
    combine.setOutput(dest).setInput(texsrc, pingPongBuffer.getResultTexture()).render();
}

From source file:seventh.client.gfx.GdxCanvas.java

License:Open Source License

@Override
public void drawLine(int x1, int y1, int x2, int y2, Integer color) {
    Color c = setTempColor(color);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    this.shapes.setColor(c);

    this.shapes.begin(ShapeType.Line);
    this.shapes.line(x1, y1, x2, y2);
    this.shapes.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);/*  w  w  w .j  a  va  2s .c  om*/
}

From source file:seventh.client.gfx.GdxCanvas.java

License:Open Source License

@Override
public void drawLine(float x1, float y1, float x2, float y2, Integer color) {
    Color c = setTempColor(color);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    this.shapes.setColor(c);

    this.shapes.begin(ShapeType.Line);
    this.shapes.line(x1, y1, x2, y2);
    this.shapes.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);//from   www. j  a  va  2s  .c o  m
}

From source file:seventh.client.gfx.GdxCanvas.java

License:Open Source License

@Override
public void drawRect(int x, int y, int width, int height, Integer color) {
    Color c = setTempColor(color);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    this.shapes.setColor(c);

    this.shapes.begin(ShapeType.Line);
    this.shapes.rect(x, y, width, height);
    this.shapes.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);//from  ww w.  ja  v a2s . c  om
}

From source file:seventh.client.gfx.GdxCanvas.java

License:Open Source License

@Override
public void drawRect(float x, float y, float width, float height, Integer color) {
    Color c = setTempColor(color);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    this.shapes.setColor(c);

    this.shapes.begin(ShapeType.Line);
    this.shapes.rect(x, y, width, height);
    this.shapes.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);/*from  w  ww .  j a  v  a  2 s .  c  o  m*/
}

From source file:seventh.client.gfx.GdxCanvas.java

License:Open Source License

@Override
public void fillRect(int x, int y, int width, int height, Integer color) {
    Color c = setTempColor(color);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    this.shapes.begin(ShapeType.Filled);
    this.shapes.setColor(c);
    this.shapes.rect(x, y, width, height);
    this.shapes.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);/*w w w.ja v a 2s  . c  o m*/

}