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

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

Introduction

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

Prototype

int GL_ONE_MINUS_SRC_ALPHA

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

Click Source Link

Usage

From source file:com.shatteredpixel.shatteredpixeldungeon.scenes.WelcomeScene.java

License:Open Source License

@Override
public void create() {
    super.create();

    final int previousVersion = ShatteredPixelDungeon.version();

    if (ShatteredPixelDungeon.versionCode == previousVersion) {
        ShatteredPixelDungeon.switchNoFade(TitleScene.class);
        return;/*from  w w w.j av  a  2  s.c  o m*/
    }

    uiCamera.visible = false;

    int w = Camera.main.width;
    int h = Camera.main.height;

    Image title = BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON);
    title.brightness(0.6f);
    add(title);

    float height = title.height + (ShatteredPixelDungeon.landscape() ? 48 : 96);

    title.x = (w - title.width()) / 2;
    title.y = (h - height) / 2;

    placeTorch(title.x + 18, title.y + 20);
    placeTorch(title.x + title.width - 18, title.y + 20);

    Image signs = new Image(BannerSprites.get(BannerSprites.Type.PIXEL_DUNGEON_SIGNS)) {
        private float time = 0;

        @Override
        public void update() {
            super.update();
            am = (float) Math.sin(-(time += Game.elapsed));
        }

        @Override
        public void draw() {
            Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
            super.draw();
            Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
        }
    };
    signs.x = title.x;
    signs.y = title.y;
    add(signs);

    DarkRedButton okay = new DarkRedButton(Messages.get(this, "continue")) {
        @Override
        protected void onClick() {
            super.onClick();
            updateVersion(previousVersion);
            ShatteredPixelDungeon.switchScene(TitleScene.class);
        }
    };

    if (previousVersion != 0) {
        DarkRedButton changes = new DarkRedButton(Messages.get(this, "changelist")) {
            @Override
            protected void onClick() {
                super.onClick();
                updateVersion(previousVersion);
                ShatteredPixelDungeon.switchScene(ChangesScene.class);
            }
        };
        okay.setRect(title.x, h - 20, (title.width() / 2) - 2, 16);
        okay.textColor(0xBBBB33);
        add(okay);

        changes.setRect(okay.right() + 2, h - 20, (title.width() / 2) - 2, 16);
        changes.textColor(0xBBBB33);
        add(changes);
    } else {
        okay.setRect(title.x, h - 20, title.width(), 16);
        okay.textColor(0xBBBB33);
        add(okay);
    }

    RenderedTextMultiline text = PixelScene.renderMultiline(6);
    String message;
    if (previousVersion == 0) {
        message = Messages.get(this, "welcome_msg");
    } else if (previousVersion <= ShatteredPixelDungeon.versionCode) {
        if (previousVersion < LATEST_UPDATE) {
            message = Messages.get(this, "update_intro");
            message += "\n\n" + Messages.get(this, "update_msg");
        } else {
            //TODO: change the messages here in accordance with the type of patch.
            message = Messages.get(this, "patch_intro");
            message += "\n\n" + Messages.get(this, "patch_bugfixes");
            message += "\n" + Messages.get(this, "patch_translations");
            message += "\n" + Messages.get(this, "patch_balance");

        }
    } else {
        message = Messages.get(this, "what_msg");
    }
    text.text(message, w - 20);
    float textSpace = h - title.y - (title.height() - 10) - okay.height() - 2;
    text.setPos(10, title.y + (title.height() - 10) + ((textSpace - text.height()) / 2));
    add(text);

}

From source file:com.shatteredpixel.shatteredpixeldungeon.ui.Archs.java

License:Open Source License

@Override
protected void createChildren() {
    arcsBg = new SkinnedBlock(1, 1, Assets.ARCS_BG) {
        @Override/*from   ww  w  .  j  ava  2  s .  com*/
        protected NoosaScript script() {
            return NoosaScriptNoLighting.get();
        }

        @Override
        public void draw() {
            //arch bg has no alpha component, this improves performance
            Gdx.gl.glBlendFunc(GL20.GL_ONE, GL20.GL_ZERO);
            super.draw();
            Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
        }
    };
    arcsBg.autoAdjust = true;
    arcsBg.offsetTo(0, offsB);
    add(arcsBg);

    arcsFg = new SkinnedBlock(1, 1, Assets.ARCS_FG) {
        @Override
        protected NoosaScript script() {
            return NoosaScriptNoLighting.get();
        }
    };
    arcsFg.autoAdjust = true;
    arcsFg.offsetTo(0, offsF);
    add(arcsFg);
}

From source file:com.strategames.ui.helpers.FilledRectangleImage.java

License:Open Source License

@Override
public void draw(Batch batch, float parentAlpha) {
    batch.end();/*from  w w w  .  ja v a 2s  .co  m*/
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    this.shapeRendererColor.a = this.color.a;
    this.shapeRendererColor.r = this.color.r;
    this.shapeRendererColor.g = this.color.g;
    this.shapeRendererColor.b = this.color.b;
    this.shapeRenderer.begin(ShapeType.Filled);
    this.shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
    this.shapeRenderer.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
}

