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

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

Introduction

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

Prototype

int GL_COVERAGE_BUFFER_BIT_NV

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

Click Source Link

Usage

From source file:com.bladecoder.engine.model.Sprite3DRenderer.java

License:Apache License

@Override
public void draw(SpriteBatch batch, float x, float y, float scale) {

    x = x - getWidth() / 2 * scale;/*from w w  w.j  av a  2 s.  c  om*/

    if (USE_FBO) {
        batch.draw(tex, x, y, 0, 0, width, height, scale, scale, 0);
    } else {
        float p0x, p0y, pfx, pfy;

        Vector3 tmp = new Vector3(); // TODO Make static for performance?
        updateViewport();

        // get screen coords for x and y
        tmp.set(x, y, 0);

        tmp.mul(batch.getTransformMatrix());
        tmp.prj(batch.getProjectionMatrix());
        p0x = VIEWPORT.width * (tmp.x + 1) / 2;
        p0y = VIEWPORT.height * (tmp.y + 1) / 2;

        tmp.set(x + width * scale, y + height * scale, 0);
        tmp.mul(batch.getTransformMatrix());
        tmp.prj(batch.getProjectionMatrix());
        pfx = VIEWPORT.width * (tmp.x + 1) / 2;
        pfy = VIEWPORT.height * (tmp.y + 1) / 2;

        batch.end();

        Gdx.gl20.glViewport((int) (p0x + VIEWPORT.x), (int) (p0y + VIEWPORT.y), (int) (pfx - p0x),
                (int) (pfy - p0y));

        Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT
                | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));

        drawModel();

        Gdx.gl20.glViewport((int) VIEWPORT.x, (int) VIEWPORT.y, (int) VIEWPORT.width, (int) VIEWPORT.height);
        batch.begin();
    }
}

From source file:de.bitbrain.craft.screens.AbstractScreen.java

License:Open Source License

@Override
public final void render(float delta) {

    Gdx.gl.glClearColor(0.08f, 0.02f, 0f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));

    if (Gdx.input.isKeyJustPressed(Keys.F1)) {
        screenShake.shake(15f, 3f);/*from  www . j av  a  2  s.c  o m*/
    }

    onUpdate(delta);

    animator.act(delta);
    tweenManager.update(delta);
    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    if (background != null) {
        background.setBounds(camera.position.x - camera.viewportWidth / 2,
                camera.position.y - camera.viewportHeight / 2, camera.viewportWidth, camera.viewportHeight);
        background.draw(batch);
    }
    onDraw(batch, delta);
    batch.end();
    if (uiRenderer != null) {
        uiRenderer.render(delta);
        camera.update();
        batch.begin();
        batch.setProjectionMatrix(camera.combined);
        onStageDraw(batch, delta);
        batch.end();
    }
    batch.begin();
    particleRenderer.render(batch, delta);
    batch.end();
    uiRenderer.render(delta);
    tooltipManager.draw(batch);
    fader.render(batch);
}

From source file:de.longri.cachebox3.CacheboxMain.java

License:Open Source License

@Override
public void render() {

    {// calculate Memory Usage
        long maxMemory = runtime.maxMemory();
        long allocatedMemory = runtime.totalMemory();
        long freeMemory = runtime.freeMemory();
        StringBuilder memoryStringBuilder = new StringBuilder();
        memoryStringBuilder.append("f: " + format.format(freeMemory / 1048576));
        memoryStringBuilder.append("  a: " + format.format(allocatedMemory / 1048576));
        memoryStringBuilder.append("  m: " + format.format(maxMemory / 1048576));
        memoryStringBuilder/* w w  w .  ja va2 s.c  om*/
                .append("  tf: " + format.format((freeMemory + (maxMemory - allocatedMemory)) / 1048576));
        memoryUsage = memoryStringBuilder.toString();
    }

    CB.stateTime += Gdx.graphics.getDeltaTime();

    if (drawMap && mMapRenderer != null) {
        GLState.enableVertexArrays(-1, -1);

        // set map position and size
        gl.viewport(mapDrawX, mapDrawY, mapDrawWidth, mapDrawHeight);
        gl.frontFace(GL.CW);

        try {
            mMapRenderer.onDrawFrame();
        } catch (Exception e) {
            e.printStackTrace();
        }

        //release Buffers from map renderer
        GLState.bindVertexBuffer(0);
        GLState.bindElementBuffer(0);
    } else {
        // if MapRenderer not drawn, we must clear before draw stage
        Gdx.gl.glClearColor(CB.backgroundColor.r, CB.backgroundColor.g, CB.backgroundColor.b,
                CB.backgroundColor.a);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT
                | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));

    }

    gl.flush();
    gl.viewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    // MapRender sets the FrontFace to GL.CW, so we revert to GL.CCW
    gl.frontFace(GL.CCW);

    StageManager.draw();

    if (CB.isTestVersion()) {
        float FpsInfoSize = CB.getScaledFloat(4f);
        if (FpsInfoSprite != null) {
            batch = StageManager.getBatch();
            batch.begin();
            Color lastColor = batch.getColor();
            batch.setColor(1.0f, 0.0f, 0.0f, 1.0f);
            batch.draw(FpsInfoSprite, FpsInfoPos, 2, FpsInfoSize, FpsInfoSize);
            batch.setColor(lastColor);
            batch.end();
        } else {
            Sprite sprite = CB.getSprite("color");
            if (sprite != null) {
                FpsInfoSprite = new Sprite(sprite);
                FpsInfoSprite.setColor(1.0f, 0.0f, 0.0f, 1.0f);
                FpsInfoSprite.setSize(FpsInfoSize, FpsInfoSize);
            }
        }

        FpsInfoPos += FpsInfoSize;
        if (FpsInfoPos > 60 * FpsInfoSize) {
            FpsInfoPos = 0;
        }
    }
}

