浏览代码

display shader line numbers in case of error

ncannasse 8 年之前
父节点
当前提交
efa36d9a29
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      h3d/impl/GlDriver.hx

+ 4 - 1
h3d/impl/GlDriver.hx

@@ -149,7 +149,10 @@ class GlDriver extends Driver {
 			var lid = Std.parseInt(log.substr(9));
 			var line = lid == null ? null : code.split("\n")[lid - 1];
 			if( line == null ) line = "" else line = "(" + StringTools.trim(line) + ")";
-			throw "An error occurred compiling the shaders: " + log + line+"\n\n"+code;
+			var codeLines = code.split("\n");
+			for( i in 0...codeLines.length )
+				codeLines[i] = (i+1) + "\t" + codeLines[i];
+			throw "An error occurred compiling the shaders: " + log + line+"\n\n"+codeLines.join("\n");
 		}
 		return new CompiledShader(s, shader.vertex, shader);
 	}