aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2022-06-10 14:15:59 +0200
committermakamys <makamys@outlook.com>2022-06-10 19:20:55 +0200
commit1ba50cbfb724560d58f2056f7f0123bfef2f4371 (patch)
tree57570bf1dc262d9375fed96d781ac39e1d1d6742 /src
parent424363d6ec58f44d76c5d9686b69266298965d5e (diff)
downloadNeodymium-1ba50cbfb724560d58f2056f7f0123bfef2f4371.tar.gz
Neodymium-1ba50cbfb724560d58f2056f7f0123bfef2f4371.tar.bz2
Neodymium-1ba50cbfb724560d58f2056f7f0123bfef2f4371.zip
Fix log spam when loading a broken shader
Diffstat (limited to 'src')
-rw-r--r--src/main/java/makamys/neodymium/renderer/NeoRenderer.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
index 1a6ee07..a49a77a 100644
--- a/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
+++ b/src/main/java/makamys/neodymium/renderer/NeoRenderer.java
@@ -323,6 +323,8 @@ public class NeoRenderer {
Matrix4f projMatrix = new Matrix4f();
private void render(double alpha) {
+ if(shaderProgram == 0) return;
+
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
GL11.glDisable(GL11.GL_TEXTURE_2D);
@@ -442,6 +444,8 @@ public class NeoRenderer {
}
public void reloadShader() {
+ boolean errors = false;
+
int vertexShader;
vertexShader = glCreateShader(GL_VERTEX_SHADER);
@@ -450,6 +454,7 @@ public class NeoRenderer {
if(glGetShaderi(vertexShader, GL_COMPILE_STATUS) == 0) {
System.out.println("Error compiling vertex shader: " + glGetShaderInfoLog(vertexShader, 256));
+ errors = true;
}
int fragmentShader;
@@ -460,15 +465,21 @@ public class NeoRenderer {
if(glGetShaderi(fragmentShader, GL_COMPILE_STATUS) == 0) {
System.out.println("Error compiling fragment shader: " + glGetShaderInfoLog(fragmentShader, 256));
+ errors = true;
}
- shaderProgram = glCreateProgram();
- glAttachShader(shaderProgram, vertexShader);
- glAttachShader(shaderProgram, fragmentShader);
- glLinkProgram(shaderProgram);
+ int newShaderProgram = glCreateProgram();
+ glAttachShader(newShaderProgram, vertexShader);
+ glAttachShader(newShaderProgram, fragmentShader);
+ glLinkProgram(newShaderProgram);
+
+ if(glGetProgrami(newShaderProgram, GL_LINK_STATUS) == 0) {
+ System.out.println("Error linking shader: " + glGetShaderInfoLog(newShaderProgram, 256));
+ errors = true;
+ }
- if(glGetProgrami(shaderProgram, GL_LINK_STATUS) == 0) {
- System.out.println("Error linking shader: " + glGetShaderInfoLog(shaderProgram, 256));
+ if(!errors) {
+ shaderProgram = newShaderProgram;
}
glDeleteShader(vertexShader);