From source file:headmade.arttag.screens.ArtTagScreen.java

License:Apache License

@Override
public void render(float delta) {
    fpsLogger.log();//  w w  w .  ja  v  a2 s .  c om

    // while (FlickrService.instance.getWebArtCount() == 0) {
    // // wait
    // return;
    // }

    if (gameOverDelta > 3f) {
        endLevel();
        gameOverDelta = 0f;
    }

    if (Player.instance.body != null && Player.instance.isCaught) {
        final PooledEffect effect = smokeEffectPool.obtain();
        effect.setPosition(Player.instance.body.getWorldCenter().x, Player.instance.body.getWorldCenter().y);
        effects.add(effect);
        Assets.instance.playSound(AssetSounds.smoke);
        Assets.instance.playSound(AssetSounds.cough);
        Player.instance.isCaught = false;
        Player.instance.destroyBody(this);
        isGameOver = true;
    }

    if (!isGameOver) {
        // isSpotted will be set by guards
        Player.instance.isSpotted = false;
        for (final Guard g : guards) {
            g.update(this, delta);
        }
        Player.instance.update(this, delta);
        world.step(ArtTag.TIME_STEP, ArtTag.VELOCITY_ITERS, ArtTag.POSITION_ITERS);
    } else {
        gameOverDelta += delta;
    }

    if (Player.instance.isTouchingWarp) {
        newRoom();
    }

    // camera.position.x = camera.position.x * ArtTag.UNIT_SCALE;
    // camera.position.y = camera.position.y * ArtTag.UNIT_SCALE;
    if (Player.instance.body != null) {
        camera.position.x = Player.instance.body.getPosition().x;
        camera.position.y = Player.instance.body.getPosition().y;
        camera.update();
    }

    Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
    // Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
    // Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));

    final SpriteBatch batch = game.getBatch();
    batch.setColor(Color.WHITE);
    batch.setProjectionMatrix(camera.combined);

    mapRenderer.setView((OrthographicCamera) camera);
    mapRenderer.render(MapUtils.MAP_LAYERS_LOW);

    { // player and goards
        batch.begin();
        shapeRenderer.begin(ShapeType.Line);

        Box2DSprite.draw(batch, world);

        // for (final headmade.arttag.spriter.Player player : players) {
        // player.update();
        // if (Player.instance.body != null) {
        // player.setPosition(Player.instance.body.getWorldCenter().x, Player.instance.body.getWorldCenter().y);
        // }
        // drawer.draw(player);
        // }

        batch.end();
        shapeRenderer.end();
    }

    mapRenderer.render(MapUtils.MAP_LAYERS_HIGH);

    {
        batch.begin();
        {
            // final Matrix4 oldTransMat = batch.getTransformMatrix();
            for (final Art art : currentRoom.getArtList()) {
                art.draw(batch);
                // art.drawFrame(batch);
            }

            for (int i = effects.size - 1; i >= 0; i--) {
                final PooledEffect effect = effects.get(i);
                effect.draw(batch, delta);
                if (effect.isComplete()) {
                    effect.free();
                    effects.removeIndex(i);
                }
            }
        }
        batch.end();
    }

    rayHandler.setCombinedMatrix((OrthographicCamera) camera);
    rayHandler.updateAndRender();

    // UI update
    if (Player.instance.artInView.size == 0) {
        currentArt = null;
    }
    if (currentArt != null) {
        imageActor.setDrawable(currentArt.getDrawable());
        rootTable.layout();
    } else {
        imageActor.setDrawable(null);
    }
    // show scan result?
    if (Player.instance.isTouchingArt
            && (Player.instance.isScanning || currentArt != null && currentArt.isScanned())) {
        resultActor.setVisible(true);
    } else {
        resultActor.setVisible(false);
    }
    // render UI
    if (currentArt != null) {
        final float alpha = Player.instance.imageAlpha;
        imageActor.getColor().a = alpha;
        if (alpha > 0f) {
            instructionsActor.setVisible(true);
            jobDescActor.setVisible(true);
        } else {
            instructionsActor.setVisible(false);
            jobDescActor.setVisible(false);
        }

        if (alpha > 0.3f) {
            if (sumDeltaLookAtImage > 0.3f) {
                currentArt.setSeen(true);
                TagService.instance.tagNotMatched(currentArt, jobDescription);
            } else {
                sumDeltaLookAtImage += delta;
            }
        } else {
            sumDeltaLookAtImage = 0f;
        }
    }

    if (isHideJobDesc) {
        jobDescActor.setVisible(false);
    }

    if (Player.instance.inventory.size >= Player.instance.getCarryCacity()) {
        instructionsActor.setVisible(true);
    }
    stage.act(delta);
    stage.draw();

    if (debugEnabled) {
        shapeRenderer.setProjectionMatrix(camera.combined);
        shapeRenderer.setAutoShapeType(true);
        shapeRenderer.begin();
        for (final Guard g : guards) {
            {
                if (g.getBackToPath().size > 0) {
                    final float[] vertices = new float[2 + g.getBackToPath().size * 2];
                    vertices[0] = g.body.getPosition().x;
                    vertices[1] = g.body.getPosition().y;
                    int index = 1;
                    for (int i = g.getBackToPath().size - 1; i >= 0; i--) {
                        vertices[index * 2] = g.getBackToPath().get(i).x;
                        vertices[index * 2 + 1] = g.getBackToPath().get(i).y;
                        index++;
                    }
                    shapeRenderer.polyline(vertices);
                }
            }
            {
                if (g.path.size > 0) {
                    final float[] vertices = new float[2 + g.path.size * 2];
                    vertices[0] = g.body.getPosition().x;
                    vertices[1] = g.body.getPosition().y;
                    int index = 1;
                    for (int i = g.path.size - 1; i >= 0; i--) {
                        vertices[index * 2] = g.path.get(i).x;
                        vertices[index * 2 + 1] = g.path.get(i).y;
                        index++;
                    }
                    shapeRenderer.polyline(vertices);
                }
            }
        }
        shapeRenderer.end();
        box2dDebugRenderer.render(world, camera.combined);
    }
}

