Example usage for com.badlogic.gdx Gdx gl

List of usage examples for com.badlogic.gdx Gdx gl

Introduction

In this page you can find the example usage for com.badlogic.gdx Gdx gl.

Prototype

GL20 gl

To view the source code for com.badlogic.gdx Gdx gl.

Click Source Link

Usage

From source file:com.gdx.game.screens.PlayScreen.java

@Override
public void render(float delta) {
    this.update(delta);
    // Clear the game screen
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    //render game map
    renderer.render();//from w w  w. ja  va  2s. c  o m

    this.box2DDebugRenderer.render(this.world, this.gameCam.combined);

    game.getBatch().setProjectionMatrix(gameCam.combined);
    game.getBatch().begin();
    player.draw(game.getBatch());
    game.getBatch().end();

    game.getBatch().setProjectionMatrix(hud.stage.getCamera().combined);
    hud.stage.draw();
}

From source file:com.github.badoualy.badoualyve.ui.screen.FixedFpsScreen.java

License:Open Source License

@Override
public void render(float delta) {
    Gdx.gl.glClearColor(1f, 1f, 1f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Max frame time
    if (delta > 0.25f)
        delta = 0.25f;/*from  w ww  .j  a v  a 2 s .  c  o  m*/

    accumulator += delta;

    // We update simulation as much as needed
    while (accumulator >= fps) {
        stage.act(); // Update

        accumulator -= fps;
    }

    // We still draw once
    stage.draw(); // Draw
}

From source file:com.github.badoualy.badoualyve.ui.stage.IntroStage.java

License:Open Source License

@Override
public void draw() {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.rect(0, 0, WIDTH, HEIGHT);
    shapeRenderer.end();/*from   w  ww  .j ava2 s.  c  om*/

    super.draw();
}

From source file:com.github.fauu.helix.system.ScreenFadingSystem.java

License:Open Source License

@Override
protected void processSystem() {
    if (fadeLevel >= fadeDuration) {
        fadeLevel = fadeDuration;//from   ww  w.  j  ava  2  s  .c  o m
    } else if (fadeLevel <= 0) {
        fadeLevel = 0;
    }

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

    shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
    shapeRenderer.setColor(0, 0, 0, fadeLevel / fadeDuration);
    shapeRenderer.rect(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    shapeRenderer.end();

    Gdx.gl.glDisable(GL20.GL_BLEND);

    switch (fadeType) {
    case FADE_OUT:
        fadeLevel += Gdx.graphics.getDeltaTime();
        break;
    case FADE_IN:
        fadeLevel -= Gdx.graphics.getDeltaTime();
        break;
    default:
        throw new IllegalStateException();
    }
}

From source file:com.github.mkjensen.breakall.Breakall.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    stage.act(Gdx.graphics.getDeltaTime());
    stage.draw();/*from   w  ww. ja  v  a  2  s. c  o m*/

    debugRenderer.draw();
    world.step();
}

From source file:com.github.skittishSloth.openSkies.battles.BattleScreen.java

@Override
public void render(final float delta) {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.isKeyPressed(Input.Keys.SHIFT_LEFT)) {
        if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
            player.setBankState(BankState.LEFT);
            player.bankLeft(delta);/*from ww w  . j a v a  2 s .com*/
        } else if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
            player.setBankState(BankState.RIGHT);
            player.bankRight(delta);
        } else {
            player.setBankState(BankState.NONE);
        }
    } else {
        player.setBankState(BankState.NONE);
        if (Gdx.input.isKeyPressed(Input.Keys.LEFT)) {
            player.rotateLeft(delta);
        } else if (Gdx.input.isKeyPressed(Input.Keys.RIGHT)) {
            player.rotateRight(delta);
        }
    }

    if (Gdx.input.isKeyPressed(Input.Keys.UP)) {
        player.moveForward(delta);
    } else if (Gdx.input.isKeyPressed(Input.Keys.DOWN)) {
        player.moveBackward(delta);
    }

    if (Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
        if (player.canFire()) {
            final Laser laser = player.fireLaser();
            lasers.add(laser);
        }
    }

    camera.update();
    batch.setProjectionMatrix(camera.combined);
    batch.begin();
    updateLasers(delta);
    player.render(batch, delta);
    batch.end();
}

