X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=scripts%2Fextgen.py;h=0ea8b8ee3c7ac8355b3d85ba1db6a62890bb976e;hb=fe89237f22d6557d8ad7afdbd694c0fb35253c99;hp=c5bc219a392e35db1d823a61df8dc3b927e28c88;hpb=d072b64415abd87ca07e34eea00546774823f322;p=libs%2Fgl.git diff --git a/scripts/extgen.py b/scripts/extgen.py index c5bc219a..0ea8b8ee 100755 --- a/scripts/extgen.py +++ b/scripts/extgen.py @@ -31,6 +31,7 @@ if sys.argv[i].startswith("gl"): i += 1 target_ext = sys.argv[i] +backport_ext = None out_base = None if target_ext.endswith(".glext"): fn = target_ext @@ -46,6 +47,8 @@ if target_ext.endswith(".glext"): core_version = parts[2] elif parts[0]=="secondary": secondary.append(parts[1]) + elif parts[0]=="backport": + backport_ext = parts[1] if i+11: + print "Warning: multiple backport extension candidates: %s"%(" ".join(e.name for e in backport_ext_candidates)) + + for e in backport_ext_candidates: + if e.base_name==target_ext.base_name: + backport_ext = e + + if not backport_ext and len(backport_ext_candidates)==1: + print "Warning: potential backport extension has mismatched name: %s"%backport_ext_candidates[0].name for f in funcs: f.typedef = "FPtr_%s"%f.name @@ -386,7 +411,7 @@ namespace GL { if funcs or enums: if funcs: for f in funcs: - out.write("typedef %s (*%s)(%s);\n"%(f.return_type, f.typedef, ", ".join(f.params))) + out.write("typedef %s (APIENTRY *%s)(%s);\n"%(f.return_type, f.typedef, ", ".join(f.params))) out.write("\n") if enums: @@ -430,10 +455,16 @@ out.write("#include \"%s.h\"\n"%target_ext.name.lower()) if funcs: out.write(""" #ifdef __APPLE__ -#define GET_PROC_ADDRESS(x) ::x +#define GET_PROC_ADDRESS(x) &::x #else #define GET_PROC_ADDRESS(x) get_proc_address(#x) #endif + +#ifdef WIN32 +#define GET_PROC_ADDRESS_1_1(x) &::x +#else +#define GET_PROC_ADDRESS_1_1(x) GET_PROC_ADDRESS(x) +#endif """) out.write(""" namespace Msp { @@ -452,7 +483,10 @@ if core_version: out.write(")\n\t{\n") for f in funcs: if target_api in f.supported_apis: - out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS(%s));\n"%(f.name, f.typedef, f.name)) + gpa_suffix = "" + if f.version is not None and f.version<=[1, 1]: + gpa_suffix = "_1_1" + out.write("\t\t%s = reinterpret_cast<%s>(GET_PROC_ADDRESS%s(%s));\n"%(f.name, f.typedef, gpa_suffix, f.name)) out.write("\t\treturn Extension::CORE;\n") out.write("\t}\n") if source_ext and source_ext!=backport_ext: