From c1bb679c5d6d36e91c146d5e075e093bc83a07f1 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 22 Oct 2013 00:12:44 -0700 Subject: 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 --- .../gluegen/opengl/BuildComposablePipeline.java | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'src/jogl/classes/com/jogamp') 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 -- cgit v1.2.3