genericed graphic vector design
This commit is contained in:
@@ -80,6 +80,9 @@ namespace StgSharp.GenerateGL.Generation
|
||||
new GeneratedFile(
|
||||
"OpenglContext.g.cs",
|
||||
GenerateContext(commands, typeMapper)),
|
||||
new GeneratedFile(
|
||||
"glContextShadow.g.cs",
|
||||
GenerateContextShadow(commands)),
|
||||
};
|
||||
for (int index = 0; index < managedGroups.Count; index++)
|
||||
{
|
||||
@@ -329,11 +332,10 @@ namespace StgSharp.GenerateGL.Generation
|
||||
AppendGeneratedHeader(builder, "Desktop OpenGL core function pointer table");
|
||||
builder.Append("namespace StgSharp.Graphics.OpenGL\n");
|
||||
builder.Append("{\n");
|
||||
builder.Append(" [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]\n");
|
||||
builder.Append(" public unsafe partial struct OpenglContext\n");
|
||||
builder.Append(" {\n");
|
||||
foreach (GlCommandDefinition command in commands.OrderBy(
|
||||
value => value.Name,
|
||||
StringComparer.Ordinal))
|
||||
foreach (GlCommandDefinition command in OrderCommands(commands))
|
||||
{
|
||||
builder.Append(" internal delegate* unmanaged<");
|
||||
foreach (GlParameterDefinition parameter in command.Parameters)
|
||||
@@ -353,6 +355,38 @@ namespace StgSharp.GenerateGL.Generation
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static string GenerateContextShadow(
|
||||
IReadOnlyList<GlCommandDefinition> commands
|
||||
)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(64 * 1024);
|
||||
AppendGeneratedHeader(builder, "Native-address shadow of the OpenGL function pointer table");
|
||||
builder.Append("namespace StgSharp.Graphics.OpenGL\n");
|
||||
builder.Append("{\n");
|
||||
builder.Append(" [System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]\n");
|
||||
builder.Append(" internal struct glContextShadow\n");
|
||||
builder.Append(" {\n");
|
||||
foreach (GlCommandDefinition command in OrderCommands(commands))
|
||||
{
|
||||
builder.Append(" internal nint ");
|
||||
builder.Append(command.Name);
|
||||
builder.Append(";\n");
|
||||
}
|
||||
|
||||
builder.Append(" }\n");
|
||||
builder.Append("}\n");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static IEnumerable<GlCommandDefinition> OrderCommands(
|
||||
IReadOnlyList<GlCommandDefinition> commands
|
||||
)
|
||||
{
|
||||
return commands.OrderBy(
|
||||
value => value.Name,
|
||||
StringComparer.Ordinal);
|
||||
}
|
||||
|
||||
private static string GenerateFunctions(
|
||||
IReadOnlyList<ManagedMethodDefinition> methods,
|
||||
string description,
|
||||
|
||||
Reference in New Issue
Block a user