Java 类com.badlogic.gdx.graphics.Texture.TextureFilter 实例源码

项目:libgdxcn    文件:FilterPerformanceTest.java   
public void create () {
    batch = new SpriteBatch();
    sceneMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);
    textMatrix = new Matrix4().setToOrtho2D(0, 0, 480, 320);

    atlas = new TextureAtlas(Gdx.files.internal("data/issue_pack"), Gdx.files.internal("data/"));
    texture = new Texture(Gdx.files.internal("data/resource1.jpg"), true);
    texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);
    setTextureFilter(0);
    setModeString();

    sprite = atlas.createSprite("map");
    sprite2 = new Sprite(texture, 0, 0, 855, 480);
    font = new BitmapFont(Gdx.files.internal("data/font.fnt"), Gdx.files.internal("data/font.png"), false);

    Gdx.input.setInputProcessor(new InputAdapter() {
        public boolean touchDown (int x, int y, int pointer, int newParam) {
            mode++;
            if (mode == filters.length * 2) mode = 0;
            setTextureFilter(mode / 2);
            setModeString();
            return false;
        }
    });
}
项目:GDX-Engine    文件:Wave.java   
/**
    * @param hitPoint
    * @param bonus
    * @param speed
    * @param numberOfMonster
    * @param timeToRelease
    */
   public Wave(IGameService service, int index) {
super(service);
this.index = index;
texture= GameAsset.monsterTexture[index];
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
ended = false;
action = new BaseLoopingAction(GameSpecs.numberOfMonster[index], GameSpecs.timeToRelease[index]) {

    @Override
    public void onActionRemove() {
    ended = true;
    }

    @Override
    public void onActionPerformance() {
    createMonster();
    }
};
   }
项目:GDX-Engine    文件:MyGdxGame.java   
@Override
public void create() {      
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera(1, h/w);
    batch = new SpriteBatch();

    texture = new Texture(Gdx.files.internal("data/libgdx.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    TextureRegion region = new TextureRegion(texture, 0, 0, 200, 200);

    sprite = new Sprite(region);
    sprite.setSize(1f,  sprite.getHeight() / sprite.getWidth());
    sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
    sprite.setPosition(-.5f, -.5f);

}
项目:Polymorph    文件:GameScreen.java   
private void initUtils() {
    //init camera & viewport
    camera = new OrthographicCamera();
    viewport = new StretchViewport(Polymorph.WORLD_WIDTH, Polymorph.WORLD_HEIGHT, camera);
    viewport.apply(true);
    camera.update();

    //init sprite batch
    batch = new SpriteBatch();
    batch.setProjectionMatrix(camera.combined);

    //init font
    FreeTypeFontGenerator fontGenerator = polymorph.getAssetManager().get(Polymorph.FONT_BOLD_PATH, FreeTypeFontGenerator.class);
    FreeTypeFontParameter fontSettings = new FreeTypeFontParameter();
    fontSettings.size = 80;
    fontSettings.minFilter = TextureFilter.Linear;
    fontSettings.magFilter = TextureFilter.Linear;
    font = fontGenerator.generateFont(fontSettings);
}
项目:exterminate    文件:Biome.java   
public void addTexture(String file) {
        Texture texture = new Texture(Gdx.files.internal(file), true);

        texture.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
        if(ExterminateGame.useGL3) {
            texture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear);
        }
        else {
            texture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Linear);             
        }

        if(ltid==0) {
            textureHerbe = texture;
        }
        else if(ltid==1) {
            textureSand = texture;
        }
        else if(ltid==2) {
            textureDirt = texture;
        }
        else if(ltid==3) {
            textureRock = texture;
        }

    ltid++;
}
项目:neblina-libgdx3d    文件:Renderer.java   
public Renderer () {
    try {
        lights = new Environment();
        lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));

        spriteBatch = new SpriteBatch();
        modelBatch = new ModelBatch();

        backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
        backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:neblina-libgdx3d    文件:GameOver.java   
