Search in sources :

Example 11 with Texture

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

the class ContainerTest method create.

@Override
public void create() {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);
    TextureRegionDrawable logo = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("data/badlogic.jpg"))));
    Table root = new Table();
    root.setFillParent(true);
    root.debug().defaults().space(6).size(110);
    stage.addActor(root);
    root.add(new Container(label("center")));
    root.add(new Container(label("top")).top());
    root.add(new Container(label("right")).right());
    root.add(new Container(label("bottom")).bottom());
    root.add(new Container(label("left")).left());
    root.row();
    root.add(new Container(label("fill")).fill());
    root.add(new Container(label("fillX")).fillX());
    root.add(new Container(label("fillY")).fillY());
    root.add(new Container(label("fill 75%")).fill(0.75f, 0.75f));
    root.add(new Container(label("fill 75% br")).fill(0.75f, 0.75f).bottom().right());
    root.row();
    root.add(new Container(label("padTop 5\ntop")).padTop(5).top());
    root.add(new Container(label("padBottom 5\nbottom")).padBottom(5).bottom());
    root.add(new Container(label("padLeft 15")).padLeft(15));
    root.add(new Container(label("pad 10 fill")).pad(10).fill());
    root.add(new Container(label("pad 10 tl")).pad(10).top().left());
    root.row();
    root.add(new Container(label("bg")).background(logo));
    root.add(new Container(label("bg height 50")).background(logo).height(50));
    Container transformBG = new Container(label("bg transform")).background(logo);
    transformBG.setTransform(true);
    transformBG.setOrigin(55, 55);
    transformBG.rotateBy(90);
    root.add(transformBG);
    Container transform = new Container(label("transform"));
    transform.setTransform(true);
    transform.setOrigin(55, 55);
    transform.rotateBy(90);
    root.add(transform);
    Container clip = new Container(label("clip1clip2clip3clip4"));
    clip.setClip(true);
    root.add(clip);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Container(com.badlogic.gdx.scenes.scene2d.ui.Container) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) Texture(com.badlogic.gdx.graphics.Texture)

Example 12 with Texture

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

the class CpuSpriteBatchTest method create.

public void create() {
    Batch batch = new CpuSpriteBatch();
    // batch = new SpriteBatch();
    stage = new Stage(new ExtendViewport(500, 500), batch);
    Gdx.input.setInputProcessor(stage);
    texture = new Texture("data/bobargb8888-32x32.png");
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    TextureRegionDrawable drawable = new TextureRegionDrawable(new TextureRegion(texture));
    for (int i = 0; i < NUM_GROUPS; i++) {
        Group group = createActorGroup(drawable);
        stage.addActor(group);
    }
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Group(com.badlogic.gdx.scenes.scene2d.Group) ExtendViewport(com.badlogic.gdx.utils.viewport.ExtendViewport) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Batch(com.badlogic.gdx.graphics.g2d.Batch) CpuSpriteBatch(com.badlogic.gdx.graphics.g2d.CpuSpriteBatch) Stage(com.badlogic.gdx.scenes.scene2d.Stage) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) CpuSpriteBatch(com.badlogic.gdx.graphics.g2d.CpuSpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 13 with Texture

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

the class CustomShaderSpriteBatchTest method create.

@Override
public void create() {
    batch = new SpriteBatch(10);
    ShaderProgram.pedantic = false;
    shader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/batch.frag").readString());
    batch.setShader(shader);
    texture = new Texture("data/badlogic.jpg");
}
Also used : ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 14 with Texture

use of com.badlogic.gdx.graphics.Texture 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 15 with Texture

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

the class DownloadTest method create.

@Override
public void create() {
    batch = new SpriteBatch();
    HttpRequest request = new HttpRequest(HttpMethods.GET);
    request.setUrl("https://www.google.at/images/srpr/logo11w.png");
    Gdx.net.sendHttpRequest(request, new HttpResponseListener() {

        @Override
        public void handleHttpResponse(HttpResponse httpResponse) {
            final byte[] bytes = httpResponse.getResult();
            Gdx.app.postRunnable(new Runnable() {

                @Override
                public void run() {
                    Pixmap pixmap = new Pixmap(bytes, 0, bytes.length);
                    texture = new Texture(new PixmapTextureData(pixmap, pixmap.getFormat(), false, false, true));
                }
            });
        }

        @Override
        public void failed(Throwable t) {
            t.printStackTrace();
            Gdx.app.log("EmptyDownloadTest", "Failed", t);
        }

        @Override
        public void cancelled() {
            Gdx.app.log("EmptyDownloadTest", "Cancelled");
        }
    });
}
Also used : HttpRequest(com.badlogic.gdx.Net.HttpRequest) HttpResponse(com.badlogic.gdx.Net.HttpResponse) PixmapTextureData(com.badlogic.gdx.graphics.glutils.PixmapTextureData) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) Pixmap(com.badlogic.gdx.graphics.Pixmap) HttpResponseListener(com.badlogic.gdx.Net.HttpResponseListener)

Aggregations

Texture (com.badlogic.gdx.graphics.Texture)162 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)59 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)56 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)31 Pixmap (com.badlogic.gdx.graphics.Pixmap)27 Stage (com.badlogic.gdx.scenes.scene2d.Stage)23 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)20 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)17 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)14 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)11 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)11 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)11 Material (com.badlogic.gdx.graphics.g3d.Material)10 ShaderProgram (com.badlogic.gdx.graphics.glutils.ShaderProgram)10 PerspectiveCamera (com.badlogic.gdx.graphics.PerspectiveCamera)9 VertexAttribute (com.badlogic.gdx.graphics.VertexAttribute)8 ColorAttribute (com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute)8 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)8 Actor (com.badlogic.gdx.scenes.scene2d.Actor)8 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)8