Search in sources :

Example 21 with Texture

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

the class ShaderMultitextureTest method createTexture.

private void createTexture() {
    Pixmap pixmap = new Pixmap(256, 256, Format.RGBA8888);
    pixmap.setColor(1, 1, 1, 1);
    pixmap.fill();
    pixmap.setColor(0, 0, 0, 1);
    pixmap.drawLine(0, 0, 256, 256);
    pixmap.drawLine(256, 0, 0, 256);
    texture = new Texture(pixmap);
    pixmap.dispose();
    pixmap = new Pixmap(256, 256, Format.RGBA8888);
    pixmap.setColor(1, 1, 1, 1);
    pixmap.fill();
    pixmap.setColor(0, 0, 0, 1);
    pixmap.drawLine(128, 0, 128, 256);
    texture2 = new Texture(pixmap);
    pixmap.dispose();
}
Also used : Texture(com.badlogic.gdx.graphics.Texture) Pixmap(com.badlogic.gdx.graphics.Pixmap)

Example 22 with Texture

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

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

the class SortedSpriteTest method create.

@Override
public void create() {
    // create the SpriteBatch
    batch = new SpriteBatch();
    // load a texture, usually you dispose of this
    // eventually.
    texture = new Texture("data/badlogicsmall.jpg");
    // can see that the sorting works.
    for (int i = 0; i < 100; i++) {
        // create the sprite and set a random position
        MySprite sprite = new MySprite(texture);
        sprite.setPosition(MathUtils.random() * Gdx.graphics.getWidth(), MathUtils.random() * Gdx.graphics.getHeight());
        // create a random z coordinate in the range 0-1
        sprite.z = MathUtils.random();
        // set the tinting color to the z coordinate as well
        // for visual inspection
        sprite.setColor(sprite.z, 0, 0, 1);
        // add the sprite to the array
        sprites.add(sprite);
    }
}
Also used : SpriteBatch(com.badlogic.gdx.graphics.g2d.SpriteBatch) Texture(com.badlogic.gdx.graphics.Texture)

Example 24 with Texture

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

the class EffectPanel method createDefaultPointController.

private ParticleController createDefaultPointController() {
    //Emission
    RegularEmitter emitter = new RegularEmitter();
    emitter.getDuration().setLow(3000);
    emitter.getEmission().setHigh(250);
    emitter.getLife().setHigh(500, 1000);
    emitter.getLife().setTimeline(new float[] { 0, 0.66f, 1 });
    emitter.getLife().setScaling(new float[] { 1, 1, 0.3f });
    emitter.setMaxParticleCount(200);
    //Scale
    ScaleInfluencer scaleInfluencer = new ScaleInfluencer();
    scaleInfluencer.value.setHigh(1);
    //Color
    ColorInfluencer.Single colorInfluencer = new ColorInfluencer.Single();
    colorInfluencer.colorValue.setColors(new float[] { 0.12156863f, 0.047058824f, 1, 0, 0, 0 });
    colorInfluencer.colorValue.setTimeline(new float[] { 0, 1 });
    colorInfluencer.alphaValue.setHigh(1);
    colorInfluencer.alphaValue.setTimeline(new float[] { 0, 0.5f, 0.8f, 1 });
    colorInfluencer.alphaValue.setScaling(new float[] { 0, 0.15f, 0.5f, 0 });
    //Spawn
    PointSpawnShapeValue pointSpawnShapeValue = new PointSpawnShapeValue();
    SpawnInfluencer spawnSource = new SpawnInfluencer(pointSpawnShapeValue);
    //Velocity
    DynamicsInfluencer velocityInfluencer = new DynamicsInfluencer();
    //Directional
    DynamicsModifier.PolarAcceleration velocityValue = new DynamicsModifier.PolarAcceleration();
    velocityValue.phiValue.setHigh(-35, 35);
    velocityValue.phiValue.setActive(true);
    velocityValue.phiValue.setTimeline(new float[] { 0, 0.5f, 1 });
    velocityValue.phiValue.setScaling(new float[] { 1, 0, 0 });
    velocityValue.thetaValue.setHigh(0, 360);
    velocityValue.strengthValue.setHigh(5, 10);
    return new ParticleController("PointSprite Controller", emitter, new PointSpriteRenderer(editor.getPointSpriteBatch()), new RegionInfluencer.Single((Texture) editor.assetManager.get(FlameMain.DEFAULT_BILLBOARD_PARTICLE)), spawnSource, scaleInfluencer, colorInfluencer, velocityInfluencer);
}
Also used : DynamicsInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsInfluencer) RegularEmitter(com.badlogic.gdx.graphics.g3d.particles.emitters.RegularEmitter) Texture(com.badlogic.gdx.graphics.Texture) DynamicsModifier(com.badlogic.gdx.graphics.g3d.particles.influencers.DynamicsModifier) PointSpawnShapeValue(com.badlogic.gdx.graphics.g3d.particles.values.PointSpawnShapeValue) ScaleInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ScaleInfluencer) PointSpriteRenderer(com.badlogic.gdx.graphics.g3d.particles.renderers.PointSpriteRenderer) ParticleController(com.badlogic.gdx.graphics.g3d.particles.ParticleController) ColorInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.ColorInfluencer) RegionInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.RegionInfluencer) SpawnInfluencer(com.badlogic.gdx.graphics.g3d.particles.influencers.SpawnInfluencer)

Example 25 with Texture

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

the class TextureAtlasPanel method setAtlas.

public void setAtlas(TextureAtlas atlas) {
    if (atlas == this.atlas)
        return;
    regionsPanel.removeAll();
    Array<AtlasRegion> atlasRegions = atlas.getRegions();
    CustomCardLayout layout = (CustomCardLayout) regionsPanel.getLayout();
    Array<TextureRegion> regions = new Array<TextureRegion>();
    for (Texture texture : atlas.getTextures()) {
        FileTextureData file = (FileTextureData) texture.getTextureData();
        regionsPanel.add(new TexturePanel(texture, getRegions(texture, atlasRegions, regions)));
    }
    layout.first(regionsPanel);
    this.atlas = atlas;
}
Also used : Array(com.badlogic.gdx.utils.Array) TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) AtlasRegion(com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion) FileTextureData(com.badlogic.gdx.graphics.glutils.FileTextureData) Texture(com.badlogic.gdx.graphics.Texture)

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