Search in sources :

Example 6 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class PixelPerfectTest method create.

@Override
public void create() {
    Pixmap pixmap = new Pixmap(16, 16, Pixmap.Format.RGBA8888);
    pixmap.setColor(Color.BLUE);
    pixmap.fill();
    pixmap.setColor(Color.RED);
    pixmap.drawLine(0, 0, 15, 15);
    pixmap.drawLine(0, 15, 15, 0);
    tex = new Texture(pixmap);
    batch = new SpriteBatch();
    cam = new OrthographicCamera();
    cam.setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
Also used : OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 7 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class NinePatchTest method resize.

@Override
public void resize(int width, int height) {
    float ratio = ((float) Gdx.graphics.getWidth() / (float) Gdx.graphics.getHeight());
    int h = 10;
    int w = (int) (h * ratio);
    camera = new OrthographicCamera(w, h);
}
Also used : OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera)

Example 8 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class SimpleStageCullingTest method create.

@Override
public void create() {
    // create a stage and a camera controller so we can pan the view.
    stage = new Stage();
    ;
    // we know it's an ortho cam at this point!
    camController = new OrthoCamController((OrthographicCamera) stage.getCamera());
    Gdx.input.setInputProcessor(camController);
    // load a dummy texture
    texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    // populate the stage with some actors and groups.
    for (int i = 0; i < 5000; i++) {
        Actor img = new CullableActor("img" + i, texture, (OrthographicCamera) stage.getCamera());
        img.setX((float) Math.random() * 480 * 10);
        img.setY((float) Math.random() * 320 * 10);
        stage.addActor(img);
    }
    // we also want to output the number of visible actors, so we need a SpriteBatch and a BitmapFont
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
}
Also used : Actor(com.badlogic.gdx.scenes.scene2d.Actor) Stage(com.badlogic.gdx.scenes.scene2d.Stage) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch)

Example 9 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class DecalTest method create.

@Override
public void create() {
    Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
    Gdx.gl.glDepthFunc(GL20.GL_LESS);
    egg = new Texture(Gdx.files.internal("data/egg.png"));
    egg.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    egg.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
    wheel = new Texture(Gdx.files.internal("data/wheel.png"));
    wheel.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
    wheel.setWrap(Texture.TextureWrap.ClampToEdge, Texture.TextureWrap.ClampToEdge);
    w = Gdx.graphics.getWidth() / 0.8f;
    h = Gdx.graphics.getHeight() / 0.8f;
    for (int i = 0; i < INITIAL_RENDERED; i++) {
        toRender.add(makeDecal());
    }
    cam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.near = 0.1f;
    cam.far = 10f;
    cam.position.set(0, 0, 0.1f);
    cam.direction.set(0, 0, -1f);
    batch = new DecalBatch(new CameraGroupStrategy(cam));
    Gdx.gl.glClearColor(1, 1, 0, 1);
}
Also used : DecalBatch(com.badlogic.gdx.graphics.g3d.decals.DecalBatch) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) CameraGroupStrategy(com.badlogic.gdx.graphics.g3d.decals.CameraGroupStrategy) Texture(com.badlogic.gdx.graphics.Texture)

Example 10 with OrthographicCamera

use of com.badlogic.gdx.graphics.OrthographicCamera in project libgdx by libgdx.

the class ETC1Test method create.

@Override
public void create() {
    font = new BitmapFont();
    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    controller = new OrthoCamController(camera);
    Gdx.input.setInputProcessor(controller);
    Pixmap pixmap = new Pixmap(32, 32, Format.RGB565);
    pixmap.setColor(1, 0, 0, 1);
    pixmap.fill();
    pixmap.setColor(0, 1, 0, 1);
    pixmap.drawLine(0, 0, 32, 32);
    pixmap.drawLine(0, 32, 32, 0);
    ETC1Data encodedImage = ETC1.encodeImagePKM(pixmap);
    pixmap.dispose();
    pixmap = ETC1.decodeImage(encodedImage, Format.RGB565);
    encodedImage.dispose();
    img1 = new Texture(pixmap);
    img2 = new Texture("data/test.etc1");
    batch = new SpriteBatch();
    pixmap.dispose();
}
Also used : ETC1Data(com.badlogic.gdx.graphics.glutils.ETC1.ETC1Data) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) OrthoCamController(com.badlogic.gdx.tests.utils.OrthoCamController) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Aggregations

OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)50 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)32 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)21 Texture (com.badlogic.gdx.graphics.Texture)20 OrthoCamController (com.badlogic.gdx.tests.utils.OrthoCamController)15 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)10 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)10 OrthogonalTiledMapRenderer (com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer)7 TmxMapLoader (com.badlogic.gdx.maps.tiled.TmxMapLoader)6 Box2DDebugRenderer (com.badlogic.gdx.physics.box2d.Box2DDebugRenderer)6 AssetManager (com.badlogic.gdx.assets.AssetManager)5 InternalFileHandleResolver (com.badlogic.gdx.assets.loaders.resolvers.InternalFileHandleResolver)4 Pixmap (com.badlogic.gdx.graphics.Pixmap)4 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)3 PolygonSpriteBatch (com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch)3 Vector2 (com.badlogic.gdx.math.Vector2)3 World (com.badlogic.gdx.physics.box2d.World)3 Stage (com.badlogic.gdx.scenes.scene2d.Stage)3 InputAdapter (com.badlogic.gdx.InputAdapter)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)2