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

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

Introduction

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

Prototype

public void glClear(int mask);

Source Link

Usage

From source file:com.android.projet.projetandroid.game.superjumper.GameScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    renderer.render();/*from   w ww.ja v a  2s.  c om*/

    guiCam.update();
    game.batcher.setProjectionMatrix(guiCam.combined);
    game.batcher.enableBlending();
    game.batcher.begin();
    switch (state) {
    case GAME_READY:
        presentReady();
        break;
    case GAME_RUNNING:
        presentRunning();
        break;
    case GAME_PAUSED:
        presentPaused();
        break;
    case GAME_LEVEL_END:
        presentLevelEnd();
        break;
    case GAME_OVER:
        presentGameOver();
        break;
    }
    game.batcher.end();
}

From source file:com.android.projet.projetandroid.game.superjumper.HighscoresScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    guiCam.update();// w w  w. ja  va  2s .c  o  m

    game.batcher.setProjectionMatrix(guiCam.combined);
    game.batcher.disableBlending();
    game.batcher.begin();
    game.batcher.draw(Assets.backgroundRegion, 0, 0, 480, 320);
    game.batcher.end();

    game.batcher.enableBlending();
    game.batcher.begin();
    game.batcher.draw(Assets.highScoresRegion, 240 - 150, 320 - 60, 300, 33);

    float y = 320 - 200;
    for (int i = 4; i >= 0; i--) {
        Assets.font.draw(game.batcher, highScores[i], xOffset, y);
        y += Assets.font.getLineHeight();
    }

    game.batcher.draw(Assets.arrow, 0, 0, 64, 64);
    game.batcher.end();
}

From source file:com.android.projet.projetandroid.game.superjumper.MainMenuScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClearColor(1, 0, 0, 1);//from  ww  w.j  a  va 2  s. c om
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    guiCam.update();
    game.batcher.setProjectionMatrix(guiCam.combined);

    game.batcher.disableBlending();
    game.batcher.begin();
    game.batcher.draw(Assets.backgroundRegion, 0, 0, 480, 320);
    game.batcher.end();

    game.batcher.enableBlending();
    game.batcher.begin();
    game.batcher.draw(Assets.logo, 240 - 450 / 2, 320 - 30 - 60, 450, 60);
    game.batcher.draw(Assets.mainMenu, 240 - 300 / 2, 320 - 60 - 60 - 145, 300, 145);
    game.batcher.draw(Settings.soundEnabled ? Assets.soundOn : Assets.soundOff, 0, 0, 64, 64);

    game.batcher.end();

    // To debug menu
    /*ShapeRenderer shapeRenderer = new ShapeRenderer();
    shapeRenderer.setProjectionMatrix(guiCam.combined);
            
    shapeRenderer.begin(ShapeRenderer.ShapeType.Line);
    shapeRenderer.rect(playBounds.x, playBounds.y, playBounds.width, playBounds.height);
    shapeRenderer.rect(highscoresBounds.x, highscoresBounds.y, highscoresBounds.width, highscoresBounds.height);
    shapeRenderer.rect(mapBounds.x, mapBounds.y, mapBounds.width, mapBounds.height);
    shapeRenderer.rect(saveBounds.x, saveBounds.y, saveBounds.width, saveBounds.height);
    shapeRenderer.end();*/

}

From source file:com.arkanoid.game.view.GameScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClearColor(0, 0, 1, 1);/*from w ww  . ja  v a  2s  .c o m*/
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    batcher.renderBackground();
    batcher.renderBall(field.getBall());
    batcher.renderBricks(field.getBricks());
    batcher.renderVaus(field.getVaus());
    //debugRenderer.render(field.getWorld(), guiCam.combined);

    guiCam.update();
    batcher.setProjectionMatrix(guiCam.combined);
    batcher.enableBlending();
    batcher.begin();

    switch (state) {
    case GAME_RUNNING:
        field.step();
        batcher.presentRunning();
        batcher.renderLives(field.getLives());
        break;
    case GAME_READY:
        batcher.presentReady();
        break;
    case GAME_PAUSED:
        batcher.presentPaused();
        batcher.renderLives(field.getLives());
        break;
    case GAME_LEVEL_END:
        batcher.presentLevelEnd();
        break;
    case GAME_OVER:
        batcher.presentGameOver();
        break;
    }
    batcher.end();
}

