diff --git a/SPD-classes/src/main/java/com/watabou/glwrap/Blending.java b/SPD-classes/src/main/java/com/watabou/glwrap/Blending.java new file mode 100644 index 000000000..5d046db2e --- /dev/null +++ b/SPD-classes/src/main/java/com/watabou/glwrap/Blending.java @@ -0,0 +1,53 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2017 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.watabou.glwrap; + +import android.opengl.GLES20; + +import javax.microedition.khronos.opengles.GL10; + +public class Blending { + + public static void useDefault(){ + enable(); + setNormalMode(); + } + + public static void enable(){ + GLES20.glEnable( GL10.GL_BLEND ); + } + + public static void disable(){ + GLES20.glDisable( GL10.GL_BLEND ); + } + + //in this mode colors overwrite eachother, based on alpha value + public static void setNormalMode(){ + GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + } + + //in this mode colors add to eachother, eventually reaching pure white + public static void setLightMode(){ + GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + } + +} diff --git a/SPD-classes/src/main/java/com/watabou/noosa/Game.java b/SPD-classes/src/main/java/com/watabou/noosa/Game.java index 56381bfd1..99b46b2c9 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/Game.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/Game.java @@ -39,6 +39,7 @@ import android.view.View; import com.watabou.glscripts.Script; import com.watabou.gltextures.TextureCache; +import com.watabou.glwrap.Blending; import com.watabou.glwrap.ScreenConfigChooser; import com.watabou.glwrap.Vertexbuffer; import com.watabou.input.Keys; @@ -307,8 +308,7 @@ public class Game extends Activity implements GLSurfaceView.Renderer, View.OnTou @Override public void onSurfaceCreated( GL10 gl, EGLConfig config ) { - GLES20.glEnable( GL10.GL_BLEND ); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.useDefault(); //refreshes texture and vertex data stored on the gpu TextureCache.reload(); diff --git a/SPD-classes/src/main/java/com/watabou/noosa/particles/Emitter.java b/SPD-classes/src/main/java/com/watabou/noosa/particles/Emitter.java index 39157fcc4..26f265e93 100644 --- a/SPD-classes/src/main/java/com/watabou/noosa/particles/Emitter.java +++ b/SPD-classes/src/main/java/com/watabou/noosa/particles/Emitter.java @@ -21,10 +21,7 @@ package com.watabou.noosa.particles; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLES20; - +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.Visual; @@ -150,9 +147,9 @@ public class Emitter extends Group { @Override public void draw() { if (lightMode) { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } else { super.draw(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Beam.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Beam.java index b71102984..82c2e941f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Beam.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Beam.java @@ -21,15 +21,13 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; -import android.opengl.GLES20; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; import com.watabou.utils.PointF; -import javax.microedition.khronos.opengles.GL10; - public class Beam extends Image { private static final double A = 180 / Math.PI; @@ -89,8 +87,8 @@ public class Beam extends Image { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Degradation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Degradation.java index 1f85d9b3b..011201be9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Degradation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Degradation.java @@ -21,14 +21,12 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; -import android.opengl.GLES20; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Group; import com.watabou.noosa.particles.PixelParticle; import com.watabou.utils.PointF; import com.watabou.utils.Random; -import javax.microedition.khronos.opengles.GL10; - public class Degradation extends Group { private static int[] WEAPON = { @@ -114,9 +112,9 @@ public class Degradation extends Group { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } public static class Speck extends PixelParticle { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Fireball.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Fireball.java index 678778ae7..594d39cff 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Fireball.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Fireball.java @@ -22,8 +22,9 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; import android.graphics.RectF; -import android.opengl.GLES20; + import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.watabou.glwrap.Blending; import com.watabou.glwrap.Texture; import com.watabou.noosa.Game; import com.watabou.noosa.Group; @@ -34,8 +35,6 @@ import com.watabou.noosa.ui.Component; import com.watabou.utils.ColorMath; import com.watabou.utils.Random; -import javax.microedition.khronos.opengles.GL10; - public class Fireball extends Component { private static final RectF BLIGHT = new RectF( 0, 0, 0.25f, 1 ); @@ -118,9 +117,9 @@ public class Fireball extends Component { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } public static class Flame extends Image { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java index 0684beedc..16649e459 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Flare.java @@ -22,10 +22,10 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; import android.annotation.SuppressLint; -import android.opengl.GLES20; import com.watabou.gltextures.SmartTexture; import com.watabou.gltextures.TextureCache; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.NoosaScript; @@ -37,8 +37,6 @@ import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.ShortBuffer; -import javax.microedition.khronos.opengles.GL10; - public class Flare extends Visual { private float duration = 0; @@ -158,9 +156,9 @@ public class Flare extends Visual { super.draw(); if (lightMode) { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); drawRays(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } else { drawRays(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Identification.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Identification.java index 90d776f6c..38d5ccf83 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Identification.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Identification.java @@ -21,14 +21,12 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; -import android.opengl.GLES20; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Group; import com.watabou.noosa.particles.PixelParticle; import com.watabou.utils.PointF; import com.watabou.utils.Random; -import javax.microedition.khronos.opengles.GL10; - public class Identification extends Group { private static int[] DOTS = { @@ -62,9 +60,9 @@ public class Identification extends Group { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } public static class Speck extends PixelParticle { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Lightning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Lightning.java index e82fa0611..df080bda9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Lightning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/Lightning.java @@ -21,9 +21,9 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; -import android.opengl.GLES20; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.Image; @@ -32,7 +32,6 @@ import com.watabou.utils.Callback; import com.watabou.utils.PointF; import com.watabou.utils.Random; -import javax.microedition.khronos.opengles.GL10; import java.util.Arrays; import java.util.List; @@ -102,9 +101,9 @@ public class Lightning extends Group { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } //A lightning object is meant to be loaded up with arcs. diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/TorchHalo.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/TorchHalo.java index 9f6ad3379..e49f6a7f4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/TorchHalo.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/effects/TorchHalo.java @@ -21,12 +21,10 @@ package com.shatteredpixel.shatteredpixeldungeon.effects; -import android.opengl.GLES20; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; -import javax.microedition.khronos.opengles.GL10; - public class TorchHalo extends Halo { private CharSprite target; @@ -63,9 +61,9 @@ public class TorchHalo extends Halo { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } public void putOut() { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsLevel.java index e6aec2f0c..5d713d438 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsLevel.java @@ -21,8 +21,6 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; -import android.opengl.GLES20; - import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Torch; @@ -47,14 +45,13 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WarpingTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WeakeningTrap; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.particles.PixelParticle; import com.watabou.utils.PointF; import com.watabou.utils.Random; -import javax.microedition.khronos.opengles.GL10; - public class HallsLevel extends RegularLevel { { @@ -199,9 +196,9 @@ public class HallsLevel extends RegularLevel { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java index bbf547ef0..f82c4313f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/GameScene.java @@ -21,8 +21,6 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; -import android.opengl.GLES20; - import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; @@ -94,6 +92,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory; import com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; import com.watabou.noosa.Group; @@ -185,9 +184,9 @@ public class GameScene extends PixelScene { @Override public void draw() { //water has no alpha component, this improves performance - GLES20.glBlendFunc( GLES20.GL_ONE, GLES20.GL_ZERO ); + Blending.disable(); super.draw(); - GLES20.glBlendFunc( GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA ); + Blending.enable(); } }; terrain.add( water ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java index 0e773b4b2..605f3b217 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/PixelScene.java @@ -21,12 +21,12 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; -import android.opengl.GLES20; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; +import com.watabou.glwrap.Blending; import com.watabou.glwrap.Texture; import com.watabou.input.Touchscreen; import com.watabou.noosa.BitmapText; @@ -41,8 +41,6 @@ import com.watabou.noosa.Visual; import com.watabou.noosa.ui.Component; import com.watabou.utils.BitmapCache; -import javax.microedition.khronos.opengles.GL10; - public class PixelScene extends Scene { // Minimum virtual display size for portrait orientation @@ -240,7 +238,7 @@ public class PixelScene extends Scene { if (noFade) { noFade = false; } else { - fadeIn( 0xFF000000, false ); + fadeIn( 0xFF000000, true ); } } @@ -291,9 +289,9 @@ public class PixelScene extends Scene { @Override public void draw() { if (light) { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } else { super.draw(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java index 7023a11ff..91b90c773 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/TitleScene.java @@ -21,8 +21,6 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; -import android.opengl.GLES20; - import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites; @@ -33,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton; import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; import com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton; import com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton; +import com.watabou.glwrap.Blending; import com.watabou.noosa.BitmapText; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; @@ -42,8 +41,6 @@ import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.noosa.ui.Button; -import javax.microedition.khronos.opengles.GL10; - public class TitleScene extends PixelScene { @Override @@ -88,9 +85,9 @@ public class TitleScene extends PixelScene { } @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); + Blending.setNormalMode(); } }; signs.x = title.x + (title.width() - signs.width())/2f; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java index a1a5499a9..02fb064a5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/WelcomeScene.java @@ -21,8 +21,6 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; -import android.opengl.GLES20; - import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Rankings; @@ -32,13 +30,12 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextMultiline; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Camera; import com.watabou.noosa.Game; import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; -import javax.microedition.khronos.opengles.GL10; - public class WelcomeScene extends PixelScene { private static int LATEST_UPDATE = ShatteredPixelDungeon.v0_6_2; @@ -83,9 +80,9 @@ public class WelcomeScene extends PixelScene { } @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); + Blending.setNormalMode(); } }; signs.x = title.x + (title.width() - signs.width())/2f; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GhostSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GhostSprite.java index f3ebe629f..d251715f5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GhostSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/GhostSprite.java @@ -21,15 +21,12 @@ package com.shatteredpixel.shatteredpixeldungeon.sprites; -import android.opengl.GLES20; - import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShaftParticle; +import com.watabou.glwrap.Blending; import com.watabou.noosa.TextureFilm; -import javax.microedition.khronos.opengles.GL10; - public class GhostSprite extends MobSprite { public GhostSprite() { @@ -56,9 +53,9 @@ public class GhostSprite extends MobSprite { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } @Override diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/WandmakerSprite.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/WandmakerSprite.java index 0801ddbb3..8a6362f89 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/WandmakerSprite.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/sprites/WandmakerSprite.java @@ -21,18 +21,16 @@ package com.shatteredpixel.shatteredpixeldungeon.sprites; -import android.opengl.GLES20; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.effects.Halo; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; import com.watabou.noosa.TextureFilm; import com.watabou.noosa.audio.Sample; import com.watabou.utils.PointF; -import javax.microedition.khronos.opengles.GL10; - public class WandmakerSprite extends MobSprite { private Shield shield; @@ -115,9 +113,9 @@ public class WandmakerSprite extends MobSprite { @Override public void draw() { - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE ); + Blending.setLightMode(); super.draw(); - GLES20.glBlendFunc( GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA ); + Blending.setNormalMode(); } public void putOut() { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Archs.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Archs.java index e94d21f1a..8953425ea 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Archs.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Archs.java @@ -21,9 +21,8 @@ package com.shatteredpixel.shatteredpixeldungeon.ui; -import android.opengl.GLES20; - import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.watabou.glwrap.Blending; import com.watabou.noosa.Game; import com.watabou.noosa.NoosaScript; import com.watabou.noosa.NoosaScriptNoLighting; @@ -53,9 +52,9 @@ public class Archs extends Component { @Override public void draw() { //arch bg has no alpha component, this improves performance - GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ZERO); + Blending.disable(); super.draw(); - GLES20.glBlendFunc( GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA ); + Blending.enable(); } }; arcsBg.autoAdjust = true;