failsafe for problematic shaders

This commit is contained in:
Harrison Deng 2018-01-30 11:48:41 -06:00
parent ee113fb90d
commit 5e3188ccc8

View File

@ -355,7 +355,8 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen {
return optionsPage; return optionsPage;
} }
public void attemptLoadShaders() { public int attemptLoadShaders() {
Gdx.app.debug("MainMenu", "Attempting to load shaders."); Gdx.app.debug("MainMenu", "Attempting to load shaders.");
if (core.getPrefs().getBoolean("glow shader", true) && !shaderLoaded) { if (core.getPrefs().getBoolean("glow shader", true) && !shaderLoaded) {
if (core.getPrefs().getBoolean("enhanced glow", false)) { if (core.getPrefs().getBoolean("enhanced glow", false)) {
@ -372,30 +373,32 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen {
brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh")); brightFilterShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/bright_filter.fsh"));
if (!brightFilterShader.isCompiled()) { if (!brightFilterShader.isCompiled()) {
Gdx.app.error("Shader failed to compile", brightFilterShader.getLog()); Gdx.app.error("Shader failed to compile", brightFilterShader.getLog());
setBlurlvl(0); if (brightFilterShader.getLog().length() != 0) {
} Gdx.app.error("Shader", brightFilterShader.getLog());
if (brightFilterShader.getLog().length() != 0) { }
Gdx.app.error("Shader", brightFilterShader.getLog()); setBlurlvl(0);
return 1;
} }
gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh")); gaussianBlurShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/gaussian_blur.fsh"));
if (!gaussianBlurShader.isCompiled()) { if (!gaussianBlurShader.isCompiled()) {
Gdx.app.error("Shader failed to compile", gaussianBlurShader.getLog()); Gdx.app.error("Shader failed to compile", gaussianBlurShader.getLog());
setBlurlvl(0); if (gaussianBlurShader.getLog().length() != 0) {
} Gdx.app.error("Shader", gaussianBlurShader.getLog());
if (gaussianBlurShader.getLog().length() != 0) { }
Gdx.app.error("Shader", gaussianBlurShader.getLog()); setBlurlvl(0);
return 1;
} }
combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh")); combineShader = new ShaderProgram(Gdx.files.internal("shaders/basic.vsh"), Gdx.files.internal("shaders/combine.fsh"));
if (!combineShader.isCompiled()) { if (!combineShader.isCompiled()) {
Gdx.app.error("Shader failed to compile", combineShader.getLog()); Gdx.app.error("Shader failed to compile", combineShader.getLog());
setBlurlvl(0); if (combineShader.getLog().length() != 0) {
Gdx.app.error("Shader", combineShader.getLog());
}
setBlurlvl(0);
return 1;
} }
if (combineShader.getLog().length() != 0) {
Gdx.app.error("Shader", combineShader.getLog());
}
if (Gdx.graphics.getWidth() < 1024) { if (Gdx.graphics.getWidth() < 1024) {
fboSize = 1024; fboSize = 1024;
@ -423,6 +426,7 @@ public class MainMenu extends ScreenAdapter implements AdvancedResizeScreen {
ShaderProgram.pedantic = false; ShaderProgram.pedantic = false;
shaderLoaded = true; shaderLoaded = true;
} }
return 0;
} }
} }