MJ93
MJ93

Reputation: 5286

How can I optimize my BitmapTextureAtlas in AndEngine?

Currently I have 4 different images that I am loading into 4 seperate BitmapTextureAtlas's. What I would like to do is load 4 different images inside 1 BitMapTextureAtlas to try and optimize speed. I have edited the code to what I believe should have made it work however when this (Live wallpaper) loads the texture, the screen is just white. Here is what I have done so far:

onLoadResources()

Original BitmapTextureAtlas:

this.StarsAtlas = new BitmapTextureAtlas(1024, 1024, TextureOptions.DEFAULT);   
this.SpaceAtlas = new BitmapTextureAtlas(1024, 1024, TextureOptions.DEFAULT);
this.CloudsAtlas = new BitmapTextureAtlas(1024, 1024, TextureOptions.DEFAULT);
this.SunetAtlas = new BitmapTextureAtlas(1024, 512, TextureOptions.DEFAULT);

I have condensed to:

this.skyAtlas = new BitmapTextureAtlas(1024, 4096, TextureOptions.BILINEAR);

Original Texture Regions:

    this.LayerStars = BitmapTextureAtlasTextureRegionFactory 
            .createFromAsset(this.StarsAtlas, this,
                    "stars.jpg", 0, 0); //568x518
    this.LayerSpace = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(this.SpaceAtlas, this,
                    "space.jpg", 0, 0); //500x800
    this.LayerClouds = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(this.CloudsAtlas, this,
                    "clouds.jpg", 0, 0); //600x478
    this.LayerSunset = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(this.SunsetAtlas, this,
                    "sunset.jpg", 0, 0); //997x460

I have changed to:

    this.LayerStars = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(this.skyAtlas, this,
                    "stars.jpg", 0, 0); //568x518
    this.LayerSpace = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(this.skyAtlas, this,
                    "space.jpg", 0, 518); //500x800
    this.LayerClouds = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(this.skyAtlas, this,
                    "clouds.jpg", 0, 1318); //600x478
    this.LayerSunset = BitmapTextureAtlasTextureRegionFactory
            .createFromAsset(this.skyAtlas, this,
                    "sunset.jpg", 0, 1796); //997x460

Loading the texture:

this.mEngine.getTextureManager().loadTexture(
            this.skyAtlas);

...Later on in the onLoadScene() This stays the same:

    Sprite starSprite = new Sprite(0, 0, 568, 518, this.LayerStars);
    Sprite cloudSprite = new Sprite(0, 0, 600, 478, this.LayerClouds);
    Sprite spaceSprite = new Sprite(0, 0, 500, 800, this.LayerSpace);
    Sprite sunsetSprite = new Sprite(0, 0, 997, 460, this.LayerSunset);

Any idea what could be causing the white screen? On a side note, it loaded fine when I had 4 different images in 4 separate BitmapTextureAtlas's.

Upvotes: 3

Views: 3854

Answers (1)

JohnEye
JohnEye

Reputation: 6895

The only thing I can see is that you are using different texture options. Have you tried TextureOptions.DEFAULT instead of TextureOptions.BILINEAR? Theturtleboy on the AndEngine forums had some problems with JPEGs using the same settings. See http://www.andengine.org/forums/development/jpeg-support-t26.html

Upvotes: 2

Related Questions