diff options
author | Harvey Harrison <[email protected]> | 2013-10-22 00:12:44 -0700 |
---|---|---|
committer | Harvey Harrison <[email protected]> | 2013-10-22 00:14:33 -0700 |
commit | c1bb679c5d6d36e91c146d5e075e093bc83a07f1 (patch) | |
tree | 87793aa7506b96429734351de895a5353d4854bc | |
parent | 27f6fce2e629e421793eaeb0e09cb6c10d9c0aa1 (diff) |
jogl: change code generation for Debug pipelines to avoid building large strings
- split the check for a GL error from the output of the error string
- only build the caller String when there is an error to report
- wrap String building in an if() block rather than using an early return as we
don't know the return type in the postDownstreamCallHook
Signed-off-by: Harvey Harrison <[email protected]>
-rw-r--r-- | src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 082ecfe5e..d7196f77e 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -925,23 +925,16 @@ public class BuildComposablePipeline { @Override protected void postMethodEmissionHook(PrintWriter output) { super.postMethodEmissionHook(output); - output.println(" private void checkGLGetError(String caller)"); - output.println(" {"); + output.println(" private int checkGLError() {"); if (hasImmediateMode) { - output.println(" if (insideBeginEndPair) {"); - output.println(" return;"); - output.println(" }"); + output.println(" if (insideBeginEndPair) return GL_NO_ERROR;"); output.println(); } - output.println(" // Debug code to make sure the pipeline is working; leave commented out unless testing this class"); - output.println(" //System.err.println(\"Checking for GL errors " - + "after call to \" + caller);"); - output.println(); - output.println(" int err = " - + getDownstreamObjectName() - + ".glGetError();"); - output.println(" if (err == GL_NO_ERROR) { return; }"); - output.println(); + output.format(" return %s.glGetError();%n", getDownstreamObjectName()); + output.println(" }"); + + output.println(" private void writeGLError(int err, String caller)"); + output.println(" {"); output.println(" StringBuilder buf = new StringBuilder(Thread.currentThread()+"); output.println(" \" glGetError() returned the following error codes after a call to \" + caller + \": \");"); output.println(); @@ -1027,6 +1020,8 @@ public class BuildComposablePipeline { output.println(" insideBeginEndPair = false;"); } + output.println(" int err = checkGLError();"); + output.println(" if (err != GL_NO_ERROR) {"); output.println(" String txt = new String(\"" + m.getName() + "(\" +"); Class<?>[] params = m.getParameterTypes(); for (int i = 0; params != null && i < params.length; i++) { @@ -1044,7 +1039,8 @@ public class BuildComposablePipeline { } output.println(" \")\");"); // calls to glGetError() are only allowed outside of glBegin/glEnd pairs - output.println(" checkGLGetError( txt );"); + output.println(" writeGLError( err, txt );"); + output.println(" }"); } } } // end class DebugPipeline |