("glGetVertexAttrib", E, 1, "GL_VERTEX_ATTRIB_ARRAY_TYPE"), # 0x8625
("glGetVertexAttrib", D, 4, "GL_CURRENT_VERTEX_ATTRIB"), # 0x8626
("glGetProgramARB", I, 1, "GL_PROGRAM_LENGTH_ARB"), # 0x8627
- ("glGetProgramARB", S, 1, "GL_PROGRAM_STRING_ARB"), # 0x8628
+ ("", S, 1, "GL_PROGRAM_STRING_ARB"), # 0x8628
("glGet", X, 1, "GL_MODELVIEW_PROJECTION_NV"), # 0x8629
("glGet", X, 1, "GL_IDENTITY_NV"), # 0x862A
("glGet", X, 1, "GL_INVERSE_NV"), # 0x862B
("glGet", X, 1, "GL_MAP2_VERTEX_ATTRIB4_4_NV"), # 0x8674
("glGet", X, 1, "GL_MAP2_VERTEX_ATTRIB5_4_NV"), # 0x8675
("glGet", X, 1, "GL_MAP2_VERTEX_ATTRIB6_4_NV"), # 0x8676
- ("glGet", I, 1, "GL_PROGRAM_BINDING_ARB"), # 0x8677
+ ("glGetProgramARB", I, 1, "GL_PROGRAM_BINDING_ARB"), # 0x8677
("glGet", X, 1, "GL_MAP2_VERTEX_ATTRIB8_4_NV"), # 0x8678
("glGet", X, 1, "GL_MAP2_VERTEX_ATTRIB9_4_NV"), # 0x8679
("glGet", X, 1, "GL_MAP2_VERTEX_ATTRIB10_4_NV"), # 0x867A
It will declare any temporary variable
'''
- def __init__(self, radical, suffixes):
- self.inflector = GetInflector(radical, suffixes)
+ def __init__(self, radical, inflections, suffix=''):
+ self.inflector = GetInflector(radical, inflections)
+ self.suffix = suffix
def __call__(self, *args):
pname = args[-1]
inflection = self.inflector.inflect(type)
if inflection.endswith('v'):
print ' %s %s = 0;' % (elem_type, temp_name)
- print ' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name)
+ print ' %s(%s, &%s);' % (inflection + self.suffix, ', '.join(args), temp_name)
else:
- print ' %s %s = %s(%s);' % (elem_type, temp_name, inflection, ', '.join(args))
+ print ' %s %s = %s(%s);' % (elem_type, temp_name, inflection + self.suffix, ', '.join(args))
return temp_name
def visit_string(self, string, args):
temp_name = self.temp_name(args)
inflection = self.inflector.inflect(string)
assert not inflection.endswith('v')
- print ' %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection, ', '.join(args))
+ print ' %s %s = (%s)%s(%s);' % (string, temp_name, string, inflection + self.suffix, ', '.join(args))
return temp_name
def visit_alias(self, alias, args):
assert inflection.endswith('v')
print ' %s %s[%s];' % (elem_type, temp_name, array.length)
print ' memset(%s, 0, %s * sizeof *%s);' % (temp_name, array.length, temp_name)
- print ' %s(%s, %s);' % (inflection, ', '.join(args), temp_name)
+ print ' %s(%s, %s);' % (inflection + self.suffix, ', '.join(args), temp_name)
return temp_name
def visit_opaque(self, pointer, args):
inflection = self.inflector.inflect(pointer)
assert inflection.endswith('v')
print ' GLvoid *%s;' % temp_name
- print ' %s(%s, &%s);' % (inflection, ', '.join(args), temp_name)
+ print ' %s(%s, &%s);' % (inflection + self.suffix, ', '.join(args), temp_name)
return temp_name
glGetTexParameter = StateGetter('glGetTexParameter', {I: 'iv', F: 'fv'})
glGetTexEnv = StateGetter('glGetTexEnv', {I: 'iv', F: 'fv'})
glGetTexLevelParameter = StateGetter('glGetTexLevelParameter', {I: 'iv', F: 'fv'})
+glGetProgramARB = StateGetter('glGetProgram', {I: 'iv', F: 'fv', S: 'Stringv'}, 'ARB')
class JsonWriter(Visitor):
self.dump_light_params()
self.dump_vertex_attribs()
self.dump_texenv_params()
+ self.dump_program_params()
self.dump_texture_parameters()
print ' json.endObject();'
print ' }'
print
+ program_targets = [
+ 'GL_FRAGMENT_PROGRAM_ARB',
+ 'GL_VERTEX_PROGRAM_ARB',
+ ]
+
+ def dump_program_params(self):
+ for target in self.program_targets:
+ print ' json.beginMember("%s");' % target
+ print ' json.beginObject();'
+ self.dump_atoms(glGetProgramARB, target)
+ print ' json.endObject();'
+
def dump_texture_parameters(self):
print ' {'
print ' GLint active_texture = GL_TEXTURE0;'
print ' json.beginMember("shaders");'
print ' json.beginObject();'
print ' writeCurrentProgram(json);'
- print ' writeArbProgram(json, GL_FRAGMENT_PROGRAM_ARB);'
- print ' writeArbProgram(json, GL_VERTEX_PROGRAM_ARB);'
+ for target in self.program_targets:
+ print ' writeArbProgram(json, %s);' % target
print ' json.endObject();'
print ' json.endMember(); //shaders'
print
def dump_atoms(self, getter, *args):
for function, type, count, name in parameters:
+ inflection = getter.inflector.radical + getter.suffix
if function is None:
continue
- if getter.inflector.radical not in function.split(','):
+ if inflection not in function.split(','):
continue
if type is X:
continue
print ' {'
type, value = getter(*(args + (name,)))
print ' if (glGetError() != GL_NO_ERROR) {'
- #print ' std::cerr << "warning: %s(%s) failed\\n";' % (glGet.radical, name)
+ print ' std::cerr << "warning: %s(%s) failed\\n";' % (inflection, name)
print ' } else {'
print ' json.beginMember("%s");' % name
JsonWriter().visit(type, value)