From source file:headmade.arttag.screens.StageScreen.java

License:Apache License

@Override
public void render(float delta) {
    preAct(delta);/*  w w  w .j ava2s  .  c  o m*/
    stage.act(delta);
    preDraw(delta);
    Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
    // Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
    // Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));
    stage.draw();
}

From source file:org.ah.gcode.preview.GCodePreview.java

License:Open Source License

@Override
public void render() {
    if (loadingAssets && assetManager.update()) {
        finishedLoading();/*from   w  w  w .j  av a 2 s  .  com*/
    }

    if (loadingAssets) {
    } else {
        if (parsingGCode) {
            parseGCode();
        } else if (preparingMeshes) {
            prepareMesh();
        } else {
        }
    }
    camera.update();
    Vector3 lightDirection = new Vector3(camera.direction).nor();
    directionalLight.set(lightColor, lightDirection);

    // Magic rendering initialisation
    Gdx.gl.glDisable(GL20.GL_CULL_FACE);
    Gdx.gl.glDisable(GL20.GL_DEPTH_TEST);
    //        Gdx.gl.glEnable(GL20.GL_BLEND);
    //        Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
    Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT
            | (Gdx.graphics.getBufferFormat().coverageSampling ? GL20.GL_COVERAGE_BUFFER_BIT_NV : 0));

    Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    if (instances.size() > 0) {
        modelBatch.begin(camera);
        for (ModelInstance instance : instances) {
            modelBatch.render(instance, environment);
        }

        // gCodeModel.render(modelBatch, environment);
        modelBatch.end();
    }
    if (controller != null) {
        controller.render(camera, environment);
    }

    spriteBatch.begin();
    spriteBatch.setProjectionMatrix(spriteFontCamera.combined);
    spriteBatch.enableBlending();
    window.render(spriteBatch);
    spriteBatch.end();
}