retored previous shader functions

This commit is contained in:
Harrison Deng 2017-07-17 01:25:53 -05:00
parent f37c2693ae
commit 17b65ed5d6

View File

@ -32,9 +32,12 @@ public class GamePlayArea extends Stage {
private int score;
private ShaderProgram invert;
private ShaderProgram bgShader;
private Texture background;
private float time;
public GamePlayArea(AssetManager assetManager, Preferences prefs) {
super(new FitViewport(Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT));
Gdx.app.debug("Game Area", "new area created");
@ -48,6 +51,7 @@ public class GamePlayArea extends Stage {
}
public void setAudioMap(GamePlayMap audioMap) {
time = 0;
this.audioMap = audioMap;
}
@ -71,6 +75,23 @@ public class GamePlayArea extends Stage {
}
if (prefs.getBoolean("bg shader")) {
Gdx.app.debug("Shader", "using background shader");
bgShader = new ShaderProgram(Gdx.files.internal("shaders/star_vert.glsl").readString(), Gdx.files.internal("shaders/star_frag.glsl").readString());
if (!bgShader.isCompiled()) {
System.err.println(bgShader.getLog());
System.exit(0);
}
if (bgShader.getLog().length()!=0) {
System.out.println(bgShader.getLog());
}
} else {
//TODO prepare background rendering without shader
}
ShaderProgram.pedantic = false;
}
@ -78,8 +99,18 @@ public class GamePlayArea extends Stage {
public void draw() {
//TODO batch draw background
getBatch().begin();
if (bgShader != null) {
getBatch().setShader(bgShader);
bgShader.setUniformf("resolution", background.getWidth(), background.getHeight());
bgShader.setUniformf("time", time);
}
getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT);
getBatch().end();
getBatch().setShader(null);
super.draw();
}
@ -88,6 +119,7 @@ public class GamePlayArea extends Stage {
MapWindowData mwd;
if (audioMap != null && audioMap.getPlayableClip().isPlaying()) {
audioMap.getMusicData().readIndexUpdate();
time = audioMap.getPlayableClip().getPosition();
if ((mwd = audioMap.nextWindowData()) != null) {
EntitySpawnInfo[] currentSpawnInfo = mwd.getArray();
if (currentSpawnInfo != null) {