From source file:com.arkanoid.game.view.MainMenuScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClearColor(1, 0, 0, 1);//from  w  w w .jav  a  2 s.  c  om
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    guiCam.update();
    batcher.setProjectionMatrix(guiCam.combined);

    batcher.disableBlending();
    batcher.begin();
    batcher.draw(Assets.backgroundRegion, 0, 0, 320, 480);
    batcher.end();

    batcher.enableBlending();
    batcher.begin();
    //batcher.draw(Assets.logo, 160 - 274 / 2, 480 - 10 - 142, 274, 142);
    batcher.draw(Assets.mainMenu, 10, 200 - 110 / 2, 300, 110);
    batcher.draw(Settings.soundEnabled ? Assets.soundOn : Assets.soundOff, 0, 0, 64, 64);
    batcher.end();

    if (TimeUtils.nanoTime() - last > 2000000000) {
        Gdx.app.log("Arkanoid",
                "version: " + Gdx.app.getVersion() + ", memory: " + Gdx.app.getJavaHeap() + ", "
                        + Gdx.app.getNativeHeap() + ", native orientation:" + Gdx.input.getNativeOrientation()
                        + ", orientation: " + Gdx.input.getRotation() + ", accel: "
                        + (int) Gdx.input.getAccelerometerX() + ", " + (int) Gdx.input.getAccelerometerY()
                        + ", " + (int) Gdx.input.getAccelerometerZ() + ", apr: " + (int) Gdx.input.getAzimuth()
                        + ", " + (int) Gdx.input.getPitch() + ", " + (int) Gdx.input.getRoll());
        last = TimeUtils.nanoTime();
    }
}

From source file:com.badlogic.invaders.Renderer.java

License:Apache License

public void render(Simulation simulation, float delta) {
    // We explicitly require GL10, otherwise we could've used the GLCommon
    // interface via Gdx.gl
    GL20 gl = Gdx.gl;
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    renderBackground();//from  ww  w . j ava2s  . c  om
    gl.glEnable(GL20.GL_DEPTH_TEST);
    gl.glEnable(GL20.GL_CULL_FACE);
    setProjectionAndCamera(simulation.ship);

    modelBatch.begin(camera);
    modelBatch.render(simulation.explosions);
    if (!simulation.ship.isExploding)
        modelBatch.render(simulation.ship, lights);
    modelBatch.render(simulation.invaders, lights);
    modelBatch.render(simulation.blocks);
    modelBatch.render(simulation.shots);
    modelBatch.end();

    gl.glDisable(GL20.GL_CULL_FACE);
    gl.glDisable(GL20.GL_DEPTH_TEST);

    spriteBatch.setProjectionMatrix(viewMatrix);
    spriteBatch.begin();
    if (simulation.ship.lives != lastLives || simulation.score != lastScore || simulation.wave != lastWave) {
        status = "lives: " + simulation.ship.lives + " wave: " + simulation.wave + " score: "
                + simulation.score;
        lastLives = simulation.ship.lives;
        lastScore = simulation.score;
        lastWave = simulation.wave;
    }
    spriteBatch.enableBlending();
    font.draw(spriteBatch, status, 0, 320);
    spriteBatch.end();

    invaderAngle += delta * 90;
    if (invaderAngle > 360)
        invaderAngle -= 360;
}

From source file:com.badlogicgames.superjumper.helpscreen.HelpScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());

    guiCam.update();/*w w  w. ja v  a2 s. co  m*/
    game.batch.setProjectionMatrix(guiCam.combined);
    game.batch.disableBlending();
    game.batch.begin();
    game.batch.draw(helpRegion, 0, 0);
    game.batch.end();

    game.batch.enableBlending();
    game.batch.begin();
    game.batch.draw(Assets.arrow, 320, 0, -64, 64);
    game.batch.end();
}

From source file:com.badlogicgames.superjumper.helpscreen.HelpScreen2.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    guiCam.update();//from   w  w  w  .  j  av a  2  s  .c  o  m

    game.batch.setProjectionMatrix(guiCam.combined);
    game.batch.disableBlending();
    game.batch.begin();
    game.batch.draw(helpRegion, 0, 0, 320, 480);
    game.batch.end();

    game.batch.enableBlending();
    game.batch.begin();
    game.batch.draw(Assets.arrow, 320, 0, -64, 64);
    game.batch.end();

    gl.glDisable(GL20.GL_BLEND);
}

From source file:com.badlogicgames.superjumper.mainmenu.HighScoresScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    guiCam.update();//from  w w w.j a  v  a  2 s  .  c  o  m

    game.batch.setProjectionMatrix(guiCam.combined);
    game.batch.disableBlending();
    game.batch.begin();
    game.batch.draw(Assets.backgroundRegion, 0, 0, 320, 480);
    game.batch.end();

    game.batch.enableBlending();
    game.batch.begin();
    game.batch.draw(Assets.highScoresRegion, 10, 360 - 16, 300, 33);

    float y = 230;
    for (int i = 4; i >= 0; i--) {
        Assets.font.draw(game.batch, highScores[i], xOffset, y);
        y += Assets.font.getLineHeight();
    }

    game.batch.draw(Assets.arrow, 0, 0, 64, 64);
    game.batch.end();
}

From source file:com.bss.game.GameScreen.java

License:Apache License

public void draw() {
    GL20 gl = Gdx.gl;
    gl.glClearColor(0f, 0f, 0f, 1);/*from   w w w. ja  v  a  2  s.c o  m*/
    gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    renderer.render();

    guiCam.update();
    game.batcher.setProjectionMatrix(guiCam.combined);
    game.batcher.enableBlending();
    game.batcher.begin();
    switch (state) {
    case GAME_READY:
        presentReady();
        break;
    case GAME_RUNNING:
        presentRunning();
        break;
    case GAME_PAUSED:
        presentPaused();
        break;
    case GAME_OVER:
        presentGameOver();
        break;
    }
    game.batcher.end();
}