summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-05-08 05:32:52 +0200
committerSven Gothel <[email protected]>2011-05-08 05:32:52 +0200
commit169f4a60fee62e7742c33596c1494901d9ba8df9 (patch)
tree94a04c61b2ae18cf5099c4a789cb6f6f1e55e53a
parent2c5bdd6b2810d9fd19f358d92cf63e03cefeec2d (diff)
JOGL/ShaderCode: Dump proper GLSL source w/ line numbers if GLSLCode debug prop is set
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
index c6a52a33e..ad17dd288 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/ShaderCode.java
@@ -67,7 +67,7 @@ public class ShaderCode {
if(DEBUG_CODE) {
System.out.println("Created: "+toString());
- dumpShaderSource(System.out);
+ // dumpShaderSource(System.out); // already done in readShaderSource
}
}
@@ -282,14 +282,18 @@ public class ShaderCode {
}
}
- public static void readShaderSource(Class context, URL url, StringBuffer result) {
+ private static int readShaderSource(Class context, URL url, StringBuffer result, int lineno) {
try {
if(DEBUG_CODE) {
- System.err.println("ShaderCode.readShaderSource<0>: "+url);
+ System.err.printf("%3d: // %s\n", lineno, url);
}
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line = null;
while ((line = reader.readLine()) != null) {
+ lineno++;
+ if(DEBUG_CODE) {
+ System.err.printf("%3d: %s\n", lineno, line);
+ }
if (line.startsWith("#include ")) {
String includeFile = line.substring(9).trim();
URL nextURL = null;
@@ -307,10 +311,7 @@ public class ShaderCode {
// Fail
throw new FileNotFoundException("Can't find include file " + includeFile);
}
- if(DEBUG_CODE) {
- System.err.println("ShaderCode.readShaderSource<I>: "+url+" + "+includeFile+" := "+nextURL);
- }
- readShaderSource(context, nextURL, result);
+ lineno = readShaderSource(context, nextURL, result, lineno);
} else {
result.append(line + "\n");
}
@@ -318,6 +319,19 @@ public class ShaderCode {
} catch (IOException e) {
throw new RuntimeException(e);
}
+ return lineno;
+ }
+
+ public static void readShaderSource(Class context, URL url, StringBuffer result) {
+ if(DEBUG_CODE) {
+ System.err.println();
+ System.err.println("// -----------------------------------------------------------");
+ }
+ readShaderSource(context, url, result, 0);
+ if(DEBUG_CODE) {
+ System.err.println("// -----------------------------------------------------------");
+ System.err.println();
+ }
}
public static String readShaderSource(Class context, String path) {