Example usage for com.badlogic.gdx.graphics OrthographicCamera setToOrtho

List of usage examples for com.badlogic.gdx.graphics OrthographicCamera setToOrtho

Introduction

In this page you can find the example usage for com.badlogic.gdx.graphics OrthographicCamera setToOrtho.

Prototype

public void setToOrtho(boolean yDown) 

Source Link

Document

Sets this camera to an orthographic projection using a viewport fitting the screen resolution, centered at (Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2), with the y-axis pointing up or down.

Usage

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

public PlanetScreen() {
    //        final ElevationParameters elevParams = ElevationParameters.buildEvenRanges();
    //        final ElevationParameters elevParams = ElevationParameters.buildByPercent(75, 5, 15, 5, 5);
    final ElevationParameters elevParams = ElevationParameters.buildByEnumValues();
    final LatitudeParameters latParams = LatitudeParameters.getEvenPercentages();
    final TerrainParameters terrainParams = new TerrainParameters(elevParams, latParams, 10, 9, 9);

    final MapGenerator mg = new MapGenerator(terrainParams);
    tileSize = 1;/*from  w w w.j  a v  a2 s  .  c  o  m*/
    width = Gdx.graphics.getWidth() / tileSize;
    height = Gdx.graphics.getHeight() / tileSize;
    tiles = mg.generateTiles(width, height);
    elevationTexture = mg.generateElevationTexture(tiles, width, height, tileSize);
    rawElevationTexture = mg.generateRawElevationTexture(tiles, width, height, tileSize);
    temperatureTexture = mg.generateTemperatureTexture(tiles, width, height, tileSize);
    rainfallTexture = mg.generateRainfallTexture(tiles, width, height, tileSize);
    mineralTexture = mg.generateMineralsTexture(tiles, width, height, tileSize);
    elevationGrayScaleTexture = mg.generateElevationGrayscaleTexture(tiles, width, height, tileSize);

    batch = new SpriteBatch();

    final Texture latColorTexture = mg.generateLatitudeTexture(tiles, width, height, tileSize);
    final FrameBuffer frameBuffer = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, false);
    final OrthographicCamera camera = new OrthographicCamera();
    camera.setToOrtho(true);
    final Matrix4 oldBatchMatrix = batch.getProjectionMatrix();
    batch.setProjectionMatrix(camera.combined);
    frameBuffer.begin();
    batch.begin();
    batch.draw(elevationTexture, 0, 0);
    final Sprite latColorSprite = new Sprite(latColorTexture);
    latColorSprite.setAlpha(0.5f);
    latColorSprite.draw(batch);
    batch.end();
    frameBuffer.end();

    batch.setProjectionMatrix(oldBatchMatrix);
    latitudeTexture = frameBuffer.getColorBufferTexture();
    currentTextureIdx = 0;

    textures.add(elevationTexture);
    textures.add(rawElevationTexture);
    textures.add(elevationGrayScaleTexture);
    textures.add(temperatureTexture);
    textures.add(rainfallTexture);
    textures.add(mineralTexture);
    textures.add(latitudeTexture);
    //        textures.add(zoomedElevationTexture);

    numTextures = textures.size();
}