v0.9.4: moved last bits of texture creation into TextureCache

This commit is contained in:
Evan Debenham
2021-07-29 13:18:41 -04:00
parent 630fbbb43f
commit d03c80cb97
3 changed files with 38 additions and 21 deletions
@@ -24,9 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.tiles;
import com.badlogic.gdx.graphics.Pixmap;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
import com.watabou.gltextures.SmartTexture;
import com.watabou.gltextures.TextureCache;
import com.watabou.glwrap.Texture;
import com.watabou.noosa.Image;
import com.watabou.noosa.NoosaScript;
import com.watabou.noosa.NoosaScriptNoLighting;
@@ -88,39 +86,34 @@ public class FogOfWar extends Image {
*/
public FogOfWar( int mapWidth, int mapHeight ) {
super();
this.mapWidth = mapWidth;
this.mapHeight = mapHeight;
mapLength = mapHeight * mapWidth;
pWidth = mapWidth * PIX_PER_TILE;
pHeight = mapHeight * PIX_PER_TILE;
width2 = 1;
while (width2 < pWidth) {
width2 <<= 1;
}
height2 = 1;
while (height2 < pHeight) {
height2 <<= 1;
}
float size = DungeonTilemap.SIZE / PIX_PER_TILE;
width = width2 * size;
height = height2 * size;
//TODO might be nice to compartmentalize the pixmap access and modification into texture/texturecache
Pixmap px = new Pixmap(width2, height2, Pixmap.Format.RGBA8888);
px.setBlending(Pixmap.Blending.None);
px.setColor(0x000000FF);
px.fill();
SmartTexture tx = new SmartTexture(px, Texture.LINEAR, Texture.CLAMP, false);
TextureCache.add(FogOfWar.class, tx);
texture( tx );
String key = "FogOfWar" + width2 + "x" + height2;
texture(TextureCache.create(key, width2, height2));
texture.bind();
scale.set( size, size );
toUpdate = new ArrayList<>();
@@ -188,6 +181,7 @@ public class FogOfWar extends Image {
}
Pixmap fog = texture.bitmap;
fog.setBlending(Pixmap.Blending.None);
int cell;