From 2143a066d7ebb52ea48e25da4f9de70b65c0ab79 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Jos=C3=A9=20Fonseca?= <jfonseca@vmware.com>
Date: Fri, 7 Jun 2013 08:55:03 +0100
Subject: [PATCH] glstate: Use helper function for flushing GL errors.

---
 retrace/glstate_params.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/retrace/glstate_params.py b/retrace/glstate_params.py
index 9e4fab0..54e0c67 100644
--- a/retrace/glstate_params.py
+++ b/retrace/glstate_params.py
@@ -280,6 +280,12 @@ class StateDumper:
         print 'namespace glstate {'
         print
 
+        print 'static void'
+        print 'flushErrors(void) {'
+        print '    while (glGetError() != GL_NO_ERROR) {}'
+        print '}'
+        print
+
         print 'void'
         print 'dumpBoolean(JSONWriter &json, GLboolean value)'
         print '{'
@@ -540,11 +546,11 @@ class StateDumper:
 
         print '        // %s' % name
         print '        {'
-        print '            while (glGetError() != GL_NO_ERROR) {}'
+        print '            flushErrors();'
         type, value = getter(*args)
         print '            if (glGetError() != GL_NO_ERROR) {'
         #print '                std::cerr << "warning: %s(%s) failed\\n";' % (inflection, name)
-        print '                while (glGetError() != GL_NO_ERROR) {}'
+        print '                flushErrors();'
         print '            } else {'
         print '                json.beginMember("%s");' % name
         JsonWriter().visit(type, value)
-- 
2.45.2