Generated opengl function binding added. All opengl core profile function is now available but not in C# flavour.

This commit is contained in:
Youmu Liu
2025-12-30 19:16:05 +08:00
parent b7c32bdf6d
commit 6484307b8a
40 changed files with 14965 additions and 3893 deletions
+40 -10
View File
@@ -49,11 +49,12 @@ namespace GenerateGL.CodeGen
XElement element
)
{
return BuildCType(element, out _, out _);
return BuildCType(element, out _, out _, out _);
}
private static string BuildCType(
XElement element,
out int pointerLevel,
out bool isPointer,
out bool isConst
)
@@ -67,7 +68,8 @@ namespace GenerateGL.CodeGen
_ => string.Empty
});
string raw = string.Concat(parts).Trim();
isPointer = raw.Contains('*');
pointerLevel = raw.Count(ch => ch == '*');
isPointer = pointerLevel > 0;
isConst = raw.Contains("const", StringComparison.OrdinalIgnoreCase);
string cleaned = raw.Replace("const", string.Empty, StringComparison.OrdinalIgnoreCase)
.Replace("*", string.Empty)
@@ -91,18 +93,20 @@ namespace GenerateGL.CodeGen
}
string name = proto.Element("name")?.Value ?? string.Empty;
string returnType = BuildCType(proto);
string returnType = BuildCType(proto, out int retPtrLevel, out _,
out bool retIsConst);
List<GlParam> parameters = new List<GlParam>();
foreach (XElement p in cmd.Elements("param"))
{
string pName = p.Element("name")?.Value ?? string.Empty;
string cType = BuildCType(p, out bool isPtr, out bool isConst);
parameters.Add(new GlParam(pName, cType, isPtr, isConst));
string cType = BuildCType(p, out int pointerLevel, out _, out bool isConst);
parameters.Add(new GlParam(pName, cType, pointerLevel, isConst));
}
if (!string.IsNullOrEmpty(name)) {
dict[name] = new GlCommand(name, returnType, parameters);
dict[name] = new GlCommand(name, returnType, retPtrLevel, retIsConst,
parameters);
}
}
return dict;
@@ -125,10 +129,9 @@ namespace GenerateGL.CodeGen
string? profile = feature.Attribute("profile")?.Value;
// accept core, compatibility, or missing profile
// Only core (or no profile for legacy) to stay aligned with core profile
if (!string.IsNullOrEmpty(profile) &&
!string.Equals(profile, "core", StringComparison.Ordinal) &&
!string.Equals(profile, "compatibility", StringComparison.Ordinal))
!string.Equals(profile, "core", StringComparison.Ordinal))
{
continue;
}
@@ -137,6 +140,13 @@ namespace GenerateGL.CodeGen
List<string> requires = new List<string>();
foreach (XElement req in feature.Elements("require"))
{
string? reqProfile = req.Attribute("profile")?.Value;
if (!string.IsNullOrEmpty(reqProfile) &&
!string.Equals(reqProfile, "core", StringComparison.Ordinal))
{
continue;
}
foreach (XElement cmd in req.Elements("command"))
{
string? name = cmd.Attribute("name")?.Value;
@@ -145,7 +155,27 @@ namespace GenerateGL.CodeGen
}
}
}
list.Add(new GlFeature(version, requires));
List<string> removes = new List<string>();
foreach (XElement rem in feature.Elements("remove"))
{
string? remProfile = rem.Attribute("profile")?.Value;
if (!string.IsNullOrEmpty(remProfile) &&
!string.Equals(remProfile, "core", StringComparison.Ordinal))
{
continue;
}
foreach (XElement cmd in rem.Elements("command"))
{
string? name = cmd.Attribute("name")?.Value;
if (!string.IsNullOrEmpty(name)) {
removes.Add(name);
}
}
}
list.Add(new GlFeature(version, requires, removes));
}
return list;
}