public GameOver (Invaders invaders) {
    super(invaders);
    spriteBatch = new SpriteBatch();
    background = new Texture(Gdx.files.internal("data/planet.jpg"));
    background.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new Texture(Gdx.files.internal("data/title.png"));
    logo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false);

    if (invaders.getController() != null) {
        invaders.getController().addListener(new ControllerAdapter() {
            @Override
            public boolean buttonUp(Controller controller,
                    int buttonIndex) {
                controller.removeListener(this);
                isDone = true;
                return false;
            }
        });
    }
}
项目:neblina-libgdx3d    文件:MainMenu.java   
public MainMenu (Invaders invaders) {
    super(invaders);

    spriteBatch = new SpriteBatch();
    background = new Texture(Gdx.files.internal("data/planet.jpg"));
    background.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new Texture(Gdx.files.internal("data/title.png"));
    logo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false);

    if (invaders.getController() != null) {
        invaders.getController().addListener(new ControllerAdapter() {
            @Override
            public boolean buttonUp(Controller controller, int buttonIndex) {
                controller.removeListener(this);
                isDone = true;
                return false;
            }
        });
    }
}
项目:RavTech    文件:SpriteRenderer.java   
@Override
public void write (Json json) {
    super.write(json);
    json.writeValue("width", width);
    json.writeValue("height", height);
    json.writeValue("texture", texturePath);
    if (regionName != null)
        json.writeValue(regionName);
    json.writeValue("srcX", srcX);
    json.writeValue("srcY", srcY);
    json.writeValue("srcWidth", srcWidth);
    json.writeValue("srcHeight", srcHeight);
    json.writeValue("originX", originX);
    json.writeValue("originY", originY);
    json.writeValue("minFilter", minFilter == TextureFilter.Linear ? "Linear" : "Nearest");
    json.writeValue("magFilter", magFilter == TextureFilter.Linear ? "Linear" : "Nearest");
    JsonUtil.writeColorToJson(json, color, "tint");
    json.writeValue("uWrap",
        uWrap == TextureWrap.ClampToEdge ? "ClampToEdge" : uWrap == TextureWrap.Repeat ? "Repeat" : "MirroredRepeat");
    json.writeValue("vWrap",
        vWrap == TextureWrap.ClampToEdge ? "ClampToEdge" : vWrap == TextureWrap.Repeat ? "Repeat" : "MirroredRepeat");
}
项目:TheEndlessCastle    文件:LoadingScreen.java   
public LoadingScreen(TheEndlessCastle game)
{
    super(game);

    // We need to use raw path to assets and load it without assetsHandler as we are loading assets and reading ressources xml file
    Texture INSATexture = new Texture(Gdx.files.internal(_INSA_LOGO_TEXTURE_PATH), true);
    INSATexture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear);
    Texture OpenTexture = new Texture(Gdx.files.internal(_OPEN_LOGO_TEXTURE_PATH), true);
    OpenTexture.setFilter(TextureFilter.MipMapLinearLinear, TextureFilter.Linear);
    _INSALogoSprite = new Sprite(INSATexture);
    _mainLogoSprite = new Sprite(OpenTexture);
    _mainLogoSprite.setSize(9, 9f *_mainLogoSprite.getHeight()/_mainLogoSprite.getWidth());
    _INSALogoSprite.setSize(4, 4f *_INSALogoSprite.getHeight()/_INSALogoSprite.getWidth());
    _INSALogoSprite.setCenter(_camera.viewportWidth/2f, 1f);
    _mainLogoSprite.setCenter(_camera.viewportWidth/2f+1f, 9.5f);
}
项目:Mario-Libgdx    文件:AbstractMenuScreen.java   
public <E extends Enum<?>> AbstractMenuScreen(Class<E> menuEnumClass, BitmapFont pFont, Class<?> selectorClass) {

        stage = new Stage();
        Gdx.input.setInputProcessor(stage);
        font = pFont != null ? pFont : new BitmapFont();
        font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);        
        font.setColor(0, 0, 0, 1);
        selectorHeight = font.getCapHeight();
        initItemsPositions(menuEnumClass);
        generateSelector(selectorClass);
        foregroundGroup= new Group();
        backgroundGroup = new Group();
        addBackgroundElements();
        foregroundGroup.addActor(selector);
        stage.addActor(backgroundGroup);
        stage.addActor(foregroundGroup);        
    }
项目:METRO    文件:TrainTemplate.java   
/**
 * Load the normal texture for this train. This will be used to display the train one the playing field.
 */
private void loadTitleTextures()
{
    try
    {
        TextureRegion texture = new TextureRegion(new Texture(Gdx.files.internal("textures/Trains_" + _modelName + ".png")));
        texture.flip(false, true);
        texture.getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
        _textures.put(_modelName, texture);

        Logger.__info("Succesfully loaded image for train " + _modelName + ".");
    }
    catch (GdxRuntimeException ex)
    {
        Logger.__error("Error while loading trains title image!", ex);
    }
}
项目:METRO    文件:TrainTemplate.java   
/**
 * Load the title image for this train that'll be displayed by the train buy dialog.
 */
