Search in sources :

Example 11 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion 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 12 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.

the class DecalTest method makeDecal.

private Decal makeDecal() {
    Decal sprite = null;
    switch(idx % 2) {
        case 0:
            sprite = Decal.newDecal(new TextureRegion(egg), willItBlend_that_is_the_question);
            break;
        case 1:
            sprite = Decal.newDecal(new TextureRegion(wheel));
            break;
    }
    sprite.setPosition(-w / 2 + (float) Math.random() * w, h / 2 - (float) Math.random() * h, (float) -Math.random() * 10);
    idx++;
    return sprite;
}
Also used : Decal(com.badlogic.gdx.graphics.g3d.decals.Decal) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion)

Example 13 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.

the class EdgeDetectionTest method create.

public void create() {
    ShaderProgram.pedantic = false;
    /*
		 * shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal(
		 * "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest",
		 * "couldn't compile scene shader: " + shader.getLog()); }
		 */
    batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/convolution.frag").readString());
    if (!batchShader.isCompiled()) {
        Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog());
    }
    ObjLoader objLoader = new ObjLoader();
    scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj"));
    sceneInstance = new ModelInstance(scene);
    modelBatch = new ModelBatch();
    fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true);
    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0, 0, 10);
    cam.lookAt(0, 0, 0);
    cam.far = 30;
    batch = new SpriteBatch();
    batch.setShader(batchShader);
    fboRegion = new TextureRegion(fbo.getColorBufferTexture());
    fboRegion.flip(false, true);
    logger = new FPSLogger();
    calculateOffsets();
}
Also used : ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) ShaderProgram(com.badlogic.gdx.graphics.glutils.ShaderProgram) ModelBatch(com.badlogic.gdx.graphics.g3d.ModelBatch) ObjLoader(com.badlogic.gdx.graphics.g3d.loader.ObjLoader) PerspectiveCamera(com.badlogic.gdx.graphics.PerspectiveCamera) FrameBuffer(com.badlogic.gdx.graphics.glutils.FrameBuffer) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) FPSLogger(com.badlogic.gdx.graphics.FPSLogger)

Example 14 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion in project libgdx by libgdx.

the class Box2DTest method create.

@Override
public void create() {
    // setup the camera. In Box2D we operate on a
    // meter scale, pixels won't do it. So we use
    // an orthographic camera with a viewport of
    // 48 meters in width and 32 meters in height.
    // We also position the camera so that it
    // looks at (0,16) (that's where the middle of the
    // screen will be located).
    camera = new OrthographicCamera(48, 32);
    camera.position.set(0, 16, 0);
    // next we setup the immediate mode renderer
    renderer = new ShapeRenderer();
    // next we create the box2d debug renderer
    debugRenderer = new Box2DDebugRenderer();
    // next we create a SpriteBatch and a font
    batch = new SpriteBatch();
    font = new BitmapFont(Gdx.files.internal("data/arial-15.fnt"), false);
    font.setColor(Color.RED);
    textureRegion = new TextureRegion(new Texture(Gdx.files.internal("data/badlogicsmall.jpg")));
    // next we create out physics world.
    createPhysicsWorld();
    // register ourselfs as an InputProcessor
    Gdx.input.setInputProcessor(this);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) Box2DDebugRenderer(com.badlogic.gdx.physics.box2d.Box2DDebugRenderer) OrthographicCamera(com.badlogic.gdx.graphics.OrthographicCamera) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont) SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture) ShapeRenderer(com.badlogic.gdx.graphics.glutils.ShapeRenderer)

Example 15 with TextureRegion

use of com.badlogic.gdx.graphics.g2d.TextureRegion 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)

Aggregations

TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)115 Texture (com.badlogic.gdx.graphics.Texture)57 SpriteBatch (com.badlogic.gdx.graphics.g2d.SpriteBatch)22 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)18 Stage (com.badlogic.gdx.scenes.scene2d.Stage)18 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)13 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)13 OrthographicCamera (com.badlogic.gdx.graphics.OrthographicCamera)11 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)11 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)11 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)10 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)10 Skin (com.badlogic.gdx.scenes.scene2d.ui.Skin)10 Pixmap (com.badlogic.gdx.graphics.Pixmap)8 Color (com.badlogic.gdx.graphics.Color)7 ShapeRenderer (com.badlogic.gdx.graphics.glutils.ShapeRenderer)7 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)7 Test (org.junit.Test)7 FileHandle (com.badlogic.gdx.files.FileHandle)6 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)6