From b08f3479c17aae8753b3ffa3fc21bcf5307b7e80 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 13 Aug 2021 22:46:11 -0400 Subject: [PATCH] v0.9.4: fixed rare texture errors in fog of war --- .../main/java/com/watabou/gltextures/TextureCache.java | 10 +++------- .../shatteredpixeldungeon/tiles/FogOfWar.java | 5 +++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java index 6e6b78444..56ad9419c 100644 --- a/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java +++ b/SPD-classes/src/main/java/com/watabou/gltextures/TextureCache.java @@ -79,7 +79,8 @@ public class TextureCache { } - //texture defaults to black and given size, but no assurance is made about this is another already exists + //texture is created at given size, but size is not enforced if it already exists + //texture contents are also not enforced, make sure you know the texture's state! public synchronized static SmartTexture create( Object key, int width, int height ) { if (all.containsKey( key )) { @@ -88,12 +89,7 @@ public class TextureCache { } else { - Pixmap pixmap = new Pixmap( width, height, Pixmap.Format.RGBA8888 ); - - pixmap.setColor(0x000000FF); - pixmap.fill(); - - SmartTexture tx = new SmartTexture( pixmap ); + SmartTexture tx = new SmartTexture(new Pixmap( width, height, Pixmap.Format.RGBA8888 )); tx.filter( Texture.LINEAR, Texture.LINEAR ); tx.wrap( Texture.CLAMP, Texture.CLAMP ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java index 53245c496..32e63b283 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/tiles/FogOfWar.java @@ -112,6 +112,11 @@ public class FogOfWar extends Image { String key = "FogOfWar" + width2 + "x" + height2; texture(TextureCache.create(key, width2, height2)); + + //sets contents to all black + texture.bitmap.setColor( 0x000000FF ); + texture.bitmap.fill(); + texture.bind(); scale.set( size, size );