summaryrefslogtreecommitdiff
path: root/glstate.py
diff options
context:
space:
mode:
authorJosé Fonseca <jose.r.fonseca@gmail.com>2011-04-14 09:31:23 +0100
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-04-14 09:31:23 +0100
commitfa6d049f8bbb8337d2d524692df4b19b79466d05 (patch)
treea9965dd4949581dfea8214672a5606850bf557c5 /glstate.py
parent0a965251f5f17b93d73c82f305d085327cab46e7 (diff)
Share more code.
Diffstat (limited to 'glstate.py')
-rw-r--r--glstate.py61
1 files changed, 24 insertions, 37 deletions
diff --git a/glstate.py b/glstate.py
index 8387120..b54634e 100644
--- a/glstate.py
+++ b/glstate.py
@@ -3326,24 +3326,8 @@ writeDrawBufferImage(JSONWriter &json, GLenum format)
def dump_parameters(self):
print ' json.beginMember("parameters");'
print ' json.beginObject();'
- for function, type, count, name in parameters:
- if function != 'glGet':
- continue
- if type is X:
- continue
-
- print ' // %s' % name
- print ' {'
- type, value = glGet(name)
- print ' if (glGetError() != GL_NO_ERROR) {'
- #print ' std::cerr << "warning: %s(%s) failed\\n";' % (glGet.radical, name)
- print ' } else {'
- print ' json.beginMember("%s");' % name
- JsonWriter().visit(type, value)
- print ' json.endMember();'
- print ' }'
- print ' }'
- print
+
+ self.dump_atoms(glGet)
self.dump_vertex_attribs()
@@ -3352,34 +3336,18 @@ writeDrawBufferImage(JSONWriter &json, GLenum format)
print
def dump_vertex_attribs(self):
- print ' json.beginMember("vertex_attrib");'
+ print ' json.beginMember("GL_VERTEX_ATTRIB");'
print ' json.beginArray();'
print ' GLint max_vertex_attribs = 0;'
print ' __glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &max_vertex_attribs);'
print ' for (GLint index = 0; index < max_vertex_attribs; ++index) {'
print ' json.beginObject();'
- for function, type, count, name in parameters:
- if function != 'glGetVertexAttrib':
- continue
- if type is X:
- contine
- print ' // %s' % name
- print ' {'
- type, value = glGetVertexAttrib('index', name)
- print ' if (glGetError() != GL_NO_ERROR) {'
- #print ' std::cerr << "warning: %s(%s) failed\\n";' % (glGet.radical, name)
- print ' } else {'
- print ' json.beginMember("%s");' % name
- JsonWriter().visit(type, value)
- print ' json.endMember();'
- print ' }'
- print ' }'
- print
+ self.dump_atoms(glGetVertexAttrib, 'index')
print ' json.endObject();'
print ' }'
print
print ' json.endArray();'
- print ' json.endMember(); // vertex_attrib'
+ print ' json.endMember(); // GL_VERTEX_ATTRIB'
print
def dump_current_program(self):
@@ -3442,6 +3410,25 @@ writeDrawBufferImage(JSONWriter &json, GLenum format)
print ' json.endMember(); // framebuffer'
pass
+ def dump_atoms(self, getter, *args):
+ for function, type, count, name in parameters:
+ if function != getter.inflector.radical:
+ continue
+ if type is X:
+ continue
+ print ' // %s' % name
+ print ' {'
+ type, value = getter(*(args + (name,)))
+ print ' if (glGetError() != GL_NO_ERROR) {'
+ #print ' std::cerr << "warning: %s(%s) failed\\n";' % (glGet.radical, name)
+ print ' } else {'
+ print ' json.beginMember("%s");' % name
+ JsonWriter().visit(type, value)
+ print ' json.endMember();'
+ print ' }'
+ print ' }'
+ print
+
def write_line(s):
self.write(' '*self.level + s + '\n')