background shader now functioning
This commit is contained in:
@@ -5,8 +5,8 @@ import com.badlogic.gdx.Preferences;
|
||||
import com.badlogic.gdx.assets.AssetManager;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
import com.badlogic.gdx.utils.viewport.FitViewport;
|
||||
|
||||
import zero1hd.polyjet.Polyjet;
|
||||
@@ -32,10 +32,10 @@ public class GamePlayArea extends Stage {
|
||||
private ShaderProgram invert;
|
||||
private ShaderProgram bgShader;
|
||||
|
||||
private float timePassed;
|
||||
|
||||
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");
|
||||
@@ -81,6 +81,7 @@ public class GamePlayArea extends Stage {
|
||||
if (bgShader.getLog().length()!=0) {
|
||||
System.out.println(bgShader.getLog());
|
||||
}
|
||||
|
||||
} else {
|
||||
//TODO prepare background rendering without shader
|
||||
}
|
||||
@@ -91,10 +92,13 @@ public class GamePlayArea extends Stage {
|
||||
@Override
|
||||
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().begin();
|
||||
getBatch().draw(background, 0f, 0f, Polyjet.GAME_AREA_WIDTH, Polyjet.GAME_AREA_HEIGHT);
|
||||
getBatch().end();
|
||||
|
||||
@@ -104,10 +108,7 @@ public class GamePlayArea extends Stage {
|
||||
|
||||
@Override
|
||||
public void act(float delta) {
|
||||
if (bgShader != null) {
|
||||
timePassed += delta;
|
||||
bgShader.setUniformf("time", timePassed);
|
||||
}
|
||||
time = TimeUtils.millis()/10f;
|
||||
|
||||
collisionDetector.collisionCheck();
|
||||
ec.deathClean();
|
||||
|
Reference in New Issue
Block a user