background now renders! yay.
This commit is contained in:
parent
8fd727e7d6
commit
5ae598db36
@ -6,6 +6,7 @@ import com.badlogic.gdx.ScreenAdapter;
|
||||
import com.badlogic.gdx.graphics.GL20;
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.graphics.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
@ -59,7 +60,10 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
||||
private TextureRegion fboRegion;
|
||||
private int fboSize;
|
||||
private int blurlvl;
|
||||
private Batch batch;
|
||||
|
||||
private Texture background;
|
||||
|
||||
private Batch screenBatch;
|
||||
private ScreenViewport screenViewport;
|
||||
|
||||
public MainMenuScreen(RhythmBullet core) {
|
||||
@ -88,7 +92,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
||||
stage.getViewport().apply();
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.draw();
|
||||
draw();
|
||||
normalBuffer.end();
|
||||
|
||||
// BEGINNING NORMAL SCREEN RENDER
|
||||
@ -99,11 +103,11 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
batch.setShader(brightFilterShader);
|
||||
batch.setProjectionMatrix(screenViewport.getCamera().combined);
|
||||
batch.begin(); //BATCH STARTS HERE
|
||||
batch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
|
||||
batch.flush();
|
||||
screenBatch.setShader(brightFilterShader);
|
||||
screenBatch.setProjectionMatrix(screenViewport.getCamera().combined);
|
||||
screenBatch.begin(); //BATCH STARTS HERE
|
||||
screenBatch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.flush();
|
||||
lightFilterBuffer.end();
|
||||
//
|
||||
for (int i = 0; i < blurlvl; i++) {
|
||||
@ -114,32 +118,32 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
||||
} else {
|
||||
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
||||
}
|
||||
batch.setShader(gaussianBlurShader);
|
||||
screenBatch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 1);
|
||||
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
batch.flush();
|
||||
screenBatch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.flush();
|
||||
hBlur.end();
|
||||
|
||||
// //Vertical gaussian blur
|
||||
vBlur.begin();
|
||||
fboRegion.setTexture(hBlur.getColorBufferTexture());
|
||||
batch.setShader(gaussianBlurShader);
|
||||
screenBatch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 0);
|
||||
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
batch.flush();
|
||||
screenBatch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
screenBatch.flush();
|
||||
vBlur.end();
|
||||
}
|
||||
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
batch.setShader(combineShader);
|
||||
screenBatch.setShader(combineShader);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
batch.draw(fboRegion, 0f, 0f, fboSize, fboSize);
|
||||
batch.setShader(null);
|
||||
batch.end(); //STAGE BATCH ENDS HERE
|
||||
screenBatch.draw(fboRegion, 0f, 0f, fboSize, fboSize);
|
||||
screenBatch.setShader(null);
|
||||
screenBatch.end(); //STAGE BATCH ENDS HERE
|
||||
|
||||
} else {
|
||||
stage.draw();
|
||||
draw();
|
||||
}
|
||||
|
||||
if (stage.getCamera().position.x != cameraPosition.x || stage.getCamera().position.y != cameraPosition.y) {
|
||||
@ -149,6 +153,16 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
||||
|
||||
super.render(delta);
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
if (background != null) {
|
||||
screenBatch.begin();
|
||||
screenBatch.draw(background, 0, 0);
|
||||
screenBatch.end();
|
||||
}
|
||||
stage.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preAssetLoad() {
|
||||
stage.clear();
|
||||
@ -160,10 +174,14 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
||||
|
||||
dismantleShaders();
|
||||
setBlurlvl(0);
|
||||
|
||||
background = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postAssetLoad() {
|
||||
background = core.getAssetManager().get("backgrounds/mainBG.png", Texture.class);
|
||||
|
||||
if (core.getPrefs().getBoolean("glow shader", true)) {
|
||||
setupShaders();
|
||||
|
||||
@ -276,7 +294,7 @@ public class MainMenuScreen extends ScreenAdapter implements AdvancedResizeScree
|
||||
|
||||
public void setupShaders() {
|
||||
Gdx.app.debug("Shader", "Loading glow shaders.");
|
||||
batch = new SpriteBatch();
|
||||
screenBatch = new SpriteBatch();
|
||||
screenViewport = new ScreenViewport();
|
||||
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
Loading…
x
Reference in New Issue
Block a user