Search in sources :

Example 51 with Texture

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

the class BitmapFontAlignmentTest method create.

@Override
public void create() {
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean touchDown(int x, int y, int pointer, int newParam) {
            renderMode = (renderMode + 1) % 6;
            return false;
        }
    });
    spriteBatch = new SpriteBatch();
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    logoSprite = new Sprite(texture);
    logoSprite.setColor(1, 1, 1, 0.6f);
    logoSprite.setBounds(50, 100, 400, 100);
    font = new BitmapFont(Gdx.files.getFileHandle("data/verdana39.fnt", FileType.Internal), Gdx.files.getFileHandle("data/verdana39.png", FileType.Internal), false);
    cache = font.newFontCache();
    layout = new GlyphLayout();
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) InputAdapter(com.badlogic.gdx.InputAdapter) GlyphLayout(com.badlogic.gdx.graphics.g2d.GlyphLayout) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 52 with Texture

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

the class BitmapFontFlipTest method create.

@Override
public void create() {
    Gdx.input.setInputProcessor(new InputAdapter() {

        public boolean touchDown(int x, int y, int pointer, int newParam) {
            renderMode = (renderMode + 1) % 4;
            return false;
        }
    });
    spriteBatch = new SpriteBatch();
    spriteBatch.setProjectionMatrix(new Matrix4().setToOrtho(0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), 0, 0, 1));
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    logoSprite = new Sprite(texture);
    logoSprite.flip(false, true);
    logoSprite.setPosition(0, 320 - 256);
    logoSprite.setColor(1, 1, 1, 0.5f);
    font = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), Gdx.files.internal("data/verdana39.png"), true);
    cache1 = font.newFontCache();
    cache2 = font.newFontCache();
    cache3 = font.newFontCache();
    cache4 = font.newFontCache();
    cache5 = font.newFontCache();
    createCaches("cached", cache1, cache2, cache3, cache4, cache5);
    font.getData().setScale(1.33f);
    cacheScaled1 = font.newFontCache();
    cacheScaled2 = font.newFontCache();
    cacheScaled3 = font.newFontCache();
    cacheScaled4 = font.newFontCache();
    cacheScaled5 = font.newFontCache();
    createCaches("cache scaled", cacheScaled1, cacheScaled2, cacheScaled3, cacheScaled4, cacheScaled5);
}
Also used : Sprite(com.badlogic.gdx.graphics.g2d.Sprite) InputAdapter(com.badlogic.gdx.InputAdapter) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 53 with Texture

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

the class Gdx2DTest method textureFromPixmap.

Texture textureFromPixmap(Gdx2DPixmap pixmap) {
    Texture texture = new Texture(pixmap.getWidth(), pixmap.getHeight(), Format.RGB565);
    texture.bind();
    Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), pixmap.getHeight(), 0, pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
    return texture;
}
Also used : Texture(com.badlogic.gdx.graphics.Texture)

Example 54 with Texture

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

the class AnimationTest method create.

@Override
public void create() {
    texture = new Texture(Gdx.files.internal("data/walkanim.png"));
    TextureRegion[] leftWalkFrames = TextureRegion.split(texture, 64, 64)[0];
    TextureRegion[] rightWalkFrames = new TextureRegion[leftWalkFrames.length];
    for (int i = 0; i < rightWalkFrames.length; i++) {
        TextureRegion frame = new TextureRegion(leftWalkFrames[i]);
        frame.flip(true, false);
        rightWalkFrames[i] = frame;
    }
    leftWalk = new Animation<TextureRegion>(0.25f, leftWalkFrames);
    rightWalk = new Animation<TextureRegion>(0.25f, rightWalkFrames);
    cavemen = new Caveman[100];
    for (int i = 0; i < 100; i++) {
        cavemen[i] = new Caveman((float) Math.random() * Gdx.graphics.getWidth(), (float) Math.random() * Gdx.graphics.getHeight(), Math.random() > 0.5 ? true : false);
    }
    batch = new SpriteBatch();
    fpsLog = new FPSLogger();
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Texture(com.badlogic.gdx.graphics.Texture) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) FPSLogger(com.badlogic.gdx.graphics.FPSLogger)

Example 55 with Texture

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

the class AssetManagerTest method load.

private void load() {
    // Gdx.app.setLogLevel(Logger.DEBUG);
    start = TimeUtils.nanoTime();
    tex1 = new Texture("data/animation.png");
    tex2 = new TextureAtlas(Gdx.files.internal("data/pack"));
    font2 = new BitmapFont(Gdx.files.internal("data/verdana39.fnt"), false);
    // tex3 = new Texture("data/test.etc1");
    // map = TiledLoader.createMap(Gdx.files.internal("data/tiledmap/tilemap csv.tmx"));
    // atlas = new TileAtlas(map, Gdx.files.internal("data/tiledmap/"));
    // renderer = new TileMapRenderer(map, atlas, 8, 8);
    shader = new ShaderProgram(Gdx.files.internal("data/g2d/batchCommon.vert").readString(), Gdx.files.internal("data/g2d/monochrome.frag").readString());
    System.out.println("plain took: " + (TimeUtils.nanoTime() - start) / 1000000000.0f);
    start = TimeUtils.nanoTime();
    manager.load("data/animation.png", Texture.class);
    // manager.load("data/pack1.png", Texture.class);
    manager.load("data/pack", TextureAtlas.class);
    // manager.load("data/verdana39.png", Texture.class);
    manager.load("data/verdana39.fnt", BitmapFont.class);
    // manager.load("data/multipagefont.fnt", BitmapFont.class);
    // manager.load("data/test.etc1", Texture.class);
    // manager.load("data/tiledmap/tilemap csv.tmx", TileMapRenderer.class, new
    // TileMapRendererLoader.TileMapParameter("data/tiledmap/", 8, 8));
    manager.load("data/i18n/message2", I18NBundle.class, new I18NBundleLoader.I18NBundleParameter(reloads % 2 == 0 ? Locale.ITALIAN : Locale.ENGLISH));
    manager.load("data/g2d/monochrome.frag", ShaderProgram.class, new ShaderProgramLoader.ShaderProgramParameter() {

        {
            vertexFile = "data/g2d/batchCommon.vert";
        }
    });
}
Also used : I18NBundleLoader(com.badlogic.gdx.assets.loaders.I18NBundleLoader) ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) TextureAtlas(com.badlogic.gdx.graphics.g2d.TextureAtlas) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) ShaderProgramLoader(com.badlogic.gdx.assets.loaders.ShaderProgramLoader) Texture(com.badlogic.gdx.graphics.Texture)

Aggregations

Texture (com.badlogic.gdx.graphics.Texture)235 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)78 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)62 Pixmap (com.badlogic.gdx.graphics.Pixmap)56 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)35 Stage (com.badlogic.gdx.scenes.scene2d.Stage)35 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)26 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)21 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)20 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)19 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)17 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)16 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)16 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)16 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)14 Material (com.badlogic.gdx.graphics.g3d.Material)12 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)12 Actor (com.badlogic.gdx.scenes.scene2d.Actor)11 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)11 FileHandle (com.badlogic.gdx.files.FileHandle)10