adding generated opengl function binding

This commit is contained in:
Youmu Liu
2025-12-29 18:10:59 +08:00
parent f9288c1b3d
commit b7c32bdf6d
2 changed files with 9 additions and 17 deletions
+6 -15
View File
@@ -37,10 +37,6 @@ namespace GenerateGL.CodeGen
internal sealed class Generator internal sealed class Generator
{ {
private static readonly string[] SkipPrefixes = {
"glBegin", "glEnd", "glVertexP", "glVertex2", "glVertex3", "glVertex4", "glTexCoordP", "glTexCoord1", "glTexCoord2", "glTexCoord3", "glTexCoord4", "glColorP", "glColor3", "glColor4", "glNormalP", "glNormal3", "glMultiTexCoordP", "glMultiTexCoord1", "glMultiTexCoord2", "glMultiTexCoord3", "glMultiTexCoord4", "glSecondaryColor", "glFog", "glLight", "glMaterial", "glEval", "glMap1", "glMap2", "glRasterPos", "glBitmap"
};
private static readonly string[] TargetVersions = { private static readonly string[] TargetVersions = {
"3.3", "4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6" "3.3", "4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6"
}; };
@@ -69,9 +65,7 @@ namespace GenerateGL.CodeGen
List<GlCommand> all = new List<GlCommand>(); List<GlCommand> all = new List<GlCommand>();
foreach (string v in TargetVersions) foreach (string v in TargetVersions)
{ {
IReadOnlyList<GlCommand> cmds = CollectCommandsForVersion(v) IReadOnlyList<GlCommand> cmds = CollectCommandsUpToVersion(v);
.Where(c => !ShouldSkip(c.Name))
.ToList();
all.AddRange(cmds); all.AddRange(cmds);
WriteOpenGLFunctionFile(v, cmds); WriteOpenGLFunctionFile(v, cmds);
WriteGlContextFile(v, cmds); WriteGlContextFile(v, cmds);
@@ -79,11 +73,13 @@ namespace GenerateGL.CodeGen
WriteMergedGlContextFile(all); WriteMergedGlContextFile(all);
} }
private IReadOnlyList<GlCommand> CollectCommandsForVersion( private IReadOnlyList<GlCommand> CollectCommandsUpToVersion(
string version string version
) )
{ {
IEnumerable<GlCommand?> selected = _features.Where(f => string.Equals(f.Version, version, StringComparison.Ordinal)) Version target = Version.Parse(version);
IEnumerable<GlCommand?> selected = _features.Where(f => Version.TryParse(f.Version, out Version? fv) &&
fv <= target)
.SelectMany(f => f.RequiresCommands) .SelectMany(f => f.RequiresCommands)
.Distinct(StringComparer.Ordinal) .Distinct(StringComparer.Ordinal)
.Select(name => _commands.TryGetValue(name, out GlCommand? c) ? .Select(name => _commands.TryGetValue(name, out GlCommand? c) ?
@@ -122,12 +118,7 @@ namespace GenerateGL.CodeGen
string name string name
) )
{ {
foreach (string prefix in SkipPrefixes) // No skipping; include legacy/fixed-function APIs as well.
{
if (name.StartsWith(prefix, StringComparison.Ordinal)) {
return true;
}
}
return false; return false;
} }
+3 -2
View File
@@ -125,9 +125,10 @@ namespace GenerateGL.CodeGen
string? profile = feature.Attribute("profile")?.Value; string? profile = feature.Attribute("profile")?.Value;
// Keep core; also accept missing profile (core by default) // accept core, compatibility, or missing profile
if (!string.IsNullOrEmpty(profile) && if (!string.IsNullOrEmpty(profile) &&
!string.Equals(profile, "core", StringComparison.Ordinal)) !string.Equals(profile, "core", StringComparison.Ordinal) &&
!string.Equals(profile, "compatibility", StringComparison.Ordinal))
{ {
continue; continue;
} }