From source file:com.github.skittishSloth.openSkies.maps.PlanetScreen.java

@Override
public void render(final float delta) {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.isKeyJustPressed(Input.Keys.LEFT)) {
        currentTextureIdx--;//  ww w.  jav  a2 s  . c  o  m
    } else if (Gdx.input.isKeyJustPressed(Input.Keys.RIGHT)) {
        currentTextureIdx++;
    }

    if (currentTextureIdx < 0) {
        currentTextureIdx += numTextures;
    } else if (currentTextureIdx >= numTextures) {
        currentTextureIdx -= numTextures;
    }

    final Texture currentTexture = textures.get(currentTextureIdx);
    batch.begin();
    batch.draw(currentTexture, 0, 0);
    batch.end();
}

From source file:com.github.skittishSloth.openSkies.maps.VoronoiTestScreen.java

@Override
public void render(final float delta) {
    Gdx.gl.glClearColor(1, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    batch.begin();// ww w  .  j  a  v a  2  s  .  c  o m
    batch.draw(mapTexture, 0, 0);
    batch.end();
}

From source file:com.github.squidpony.SquidBasicDemo.java

@Override
public void render() {
    // standard clear the background routine for libGDX
    Gdx.gl.glClearColor(bgColor.r / 255.0f, bgColor.g / 255.0f, bgColor.b / 255.0f, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // need to display the map every frame, since we clear the screen to avoid artifacts.
    putMap();/*from w w  w  .  j  av  a 2  s .c o  m*/
    // if the user clicked, we have a list of moves to perform.
    if (!awaitedMoves.isEmpty()) {
        // this doesn't check for input, but instead processes and removes Coords from awaitedMoves.
        secondsWithoutMoves += Gdx.graphics.getDeltaTime();
        if (secondsWithoutMoves >= 0.1) {
            secondsWithoutMoves = 0;
            Coord m = awaitedMoves.remove(0);
            toCursor.remove(0);
            move(m.x - player.x, m.y - player.y);
        }
        // this only happens if we just removed the last Coord from awaitedMoves, and it's only then that we need to
        // re-calculate the distances from all cells to the player. We don't need to calculate this information on
        // each part of a many-cell move (just the end), nor do we need to calculate it whenever the mouse moves.
        if (awaitedMoves.isEmpty()) {
            // the next two lines remove any lingering data needed for earlier paths
            playerToCursor.clearGoals();
            playerToCursor.resetMap();
            // the next line marks the player as a "goal" cell, which seems counter-intuitive, but it works because all
            // cells will try to find the distance between themselves and the nearest goal, and once this is found, the
            // distances don't change as long as the goals don't change. Since the mouse will move and new paths will be
            // found, but the player doesn't move until a cell is clicked, the "goal" is the non-changing cell, so the
            // player's position, and the "target" of a pathfinding method like DijkstraMap.findPathPreScanned() is the
            // currently-moused-over cell, which we only need to set where the mouse is being handled.
            playerToCursor.setGoal(player);
            playerToCursor.scan(null);
        }
    }
    // if we are waiting for the player's input and get input, process it.
    else if (input.hasNext()) {
        input.next();
    }

    // stage has its own batch and must be explicitly told to draw().
    stage.draw();
    // certain classes that use scene2d.ui widgets need to be told to act() to process input.
    stage.act();
}

From source file:com.github.ykrasik.jaci.cli.libgdx.LibGdxCliExample.java

License:Apache License

@Override
public void render() {
    Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);

    stage.act();
    stage.draw();
}