mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 23:47:09 +01:00
Print final shader source on compilation error
This commit is contained in:
parent
6b67e3d55d
commit
78611b0038
3 changed files with 16 additions and 14 deletions
|
@ -94,7 +94,6 @@ sourceSets.main.resources { srcDir 'src/generated/resources' }
|
|||
|
||||
repositories {
|
||||
maven {
|
||||
//location of the maven for mixed mappings and registrate
|
||||
name "tterrag maven"
|
||||
url "https://maven.tterrag.com/"
|
||||
}
|
||||
|
|
|
@ -15,25 +15,22 @@ public class GlShader extends GlObject {
|
|||
public final ShaderType type;
|
||||
|
||||
public GlShader(Shader shader) {
|
||||
this(shader.type, shader.name, shader.getSource());
|
||||
}
|
||||
this.type = shader.type;
|
||||
this.name = shader.name;
|
||||
int handle = GL20.glCreateShader(shader.type.glEnum);
|
||||
|
||||
public GlShader(ShaderType type, ResourceLocation name, String source) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
int handle = GL20.glCreateShader(type.glEnum);
|
||||
|
||||
GlCompat.safeShaderSource(handle, source);
|
||||
GlCompat.safeShaderSource(handle, shader.getSource());
|
||||
GL20.glCompileShader(handle);
|
||||
|
||||
String log = GL20.glGetShaderInfoLog(handle);
|
||||
|
||||
if (!log.isEmpty()) {
|
||||
Backend.log.error("Shader compilation log for " + name + ": " + log);
|
||||
Backend.log.error("Shader compilation log for " + shader.name + ": " + log);
|
||||
Backend.log.error(shader.printSource());
|
||||
}
|
||||
|
||||
if (GL20.glGetShaderi(handle, GL20.GL_COMPILE_STATUS) != GL20.GL_TRUE) {
|
||||
throw new RuntimeException("Could not compile " + name + ". See log for details.");
|
||||
throw new RuntimeException("Could not compile " + shader.name + ". See log for details.");
|
||||
}
|
||||
|
||||
setHandle(handle);
|
||||
|
|
|
@ -135,12 +135,18 @@ public class Shader {
|
|||
});
|
||||
}
|
||||
|
||||
public void printSource() {
|
||||
Backend.log.debug("Source for shader '" + name + "':");
|
||||
public String printSource() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
builder.append("Source for shader '").append(name).append("':\n");
|
||||
int i = 1;
|
||||
for (String s : source.split("\n")) {
|
||||
Backend.log.debug(String.format("%1$4s: ", i++) + s);
|
||||
builder.append(String.format("%1$4s: ", i++))
|
||||
.append(s)
|
||||
.append('\n');
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static Stream<String> lines(String s) {
|
||||
|
|
Loading…
Reference in a new issue