opengl source gen tool works

This commit is contained in:
Youmu Liu
2026-08-27 15:05:43 +08:00
parent 5db9f39a46
commit 648cac9d9b
42 changed files with 10247 additions and 10189 deletions
@@ -0,0 +1,94 @@
// -----------------------------------------------------------------------------
// file="CSharpIdentifierPolicy"
// Project: StgSharp
// Copyright (c) Nitload.
// SPDX-License-Identifier: MIT
// -----------------------------------------------------------------------------
using System;
using System.Text.RegularExpressions;
namespace StgSharp.GenerateGL.Naming
{
internal static class CSharpIdentifierPolicy
{
private static readonly Regex _attributeWord = new Regex(
@"Attrib(?!ute)",
RegexOptions.Compiled | RegexOptions.CultureInvariant);
private static readonly Regex _attributeParameterWord = new Regex(
@"attrib(?!ute)",
RegexOptions.Compiled | RegexOptions.CultureInvariant);
private static readonly Regex _fragmentWord = new Regex(
@"Frag(?!ment)",
RegexOptions.Compiled | RegexOptions.CultureInvariant);
public static string NormalizeMemberName(
string value
)
{
ArgumentException.ThrowIfNullOrWhiteSpace(value);
string result = value.Replace(
"Framebuffer",
"FrameBuffer",
StringComparison.Ordinal)
.Replace(
"Renderbuffer",
"RenderBuffer",
StringComparison.Ordinal)
.Replace(
"Internalformat",
"InternalFormat",
StringComparison.Ordinal);
result = _attributeWord.Replace(result, "Attribute");
return _fragmentWord.Replace(result, "Fragment");
}
public static string NormalizeParameterName(
string value
)
{
ArgumentException.ThrowIfNullOrWhiteSpace(value);
string result = value.Replace(
"Framebuffer",
"FrameBuffer",
StringComparison.Ordinal)
.Replace(
"framebuffer",
"frameBuffer",
StringComparison.Ordinal)
.Replace(
"Renderbuffer",
"RenderBuffer",
StringComparison.Ordinal)
.Replace(
"renderbuffer",
"renderBuffer",
StringComparison.Ordinal)
.Replace(
"Internalformat",
"InternalFormat",
StringComparison.Ordinal)
.Replace(
"internalformat",
"internalFormat",
StringComparison.Ordinal)
.Replace(
"attribindex",
"attributeIndex",
StringComparison.Ordinal)
.Replace(
"bindingindex",
"bindingIndex",
StringComparison.Ordinal)
.Replace(
"relativeoffset",
"relativeOffset",
StringComparison.Ordinal);
return _attributeParameterWord.Replace(result, "attribute");
}
}
}