Exemple #1
0
def genApi(apiname, profile):
    opt = reg.CGeneratorOptions(
      filename="api_" + apiname + ".px", \
      genFuncPointers=None, \
      profile=profile, \
    # addExtensions='GL_EXT|GL_ARB', \
    # addExtensions='.+', \
      addExtensions='', \
      apiname=apiname, \
      emitversions='.+') #, versions='.+')
    # gen = PXOutputGenerator(diagFile=None, apiname=apiname)
    gen = PXOutputGenerator(diagFile=sys.stdout, apiname=apiname)
    x = reg.Registry()
    x.setGenerator(gen)
    x.loadFile(file="./gl.xml")
    x.apiGen(opt)
# Generate .spec entries for use by legacy 'gen' script
class SpecGenerator(reg.OutputGenerator):
    def __init__(self):
        reg.OutputGenerator.__init__(self, sys.stderr, sys.stderr, None)

    def genCmd(self, cmd, name):
        reg.OutputGenerator.genCmd(self, cmd, name)
        rtype, fname = parseProto(cmd.elem.find('proto'))
        params = [parseParam(p) for p in cmd.elem.findall('param')]

        print('%s %s ( %s )' % (rtype, fname, fmtParams(params)),
              file=self.outFile)


if __name__ == '__main__':
    registry = reg.Registry()
    registry.loadFile('registry/gl.xml')

    registry.setGenerator(TrampolineGen())
    TRAMPOLINE_OPTIONS = [
        reg.GeneratorOptions(apiname='gles1',
                             profile='common',
                             filename='../../libs/GLES_CM/gl_api.in'),
        reg.GeneratorOptions(apiname='gles1',
                             profile='common',
                             emitversions=None,
                             defaultExtensions='gles1',
                             filename='../../libs/GLES_CM/glext_api.in'),
        reg.GeneratorOptions(apiname='gles2',
                             profile='common',
                             filename='../../libs/GLES2/gl2_api.in'),