v0.6.3: refactored all opengl code out of the core module (except fog)

This commit is contained in:
Evan Debenham
2017-12-27 02:58:45 -05:00
parent 7afd8b8889
commit 6abb58fd81
18 changed files with 105 additions and 85 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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 );
}
}

View File

@@ -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();

View File

@@ -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();
}