private void loadModelTextures()
{
    Logger.__info("Loading train title image");
    try
    {
        FileHandle handle = Gdx.files.internal("textures/Trains_" + _modelName + "_big.png");
        Texture texture = new Texture(handle);
        TextureRegion textureRegion = new TextureRegion(texture);
        textureRegion.flip(false, true);
        textureRegion.getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);
        _titleTextures.put(_modelName, textureRegion);

        Logger.__info("Succesfully loaded title image for train " + _modelName + ".");
    }
    catch (GdxRuntimeException ex)
    {
        Logger.__error("Error while loading title image!", ex);
    }
}
项目:DoubleHelix    文件:PowerLUT.java   
/** W power will be in luminance, and H power will be in alpha**/
public PowerLUT(float powerW, float intensityW, float powerH, float intensityH, int width, int height){

    Pixmap pixmap = new Pixmap(width, height, Format.RGBA8888);
    for (int i=0; i<width; i++){
        float valueW = (float)Math.pow((float)i/width, powerW) * intensityW;
           for (int j = 0; j < height; j++) {
               float valueH = (float)Math.pow((float)j/height, powerH) * intensityH;
               pixmap.setColor(valueW, valueH, 1.0f, 1.0f);
               pixmap.drawPixel(i, j);
           }
    }

    PixmapTextureData data = new PixmapTextureData(pixmap, Format.RGBA8888, false, false, true);

    texture = new Texture(data);
    texture.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
}
项目:ud405    文件:IciclesScreen.java   
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    // TODO: Initialize the HUD viewport
    hudViewport = new ScreenViewport();

    // TODO: Initialize the SpriteBatch
    batch = new SpriteBatch();

    // TODO: Initialize the BitmapFont
    font = new BitmapFont();

    // TODO: Give the font a linear TextureFilter
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

    player = new Player(iciclesViewport);
    icicles = new Icicles(iciclesViewport);

    // TODO: Set top score to zero
    topScore = 0;
}
项目:ud405    文件:IciclesScreen.java   
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    hudViewport = new ScreenViewport();
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

    player = new Player(iciclesViewport);
    // TODO: Initialize icicles with the difficulty
    icicles = new Icicles(iciclesViewport);

    topScore = 0;
}
项目:ud405    文件:IciclesScreen.java   
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    hudViewport = new ScreenViewport();
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

    player = new Player(iciclesViewport);
    icicles = new Icicles(iciclesViewport, difficulty);

    Gdx.input.setInputProcessor(this);

    topScore = 0;
}
项目:ud405    文件:IciclesScreen.java   
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    hudViewport = new ScreenViewport();
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

    player = new Player(iciclesViewport);
    icicles = new Icicles(iciclesViewport, difficulty);

    Gdx.input.setInputProcessor(this);

    topScore = 0;
}
项目:ud405    文件:IciclesScreen.java   
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    hudViewport = new ScreenViewport();
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

    player = new Player(iciclesViewport);
    icicles = new Icicles(iciclesViewport, difficulty);

    Gdx.input.setInputProcessor(this);

    topScore = 0;
}
项目:ud405    文件:IciclesScreen.java   
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    hudViewport = new ScreenViewport();
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

    player = new Player(iciclesViewport);
    icicles = new Icicles(iciclesViewport, difficulty);

    Gdx.input.setInputProcessor(this);

    topScore = 0;
}
项目:ud405    文件:IciclesScreen.java   
@Override
public void show() {
    iciclesViewport = new ExtendViewport(Constants.WORLD_SIZE, Constants.WORLD_SIZE);

    renderer = new ShapeRenderer();
    renderer.setAutoShapeType(true);

    hudViewport = new ScreenViewport();
    batch = new SpriteBatch();

    font = new BitmapFont();
    font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear);

    player = new Player(iciclesViewport);
    // TODO: Initialize icicles with the difficulty
    icicles = new Icicles(iciclesViewport, difficulty);

    topScore = 0;
}
项目:Roguelike    文件:AssetManager.java   
public static Texture loadTexture( String path )
{
    if ( loadedTextures.containsKey( path ) ) { return loadedTextures.get( path ); }

    FileHandle file = Gdx.files.internal( path );
    if ( !file.exists() )
    {
        loadedTextures.put( path, null );
        return null;
    }

    Texture region = new Texture( path );
    region.setFilter( TextureFilter.Linear, TextureFilter.Linear );
    loadedTextures.put( path, region );

    return region;
}
项目:3D-Scanner-RBPI    文件:PolygonViewer.java   
@Override
public void create() {      
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    camera = new OrthographicCamera(1, h/w);
    batch = new SpriteBatch();

    texture = new Texture(Gdx.files.internal("data/libgdx.png"));
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    TextureRegion region = new TextureRegion(texture, 0, 0, 512, 275);

    sprite = new Sprite(region);
    sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
    sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
    sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2);
}
项目:swampmachine    文件:OrthogonalTiledMapRendererWithObjects.java   
public OrthogonalTiledMapRendererWithObjects(TiledMap map) {
    super(map);


    this.occlusionFbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, false);
    this.shadowmapFbo = new FrameBuffer(Format.RGBA8888, Gdx.graphics.getWidth() / 2, 1, false);

    this.shadowmapTex = shadowmapFbo.getColorBufferTexture();
    this.shadowmapTex.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    this.shadowmapTex.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);

    //this.orthoCam = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    //this.orthoCam.setToOrtho(Y_DOWN);

    this.lights = new ArrayList<Light>();
    this.mouseLight = new Light(0, 0, Color.WHITE);
}
项目:android-screen-recorder    文件:Renderer.java   
public Renderer () {
    try {
        lights = new Environment();
        lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));

        spriteBatch = new SpriteBatch();
        modelBatch = new ModelBatch();

        backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
        backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:android-screen-recorder    文件:GameOver.java   