From source file:com.thetruthbeyond.gui.utility.gl.GlUtils.java

License:Open Source License

public static void setDefaultBlendMode(SmartSpriteBatch batch) {
    batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
}

From source file:com.tnf.ptm.common.CommonDrawer.java

License:Apache License

public void setAdditive(boolean additive) {
    int dstFunc = additive ? GL20.GL_ONE : GL20.GL_ONE_MINUS_SRC_ALPHA;
    mySpriteBatch.setBlendFunction(GL20.GL_SRC_ALPHA, dstFunc);
}

From source file:com.torrosoft.sopistan.SopistanMain.java

License:Open Source License

@Override
public void render() {

    if (istate == 5)
        return;/* w w w.j a  v  a  2  s . c om*/

    batch.begin();

    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    cam.update();
    batch.setProjectionMatrix(cam.combined);

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

    // the end cap scale
    tris.setEndCap(5F);

    // the thickness of the line
    tris.setThickness(30F);

    // generate the triangle strip from our path
    tris.update(swipe.getPath());

    // the vertex color for tinting, i.e. for opacity
    tris.setColor(Color.RED);

    // render the triangles to the screen
    tris.draw(cam);

    int idx = 0;
    for (int y = 0; y < Position.MAX_Y; y++) {
        for (int x = 0; x < Position.MAX_X; x++) {
            ((Sprite) group_sprites.get(idx)).draw(batch);
            idx++;
        }
    }

    // uncomment to see debug lines
    //drawDebug();
    batch.end();

    istate = 1;
}

From source file:com.uwsoft.editor.gdx.ui.components.ItemPhysicsEditor.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    //super.draw(batch, parentAlpha);

    if (isTransform())
        applyTransform(batch, computeTransform());
    Rectangle calculatedScissorBounds = Pools.obtain(Rectangle.class);
    getStage().calculateScissors(new Rectangle(0, 0, getWidth(), getHeight()), calculatedScissorBounds);
    // Enable scissors.
    if (ScissorStack.pushScissors(calculatedScissorBounds)) {
        drawChildren(batch, parentAlpha);
        ScissorStack.popScissors();//from  w w  w  .j av a2s  .  c o m
        if (isTransform())
            resetTransform(batch);
    }

    batch.end();

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

    shapeRenderer.setProjectionMatrix(stage.getCamera().combined);
    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glScissor((int) calculatedScissorBounds.x, (int) calculatedScissorBounds.y, (int) getWidth(),
            (int) getHeight());
    Pools.free(calculatedScissorBounds);
    if (currentMode == EditMode.Create) {
        drawOutlines();
        drawPoints();
        drawNextLine();
    }
    if (currentMode == EditMode.Edit) {
        drawPolygon();
        drawOutlines();
        drawPoints();

    }
    Gdx.gl.glDisable(GL20.GL_SCISSOR_TEST);
    Gdx.gl.glDisable(GL20.GL_BLEND);
    if (currentMode == EditMode.Test) {
        box2dRenderer.render(physicsEditorWorld, stage.getCamera().combined.scl(1 / PhysicsBodyLoader.SCALE));
    }
    batch.begin();
}

From source file:com.vlaaad.dice.ui.components.Rain.java

License:Open Source License

@Override
public void draw(Batch batch, float parentAlpha) {
    validate();//w  ww . jav  a  2  s .  co m
    batch.end();
    Gdx.gl.glClearColor(0, 0, 0, 0);
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    ShapeRenderer renderer = Config.shapeRenderer;
    renderer.setProjectionMatrix(batch.getProjectionMatrix());
    renderer.setTransformMatrix(batch.getTransformMatrix());

    renderer.begin(ShapeRenderer.ShapeType.Filled);
    renderer.setColor(style.color.r, style.color.g, style.color.b, style.color.a * parentAlpha);
    float usedWidth = getWidth() - style.pad;
    int count = (int) (usedWidth / (style.dropWidth + style.pad));
    if (count == 0)
        return;
    float step = usedWidth / ((float) count);
    float x = style.pad;
    for (int i = 0, n = rows.size; i < n; i++) {
        Row row = rows.get(i);
        drawRow(x, row);
        x += step;
    }
    renderer.end();
    Gdx.gl.glDisable(GL20.GL_BLEND);
    batch.begin();
}

From source file:com.watabou.noosa.Game.java

License:Open Source License

public void onSurfaceCreated() {
    Gdx.gl.glEnable(GL20.GL_BLEND);//from w w w  . ja  v a 2s.c  o m
    // For premultiplied alpha:
    // Gdx.gl.glBlendFunc( GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA );
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    Gdx.gl.glEnable(GL20.GL_SCISSOR_TEST);

    TextureCache.reload();
}

From source file:com.watabou.noosa.particles.Emitter.java

License:Open Source License

@Override
public void draw() {
    if (lightMode) {
        Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE);
        super.draw();
        Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    } else {/*  w  w  w . ja v  a2s  .c  o m*/
        super.draw();
    }
}