From 1af44e9e5a3b522dd083f7e1486146376b01fdff Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Thu, 3 Sep 2009 11:05:06 +0800 Subject: glapi: Add OpenGL ES compatibility mode to scripts. When the mode is on, the scripts would generate headers that are suitable for OpenGL ES. There are two differences. One is that they will generate function prototypes for OpenGL ES specific functions. The other is that, when a function has multiple names, SET/GET/CALL macros would be generated for each of names. Signed-off-by: Chia-I Wu --- src/mesa/glapi/gl_offsets.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/mesa/glapi/gl_offsets.py') diff --git a/src/mesa/glapi/gl_offsets.py b/src/mesa/glapi/gl_offsets.py index b8b509d09f..54867b3463 100644 --- a/src/mesa/glapi/gl_offsets.py +++ b/src/mesa/glapi/gl_offsets.py @@ -30,9 +30,10 @@ import license import sys, getopt class PrintGlOffsets(gl_XML.gl_print_base): - def __init__(self): + def __init__(self, es=False): gl_XML.gl_print_base.__init__(self) + self.es = es self.name = "gl_offsets.py (from Mesa)" self.header_tag = '_GLAPI_OFFSETS_H_' self.license = license.bsd_license_template % ( \ @@ -46,6 +47,7 @@ class PrintGlOffsets(gl_XML.gl_print_base): functions = [] abi_functions = [] + alias_functions = [] count = 0 for f in api.functionIterateByOffset(): if not f.is_abi(): @@ -54,6 +56,10 @@ class PrintGlOffsets(gl_XML.gl_print_base): else: abi_functions.append( f ) + if self.es: + # remember functions with aliases + if len(f.entry_points) > 1: + alias_functions.append(f) for f in abi_functions: print '#define _gloffset_%s %d' % (f.name, f.offset) @@ -78,26 +84,37 @@ class PrintGlOffsets(gl_XML.gl_print_base): print '' print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */' + if alias_functions: + print '' + print '/* define aliases for compatibility */' + for f in alias_functions: + for name in f.entry_points: + if name != f.name: + print '#define _gloffset_%s _gloffset_%s' % (name, f.name) return def show_usage(): - print "Usage: %s [-f input_file_name]" % sys.argv[0] + print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0] + print " -c Enable compatibility with OpenGL ES." sys.exit(1) if __name__ == '__main__': file_name = "gl_API.xml" try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:") + (args, trail) = getopt.getopt(sys.argv[1:], "f:c") except Exception,e: show_usage() + es = False for (arg,val) in args: if arg == "-f": file_name = val + elif arg == "-c": + es = True api = gl_XML.parse_GL_API( file_name ) - printer = PrintGlOffsets() + printer = PrintGlOffsets(es) printer.Print( api ) -- cgit v1.2.3