public GameOver (Invaders invaders) {
    super(invaders);
    spriteBatch = new SpriteBatch();
    background = new Texture(Gdx.files.internal("data/planet.jpg"));
    background.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new Texture(Gdx.files.internal("data/title.png"));
    logo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false);

    if (invaders.getController() != null) {
        invaders.getController().addListener(new ControllerAdapter() {
            @Override
            public boolean buttonUp(Controller controller,
                    int buttonIndex) {
                controller.removeListener(this);
                isDone = true;
                return false;
            }
        });
    }
}
项目:android-screen-recorder    文件:MainMenu.java   
public MainMenu (Invaders invaders) {
    super(invaders);

    spriteBatch = new SpriteBatch();
    background = new Texture(Gdx.files.internal("data/planet.jpg"));
    background.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new Texture(Gdx.files.internal("data/title.png"));
    logo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false);

    if (invaders.getController() != null) {
        invaders.getController().addListener(new ControllerAdapter() {
            @Override
            public boolean buttonUp(Controller controller, int buttonIndex) {
                controller.removeListener(this);
                isDone = true;
                return false;
            }
        });
    }
}
项目:teavm-libgdx    文件:Renderer.java   
public Renderer () {
    try {
        lights = new Environment();
        lights.add(new DirectionalLight().set(Color.WHITE, new Vector3(-1, -0.5f, 0).nor()));

        spriteBatch = new SpriteBatch();
        modelBatch = new ModelBatch();

        backgroundTexture = new Texture(Gdx.files.internal("data/planet.jpg"), Format.RGB565, true);
        backgroundTexture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);

        font = new BitmapFont(Gdx.files.internal("data/font10.fnt"), Gdx.files.internal("data/font10.png"), false);

        camera = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
项目:teavm-libgdx    文件:GameOver.java   
public GameOver (Invaders invaders) {
    super(invaders);
    spriteBatch = new SpriteBatch();
    background = new Texture(Gdx.files.internal("data/planet.jpg"));
    background.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new Texture(Gdx.files.internal("data/title.png"));
    logo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false);

    if (invaders.getController() != null) {
        invaders.getController().addListener(new ControllerAdapter() {
            @Override
            public boolean buttonUp(Controller controller,
                    int buttonIndex) {
                controller.removeListener(this);
                isDone = true;
                return false;
            }
        });
    }
}
项目:teavm-libgdx    文件:MainMenu.java   
public MainMenu (Invaders invaders) {
    super(invaders);

    spriteBatch = new SpriteBatch();
    background = new Texture(Gdx.files.internal("data/planet.jpg"));
    background.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    logo = new Texture(Gdx.files.internal("data/title.png"));
    logo.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    font = new BitmapFont(Gdx.files.internal("data/font16.fnt"), Gdx.files.internal("data/font16.png"), false);

    if (invaders.getController() != null) {
        invaders.getController().addListener(new ControllerAdapter() {
            @Override
            public boolean buttonUp(Controller controller, int buttonIndex) {
                controller.removeListener(this);
                isDone = true;
                return false;
            }
        });
    }
}
项目:libgdxcn    文件:PixmapPacker.java   
/** Generates a new {@link TextureAtlas} from the {@link Pixmap} instances inserted so far.
 * @param minFilter
 * @param magFilter
 * @return the TextureAtlas */
