adding generated opengl function binding
This commit is contained in:
@@ -37,10 +37,6 @@ namespace GenerateGL.CodeGen
|
||||
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 = {
|
||||
"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>();
|
||||
foreach (string v in TargetVersions)
|
||||
{
|
||||
IReadOnlyList<GlCommand> cmds = CollectCommandsForVersion(v)
|
||||
.Where(c => !ShouldSkip(c.Name))
|
||||
.ToList();
|
||||
IReadOnlyList<GlCommand> cmds = CollectCommandsUpToVersion(v);
|
||||
all.AddRange(cmds);
|
||||
WriteOpenGLFunctionFile(v, cmds);
|
||||
WriteGlContextFile(v, cmds);
|
||||
@@ -79,11 +73,13 @@ namespace GenerateGL.CodeGen
|
||||
WriteMergedGlContextFile(all);
|
||||
}
|
||||
|
||||
private IReadOnlyList<GlCommand> CollectCommandsForVersion(
|
||||
private IReadOnlyList<GlCommand> CollectCommandsUpToVersion(
|
||||
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)
|
||||
.Distinct(StringComparer.Ordinal)
|
||||
.Select(name => _commands.TryGetValue(name, out GlCommand? c) ?
|
||||
@@ -122,12 +118,7 @@ namespace GenerateGL.CodeGen
|
||||
string name
|
||||
)
|
||||
{
|
||||
foreach (string prefix in SkipPrefixes)
|
||||
{
|
||||
if (name.StartsWith(prefix, StringComparison.Ordinal)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// No skipping; include legacy/fixed-function APIs as well.
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,9 +125,10 @@ namespace GenerateGL.CodeGen
|
||||
|
||||
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) &&
|
||||
!string.Equals(profile, "core", StringComparison.Ordinal))
|
||||
!string.Equals(profile, "core", StringComparison.Ordinal) &&
|
||||
!string.Equals(profile, "compatibility", StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user