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:tools.SpriteBatch.java

License:Apache License

private void renderMesh() {
    if (idx == 0) {
        return;/*  w ww . j a  v  a  2 s  .c o m*/
    }

    renderCalls++;
    totalRenderCalls++;
    int spritesInBatch = idx / 24;
    if (spritesInBatch > maxSpritesInBatch) {
        maxSpritesInBatch = spritesInBatch;
    }

    lastTexture.bind();
    mesh.setVertices(vertices, 0, idx);
    mesh.getIndicesBuffer().position(0);
    mesh.getIndicesBuffer().limit(spritesInBatch * 6);

    if (blendingDisabled) {
        Gdx.gl.glDisable(GL20.GL_BLEND);
    } else {
        Gdx.gl.glEnable(GL20.GL_BLEND);
        Gdx.gl.glBlendFunc(blendSrcFunc, blendDstFunc);
    }

    if (customShader != null) {
        mesh.render(customShader, GL20.GL_TRIANGLES, 0, spritesInBatch * 6);
    } else {
        mesh.render(shader, GL20.GL_TRIANGLES, 0, spritesInBatch * 6);
    }

    idx = 0;
    currBufferIdx++;
    if (currBufferIdx == buffers.length) {
        currBufferIdx = 0;
    }
    mesh = buffers[currBufferIdx];
}

From source file:vault.clockwork.controllers.CameraController.java

License:Open Source License

/**
 * Wykonuje sie przed rysowaniem debug screena.
 * @param gizmo //from  w w w. j  av  a  2 s.c om
 */
@Override
public void preDebug(ShapeRenderer gizmo) {
    gizmo.setProjectionMatrix(camera.combined);

    // enable alpha channel usage
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    // draw scene regions
    gizmo.begin(ShapeRenderer.ShapeType.Line);
    gizmo.setColor(1.f, 0.1f, 0.f, 0.5f);
    gizmo.rect(CameraController.SCREEN_BOUNDS.x, CameraController.SCREEN_BOUNDS.y,
            CameraController.SCREEN_BOUNDS.width, CameraController.SCREEN_BOUNDS.height);
    gizmo.end();
}

From source file:vault.clockwork.editor.gui.GUIFieldElement.java

License:Open Source License

/**
 * Draw the field input.//from w w w .  j  a v  a 2 s. c  o m
 * @param shape
 * @param batch 
 */
@Override
public void draw(ShapeRenderer shape, SpriteBatch batch) {
    text = value + (focused && ticks % 20 > 10 ? "|" : "");

    if (focused) {
        ticks++;
    }

    // calculate label text bounds
    Rectangle bounds = getBounds();

    // enable alpha channel usage
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    // draw the shape
    shape.begin(ShapeRenderer.ShapeType.Filled);
    shape.setColor(0, 0, 0, .5f);
    shape.rect(bounds.x - 2, bounds.y - 2, bounds.width + 4, bounds.height + 4);
    shape.end();

    // draw the label
    batch.begin();
    {
        font.setColor(!focused ? (overed ? Color.PINK : Color.WHITE) : Color.RED);
        font.draw(batch, field.getName() + ": " + text, bounds.x, bounds.y + bounds.height);
    }
    batch.end();
}

From source file:vault.clockwork.editor.gui.GUILabelElement.java

License:Open Source License

/**
 * Draw the label.//from  ww  w  .j  a  va 2 s  .c  om
 * @param shape
 * @param batch 
 */
@Override
public void draw(ShapeRenderer shape, SpriteBatch batch) {
    // calculate label text bounds
    Rectangle bounds = getBounds();

    // enable alpha channel usage
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);

    // draw the shape
    shape.begin(ShapeRenderer.ShapeType.Filled);
    shape.setColor(0, 0, 0, .5f);
    shape.rect(bounds.x - 2, bounds.y - 2, bounds.width + 4, bounds.height + 4);
    shape.end();

    // draw the label
    batch.begin();
    {
        font.setColor(!focused ? (overed ? Color.PINK : Color.WHITE) : Color.RED);
        font.draw(batch, text, bounds.x, bounds.y + bounds.height);
    }
    batch.end();
}

From source file:vault.clockwork.system.Console.java

License:Open Source License

/**
 * Render the console.// w w  w.  ja  v  a 2  s  .c  o  m
 * @see System#postPerform() 
 */
@Override
public void postPerform() {
    if (!visible) {
        return;
    }

    float scwidth = (float) Gdx.graphics.getWidth(), scheight = (float) Gdx.graphics.getHeight();

    // assign projection to the renderers
    Matrix4 ortho = new Matrix4().setToOrtho2D(0.f, 0.f, scwidth, scheight);

    renderer.setProjectionMatrix(ortho);
    batch.setProjectionMatrix(ortho);

    // draw the console background
    Gdx.gl.glEnable(GL20.GL_BLEND);
    Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    renderer.begin(ShapeRenderer.ShapeType.Filled);
    renderer.setColor(color);
    renderer.rect(0.f, scheight - height, scwidth, height);
    renderer.end();

    // crop the logs list
    while (logs.size > (int) (height / 19.f) - 1) {
        logs.removeIndex(0);
    }

    // draw the console logs
    batch.begin();
    for (int i = 0; i < logs.size; i++) {
        font.draw(batch, logs.get(logs.size - i - 1), 5.f, scheight - height + 25.f + 19.f * (i + 1));
    }
    font.draw(batch, input + ((tickness % 30 < 15) ? "|" : ""), 5.f, scheight - height + 25.f);
    batch.end();
}