public synchronized TextureAtlas generateTextureAtlas (TextureFilter minFilter, TextureFilter magFilter, boolean useMipMaps) {
    TextureAtlas atlas = new TextureAtlas();
    for (Page page : pages) {
        if (page.rects.size != 0) {
            Texture texture = new Texture(new PixmapTextureData(page.image, page.image.getFormat(), useMipMaps, false, true)) {
                @Override
                public void dispose () {
                    super.dispose();
                    getTextureData().consumePixmap().dispose();
                }
            };
            texture.setFilter(minFilter, magFilter);

            Keys<String> names = page.rects.keys();
            for (String name : names) {
                Rectangle rect = page.rects.get(name);
                TextureRegion region = new TextureRegion(texture, (int)rect.x, (int)rect.y, (int)rect.width, (int)rect.height);
                atlas.addRegion(name, region);
            }
        }
    }
    return atlas;
}
项目:libgdxcn    文件:PixmapPackerTest.java   
@Override
public void create () {
    batch = new SpriteBatch();

    camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    camera.position.set(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2, 0);
    camera.update();

    Pixmap pixmap1 = new Pixmap(Gdx.files.internal("data/badlogic.jpg"));
    Pixmap pixmap2 = new Pixmap(Gdx.files.internal("data/wheel.png"));
    Pixmap pixmap3 = new Pixmap(Gdx.files.internal("data/egg.png"));

    PixmapPacker packer = new PixmapPacker(1024, 1024, Format.RGBA8888, 2, true);
    packer.pack("badlogic", pixmap1);
    packer.pack("wheel", pixmap1);
    packer.pack("egg", pixmap1);

    pixmap1.dispose();
    pixmap2.dispose();
    pixmap3.dispose();

    atlas = packer.generateTextureAtlas(TextureFilter.Nearest, TextureFilter.Nearest, false);
    Gdx.app.log("PixmaPackerTest", "Number of textures: " + atlas.getTextures().size);
}
项目:libgdxcn    文件:CpuSpriteBatchTest.java   
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);
    }
}
项目:libgdxcn    文件:ProjectiveTextureTest.java   
public void setupScene () {
    plane = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE), new VertexAttribute(
        Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
    plane.setVertices(new float[] {-10, -1, 10, 0, 1, 0, 10, -1, 10, 0, 1, 0, 10, -1, -10, 0, 1, 0, -10, -1, -10, 0, 1, 0});
    plane.setIndices(new short[] {3, 2, 1, 1, 0, 3});

    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), Format.RGB565, true);
    texture.setFilter(TextureFilter.MipMap, TextureFilter.Nearest);

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(0, 5, 10);
    cam.lookAt(0, 0, 0);
    cam.update();
    controller = new PerspectiveCamController(cam);

    projector = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    projector.position.set(2, 3, 2);
    projector.lookAt(0, 0, 0);
    projector.normalizeUp();
    projector.update();
}
项目:libgdxcn    文件:FramebufferToTextureTest.java   
@Override
public void create () {
    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), true);
    texture.setFilter(TextureFilter.MipMap, TextureFilter.Linear);
    ObjLoader objLoader = new ObjLoader();
    mesh = objLoader.loadObj(Gdx.files.internal("data/cube.obj"));
    mesh.materials.get(0).set(new TextureAttribute(TextureAttribute.Diffuse, texture));
    modelInstance = new ModelInstance(mesh);
    modelBatch = new ModelBatch();

    cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
    cam.position.set(3, 3, 3);
    cam.direction.set(-1, -1, -1);
    batch = new SpriteBatch();
    font = new BitmapFont();
}
项目:libgdxcn    文件:MipMapTest.java   
private void createUI () {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    ui = new Stage();

    String[] filters = new String[TextureFilter.values().length];
    int idx = 0;
    for (TextureFilter filter : TextureFilter.values()) {
        filters[idx++] = filter.toString();
    }
    hwMipMap = new CheckBox("Hardware Mips", skin);
    minFilter = new SelectBox(skin);
    minFilter.setItems(filters);
    magFilter = new SelectBox(skin.get(SelectBoxStyle.class));
    magFilter.setItems("Nearest", "Linear");

    Table table = new Table();
    table.setSize(ui.getWidth(), 30);
    table.setY(ui.getHeight() - 30);
    table.add(hwMipMap).spaceRight(5);
    table.add(new Label("Min Filter", skin)).spaceRight(5);
    table.add(minFilter).spaceRight(5);
    table.add(new Label("Mag Filter", skin)).spaceRight(5);
    table.add(magFilter);

    ui.addActor(table);
}
项目:libgdxcn    文件:MipMapTest.java   
@Override
public void render () {
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    Gdx.gl.glEnable(GL20.GL_TEXTURE_2D);

    camera.update();

    currTexture = hwMipMap.isChecked() ? textureHW : textureSW;
    currTexture.bind();
    currTexture.setFilter(TextureFilter.valueOf(minFilter.getSelected()), TextureFilter.valueOf(magFilter.getSelected()));

    shader.begin();
    shader.setUniformMatrix("u_projTrans", camera.combined);
    shader.setUniformi("s_texture", 0);
    mesh.render(shader, GL20.GL_TRIANGLE_FAN);
    shader.end();

    ui.act();
    ui.draw();
}
项目:libgdxcn    文件:ComplexActionTest.java   
@Override
public void create () {
    stage = new Stage();

    Action complexAction = forever(sequence(parallel(rotateBy(180, 2), scaleTo(1.4f, 1.4f, 2), alpha(0.7f, 2)),
        parallel(rotateBy(180, 2), scaleTo(1.0f, 1.0f, 2), alpha(1.0f, 2))));

    texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
    texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

    final Image img1 = new Image(new TextureRegion(texture));
    img1.setSize(100, 100);
    img1.setOrigin(50, 50);
    img1.setPosition(50, 50);

    final Image img2 = new Image(new TextureRegion(texture));
    img2.setSize(50, 50);
    img2.setOrigin(50, 50);
    img2.setPosition(150, 150);

    stage.addActor(img1);
    stage.addActor(img2);

    img1.addAction(complexAction);
    // img2.action(complexAction.copy());
}
项目:FirstGame    文件:MyGame.java   
@Override
public void create() {
    camera = new OrthographicCamera(1280, 720);

    worldBatch = new SpriteBatch();
    worldTexture = new Texture(Gdx.files.internal("sc_map.png"));
    worldTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
    worldSprite = new Sprite(worldTexture);
    worldSprite.setOrigin(0,0);
    worldSprite.setPosition(-worldSprite.getWidth()/2,-worldSprite.getHeight()/2);

    uiBatch = new SpriteBatch();
    uiTexture = new Texture(Gdx.files.internal("link.png"));
    uiSprite = new Sprite(uiTexture);
    uiSprite.setOrigin(0,0);
    uiSprite.setPosition(0,0);

    mMap = new Map(100,100,20);
    mMap.generate();

    Gdx.input.setInputProcessor(new GestureDetector(new InputHandler(camera)));
}
项目:chainball    文件:Assets.java   
public static void loadFonts(){
    FreeTypeFontGenerator font_gen = new FreeTypeFontGenerator(Gdx.files.internal("font.ttf"));
    FreeTypeFontParameter parameter = new FreeTypeFontParameter();
    parameter.size = 100;
    font100 = font_gen.generateFont(parameter);
    font100.getRegion().getTexture().setFilter(TextureFilter.Linear,TextureFilter.Linear);
    font100.setColor(Color.BLACK);  
    font100.setScale(1, -1);

    parameter.size = 75;
    font75 = font_gen.generateFont(parameter);
    font75.getRegion().getTexture().setFilter(TextureFilter.Linear,TextureFilter.Linear);
    font75.setColor(Color.BLACK);   
    font75.setScale(1, -1);

    parameter.size = 250;   
    font250 = font_gen.generateFont(parameter);
    font250.getRegion().getTexture().setFilter(TextureFilter.Linear,TextureFilter.Linear);
    font250.setColor(Color.BLACK);  
    font250.setScale(1, -1);

    font_gen.dispose();
}