functioning main menu with scissor issue
This commit is contained in:
parent
9da3670d04
commit
f548c4828f
@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
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.g2d.Batch;
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
|
||||
@ -129,6 +130,7 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
batch = new SpriteBatch();
|
||||
screenViewport = new ScreenViewport();
|
||||
screenViewport.update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
((OrthographicCamera) screenViewport.getCamera()).setToOrtho(false, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
|
||||
|
||||
Gdx.app.debug("Shader", "using glow shader");
|
||||
brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh"));
|
||||
@ -197,58 +199,55 @@ public class MainMenu extends ScreenAdapter implements TransitionAdapter {
|
||||
//Begin drawing a normal version of screen
|
||||
stage.getViewport().apply();
|
||||
normalBuffer.begin();
|
||||
Gdx.gl.glClearColor(0.1f, 0.1f, 0f, 1f);
|
||||
// Gdx.gl.glClearColor(0.22f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClearColor(0.22f, 0f, 0f, 1f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
stage.draw();
|
||||
normalBuffer.end();
|
||||
|
||||
//BEGINNING NORMAL SCREEN RENDER
|
||||
screenViewport.apply();
|
||||
//Begin light filtering
|
||||
// lightFilterBuffer.begin();
|
||||
// Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
|
||||
// Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
// fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
// batch.setShader(brightFilterShader);
|
||||
|
||||
// Begin light filtering
|
||||
lightFilterBuffer.begin();
|
||||
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.setProjectionMatrix(stage.getCamera().combined);
|
||||
// batch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
|
||||
// batch.flush();
|
||||
// lightFilterBuffer.end();
|
||||
batch.draw(fboRegion, 0, 0, stage.getWidth(), stage.getHeight());
|
||||
batch.flush();
|
||||
lightFilterBuffer.end();
|
||||
//
|
||||
// for (int i = 0; i < blurlvl; i++) {
|
||||
// //Horizontal gaussian blur
|
||||
// hBlur.begin();
|
||||
// if (i > 0) {
|
||||
// fboRegion.setTexture(vBlur.getColorBufferTexture());
|
||||
// } else {
|
||||
// fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
||||
// }
|
||||
// batch.setShader(gaussianBlurShader);
|
||||
// gaussianBlurShader.setUniformi("horizontal", 1);
|
||||
// batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
// batch.flush();
|
||||
// hBlur.end();
|
||||
//
|
||||
for (int i = 0; i < blurlvl; i++) {
|
||||
// Horizontal gaussian blur
|
||||
hBlur.begin();
|
||||
if (i > 0) {
|
||||
fboRegion.setTexture(vBlur.getColorBufferTexture());
|
||||
} else {
|
||||
fboRegion.setTexture(lightFilterBuffer.getColorBufferTexture());
|
||||
}
|
||||
batch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 1);
|
||||
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
batch.flush();
|
||||
hBlur.end();
|
||||
|
||||
// //Vertical gaussian blur
|
||||
// vBlur.begin();
|
||||
// fboRegion.setTexture(hBlur.getColorBufferTexture());
|
||||
// batch.setShader(gaussianBlurShader);
|
||||
// gaussianBlurShader.setUniformi("horizontal", 0);
|
||||
// batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
// batch.flush();
|
||||
// vBlur.end();
|
||||
// }
|
||||
vBlur.begin();
|
||||
fboRegion.setTexture(hBlur.getColorBufferTexture());
|
||||
batch.setShader(gaussianBlurShader);
|
||||
gaussianBlurShader.setUniformi("horizontal", 0);
|
||||
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
batch.flush();
|
||||
vBlur.end();
|
||||
}
|
||||
|
||||
Gdx.gl.glClearColor(0f, 0f, 0f, 0f);
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
|
||||
// batch.setShader(combineShader);
|
||||
batch.setShader(combineShader);
|
||||
fboRegion.setTexture(normalBuffer.getColorBufferTexture());
|
||||
batch.draw(fboRegion, 0f, 0f, stage.getWidth(), stage.getHeight());
|
||||
// System.out.println(stage.getWidth() + "x" + stage.getHeight());
|
||||
// System.out.println(screenViewport.getScreenWidth() + "x" + screenViewport.getScreenHeight());
|
||||
// System.err.println(screenViewport.getWorldWidth() + "x" + screenViewport.getWorldHeight());
|
||||
batch.setShader(null);
|
||||
batch.end(); //STAGE BATCH ENDS HERE
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user