make new opengl source generator
This commit is contained in:
@@ -29,7 +29,8 @@
|
||||
<!-- 这样 F5 调试时 P/Invoke 能找到 native -->
|
||||
<!-- ════════════════════════════════════════════════════════ -->
|
||||
<Target Name="CopyNativeToProjectOutput"
|
||||
AfterTargets="Build">
|
||||
AfterTargets="Build"
|
||||
Condition="'$(DisableNativeCopy)'!='true'">
|
||||
|
||||
<!-- native 库文件 -->
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36705.20
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GenerateGL", "test\StgSharp.GenerateGL\GenerateGL.csproj", "{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StgSharp.Common", "src\StgSharp.Common\StgSharp.Common.csproj", "{5D646C0E-CCF8-B5B4-7DE8-1C37542E7B4D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Debug|x64.Build.0 = Debug|x64
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Release|x64.ActiveCfg = Release|x64
|
||||
{9FD27EE6-E94D-4E64-A13B-5A349DEA215A}.Release|x64.Build.0 = Release|x64
|
||||
{5D646C0E-CCF8-B5B4-7DE8-1C37542E7B4D}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{5D646C0E-CCF8-B5B4-7DE8-1C37542E7B4D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5D646C0E-CCF8-B5B4-7DE8-1C37542E7B4D}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{5D646C0E-CCF8-B5B4-7DE8-1C37542E7B4D}.Release|x64.ActiveCfg = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {AC71C01F-9867-4E43-85AB-4A8A7896B1BC}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,36 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="Image.Native"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Internal;
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
internal static unsafe partial class GraphicFramework
|
||||
{
|
||||
|
||||
[LibraryImport(
|
||||
Native.LibName,
|
||||
EntryPoint = "loadImageData",
|
||||
StringMarshalling = StringMarshalling.Utf8)]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
||||
internal static partial void InternalLoadImage(
|
||||
string fileName,
|
||||
ImageInfo* output,
|
||||
ImageLoader loader
|
||||
);
|
||||
|
||||
[LibraryImport(Native.LibName, EntryPoint = "unloadImageData")]
|
||||
[UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])]
|
||||
internal static partial void InternalUnloadImage(
|
||||
ImageInfo* output
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="Image"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public class Image : IImageProvider
|
||||
{
|
||||
|
||||
private byte[] _data;
|
||||
private ImageInfo _rawInfo;
|
||||
private int _pixelUpdateCount = 0;
|
||||
|
||||
internal unsafe Image()
|
||||
{
|
||||
_rawInfo = new ImageInfo();
|
||||
}
|
||||
|
||||
internal Image(
|
||||
ImageInfo information
|
||||
)
|
||||
{
|
||||
_rawInfo = information;
|
||||
_data = [];
|
||||
|
||||
// int length = _rawInfo.width * _rawInfo.height * _rawInfo.channel;
|
||||
}
|
||||
|
||||
public (int width, int height) Size => (_rawInfo.Width, _rawInfo.Height);
|
||||
|
||||
public byte[] PixelBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((_data.Length == 0) || (_data == null))
|
||||
{
|
||||
GetBytes();
|
||||
return _data!;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
}
|
||||
|
||||
public ImageChannel Channel => _rawInfo.Channel;
|
||||
|
||||
/// <summary>
|
||||
/// Hash code of time pixels updated last time.
|
||||
/// </summary>
|
||||
public int PixelUpdateCount
|
||||
{
|
||||
get => _pixelUpdateCount;
|
||||
internal set => _pixelUpdateCount = value;
|
||||
}
|
||||
|
||||
public int ChannelCount => _rawInfo.ChannelCount;
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => _rawInfo.Height;
|
||||
internal set => _rawInfo.Height = value;
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => _rawInfo.Width;
|
||||
internal set => _rawInfo.Width = value;
|
||||
}
|
||||
|
||||
public int PixelSize => ImageInfo.GetPixelSize(_rawInfo.pixelLayout, _rawInfo.Channel);
|
||||
|
||||
public PixelChannelLayout PixelLayout
|
||||
{
|
||||
get => _rawInfo.pixelLayout;
|
||||
private set => _rawInfo.pixelLayout = value;
|
||||
}
|
||||
|
||||
internal ref byte[] Data => ref _data;
|
||||
|
||||
public void FromBytes(
|
||||
byte[] stream
|
||||
) { }
|
||||
|
||||
public static unsafe Image FromFile(
|
||||
string route,
|
||||
ImageLoader loader
|
||||
)
|
||||
{
|
||||
Image ret = new Image();
|
||||
fixed (ImageInfo* iptr = &ret._rawInfo) {
|
||||
GraphicFramework.InternalLoadImage(route, iptr, loader);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Image FromMemory(
|
||||
(int width, int height) size,
|
||||
ImageChannel channel,
|
||||
byte[] stream
|
||||
)
|
||||
{
|
||||
ImageInfo _info = new ImageInfo
|
||||
{
|
||||
Height = size.height,
|
||||
Width = size.width,
|
||||
Channel = channel,
|
||||
StreamPtr = IntPtr.Zero
|
||||
};
|
||||
Image ret = new Image(_info);
|
||||
ret.PixelLayout = PixelChannelLayout.Byte;
|
||||
ret._data = stream;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Image FromMemory(
|
||||
(int width, int height) size,
|
||||
ImageChannel channel,
|
||||
PixelChannelLayout layout,
|
||||
byte[] stream
|
||||
)
|
||||
{
|
||||
ImageInfo _info = new ImageInfo
|
||||
{
|
||||
Height = size.height,
|
||||
Width = size.width,
|
||||
Channel = channel,
|
||||
StreamPtr = IntPtr.Zero
|
||||
};
|
||||
Image ret = new Image(_info);
|
||||
ret.PixelLayout = layout;
|
||||
ret._data = stream;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public unsafe byte[] GetBytes()
|
||||
{
|
||||
if (_data.Length == 0)
|
||||
{
|
||||
int size = Width * Height * ImageInfo.GetPixelSize(PixelLayout, Channel);
|
||||
_data = new Span<byte>((byte*)_rawInfo.StreamPtr, size).ToArray();
|
||||
fixed (ImageInfo* pptr = &_rawInfo) {
|
||||
GraphicFramework.InternalUnloadImage(pptr);
|
||||
}
|
||||
_rawInfo.StreamPtr = IntPtr.Zero;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
|
||||
public Image ProvideImage()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
internal static Image FromMemory(
|
||||
ImageInfo info,
|
||||
byte[] data,
|
||||
int operationCount
|
||||
)
|
||||
{
|
||||
return new Image
|
||||
{
|
||||
_rawInfo = info,
|
||||
_data = data,
|
||||
_pixelUpdateCount = operationCount
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -111,4 +111,4 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
# StgSharp.Graphics retired sources
|
||||
|
||||
This directory contains source snapshots retired during the Graphics/OpenGL
|
||||
reorganization on 2026-08-26. Files use the `.cs.old` suffix so that SDK-style
|
||||
project globbing does not compile them.
|
||||
|
||||
## Retired without an active replacement
|
||||
|
||||
- `framework.cs.old`: unused GL/debug delegate declarations.
|
||||
- `Vulkan.*.cs.old`: unreferenced Vulkan placeholders.
|
||||
- `OpenGL.glRenderStream.ThreadSecurity.cs.old`: unused thread/context fields.
|
||||
- `OpenGL.Generated.GlCommandHistory.g.cs.old`: generator report data that does
|
||||
not belong in the runtime assembly.
|
||||
|
||||
## Split before retirement
|
||||
|
||||
- `gl.cs.old`: image P/Invokes were temporarily split out and later retired;
|
||||
legacy OpenGL native helpers were replaced with direct calls through the
|
||||
OpenGL function table.
|
||||
- `glfw.dtruct.cs.old`: reduced to the four opaque GLFW types currently used by
|
||||
the wrapper in `glfw.struct.cs`.
|
||||
- `OpenGL.glType.cs.old`: only `glSync` remains active in `OpenGL/glSync.cs`.
|
||||
- `ShaderEdit.ShaderGenerator.cs.old`: only the temporary
|
||||
`InternalShaderType` compatibility enum remains active.
|
||||
- `GraphicInitializer.cs.old`: merged into the correctly named `GraphicModule`
|
||||
in `glfw.cs`.
|
||||
- `OpenGL.glApiManager.cs.old` and `OpenGL.glApiManager.Const.cs.old`: the active
|
||||
compatibility loader retains only core-version loading; the unused extension
|
||||
classification table and 619 write-only flags were retired.
|
||||
|
||||
## Retired during the image simplification
|
||||
|
||||
- `Image.cs.old`: the former image/decoder/OpenGL-format aggregate.
|
||||
- `ImageInfo.cs.old` and `Image.Native.cs.old`: the mismatched native decoder
|
||||
state and its P/Invoke bridge.
|
||||
- `Pixels.cs.old`: the unused and incorrectly sized legacy pixel abstraction.
|
||||
- `CPUanimation.ImageHelper.cs.old`: incomplete resizing and movement logic;
|
||||
image transformations now belong to a caller-selected codec or image library.
|
||||
- `CPUanimation.IImageProvider.cs.old`: the redundant image-returns-itself
|
||||
provider contract.
|
||||
- `TexturePipeline.cs.old`: an unused pipeline payload tied to the retired
|
||||
non-generic image type.
|
||||
- `OpenGL.Buffer.AutoTexture.cs.old`: the unused texture cache depended on image
|
||||
mutation counters and also contained incorrect slot/recycling bookkeeping.
|
||||
|
||||
## Retired during the data-only OpenGL resource migration
|
||||
|
||||
- `Define.BufferObjectBase.cs.old` and
|
||||
`OpenGL.Buffer.GLBufferObjectBase.cs.old`: the former resource base classes
|
||||
injected `glRender`/`OpenGLFunction` and attempted context-bound disposal from
|
||||
resource objects and finalizers.
|
||||
- `OpenGL.glRenderObjectGenrator.cs.old`: the former factories implicitly
|
||||
created resources through a render-stream instance.
|
||||
- `OpenGL.ShaderEdit.IglConvertable.cs.old`, `ShaderEdit.ShaderStruct.cs.old`,
|
||||
and `ShaderEdit.InternalShaderType.cs.old`: the obsolete shader conversion
|
||||
layer submitted uniforms through the global `CurrentGL` context.
|
||||
|
||||
Active OpenGL resource and shader types are passive handle records. Creation,
|
||||
binding, upload, compilation, use, and deletion are explicitly submitted to an
|
||||
`OpenGLFunction` instance.
|
||||
|
||||
The active `Image<TPixel>` is only a tightly packed managed bitmap buffer. It
|
||||
does not load files, convert formats, resize pixels, or retain native memory.
|
||||
|
||||
These files are historical references, not candidates for restoration as a
|
||||
group. Restore individual behavior only after checking it against the new
|
||||
Graphics and OpenGL architecture.
|
||||
@@ -0,0 +1,37 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="InternalShaderType"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace StgSharp.Graphics.ShaderEdit
|
||||
{
|
||||
// Temporary compatibility type for ShaderStruct. The new shader model will replace it.
|
||||
public enum InternalShaderType
|
||||
{
|
||||
#pragma warning disable CS1591
|
||||
Struct,
|
||||
Void,
|
||||
Int,
|
||||
UInt,
|
||||
Float,
|
||||
Double,
|
||||
Vector2,
|
||||
Vector3,
|
||||
Vector4,
|
||||
VectorD2,
|
||||
VectorD3,
|
||||
VectorD4,
|
||||
Matrix2x2,
|
||||
Matrix2x3,
|
||||
Matrix2x4,
|
||||
Matrix3x2,
|
||||
Matrix3x3,
|
||||
Matrix3x4,
|
||||
Matrix4x2,
|
||||
Matrix4x3,
|
||||
Matrix4x4,
|
||||
#pragma warning restore CS1591
|
||||
}
|
||||
}
|
||||
@@ -5,14 +5,11 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.Graphics.ShaderEdit;
|
||||
|
||||
using System;
|
||||
|
||||
namespace StgSharp.Mathematics.Graphics
|
||||
{
|
||||
public sealed class Camera : IglConvertable
|
||||
public sealed class Camera
|
||||
{
|
||||
|
||||
private bool _isLookAtAvailable;
|
||||
@@ -24,7 +21,6 @@ namespace StgSharp.Mathematics.Graphics
|
||||
internal Radius _pitch;
|
||||
internal Radius _row;
|
||||
internal Radius _yaw;
|
||||
internal Uniform<GraphicsMatrix> convertedUniform;
|
||||
internal Vec3 _target, up;
|
||||
|
||||
public Camera()
|
||||
@@ -75,36 +71,6 @@ namespace StgSharp.Mathematics.Graphics
|
||||
return Projection * View;
|
||||
}
|
||||
|
||||
public void DisplayGLtypeDefinition()
|
||||
{
|
||||
Console.WriteLine("uniform matrix4x4 cameraName;");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all uniform related to this <see cref="Camera" />.
|
||||
/// </summary>
|
||||
/// <param _label="source">
|
||||
/// Shader program requires this camera.
|
||||
/// </param>
|
||||
/// <param _label="uniformName">
|
||||
/// ContextName of all related uniforms. If you fallow form from <see ///
|
||||
/// cref="IglConvertable.DisplayGLtypeDefinition" />
|
||||
/// </param>
|
||||
/// <exception cref="ArgumentException">
|
||||
///
|
||||
/// </exception>
|
||||
public unsafe void GainAllUniforms(
|
||||
ShaderProgram source,
|
||||
params string[] uniformName
|
||||
)
|
||||
{
|
||||
if ((uniformName is null) || (uniformName.Length != 1)) {
|
||||
throw new ArgumentException(
|
||||
"Camera needs exactly one uniform.", nameof(uniformName));
|
||||
}
|
||||
convertedUniform = source.GetUniform<GraphicsMatrix>(uniformName[0]);
|
||||
}
|
||||
|
||||
public void MoveNear(
|
||||
float distance
|
||||
)
|
||||
@@ -129,12 +95,6 @@ namespace StgSharp.Mathematics.Graphics
|
||||
_isLookAtAvailable = false;
|
||||
}
|
||||
|
||||
public unsafe void SetAllUniforms()
|
||||
{
|
||||
// Console.WriteLine(Projection * ViewBase);
|
||||
OpenGLFunction.CurrentGL.SetUniformValue(convertedUniform, Projection * View);
|
||||
}
|
||||
|
||||
public void SetViewDirection(
|
||||
Vec3 position,
|
||||
Vec3 target,
|
||||
@@ -212,13 +172,6 @@ namespace StgSharp.Mathematics.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
ShaderStruct IglConvertable.GetConvertedGLtype()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
~Camera() { }
|
||||
|
||||
#region rotation
|
||||
|
||||
public void Yaw(
|
||||
|
||||
+73
-143
@@ -5,172 +5,102 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public class Image : IImageProvider
|
||||
/// <summary>
|
||||
/// Owns a tightly packed, two-dimensional managed pixel buffer.
|
||||
/// </summary>
|
||||
/// <typeparam name="TPixel">
|
||||
/// Unmanaged storage layout of one pixel.
|
||||
/// </typeparam>
|
||||
public sealed class Image<TPixel> where TPixel : unmanaged
|
||||
{
|
||||
|
||||
private byte[] _data;
|
||||
private ImageInfo _rawInfo;
|
||||
private int _pixelUpdateCount = 0;
|
||||
private readonly TPixel[] _pixels;
|
||||
|
||||
internal unsafe Image()
|
||||
{
|
||||
_rawInfo = new ImageInfo();
|
||||
}
|
||||
public Image(
|
||||
int width,
|
||||
int height
|
||||
) : this(width, height, new TPixel[GetRequiredPixelCount(width, height)]) { }
|
||||
|
||||
internal Image(
|
||||
ImageInfo information
|
||||
)
|
||||
{
|
||||
_rawInfo = information;
|
||||
_data = [];
|
||||
|
||||
// int length = _rawInfo.width * _rawInfo.height * _rawInfo.channel;
|
||||
}
|
||||
|
||||
public (int width, int height) Size => (_rawInfo.Width, _rawInfo.Height);
|
||||
|
||||
public byte[] PixelBuffer
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((_data.Length == 0) || (_data == null))
|
||||
{
|
||||
GetBytes();
|
||||
return _data!;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
}
|
||||
|
||||
public ImageChannel Channel => _rawInfo.Channel;
|
||||
public Image(
|
||||
(int width, int height) size
|
||||
) : this(size.width, size.height) { }
|
||||
|
||||
/// <summary>
|
||||
/// Hash code of time pixels updated last time.
|
||||
/// Wraps <paramref name="pixels" /> without copying it.
|
||||
/// </summary>
|
||||
public int PixelUpdateCount
|
||||
{
|
||||
get => _pixelUpdateCount;
|
||||
internal set => _pixelUpdateCount = value;
|
||||
}
|
||||
|
||||
public int ChannelCount => _rawInfo.ChannelCount;
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => _rawInfo.Height;
|
||||
internal set => _rawInfo.Height = value;
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => _rawInfo.Width;
|
||||
internal set => _rawInfo.Width = value;
|
||||
}
|
||||
|
||||
public int PixelSize => ImageInfo.GetPixelSize(_rawInfo.pixelLayout, _rawInfo.Channel);
|
||||
|
||||
public PixelChannelLayout PixelLayout
|
||||
{
|
||||
get => _rawInfo.pixelLayout;
|
||||
private set => _rawInfo.pixelLayout = value;
|
||||
}
|
||||
|
||||
internal ref byte[] Data => ref _data;
|
||||
|
||||
public void FromBytes(
|
||||
byte[] stream
|
||||
) { }
|
||||
|
||||
public static unsafe Image FromFile(
|
||||
string route,
|
||||
ImageLoader loader
|
||||
public Image(
|
||||
int width,
|
||||
int height,
|
||||
TPixel[] pixels
|
||||
)
|
||||
{
|
||||
Image ret = new Image();
|
||||
fixed (ImageInfo* iptr = &ret._rawInfo) {
|
||||
GraphicFramework.InternalLoadImage(route, iptr, loader);
|
||||
ArgumentNullException.ThrowIfNull(pixels);
|
||||
|
||||
int requiredLength = GetRequiredPixelCount(width, height);
|
||||
if (pixels.Length != requiredLength)
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"Pixel buffer length must be exactly {requiredLength}, but was {pixels.Length}.",
|
||||
nameof(pixels));
|
||||
}
|
||||
return ret;
|
||||
|
||||
Width = width;
|
||||
Height = height;
|
||||
_pixels = pixels;
|
||||
}
|
||||
|
||||
public static Image FromMemory(
|
||||
(int width, int height) size,
|
||||
ImageChannel channel,
|
||||
byte[] stream
|
||||
public Image(
|
||||
(int width, int height) size,
|
||||
TPixel[] pixels
|
||||
) : this(size.width, size.height, pixels) { }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a writable byte view over the pixel buffer without copying it.
|
||||
/// </summary>
|
||||
public Span<byte> Bytes => MemoryMarshal.AsBytes(_pixels.AsSpan());
|
||||
|
||||
public int ByteLength => Bytes.Length;
|
||||
|
||||
public int Height { get; }
|
||||
|
||||
public int PixelCount => _pixels.Length;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a writable typed view over the pixel buffer without copying it.
|
||||
/// </summary>
|
||||
public Span<TPixel> Pixels => _pixels;
|
||||
|
||||
public ReadOnlySpan<byte> ReadOnlyBytes => MemoryMarshal.AsBytes(_pixels.AsSpan());
|
||||
|
||||
public ReadOnlySpan<TPixel> ReadOnlyPixels => _pixels;
|
||||
|
||||
public (int width, int height) Size => (Width, Height);
|
||||
|
||||
public int Width { get; }
|
||||
|
||||
public static explicit operator Span<byte>(
|
||||
Image<TPixel> image
|
||||
)
|
||||
{
|
||||
ImageInfo _info = new ImageInfo
|
||||
{
|
||||
Height = size.height,
|
||||
Width = size.width,
|
||||
Channel = channel,
|
||||
StreamPtr = IntPtr.Zero
|
||||
};
|
||||
Image ret = new Image(_info);
|
||||
ret.PixelLayout = PixelChannelLayout.Byte;
|
||||
ret._data = stream;
|
||||
return ret;
|
||||
ArgumentNullException.ThrowIfNull(image);
|
||||
return image.Bytes;
|
||||
}
|
||||
|
||||
public static Image FromMemory(
|
||||
(int width, int height) size,
|
||||
ImageChannel channel,
|
||||
PixelChannelLayout layout,
|
||||
byte[] stream
|
||||
private static int GetRequiredPixelCount(
|
||||
int width,
|
||||
int height
|
||||
)
|
||||
{
|
||||
ImageInfo _info = new ImageInfo
|
||||
{
|
||||
Height = size.height,
|
||||
Width = size.width,
|
||||
Channel = channel,
|
||||
StreamPtr = IntPtr.Zero
|
||||
};
|
||||
Image ret = new Image(_info);
|
||||
ret.PixelLayout = layout;
|
||||
ret._data = stream;
|
||||
return ret;
|
||||
}
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(width);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(height);
|
||||
|
||||
public unsafe byte[] GetBytes()
|
||||
{
|
||||
if (_data.Length == 0)
|
||||
{
|
||||
int size = Width * Height * ImageInfo.GetPixelSize(PixelLayout, Channel);
|
||||
_data = new Span<byte>((byte*)_rawInfo.StreamPtr, size).ToArray();
|
||||
fixed (ImageInfo* pptr = &_rawInfo) {
|
||||
GraphicFramework.InternalUnloadImage(pptr);
|
||||
}
|
||||
_rawInfo.StreamPtr = IntPtr.Zero;
|
||||
}
|
||||
return _data;
|
||||
}
|
||||
|
||||
public Image ProvideImage()
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
internal static Image FromMemory(
|
||||
ImageInfo info,
|
||||
byte[] data,
|
||||
int operationCount
|
||||
)
|
||||
{
|
||||
return new Image
|
||||
{
|
||||
_rawInfo = info,
|
||||
_data = data,
|
||||
_pixelUpdateCount = operationCount
|
||||
};
|
||||
return checked(width * height);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
@@ -28,136 +23,51 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void DeleteBuffer(
|
||||
GlHandle handle
|
||||
public void DeleteBuffer(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
_context->glDeleteBuffers(1, (uint*)&handle);
|
||||
_context->glDeleteBuffers(1, &handle.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void DeleteBuffers(
|
||||
GlHandle[] handle
|
||||
public void DeleteBuffers(
|
||||
ReadOnlySpan<GlHandle> handles
|
||||
)
|
||||
{
|
||||
if ((handle == null) || (handle.Length == 0)) {
|
||||
throw new ArgumentNullException(nameof(handle));
|
||||
}
|
||||
fixed (GlHandle* hptr = handle)
|
||||
{
|
||||
uint* iptr = (uint*)hptr;
|
||||
for (int i = 0; i < handle.Length; i++) {
|
||||
_context->glDeleteBuffers(1, iptr + i);
|
||||
}
|
||||
fixed (GlHandle* handlesPtr = handles) {
|
||||
_context->glDeleteBuffers(handles.Length, (uint*)handlesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe GlHandle[] GenBuffers(
|
||||
int count
|
||||
public GlHandle[] GenBuffers(
|
||||
int count
|
||||
)
|
||||
{
|
||||
GlHandle[] h = new GlHandle[count];
|
||||
fixed (GlHandle* hptr = h)
|
||||
{
|
||||
for (int i = 0; i < count; i++) {
|
||||
_context->glGenBuffers(count, ((uint*)hptr) + i);
|
||||
}
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(count);
|
||||
|
||||
GlHandle[] handles = new GlHandle[count];
|
||||
if (handles.Length == 0) {
|
||||
return handles;
|
||||
}
|
||||
return h;
|
||||
|
||||
fixed (GlHandle* handlesPtr = handles) {
|
||||
_context->glGenBuffers(count, (uint*)handlesPtr);
|
||||
}
|
||||
return handles;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
T bufferData,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, INumber<T>
|
||||
public void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
ReadOnlySpan<T> bufferData,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged
|
||||
{
|
||||
int size = Marshal.SizeOf<T>();
|
||||
T* p = &bufferData;
|
||||
_context->glBufferData((uint)bufferType, size, (nint*)p, (uint)usage);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
[NotNull] T[] bufferArray,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf<T>();
|
||||
if (bufferArray == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (void* bufferPtr = bufferArray) {
|
||||
_context->glBufferData((uint)bufferType, size, (nint*)bufferPtr, (uint)usage);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
int size = bufferSpan.Length * Marshal.SizeOf<T>();
|
||||
if (bufferSpan.IsEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (void* bufferPtr = bufferSpan) {
|
||||
_context->glBufferData((uint)bufferType, size, (IntPtr*)bufferPtr, (uint)usage);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
Span<T> bufferArray,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf<T>();
|
||||
if (bufferArray.IsEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (void* bufferPtr = bufferArray) {
|
||||
_context->glBufferData((uint)bufferType, size, (IntPtr*)bufferPtr, (uint)usage);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferVectorData<T>(
|
||||
BufferType bufferType,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
int size = bufferSpan.Length * Marshal.SizeOf<T>();
|
||||
|
||||
fixed (void* bufferPtr = bufferSpan) {
|
||||
_context->glBufferData((uint)bufferType, size, (IntPtr*)bufferPtr, (uint)usage);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferVectorData<T>(
|
||||
BufferType bufferType,
|
||||
T[] bufferArray,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
|
||||
if (bufferArray == null) {
|
||||
return;
|
||||
}
|
||||
fixed (void* bufferPtr = bufferArray) {
|
||||
_context->glBufferData((uint)bufferType, (nuint)size, (IntPtr*)bufferPtr,
|
||||
(uint)usage);
|
||||
nint sizeInBytes = checked((nint)bufferData.Length * sizeof(T));
|
||||
fixed (T* bufferPtr = bufferData) {
|
||||
_context->glBufferData((uint)bufferType, sizeInBytes, bufferPtr, (uint)usage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,11 +19,26 @@ namespace StgSharp.Graphics.OpenGL
|
||||
Span<GlHandle> framebuffers
|
||||
)
|
||||
{
|
||||
if (framebuffers.IsEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
fixed (GlHandle* framebuffersPtr = framebuffers) {
|
||||
Context.glGenFramebuffers(framebuffers.Length, (uint*)framebuffersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Delete framebuffer object handles.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DeleteFramebuffers(
|
||||
ReadOnlySpan<GlHandle> framebuffers
|
||||
)
|
||||
{
|
||||
fixed (GlHandle* framebuffersPtr = framebuffers) {
|
||||
Context.glDeleteFramebuffers(framebuffers.Length, (uint*)framebuffersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bind a framebuffer object to a framebuffer target.
|
||||
/// </summary>
|
||||
@@ -73,6 +88,17 @@ namespace StgSharp.Graphics.OpenGL
|
||||
_context->glDeleteRenderbuffers(1, &bufferHandle.Value);
|
||||
}
|
||||
|
||||
/// <summary>Delete renderbuffer object handles.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DeleteRenderbuffers(
|
||||
ReadOnlySpan<GlHandle> renderbuffers
|
||||
)
|
||||
{
|
||||
fixed (GlHandle* renderbuffersPtr = renderbuffers) {
|
||||
Context.glDeleteRenderbuffers(renderbuffers.Length, (uint*)renderbuffersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void FrameBufferTexture2d(
|
||||
FrameBufferTarget target,
|
||||
@@ -91,7 +117,13 @@ namespace StgSharp.Graphics.OpenGL
|
||||
int count
|
||||
)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(count);
|
||||
|
||||
GlHandle[] h = new GlHandle[count];
|
||||
if (h.Length == 0) {
|
||||
return h;
|
||||
}
|
||||
|
||||
fixed (GlHandle* hptr = h) {
|
||||
_context->glGenRenderbuffers(count, (uint*)hptr);
|
||||
}
|
||||
|
||||
@@ -5,11 +5,8 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
@@ -18,114 +15,179 @@ namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe GlHandle CreateGraphicProgram()
|
||||
public GlHandle CreateGraphicProgram()
|
||||
{
|
||||
return GlHandle.Create(_context->glCreateProgram());
|
||||
return CreateProgram();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe GlHandle[] CreateProgram(
|
||||
int count
|
||||
public GlHandle[] CreateProgram(
|
||||
int count
|
||||
)
|
||||
{
|
||||
GlHandle[] h = new GlHandle[count];
|
||||
for (int i = 0; i < count; i++) {
|
||||
h.SetValue(i, _context->glCreateProgram());
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(count);
|
||||
|
||||
GlHandle[] handles = new GlHandle[count];
|
||||
for (int i = 0; i < handles.Length; i++) {
|
||||
handles[i] = CreateProgram();
|
||||
}
|
||||
return h;
|
||||
return handles;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public GlHandle CreateShader(
|
||||
ShaderType type
|
||||
)
|
||||
{
|
||||
GlHandle handle = CreateShader((uint)type);
|
||||
if (handle.Value == 0)
|
||||
{
|
||||
uint error = _context->glGetError();
|
||||
throw new InvalidOperationException($"Failed in creating shader: {error}");
|
||||
}
|
||||
return handle;
|
||||
}
|
||||
|
||||
public GlHandle[] CreateShaderSet(
|
||||
int count,
|
||||
ShaderType type
|
||||
)
|
||||
{
|
||||
GlHandle[] ret = new GlHandle[count];
|
||||
uint t = (uint)type;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
uint id = _context->glCreateShader(t);
|
||||
if (id == 0)
|
||||
{
|
||||
uint error = _context->glGetError();
|
||||
throw new InvalidOperationException($"Failed in creating shader: {error}");
|
||||
}
|
||||
ret[i] = GlHandle.Create(id);
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(count);
|
||||
|
||||
GlHandle[] handles = new GlHandle[count];
|
||||
for (int i = 0; i < handles.Length; i++) {
|
||||
handles[i] = CreateShader(type);
|
||||
}
|
||||
return ret;
|
||||
return handles;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public string GetShaderStatus(
|
||||
GlHandle shader,
|
||||
ShaderStatus status
|
||||
)
|
||||
{
|
||||
return GetShaderStatus(shader, (uint)status);
|
||||
}
|
||||
|
||||
public string GetShaderStatus(
|
||||
Shader s,
|
||||
int index,
|
||||
int key
|
||||
GlHandle shader,
|
||||
uint statusName
|
||||
)
|
||||
{
|
||||
IntPtr sptr = IntPtr.Zero;
|
||||
if (GraphicFramework.glCheckShaderStatus(ref Context, s.handle[index].Value, key,
|
||||
ref sptr) == 0) {
|
||||
return Marshal.PtrToStringAnsi(sptr) ?? string.Empty;
|
||||
int status;
|
||||
_context->glGetShaderiv(shader.Value, statusName, &status);
|
||||
if (status != 0) {
|
||||
return string.Empty;
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe GlHandle GetUniformLocation(
|
||||
GlHandle program,
|
||||
string name
|
||||
)
|
||||
{
|
||||
byte[] code = Encoding.UTF8.GetBytes(name);
|
||||
fixed (byte* ptr = code)
|
||||
int logLength;
|
||||
_context->glGetShaderiv(shader.Value, glConst.INFO_LOG_LENGTH, &logLength);
|
||||
if (logLength <= 1) {
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
byte[] log = new byte[logLength];
|
||||
fixed (byte* logPtr = log)
|
||||
{
|
||||
int ret = _context->glGetUniformLocation(program.Value, ptr);
|
||||
#if DEBUG
|
||||
if (ret is glConst.INVALID_OPERATION or glConst.INVALID_VALUE)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
if (ret == -1) {
|
||||
throw new UniformEmptyReferenceException(nameof(program), name);
|
||||
}
|
||||
#endif
|
||||
return GlHandle.CreateSigned(ret);
|
||||
int written;
|
||||
_context->glGetShaderInfoLog(shader.Value, log.Length, &written, logPtr);
|
||||
return Encoding.UTF8.GetString(log, 0, Math.Clamp(written, 0, log.Length));
|
||||
}
|
||||
}
|
||||
|
||||
public GlHandle GetUniformLocation(
|
||||
GlHandle program,
|
||||
string name
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(name);
|
||||
|
||||
int byteCount = Encoding.UTF8.GetByteCount(name);
|
||||
Span<byte> utf8Name = byteCount < 256
|
||||
? stackalloc byte[byteCount + 1]
|
||||
: new byte[byteCount + 1];
|
||||
int written = Encoding.UTF8.GetBytes(name.AsSpan(), utf8Name);
|
||||
utf8Name[written] = 0;
|
||||
|
||||
int location;
|
||||
fixed (byte* namePtr = utf8Name) {
|
||||
location = _context->glGetUniformLocation(program.Value, namePtr);
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
if (location == -1) {
|
||||
throw new UniformEmptyReferenceException(nameof(program), name);
|
||||
}
|
||||
#endif
|
||||
|
||||
return GlHandle.CreateSigned(location);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void LoadShaderSource(
|
||||
GlHandle shaderHandle,
|
||||
byte[] codeStream
|
||||
)
|
||||
public Uniform<T> GetUniform<T>(
|
||||
GlHandle program,
|
||||
string name
|
||||
) where T : unmanaged
|
||||
{
|
||||
fixed (byte* streamPtr = codeStream) {
|
||||
_context->glShaderSource(shaderHandle.Value, 1, &streamPtr, (int*)0);
|
||||
}
|
||||
return new Uniform<T>(GetUniformLocation(program, name));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void LoadShaderSource(
|
||||
GlHandle shaderHandle,
|
||||
ReadOnlySpan<char> codeStream
|
||||
)
|
||||
public Uniform<T, U> GetUniform<T, U>(
|
||||
GlHandle program,
|
||||
string name
|
||||
) where T : unmanaged where U : struct
|
||||
{
|
||||
fixed (char* streamPtr = codeStream) {
|
||||
_context->glShaderSource(shaderHandle.Value, 1, (byte**)&streamPtr, (int*)0);
|
||||
}
|
||||
return new Uniform<T, U>(GetUniformLocation(program, name));
|
||||
}
|
||||
|
||||
public unsafe void LoadShaderSource(
|
||||
GlHandle shaderHandle,
|
||||
ReadOnlySpan<byte> codeStream
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Uniform<T, U, V> GetUniform<T, U, V>(
|
||||
GlHandle program,
|
||||
string name
|
||||
) where T : unmanaged where U : struct where V : struct
|
||||
{
|
||||
return new Uniform<T, U, V>(GetUniformLocation(program, name));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Uniform<T, U, V, W> GetUniform<T, U, V, W>(
|
||||
GlHandle program,
|
||||
string name
|
||||
) where T : unmanaged where U : struct where V : struct where W : struct
|
||||
{
|
||||
return new Uniform<T, U, V, W>(GetUniformLocation(program, name));
|
||||
}
|
||||
|
||||
public void ShaderSource(
|
||||
GlHandle shader,
|
||||
ReadOnlySpan<byte> source
|
||||
)
|
||||
{
|
||||
fixed (byte* streamPtr = codeStream)
|
||||
int length = source.Length;
|
||||
fixed (byte* sourcePtr = source)
|
||||
{
|
||||
byte* bptr = streamPtr;
|
||||
_context->glShaderSource(shaderHandle.Value, 1, &bptr, (int*)0);
|
||||
byte emptySource = 0;
|
||||
byte* sourceAddress = sourcePtr == null ? &emptySource : sourcePtr;
|
||||
_context->glShaderSource(shader.Value, 1, &sourceAddress, &length);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShaderSource(
|
||||
GlHandle shader,
|
||||
string source
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(source);
|
||||
|
||||
int byteCount = Encoding.UTF8.GetByteCount(source);
|
||||
Span<byte> utf8Source = byteCount < 1024
|
||||
? stackalloc byte[byteCount]
|
||||
: new byte[byteCount];
|
||||
int written = Encoding.UTF8.GetBytes(source.AsSpan(), utf8Source);
|
||||
ShaderSource(shader, utf8Source[..written]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,10 +5,7 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
@@ -29,25 +26,42 @@ namespace StgSharp.Graphics.OpenGL
|
||||
int count
|
||||
)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(count);
|
||||
|
||||
GlHandle[] h = new GlHandle[count];
|
||||
if (h.Length == 0) {
|
||||
return h;
|
||||
}
|
||||
|
||||
fixed (GlHandle* hptr = h) {
|
||||
_context->glGenTextures(count, (uint*)hptr);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/// <summary>Delete texture object handles.</summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DeleteTextures(
|
||||
ReadOnlySpan<GlHandle> textures
|
||||
)
|
||||
{
|
||||
fixed (GlHandle* texturesPtr = textures) {
|
||||
Context.glDeleteTextures(textures.Length, (uint*)texturesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void GetTextureImage<T>(
|
||||
Texture2DTarget target,
|
||||
int level,
|
||||
ImageChannel channel,
|
||||
FrameBufferChannel channel,
|
||||
PixelChannelLayout channelLayout,
|
||||
T[] dataStream
|
||||
) where T : unmanaged, INumber<T>
|
||||
Span<T> destination
|
||||
) where T : unmanaged
|
||||
{
|
||||
fixed (T* tptr = dataStream) {
|
||||
fixed (T* tptr = destination) {
|
||||
_context->glGetTexImage((uint)target, level, (uint)channel, (uint)channelLayout,
|
||||
(nint*)tptr);
|
||||
tptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,73 +79,50 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadPixels(
|
||||
public void ReadPixels<T>(
|
||||
(int X, int Y) beginPosition,
|
||||
(int width, int height) size,
|
||||
FrameBufferChannel format,
|
||||
PixelChannelLayout dataType,
|
||||
ref byte[] stream
|
||||
)
|
||||
Span<T> destination
|
||||
) where T : unmanaged
|
||||
{
|
||||
fixed (byte* bptr = stream) {
|
||||
fixed (T* destinationPtr = destination) {
|
||||
_context->glReadPixels(beginPosition.X, beginPosition.Y, size.width, size.height,
|
||||
(uint)format, (uint)dataType, (nint*)bptr);
|
||||
(uint)format, (uint)dataType, destinationPtr);
|
||||
}
|
||||
}
|
||||
|
||||
public void RereadImage(
|
||||
in Image i,
|
||||
(int X, int Y) beginPosition,
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureImage2d(
|
||||
Texture2DTarget target,
|
||||
int level,
|
||||
int internalFormat,
|
||||
int width,
|
||||
int height,
|
||||
FrameBufferChannel format,
|
||||
PixelChannelLayout dataType
|
||||
PixelChannelLayout type
|
||||
)
|
||||
{
|
||||
byte[] pixels = i.PixelBuffer;
|
||||
if (!pixels.CheckArrayFormat(dataType)) {
|
||||
throw new GlArrayFormatException(dataType, "i.PixelArray");
|
||||
}
|
||||
fixed (byte* bptr = pixels) {
|
||||
_context->glReadPixels(beginPosition.X, beginPosition.Y, i.Width, i.Height,
|
||||
(uint)format, (uint)dataType, (nint*)bptr);
|
||||
}
|
||||
i.PixelUpdateCount++;
|
||||
_context->glTexImage2D((uint)target, level, internalFormat, width, height, 0,
|
||||
(uint)format, (uint)type, (void*)0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureImage2d<T>(
|
||||
Texture2DTarget target,
|
||||
int level,
|
||||
ImageChannel sourceChannel,
|
||||
int internalFormat,
|
||||
int width,
|
||||
int height,
|
||||
ImageChannel targetChannel,
|
||||
FrameBufferChannel format,
|
||||
PixelChannelLayout type,
|
||||
T[] pixels
|
||||
) where T : unmanaged, INumber<T>
|
||||
ReadOnlySpan<T> pixels
|
||||
) where T : unmanaged
|
||||
{
|
||||
fixed (T* tptr = pixels)
|
||||
{
|
||||
T* ptr = ((pixels == null) || (pixels.Length == 0)) ? (T*)IntPtr.Zero : tptr;
|
||||
_context->glTexImage2D((uint)target, level, (int)sourceChannel, width, height, 0,
|
||||
(uint)targetChannel, (uint)type, (nint*)tptr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureImage2d<T>(
|
||||
Texture2DTarget target,
|
||||
int level,
|
||||
ImageChannel sourceChannel,
|
||||
int width,
|
||||
int height,
|
||||
ImageChannel targetChannel,
|
||||
PixelChannelLayout type,
|
||||
Span<T> pixelSpan
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
fixed (T* tPtr = pixelSpan) {
|
||||
_context->glTexImage2D((uint)target, level, (int)sourceChannel, width, height, 0,
|
||||
(uint)targetChannel, (uint)type, (nint*)tPtr);
|
||||
fixed (T* pixelPtr = pixels) {
|
||||
_context->glTexImage2D((uint)target, level, internalFormat, width, height, 0,
|
||||
(uint)format, (uint)type, pixelPtr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,15 +25,11 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void DeleteVertexArrays(
|
||||
GlHandle[] arrays
|
||||
ReadOnlySpan<GlHandle> arrays
|
||||
)
|
||||
{
|
||||
fixed (GlHandle* hptr = arrays)
|
||||
{
|
||||
uint* iptr = (uint*)hptr;
|
||||
for (int i = 0; i < arrays.Length; i++) {
|
||||
_context->glDeleteVertexArrays(1, iptr + i);
|
||||
}
|
||||
fixed (GlHandle* arraysPtr = arrays) {
|
||||
_context->glDeleteVertexArrays(arrays.Length, (uint*)arraysPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +37,13 @@ namespace StgSharp.Graphics.OpenGL
|
||||
int count
|
||||
)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(count);
|
||||
|
||||
GlHandle[] h = new GlHandle[count];
|
||||
if (h.Length == 0) {
|
||||
return h;
|
||||
}
|
||||
|
||||
fixed (GlHandle* hptr = h) {
|
||||
_context->glGenVertexArrays(count, (uint*)hptr);
|
||||
}
|
||||
@@ -58,7 +60,18 @@ namespace StgSharp.Graphics.OpenGL
|
||||
int pointer
|
||||
)
|
||||
{
|
||||
uint type = GraphicFramework.GLtype[(int)t];
|
||||
uint type = t switch
|
||||
{
|
||||
TypeCode.Single => glConst.FLOAT,
|
||||
TypeCode.Int32 => glConst.INT,
|
||||
TypeCode.UInt32 => glConst.UNSIGNED_INT,
|
||||
TypeCode.Int16 => glConst.SHORT,
|
||||
TypeCode.UInt16 => glConst.UNSIGNED_SHORT,
|
||||
TypeCode.SByte => glConst.BYTE,
|
||||
TypeCode.Byte => glConst.UNSIGNED_BYTE,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(t), t,
|
||||
"The type cannot be used as an OpenGL vertex attribute."),
|
||||
};
|
||||
_context->glVertexAttribPointer(index, size, type, (byte)(normalized ? 1 : 0), stride,
|
||||
(nint*)pointer);
|
||||
_context->glEnableVertexAttribArray(index);
|
||||
|
||||
@@ -5,72 +5,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
using StgSharp.Mathematics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of handle to Element BufferHandle Object in OpenglFunc. Each <see ///
|
||||
/// langword="uint" /> value indexed from instance of this class this is the only handle to
|
||||
/// one Element BufferHandle Object.
|
||||
/// </summary>
|
||||
public sealed unsafe class ElementBuffer : GlBufferObjectBase
|
||||
/// <summary>A set of OpenGL element-buffer handles.</summary>
|
||||
public sealed record class ElementBuffer(
|
||||
GlHandle[] Handles
|
||||
)
|
||||
{
|
||||
|
||||
internal ElementBuffer(
|
||||
int n,
|
||||
glRender binding
|
||||
)
|
||||
: base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
}
|
||||
public int Count => Handles.Length;
|
||||
|
||||
public sealed override void Bind(
|
||||
int index
|
||||
)
|
||||
{
|
||||
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
||||
}
|
||||
|
||||
public void SetValue<T>(
|
||||
int index,
|
||||
T[] bufferArray,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferArray, usage);
|
||||
}
|
||||
|
||||
public void SetValue<T>(
|
||||
int index,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferData<T>(BufferType.ElementArrayBuffer, bufferSpan, usage);
|
||||
}
|
||||
|
||||
protected sealed override void Dispose(
|
||||
bool disposing
|
||||
)
|
||||
{
|
||||
if (disposing) {
|
||||
GL.DeleteBuffers(_bufferHandle);
|
||||
}
|
||||
}
|
||||
public GlHandle this[int index] => Handles[index];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,22 +5,13 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
#pragma warning disable CA1008
|
||||
#pragma warning disable CA1028
|
||||
#pragma warning disable CA1008
|
||||
#pragma warning disable CA1028
|
||||
public enum FrameBufferTarget : uint
|
||||
#pragma warning restore CA1028
|
||||
#pragma warning restore CA1008
|
||||
#pragma warning restore CA1028
|
||||
#pragma warning restore CA1008
|
||||
{
|
||||
|
||||
Read = glConst.READ_FRAMEBUFFER,
|
||||
@@ -29,67 +20,15 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
}
|
||||
|
||||
public sealed class FrameBuffer : GlBufferObjectBase
|
||||
/// <summary>A set of OpenGL framebuffer handles.</summary>
|
||||
public sealed record class FrameBuffer(
|
||||
GlHandle[] Handles
|
||||
)
|
||||
{
|
||||
|
||||
internal unsafe FrameBuffer(
|
||||
int count,
|
||||
glRender binding
|
||||
)
|
||||
: base(binding)
|
||||
{
|
||||
_bufferHandle = new GlHandle[count];
|
||||
GL.GenFrameBuffers(_bufferHandle);
|
||||
}
|
||||
public int Count => Handles.Length;
|
||||
|
||||
/// <summary>
|
||||
/// Bind the frame BufferHandle object with _label frame BufferHandle to the frame
|
||||
/// BufferHandle target specified by target. <see langword="FrameBufferTarget.All" /> will
|
||||
/// be set as default target.
|
||||
/// </summary>
|
||||
/// <param _label="index">
|
||||
/// Index of object to be binded in handle set
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override unsafe void Bind(
|
||||
int index
|
||||
)
|
||||
{
|
||||
GL.BindFrameBuffer(FrameBufferTarget.All, _bufferHandle[index]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bind the frame BufferHandle object with _label frame BufferHandle to the frame
|
||||
/// BufferHandle target specified by target. Target of this frame BufferHandle should be
|
||||
/// set manually.
|
||||
/// </summary>
|
||||
/// <param _label="target">
|
||||
/// The frame BufferHandle target of the binding operation.
|
||||
/// </param>
|
||||
/// <param _label="index">
|
||||
/// Index of object to be binded in handle set
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Bind(
|
||||
FrameBufferTarget target,
|
||||
int index
|
||||
)
|
||||
{
|
||||
GL.BindFrameBuffer(target, _bufferHandle[index]);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void BindNull()
|
||||
{
|
||||
OpenGLFunction.CurrentGL.BindFrameBuffer(FrameBufferTarget.All, GlHandle.Zero);
|
||||
}
|
||||
|
||||
protected override void Dispose(
|
||||
bool disposing
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public GlHandle this[int index] => Handles[index];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,53 +5,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public sealed class RenderBuffer : GlBufferObjectBase
|
||||
/// <summary>A set of OpenGL renderbuffer handles.</summary>
|
||||
public sealed record class RenderBuffer(
|
||||
GlHandle[] Handles
|
||||
)
|
||||
{
|
||||
|
||||
public RenderBuffer(
|
||||
int count,
|
||||
glRender binding
|
||||
)
|
||||
: base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenRenderBuffer(count);
|
||||
}
|
||||
public int Count => Handles.Length;
|
||||
|
||||
public override void Bind(
|
||||
int index
|
||||
)
|
||||
{
|
||||
GL.BindRenderBuffer(this[index]);
|
||||
}
|
||||
|
||||
public void Store(
|
||||
RenderBufferInternalFormat format,
|
||||
(int width, int height) size
|
||||
)
|
||||
{
|
||||
if ((size.width > binding.Width) || (size.height > binding.Height)) {
|
||||
World.LogWarning("FrameBuffer is larger than current canvas binding");
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(
|
||||
bool disposing
|
||||
)
|
||||
{
|
||||
foreach (GlHandle item in _bufferHandle)
|
||||
{
|
||||
Console.WriteLine("removing a render buffer");
|
||||
GL.DeleteRenderBuffer(item);
|
||||
}
|
||||
}
|
||||
public GlHandle this[int index] => Handles[index];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,235 +5,27 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||
using StgSharp.Mathematics;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public sealed unsafe class TextureGL
|
||||
/// <summary>A set of OpenGL texture handles.</summary>
|
||||
public sealed record class TextureGL(
|
||||
GlHandle[] Handles
|
||||
)
|
||||
{
|
||||
|
||||
private int currentEditingTextureIndex;
|
||||
public int Count => Handles.Length;
|
||||
|
||||
private OpenGLFunction _gl;
|
||||
internal GlHandle[] _textureHandle;
|
||||
|
||||
internal TextureGL(
|
||||
int count,
|
||||
glRender binding
|
||||
)
|
||||
{
|
||||
// sourceList = new Image[count];
|
||||
this._gl = binding.GL;
|
||||
_textureHandle = _gl.GenTextures(count);
|
||||
}
|
||||
|
||||
public GlHandle this[
|
||||
int index
|
||||
]
|
||||
{
|
||||
get => _textureHandle[index];
|
||||
}
|
||||
|
||||
public int Count => _textureHandle.Length;
|
||||
|
||||
// internal Image[] sourceList;
|
||||
|
||||
public int IndexOfCurrentTexture => currentEditingTextureIndex;
|
||||
|
||||
internal OpenGLFunction GL => _gl;
|
||||
|
||||
public void ActivateAs(
|
||||
TextureUnit unit
|
||||
)
|
||||
{
|
||||
_gl.ActiveTextureUnit((uint)unit);
|
||||
}
|
||||
|
||||
public void Bind2D(
|
||||
int index
|
||||
)
|
||||
{
|
||||
currentEditingTextureIndex = index;
|
||||
_gl.BindTexture(glConst.TEXTURE_2D, _textureHandle[index]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an <see cref="Image" /> to certain texture.
|
||||
/// </summary>
|
||||
/// <param _label="index">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="i">
|
||||
///
|
||||
/// </param>
|
||||
public unsafe void LoadTexture(
|
||||
int index,
|
||||
Image i
|
||||
)
|
||||
{
|
||||
byte[] handle = i.PixelBuffer;
|
||||
_gl.TextureImage2d(Texture2DTarget.Texture2D, 0, i.Channel, i.Width, i.Height,
|
||||
i.Channel, i.PixelLayout, pixels:handle);
|
||||
_gl.GenerateMipmap(Texture2DTarget.Texture2D);
|
||||
}
|
||||
|
||||
#region texture setting
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Set2dFilterProperty(
|
||||
int index,
|
||||
TextureFilter onMinify,
|
||||
TextureFilter onMagnify
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
if (index != currentEditingTextureIndex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Texture to be editted is not the one being activated.");
|
||||
}
|
||||
#endif
|
||||
_gl.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_MIN_FILTER, (int)onMinify);
|
||||
_gl.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_MAG_FILTER,
|
||||
(int)onMagnify);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Set2dWrapProperty(
|
||||
int index,
|
||||
TextureWrap onHorizontial,
|
||||
TextureWrap onVertical
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
if (index != currentEditingTextureIndex)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Texture to be editted is not the one being activated.");
|
||||
}
|
||||
#endif
|
||||
_gl.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_S,
|
||||
(int)onHorizontial);
|
||||
_gl.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_T, (int)onVertical);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Set2dProperty(
|
||||
int index,
|
||||
TextureProperty property
|
||||
)
|
||||
{
|
||||
Set2dFilterProperty(index, property.FilterOnMinify, property.FilterOnMagnify);
|
||||
Set2dWrapProperty(index, property.WrapOnHorizontial, property.WrapOnVertical);
|
||||
}
|
||||
|
||||
#endregion texture setting
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public struct TextureProperty
|
||||
{
|
||||
|
||||
[FieldOffset(0)] private M128 mask;
|
||||
[FieldOffset(0)] private TextureFilter mag;
|
||||
[FieldOffset(4)] private TextureFilter min;
|
||||
|
||||
[FieldOffset(8)] private TextureWrap hori;
|
||||
[FieldOffset(12)] private TextureWrap vert;
|
||||
|
||||
public TextureProperty(
|
||||
TextureFilter onMagnify,
|
||||
TextureFilter onMinify,
|
||||
TextureWrap onHorizontal,
|
||||
TextureWrap onVertical
|
||||
)
|
||||
{
|
||||
FilterOnMagnify = onMagnify;
|
||||
FilterOnMinify = onMinify;
|
||||
WrapOnHorizontial = onHorizontal;
|
||||
WrapOnVertical = onVertical;
|
||||
}
|
||||
|
||||
public TextureFilter FilterOnMagnify
|
||||
{
|
||||
get => mag;
|
||||
set => mag = value;
|
||||
}
|
||||
|
||||
public TextureFilter FilterOnMinify
|
||||
{
|
||||
get => min;
|
||||
set => min = value;
|
||||
}
|
||||
|
||||
public TextureWrap WrapOnHorizontial
|
||||
{
|
||||
get => hori;
|
||||
set => hori = value;
|
||||
}
|
||||
|
||||
public TextureWrap WrapOnVertical
|
||||
{
|
||||
get => vert;
|
||||
set => vert = value;
|
||||
}
|
||||
|
||||
public override bool Equals(
|
||||
[NotNullWhen(true)] object obj
|
||||
)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(FilterOnMagnify, FilterOnMagnify, WrapOnHorizontial,
|
||||
WrapOnVertical);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"FilterOnMagnify:{FilterOnMagnify}, " + $"FilterOnMagnify:{FilterOnMagnify}, " + $"WrapOnHorizontial:{WrapOnHorizontial}, " + $"WrapOnVertical:{WrapOnVertical}";
|
||||
}
|
||||
|
||||
public static bool operator !=(
|
||||
TextureProperty left,
|
||||
TextureProperty right
|
||||
)
|
||||
{
|
||||
return left.mask != right.mask;
|
||||
}
|
||||
|
||||
public static bool operator ==(
|
||||
TextureProperty left,
|
||||
TextureProperty right
|
||||
)
|
||||
{
|
||||
return left.mask == right.mask;
|
||||
}
|
||||
|
||||
public static implicit operator TextureProperty(
|
||||
(
|
||||
TextureFilter onMagnify, TextureFilter onMinify,
|
||||
TextureWrap onHorizontial, TextureWrap onVertical
|
||||
) propertyValueTuple
|
||||
)
|
||||
{
|
||||
return new TextureProperty(propertyValueTuple.onMagnify, propertyValueTuple.onMinify,
|
||||
propertyValueTuple.onHorizontial,
|
||||
propertyValueTuple.onVertical);
|
||||
}
|
||||
public GlHandle this[int index] => Handles[index];
|
||||
|
||||
}
|
||||
|
||||
public readonly record struct TextureProperty(
|
||||
TextureFilter FilterOnMagnify,
|
||||
TextureFilter FilterOnMinify,
|
||||
TextureWrap WrapOnHorizontal,
|
||||
TextureWrap WrapOnVertical
|
||||
);
|
||||
|
||||
#pragma warning disable CA1008
|
||||
public enum TextureFilter
|
||||
#pragma warning restore CA1008
|
||||
@@ -272,9 +64,9 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
}
|
||||
|
||||
#pragma warning disable CA1008
|
||||
#pragma warning disable CA1008
|
||||
public enum TextureWrap
|
||||
#pragma warning restore CA1008
|
||||
#pragma warning restore CA1008
|
||||
{
|
||||
|
||||
Repeat = glConst.REPEAT,
|
||||
|
||||
@@ -5,62 +5,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public sealed unsafe class VertexArray : GlBufferObjectBase
|
||||
/// <summary>A set of OpenGL vertex-array handles.</summary>
|
||||
public sealed record class VertexArray(
|
||||
GlHandle[] Handles
|
||||
)
|
||||
{
|
||||
|
||||
internal VertexArray(
|
||||
int n,
|
||||
glRender binding
|
||||
)
|
||||
: base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenVertexArrays(n);
|
||||
}
|
||||
public int Count => Handles.Length;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public sealed override void Bind(
|
||||
int index
|
||||
)
|
||||
{
|
||||
GL.BindVertexArray(_bufferHandle[index]);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void BindNull()
|
||||
{
|
||||
OpenGLFunction.CurrentGL.BindVertexArray(GlHandle.Zero);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetVertexAttribute(
|
||||
uint attributeIndex,
|
||||
int vertexLength,
|
||||
TypeCode dataType,
|
||||
bool isNomalized,
|
||||
int stride,
|
||||
int pointer
|
||||
)
|
||||
{
|
||||
GL.SetVertexAttribute(attributeIndex, vertexLength, dataType, isNomalized, stride,
|
||||
pointer);
|
||||
}
|
||||
|
||||
protected sealed override void Dispose(
|
||||
bool disposing
|
||||
)
|
||||
{
|
||||
if (disposing) {
|
||||
GL.DeleteVertexArrays(_bufferHandle);
|
||||
}
|
||||
}
|
||||
public GlHandle this[int index] => Handles[index];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,157 +5,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Security;
|
||||
using System.Numerics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public sealed unsafe class VertexBuffer : GlBufferObjectBase
|
||||
/// <summary>A set of OpenGL vertex-buffer handles.</summary>
|
||||
public sealed record class VertexBuffer(
|
||||
GlHandle[] Handles
|
||||
)
|
||||
{
|
||||
|
||||
internal VertexBuffer(
|
||||
int n,
|
||||
glRender binding
|
||||
)
|
||||
: base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
}
|
||||
public int Count => Handles.Length;
|
||||
|
||||
public sealed override void Bind(
|
||||
int index
|
||||
)
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, GlHandle.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex BufferHandle object
|
||||
/// </summary>
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="bufferArray">
|
||||
/// Data to write in
|
||||
/// </param>
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteScalerData<T>(
|
||||
int index,
|
||||
T[] bufferArray,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, INumber<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, bufferArray, usage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex BufferHandle object
|
||||
/// </summary>
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="scalerSpan">
|
||||
/// A <see cref="Span{T}" /> of _data to write in
|
||||
/// </param>
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteScalerData<T>(
|
||||
int index,
|
||||
ReadOnlySpan<T> scalerSpan,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged,INumber<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, scalerSpan, usage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set data to current vertex BufferHandle object
|
||||
/// </summary>
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="vectorSpan">
|
||||
/// A <see cref="Span{T}" /> of data to write in
|
||||
/// </param>
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteVectorData<T>(
|
||||
int index,
|
||||
ReadOnlySpan<T> vectorSpan,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorSpan, usage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex BufferHandle object
|
||||
/// </summary>
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="vectorArray">
|
||||
/// A array of _data to write in
|
||||
/// </param>
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteVectorData<T>(
|
||||
int index,
|
||||
T[] vectorArray,
|
||||
BufferUsage usage
|
||||
) where T : unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorArray, usage);
|
||||
}
|
||||
|
||||
protected sealed override void Dispose(
|
||||
bool disposing
|
||||
)
|
||||
{
|
||||
if (disposing) {
|
||||
GL.DeleteBuffers(_bufferHandle);
|
||||
}
|
||||
}
|
||||
public GlHandle this[int index] => Handles[index];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,163 +5,33 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Internal;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public abstract partial class glRender : RenderStream
|
||||
/// <summary>
|
||||
/// A set of OpenGL shader handles with their common stage type.
|
||||
/// </summary>
|
||||
public sealed record Shader
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Create an instance of <see cref="Shader" /> program
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// New instance of <see cref="Shader" /> instance.
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected sealed override ShaderProgram CreateShaderProgram()
|
||||
{
|
||||
return new ShaderProgram(this);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected sealed override Shader CreateShaderSegment(
|
||||
ShaderType type,
|
||||
int count
|
||||
public Shader(
|
||||
GlHandle[] handles,
|
||||
ShaderType type
|
||||
)
|
||||
{
|
||||
return new Shader(GL.CreateShaderSet(count, type), type, this);
|
||||
ArgumentNullException.ThrowIfNull(handles);
|
||||
Handles = handles;
|
||||
Type = type;
|
||||
}
|
||||
|
||||
}
|
||||
public int Count => Handles.Length;
|
||||
|
||||
public class Shader
|
||||
{
|
||||
public GlHandle[] Handles { get; }
|
||||
|
||||
private readonly OpenGLFunction GL;
|
||||
internal readonly GlHandle[] handle;
|
||||
public readonly ShaderType type;
|
||||
public ShaderType Type { get; }
|
||||
|
||||
internal unsafe Shader(
|
||||
GlHandle[] handle,
|
||||
ShaderType usage,
|
||||
glRender stream
|
||||
)
|
||||
{
|
||||
this.handle = handle;
|
||||
GL = stream.GL;
|
||||
type = usage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attach one shader code to a shader program.
|
||||
/// </summary>
|
||||
/// <param _label="target">
|
||||
/// Shader program to attach
|
||||
/// </param>
|
||||
/// <param _label="index">
|
||||
/// Index of shader code in current shader code set.
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void AttachTo(
|
||||
int index,
|
||||
[NotNull]ShaderProgram target
|
||||
)
|
||||
{
|
||||
GL.AttachShader(target.handle, handle[index]);
|
||||
}
|
||||
|
||||
public void CheckStatus(
|
||||
int index,
|
||||
ShaderStatus status
|
||||
)
|
||||
{
|
||||
string log = GL.GetShaderStatus(this, index, (int)status);
|
||||
if (!string.IsNullOrEmpty(log)) {
|
||||
throw new InvalidOperationException($"{$"Shader Error \t{status}\n"}{log}");
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Compile(
|
||||
int index,
|
||||
ReadOnlySpan<byte> codeU8Stream
|
||||
)
|
||||
{
|
||||
GL.LoadShaderSource(handle[index], codeU8Stream);
|
||||
GL.CompileShader(handle[index]);
|
||||
CheckStatus(index, ShaderStatus.CompileStatus);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Compile(
|
||||
int index,
|
||||
byte[] codeStream
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(codeStream);
|
||||
GL.LoadShaderSource(handle[index], codeStream);
|
||||
GL.CompileShader(handle[index]);
|
||||
CheckStatus(index, ShaderStatus.CompileStatus);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Compile(
|
||||
int index,
|
||||
string codeStream
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(codeStream);
|
||||
GL.LoadShaderSource(handle[index], codeStream.AsSpan());
|
||||
GL.CompileShader(handle[index]);
|
||||
CheckStatus(index, ShaderStatus.CompileStatus);
|
||||
}
|
||||
|
||||
public void FromBytes(
|
||||
byte[] stream
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static byte[] FromCodeFile(
|
||||
string fileRoute
|
||||
)
|
||||
{
|
||||
string str = File.ReadAllText(fileRoute);
|
||||
if (string.IsNullOrEmpty(str)) {
|
||||
throw new InvalidOperationException($"Cannot load and GLSL code from {fileRoute}");
|
||||
}
|
||||
return Encoding.UTF8.GetBytes(str);
|
||||
}
|
||||
|
||||
public byte[] GetBytes()
|
||||
{
|
||||
return Array.Empty<byte>();
|
||||
}
|
||||
|
||||
public byte[] GetBytes(
|
||||
out int length
|
||||
)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"This is a {type} shader, its shader handles are {handle.ToString()}.";
|
||||
}
|
||||
public GlHandle this[int index] => Handles[index];
|
||||
|
||||
}
|
||||
|
||||
@@ -172,125 +42,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
}
|
||||
|
||||
public class ShaderProgram
|
||||
{
|
||||
|
||||
private readonly OpenGLFunction GL;
|
||||
internal readonly GlHandle handle;
|
||||
|
||||
/// <summary>
|
||||
/// CustomizeInit a program with no shader attached.
|
||||
/// </summary>
|
||||
internal unsafe ShaderProgram(
|
||||
glRender binding
|
||||
)
|
||||
{
|
||||
GL = binding.GL;
|
||||
handle = GL.CreateProgram();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe Uniform<T> GetUniform<T>(
|
||||
string name
|
||||
) where T : unmanaged
|
||||
{
|
||||
return new Uniform<T>(GL.GetUniformLocation(this.handle, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public unsafe Uniform<T, U> GetUniform<T, U>(
|
||||
string name
|
||||
) where T : unmanaged where U : struct
|
||||
{
|
||||
return new Uniform<T, U>(GL.GetUniformLocation(this.handle, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public unsafe Uniform<T, U, V> GetUniform<T, U, V>(
|
||||
string name
|
||||
) where T : unmanaged where U : struct where V : struct
|
||||
{
|
||||
return new Uniform<T, U, V>(GL.GetUniformLocation(this.handle, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public unsafe Uniform<T, U, V, W> GetUniform<T, U, V, W>(
|
||||
string name
|
||||
) where T : unmanaged where U : struct where V : struct where W : struct
|
||||
{
|
||||
return new Uniform<T, U, V, W>(GL.GetUniformLocation(this.handle, name));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Link the shader to current viewPortDisplay.
|
||||
/// </summary>
|
||||
public unsafe void Link()
|
||||
{
|
||||
if (GraphicFramework.InternalLinkShaderProgram(
|
||||
(OpenglContext*)this.GL.ContextHandle, handle.Value) == 0)
|
||||
{
|
||||
IntPtr logPtr = GraphicFramework.InternalReadSSCLog();
|
||||
try
|
||||
{
|
||||
byte[] logByte = new byte[512];
|
||||
Marshal.Copy(logPtr, logByte, 0, 512);
|
||||
string log = Encoding.UTF8.GetString(logByte);
|
||||
log = log.Replace("\0", string.Empty);
|
||||
DefaultLog.InternalWriteLog(log, LogType.Error);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DefaultLog.InternalWriteLog(ex.Message, LogType.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Let the current viewPortDisplay use this shader.
|
||||
/// </summary>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void Use()
|
||||
{
|
||||
GL.UseProgram(handle);
|
||||
}
|
||||
|
||||
~ShaderProgram()
|
||||
{
|
||||
// handle.Dispose();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// An OpenGL shader-program handle.
|
||||
/// </summary>
|
||||
public readonly record struct ShaderProgram(GlHandle Handle);
|
||||
}
|
||||
|
||||
@@ -7,10 +7,17 @@
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public class Uniform
|
||||
public abstract class Uniform
|
||||
{
|
||||
|
||||
internal GlHandle id;
|
||||
internal readonly GlHandle id;
|
||||
|
||||
protected Uniform(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
id = handle;
|
||||
}
|
||||
|
||||
public GlHandle Handle => id;
|
||||
|
||||
@@ -19,48 +26,20 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public sealed class Uniform<T> : Uniform where T : unmanaged
|
||||
{
|
||||
|
||||
internal Uniform() { }
|
||||
|
||||
internal unsafe Uniform(
|
||||
GlHandle id
|
||||
public Uniform(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
internal static Uniform<T> FromHandle(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
return new Uniform<T>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
: base(handle) { }
|
||||
|
||||
}
|
||||
|
||||
public sealed class Uniform<T, U> : Uniform where T : unmanaged where U : struct
|
||||
{
|
||||
|
||||
internal Uniform() { }
|
||||
|
||||
internal unsafe Uniform(
|
||||
GlHandle id
|
||||
public Uniform(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
internal static Uniform<T, U> FromHandle(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
return new Uniform<T, U>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
: base(handle) { }
|
||||
|
||||
}
|
||||
|
||||
@@ -68,24 +47,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
where V : struct
|
||||
{
|
||||
|
||||
internal Uniform() { }
|
||||
|
||||
internal unsafe Uniform(
|
||||
GlHandle id
|
||||
public Uniform(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
internal static Uniform<T, U, V> FromHandle(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
return new Uniform<T, U, V>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
: base(handle) { }
|
||||
|
||||
}
|
||||
|
||||
@@ -94,25 +59,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
where W : struct
|
||||
{
|
||||
|
||||
internal Uniform() { }
|
||||
|
||||
internal unsafe Uniform(
|
||||
GlHandle id
|
||||
public Uniform(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
internal static Uniform<T, U, V, W> FromHandle(
|
||||
GlHandle handle
|
||||
)
|
||||
{
|
||||
return new Uniform<T, U, V, W>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
: base(handle) { }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4532,12 +4532,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
int i
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
if ((i > OpenGLFunction.CurrentGL.AttachmentColorRange) || (i < 0))
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
#endif
|
||||
ArgumentOutOfRangeException.ThrowIfNegative(i);
|
||||
return (uint)(glConst.COLOR_ATTACHMENT0 + i);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,12 +6,6 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
@@ -37,65 +31,4 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
}
|
||||
|
||||
public sealed class GlArrayFormatException : Exception
|
||||
{
|
||||
|
||||
internal GlArrayFormatException(
|
||||
string message
|
||||
)
|
||||
: base(message) { }
|
||||
|
||||
internal GlArrayFormatException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context
|
||||
)
|
||||
: base(info, context) { }
|
||||
|
||||
internal GlArrayFormatException(
|
||||
string message,
|
||||
Exception innerException
|
||||
)
|
||||
: base(message, innerException) { }
|
||||
|
||||
public GlArrayFormatException(
|
||||
PixelChannelLayout layout,
|
||||
string arrayname
|
||||
)
|
||||
: base($"{arrayname} cannot be used as layout of {layout}") { }
|
||||
|
||||
}
|
||||
|
||||
public static partial class GlHelper
|
||||
{
|
||||
|
||||
public static bool CheckArrayFormat(
|
||||
this Array array,
|
||||
PixelChannelLayout layout
|
||||
)
|
||||
{
|
||||
return layout switch
|
||||
{
|
||||
PixelChannelLayout.Byte or PixelChannelLayout.UByte332 or PixelChannelLayout.UByte233Rev => (array is byte[]) ||
|
||||
(array is sbyte[]),
|
||||
PixelChannelLayout.Short => array is short[],
|
||||
PixelChannelLayout.UShort => array is ushort[],
|
||||
PixelChannelLayout.Int => array is int[],
|
||||
PixelChannelLayout.Float => array is float[],
|
||||
PixelChannelLayout.UShort4444 => (array is ushort[]) || (array is byte[]),
|
||||
PixelChannelLayout.UByte => (array is byte[]) || (array is sbyte[]),
|
||||
PixelChannelLayout.UInt => array is uint[],
|
||||
PixelChannelLayout.UShort565 or
|
||||
PixelChannelLayout.UShort565Rev or
|
||||
PixelChannelLayout.UShort4444Rev or
|
||||
PixelChannelLayout.UShort5551 or
|
||||
PixelChannelLayout.UShort1555Rev => array is ushort[],
|
||||
PixelChannelLayout.UInt8888Rev or
|
||||
PixelChannelLayout.UInt1010102 or
|
||||
PixelChannelLayout.UInt2101010Rev => array is int[],
|
||||
PixelChannelLayout.UInt8888 => array is uint[] or byte[],
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,15 +117,6 @@ namespace StgSharp.Graphics.OpenGL
|
||||
CustomizeDeinit();
|
||||
}
|
||||
|
||||
protected sealed override Uniform<GraphicsMatrix> NativeCameraUniform(
|
||||
ShaderProgram source,
|
||||
string name
|
||||
)
|
||||
{
|
||||
NativeCamera.GainAllUniforms(source, name);
|
||||
return NativeCamera.convertedUniform;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected sealed override void NativeCameraViewRange(
|
||||
Radius fieldOfRange,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="glSync"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct glSync
|
||||
{
|
||||
|
||||
public IntPtr Handle;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -38,11 +38,9 @@ namespace StgSharp.Graphics
|
||||
_shape = shape;
|
||||
}
|
||||
|
||||
// private Image _texture;
|
||||
|
||||
public PlainGeometryMesh(
|
||||
PlainGeometry shape,
|
||||
Image texture,
|
||||
Image<Rgba8> texture,
|
||||
Vec2[] texCoord
|
||||
)
|
||||
{
|
||||
@@ -59,10 +57,10 @@ namespace StgSharp.Graphics
|
||||
|
||||
public Vec4[] VertexArray => _shape.VertexStream;
|
||||
|
||||
public Image TextureImage
|
||||
public Image<Rgba8> TextureImage
|
||||
{
|
||||
get => _texture.ProvideImage();
|
||||
internal set => _texture.ReadImage(value);
|
||||
get => _texture.Image;
|
||||
internal set => _texture.Image = value;
|
||||
}
|
||||
|
||||
public ReadOnlySpan<int> MeshIndices => _shape.VertexIndices;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
using StgSharp.Timing;
|
||||
@@ -133,27 +132,6 @@ namespace StgSharp.Graphics
|
||||
Vec3 up
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// Get <see cref="Uniform{T}" />(TView is <see cref="GraphicsMatrix" />) uniform from a
|
||||
/// shader. This uniform will be used as projection matrix of this camera. Additionally,
|
||||
/// for multi- shader rendering, each shader requires a uniform, so do not ignore return
|
||||
/// value of this method.
|
||||
/// </summary>
|
||||
/// <param _label="source">
|
||||
/// Shader using this camera
|
||||
/// </param>
|
||||
/// <param _label="name">
|
||||
/// ContextName of projection camera named in shader
|
||||
/// </param>
|
||||
/// <returns>
|
||||
/// <see cref="Uniform{T}" />(TView is <see cref="GraphicsMatrix" />) representing
|
||||
/// projection matrix in shader program.
|
||||
/// </returns>
|
||||
protected abstract Uniform<GraphicsMatrix> NativeCameraUniform(
|
||||
ShaderProgram source,
|
||||
string name
|
||||
);
|
||||
|
||||
#endregion
|
||||
|
||||
#region internal operation
|
||||
@@ -200,15 +178,5 @@ namespace StgSharp.Graphics
|
||||
|
||||
#endregion
|
||||
|
||||
#region public resource generator
|
||||
|
||||
protected abstract Shader CreateShaderSegment(
|
||||
ShaderType type,
|
||||
int count
|
||||
);
|
||||
|
||||
protected abstract ShaderProgram CreateShaderProgram();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="Rgba8"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
/// <summary>
|
||||
/// Four-channel, eight-bit-per-channel RGBA pixel storage.
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1, Size = 4)]
|
||||
public struct Rgba8
|
||||
{
|
||||
|
||||
public byte R;
|
||||
public byte G;
|
||||
public byte B;
|
||||
public byte A;
|
||||
|
||||
public Rgba8(
|
||||
byte red,
|
||||
byte green,
|
||||
byte blue,
|
||||
byte alpha
|
||||
)
|
||||
{
|
||||
R = red;
|
||||
G = green;
|
||||
B = blue;
|
||||
A = alpha;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,25 @@
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public class TextureProvider : IImageProvider
|
||||
public class TextureProvider
|
||||
{
|
||||
|
||||
private Vec2[] _texCoord;
|
||||
private Image _tex;
|
||||
private Image<Rgba8> _image;
|
||||
|
||||
public TextureProvider(
|
||||
Image image,
|
||||
Image<Rgba8> image,
|
||||
Vec2[] coord
|
||||
)
|
||||
{
|
||||
_tex = image;
|
||||
ArgumentNullException.ThrowIfNull(image);
|
||||
ArgumentNullException.ThrowIfNull(coord);
|
||||
|
||||
_image = image;
|
||||
_texCoord = coord;
|
||||
}
|
||||
|
||||
@@ -38,32 +40,13 @@ namespace StgSharp.Graphics
|
||||
|
||||
public Span<Vec2> TextureCoordinate => new Span<Vec2>(_texCoord);
|
||||
|
||||
public Image ProvideImage()
|
||||
public Image<Rgba8> Image
|
||||
{
|
||||
return _tex;
|
||||
}
|
||||
|
||||
public void ReadImage(
|
||||
IImageProvider provider
|
||||
)
|
||||
{
|
||||
_tex = provider.ProvideImage();
|
||||
}
|
||||
|
||||
public void UpdateFromImage(
|
||||
[NotNull]Image i
|
||||
)
|
||||
{
|
||||
if (i == _tex) {
|
||||
return;
|
||||
}
|
||||
if (i.Size == _tex.Size)
|
||||
get => _image;
|
||||
set
|
||||
{
|
||||
_tex = i;
|
||||
} else
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"Size of {nameof(i)} does not equals to current image.");
|
||||
ArgumentNullException.ThrowIfNull(value);
|
||||
_image = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace StgSharp.Graphics
|
||||
public class GraphicModule : IStaticModule
|
||||
{
|
||||
|
||||
public string ModuleName => "Graphic";
|
||||
public string ModuleName => "Graphics";
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InitializeModule(
|
||||
@@ -24,6 +24,9 @@ namespace StgSharp.Graphics
|
||||
)
|
||||
{
|
||||
GraphicFramework.LoadGlfw();
|
||||
if (GraphicFramework.glfwInit() == 0) {
|
||||
throw new InvalidOperationException("Failed to initialize GLFW.");
|
||||
}
|
||||
}
|
||||
|
||||
public void UninitializeModule()
|
||||
@@ -325,7 +328,7 @@ namespace StgSharp.Graphics
|
||||
internal static unsafe void glfwSetWindowIcon(
|
||||
IntPtr window,
|
||||
int count,
|
||||
GLFWimage* images
|
||||
GlfwImageNative* images
|
||||
)
|
||||
{
|
||||
_glfw.glfwSetWindowIcon(window, count, (IntPtr)images);
|
||||
@@ -750,7 +753,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static unsafe IntPtr glfwCreateCursor(
|
||||
GLFWimage* image,
|
||||
GlfwImageNative* image,
|
||||
int xhot,
|
||||
int yhot
|
||||
)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="glfw.struct"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
// GLFW owns these objects. The managed layer only passes opaque pointers to them.
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct glfwVideomode { }
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct glfwGammaramp { }
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
internal unsafe struct GlfwImageNative
|
||||
{
|
||||
|
||||
internal int Width;
|
||||
internal int Height;
|
||||
internal byte* Pixels;
|
||||
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct GLFWgamepadstate { }
|
||||
}
|
||||
@@ -133,10 +133,6 @@ target_compile_definitions(${PROJECT_NAME}
|
||||
set(STGSHARP_NATIVE_EXTERNAL_TARGET ${PROJECT_NAME})
|
||||
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/lib)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE opengl32)
|
||||
endif()
|
||||
|
||||
message(STATUS "StgSharp.Native target OS: ${SN_RESOLVED_OS_NAME} (${SN_RESOLVED_OS_DEFINE})")
|
||||
message(STATUS "StgSharp.Native target ISA: ${SN_RESOLVED_ARCH_NAME} (${SN_RESOLVED_ARCH_DEFINE})")
|
||||
message(STATUS "StgSharp.Native output dir: ${STGSHARP_BUILD_OUTPUT_DIR}")
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
<Link>
|
||||
<!-- DLL 应该用 Windows,不是 Console -->
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<AdditionalDependencies>opengl32.lib;$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>$(CoreLibraryDependencies);%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<!-- Debug 特有 -->
|
||||
@@ -185,7 +185,6 @@
|
||||
<ClCompile Include="sn-src\load_glfw.c" />
|
||||
<ClCompile Include="sn-src\simdid.x86.c" />
|
||||
<ClCompile Include="sn-src\simdid_compare.x86.c" />
|
||||
<ClCompile Include="sn-src\sn_native.c" />
|
||||
<ClCompile Include="sn-src\thread.linux.c" />
|
||||
<ClCompile Include="sn-src\thread.windows.c" />
|
||||
<ClCompile Include="sn-src\vector.c" />
|
||||
@@ -198,9 +197,7 @@
|
||||
<ClInclude Include="lib\glfw\glfw3.h" />
|
||||
<ClInclude Include="lib\glfw\glfw3native.h" />
|
||||
<ClInclude Include="lib\stbi\stb_image.h" />
|
||||
<ClInclude Include="sn-head\gl.h" />
|
||||
<ClInclude Include="sn-head\glfw_function.h" />
|
||||
<ClInclude Include="sn-head\khrplatform.h" />
|
||||
<ClInclude Include="sn-head\sn_internal.h" />
|
||||
<ClInclude Include="sn-head\sn_intrinsic.context.x86.h" />
|
||||
<ClInclude Include="sn-head\sn_intrinsic.std.h" />
|
||||
@@ -208,7 +205,6 @@
|
||||
<ClInclude Include="sn-head\sn_intrinsic.matkernel.h" />
|
||||
<ClInclude Include="sn-head\sn_target.h" />
|
||||
<ClInclude Include="sn-head\StgSharpNative.h" />
|
||||
<ClInclude Include="sn-head\wgl.h" />
|
||||
<ClInclude Include="sn-template\sn_template.fma.x86.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -218,4 +214,4 @@
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -36,9 +36,6 @@
|
||||
<ClCompile Include="sn-src\vector_dot.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sn-src\sn_native.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sn-src\load_glfw.c">
|
||||
<Filter>源文件</Filter>
|
||||
</ClCompile>
|
||||
@@ -77,21 +74,12 @@
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="sn-head\gl.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sn-head\khrplatform.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sn-head\sn_internal.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sn-head\StgSharpNative.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sn-head\wgl.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sn-head\glfw_function.h">
|
||||
<Filter>头文件</Filter>
|
||||
</ClInclude>
|
||||
@@ -139,4 +127,4 @@
|
||||
<Filter>Document</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -8,13 +8,6 @@
|
||||
#include "sn_internal.h"
|
||||
#include "sn_target.h"
|
||||
|
||||
#define STBIDEF SN_API
|
||||
#include "../lib/stbi/stb_image.h"
|
||||
|
||||
#include "gl.h"
|
||||
// #include "wgl.h"
|
||||
// #define GLFWAPI INTERNAL
|
||||
#include "glfw\glfw3.h"
|
||||
#include <immintrin.h>
|
||||
#include <assert.h>
|
||||
#include <glfw_function.h>
|
||||
@@ -26,24 +19,6 @@
|
||||
#ifndef SN_
|
||||
#endif
|
||||
|
||||
typedef struct Image {
|
||||
int width;
|
||||
int height;
|
||||
int channel;
|
||||
char *pixelPtr;
|
||||
} Image;
|
||||
|
||||
typedef char *(*imageLoader)(char const *filename, int *x, int *y, int *channels_in_file,
|
||||
int desired_channels);
|
||||
|
||||
extern SN_API char infolog[512];
|
||||
SN_API int SN_DECL glCheckShaderStat(GladGLContext *context, uint64_t shaderHandle, int key,
|
||||
char **logRef);
|
||||
SN_API void SN_DECL initGL(int majorVersion, int minorVersion);
|
||||
SN_API void SN_DECL loadImageData(char *location, Image *out, imageLoader loader);
|
||||
SN_API GLFWglproc SN_DECL loadGlfuncDefault(char *procName);
|
||||
SN_API void SN_DECL unloadImageData(Image *out);
|
||||
SN_API char *SN_DECL readLog(void);
|
||||
SN_API void SN_DECL load_glfw_functions(GLFWFunctionTable *table);
|
||||
SN_API void SN_DECL load_intrinsic_function(void *intrinsic_context, uint64_t id);
|
||||
SN_API SIMDID SN_DECL sn_get_simd_level_global();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,10 @@
|
||||
#ifndef GLFW_FUNCTION_TABLE_H
|
||||
#define GLFW_FUNCTION_TABLE_H
|
||||
|
||||
#ifndef GLFW_INCLUDE_NONE
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#endif
|
||||
|
||||
#include "../lib/glfw/glfw3.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,310 +0,0 @@
|
||||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
#define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
#define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
#define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined(__SYMBIAN32__)
|
||||
#define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
#define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
#define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
#define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
#define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined(__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || \
|
||||
defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
/*
|
||||
* To support platform where unsigned long cannot be used interchangeably with
|
||||
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
|
||||
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
|
||||
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
|
||||
* unsigned long long or similar (this results in different C++ name mangling).
|
||||
* To avoid changes for existing platforms, we restrict usage of intptr_t to
|
||||
* platforms where the size of a pointer is larger than the size of long.
|
||||
*/
|
||||
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
|
||||
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
|
||||
#define KHRONOS_USE_INTPTR_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(__VMS) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef KHRONOS_USE_INTPTR_T
|
||||
typedef intptr_t khronos_intptr_t;
|
||||
typedef uintptr_t khronos_uintptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
||||
#include "StgSharpNative.h"
|
||||
#include "glfw_function.h"
|
||||
|
||||
SN_API void SN_DECL load_glfw_functions(GLFWFunctionTable *table)
|
||||
{
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
#ifndef STB_IMAGE_IMPLEMENTATION
|
||||
#define STB_IMAGE_IMPLEMENTATION
|
||||
#endif
|
||||
#include "StgSharpNative.h"
|
||||
#include "gl.h"
|
||||
#include "../lib/glfw/glfw3.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
extern GladGLContext *currentContext;
|
||||
char infolog[512];
|
||||
|
||||
SN_API int SN_DECL glCheckShaderStat(GladGLContext *context, uint64_t shaderHandle, int key,
|
||||
char **logRef)
|
||||
{
|
||||
int stat = 0;
|
||||
context->GetShaderiv(shaderHandle, key, &stat);
|
||||
if (!stat) {
|
||||
context->GetShaderInfoLog(shaderHandle, 512, NULL, infolog);
|
||||
}
|
||||
*logRef = infolog;
|
||||
return stat;
|
||||
}
|
||||
|
||||
SN_API void SN_DECL initGL(int majorVersion, int minorVersion)
|
||||
{
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, majorVersion);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minorVersion);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||
}
|
||||
|
||||
SN_API GLFWglproc SN_DECL loadGlfuncDefault(char *procName)
|
||||
{
|
||||
void *ret = glfwGetProcAddress(procName);
|
||||
// printf("%llu\n", (uint64_t)ret);
|
||||
if (ret == NULL) {
|
||||
strcpy_s(infolog, 30, "Failed to load OpenGL api:");
|
||||
for (size_t i = 0; i < sizeof(procName); i++) {
|
||||
infolog[30 + i] = procName[i];
|
||||
}
|
||||
//printf("%s\n", infolog);
|
||||
}
|
||||
return (GLFWglproc)ret;
|
||||
}
|
||||
|
||||
|
||||
SN_API void SN_DECL loadImageData(char *location, Image *out, imageLoader loader)
|
||||
{
|
||||
if (loader == NULL) {
|
||||
loader = (imageLoader)stbi_load;
|
||||
}
|
||||
out->pixelPtr = loader(location, &(out->width), &(out->height), &(out->channel), 0);
|
||||
}
|
||||
SN_API void SN_DECL unloadImageData(Image *out)
|
||||
{
|
||||
free(out->pixelPtr);
|
||||
}
|
||||
|
||||
SN_API char *SN_DECL readLog()
|
||||
{
|
||||
infolog[511] = '\0';
|
||||
return infolog;
|
||||
}
|
||||
@@ -1,192 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="CsTypeMapper"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using System;
|
||||
|
||||
namespace GenerateGL.CodeGen
|
||||
{
|
||||
internal static class CsTypeMapper
|
||||
{
|
||||
|
||||
public static string MapDelegateParameter(
|
||||
GlParam param
|
||||
)
|
||||
{
|
||||
int pointerLevel = param.PointerLevel;
|
||||
if (param.CType.Equals("GLchar", StringComparison.Ordinal) && pointerLevel > 0) {
|
||||
return $"byte{new string('*', pointerLevel)}";
|
||||
}
|
||||
|
||||
string mapped = MapType(param.CType);
|
||||
if (pointerLevel > 0)
|
||||
{
|
||||
if (mapped == "void") {
|
||||
return $"void{new string('*', pointerLevel)}";
|
||||
}
|
||||
return $"{mapped}{new string('*', pointerLevel)}";
|
||||
}
|
||||
return mapped;
|
||||
}
|
||||
|
||||
public static string MapDelegateReturn(
|
||||
string cType,
|
||||
int pointerLevel
|
||||
)
|
||||
{
|
||||
string mapped = MapType(cType);
|
||||
if (pointerLevel > 0) {
|
||||
return $"{mapped}{new string('*', pointerLevel)}";
|
||||
}
|
||||
return mapped;
|
||||
}
|
||||
|
||||
public static string MapParameter(
|
||||
GlParam param
|
||||
)
|
||||
{
|
||||
if (param.PointerLevel == 0)
|
||||
{
|
||||
if (param.CType.Equals("GLuint", StringComparison.Ordinal) &&
|
||||
LooksLikeHandle(param.Name) &&
|
||||
!param.IsPointer) {
|
||||
return "GlHandle";
|
||||
}
|
||||
}
|
||||
|
||||
int pointerLevel = param.PointerLevel;
|
||||
if (param.CType.Equals("GLchar", StringComparison.Ordinal) && pointerLevel > 0) {
|
||||
return $"byte{new string('*', pointerLevel)}";
|
||||
}
|
||||
|
||||
string mapped = MapType(param.CType);
|
||||
if (pointerLevel > 0)
|
||||
{
|
||||
if (mapped == "void") {
|
||||
return $"void{new string('*', pointerLevel)}";
|
||||
}
|
||||
return $"{mapped}{new string('*', pointerLevel)}";
|
||||
}
|
||||
return mapped;
|
||||
}
|
||||
|
||||
public static string MapReturn(
|
||||
string cType,
|
||||
int pointerLevel
|
||||
)
|
||||
{
|
||||
string mapped = MapType(cType);
|
||||
if (pointerLevel > 0) {
|
||||
return $"{mapped}{new string('*', pointerLevel)}";
|
||||
}
|
||||
return mapped;
|
||||
}
|
||||
|
||||
public static bool IsHandleReturn(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
if (command.ReturnPointerLevel != 0 ||
|
||||
!command.ReturnType.Equals("GLuint", StringComparison.Ordinal)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return command.Name is "glCreateProgram" or "glCreateShader" or
|
||||
"glCreateShaderProgramv";
|
||||
}
|
||||
|
||||
public static bool TryMapPointerElement(
|
||||
GlParam param,
|
||||
out string elementType
|
||||
)
|
||||
{
|
||||
elementType = string.Empty;
|
||||
if (param.PointerLevel != 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
string mapped = MapType(param.CType);
|
||||
if (mapped is "void") {
|
||||
return false;
|
||||
}
|
||||
|
||||
elementType = mapped;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool LooksLikeHandle(
|
||||
string name
|
||||
)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return name.Contains("program", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("shader", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("buffer", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("texture", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("framebuffer", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("renderbuffer", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("vertexarray", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("query", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("sampler", StringComparison.OrdinalIgnoreCase) ||
|
||||
name.Contains("transformfeedback", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static string MapType(
|
||||
string cType
|
||||
)
|
||||
{
|
||||
return cType switch
|
||||
{
|
||||
"GLenum" or "GLbitfield" => "uint",
|
||||
"GLboolean" => "byte",
|
||||
"GLuint" or "GLhandleARB" => "uint",
|
||||
"GLint" or "GLsizei" or "GLfixed" => "int",
|
||||
"GLint64" => "long",
|
||||
"GLuint64" => "ulong",
|
||||
"GLshort" => "short",
|
||||
"GLbyte" => "sbyte",
|
||||
"GLubyte" => "byte",
|
||||
"GLushort" => "ushort",
|
||||
"GLfloat" => "float",
|
||||
"GLdouble" => "double",
|
||||
"GLhalf" => "ushort",
|
||||
"GLclampf" => "float",
|
||||
"GLclampd" => "double",
|
||||
"GLintptr" => "nint",
|
||||
"GLsizeiptr" => "nint",
|
||||
"GLchar" => "byte",
|
||||
"GLsync" => "glSync",
|
||||
"GLDEBUGPROC" => "IntPtr",
|
||||
"void" => "void",
|
||||
_ => throw new NotSupportedException($"Unsupported OpenGL C type: {cType}")
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,532 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Generator"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace GenerateGL.CodeGen
|
||||
{
|
||||
internal sealed class Generator
|
||||
{
|
||||
|
||||
private static readonly string[] TargetVersions = {
|
||||
"3.3", "4.0", "4.1", "4.2", "4.3", "4.4", "4.5", "4.6"
|
||||
};
|
||||
|
||||
private static readonly FrozenDictionary<string, string> ReservedNames =
|
||||
new Dictionary<string, string>(StringComparer.Ordinal) {
|
||||
{ "string", "@string" }, { "class", "@class" }, { "namespace", "@namespace" }, { "checked", "@checked" }, { "unchecked", "@unchecked" }, { "ref", "@ref" }, { "out", "@out" }, { "in", "@in" }, { "object", "@object" }, { "event", "@event" }, { "params", "@params" }, { "base", "@base" }, { "this", "@this" }, { "void", "@void" }, { "int", "@int" }, { "uint", "@uint" }, { "long", "@long" }, { "ulong", "@ulong" }, { "short", "@short" }, { "ushort", "@ushort" }, { "float", "@float" }, { "double", "@double" }, { "decimal", "@decimal" }, { "bool", "@bool" }, { "byte", "@byte" }, { "sbyte", "@sbyte" }, { "char", "@char" }, { "struct", "@struct" }, { "public", "@public" }, { "private", "@private" }, { "protected", "@protected" }, { "internal", "@internal" }, { "fixed", "@fixed" }
|
||||
}.ToFrozenDictionary(StringComparer.Ordinal);
|
||||
|
||||
private readonly IReadOnlyDictionary<string, GlCommand> _commands;
|
||||
private readonly IReadOnlyList<GlFeature> _features;
|
||||
private readonly string _outputRoot;
|
||||
|
||||
public Generator(
|
||||
IReadOnlyDictionary<string, GlCommand> commands,
|
||||
IReadOnlyList<GlFeature> features,
|
||||
string outputRoot
|
||||
)
|
||||
{
|
||||
_commands = commands;
|
||||
_features = features;
|
||||
_outputRoot = outputRoot;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
if (Directory.Exists(_outputRoot)) {
|
||||
Directory.Delete(_outputRoot, recursive:true);
|
||||
}
|
||||
Directory.CreateDirectory(_outputRoot);
|
||||
List<GlCommand> all = new List<GlCommand>();
|
||||
List<(string Version, List<GlCommand> Commands)> commandsByVersion = new();
|
||||
HashSet<string> previous = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (string v in TargetVersions)
|
||||
{
|
||||
IReadOnlyList<GlCommand> cmdsUpTo = CollectCommandsUpToVersion(v);
|
||||
List<GlCommand> versionCmds = cmdsUpTo.Where(c => !previous.Contains(c.Name))
|
||||
.ToList();
|
||||
foreach (GlCommand cmd in versionCmds) {
|
||||
previous.Add(cmd.Name);
|
||||
}
|
||||
all.AddRange(versionCmds);
|
||||
commandsByVersion.Add((v, versionCmds));
|
||||
}
|
||||
|
||||
IReadOnlyDictionary<string, string> managedNames = ManagedNameResolver.Resolve(
|
||||
all.Where(ShouldGenerateWrapper));
|
||||
foreach ((string version, List<GlCommand> commands) in commandsByVersion)
|
||||
{
|
||||
WriteOpenGLFunctionFile(version, commands, managedNames);
|
||||
UniformOverloadEmitter.Write(_outputRoot, version, commands);
|
||||
}
|
||||
WriteMergedGlContextFile(all);
|
||||
WriteCommandHistoryFile(BuildCommandHistory());
|
||||
}
|
||||
|
||||
private IReadOnlyDictionary<string, List<CommandHistoryEntry>> BuildCommandHistory()
|
||||
{
|
||||
Dictionary<string, List<CommandHistoryEntry>> history = new(StringComparer.Ordinal);
|
||||
|
||||
IEnumerable<GlFeature> ordered = _features.Where(f => Version.TryParse(f.Version, out _))
|
||||
.OrderBy(f => Version.Parse(f.Version));
|
||||
|
||||
foreach (GlFeature feature in ordered)
|
||||
{
|
||||
string version = feature.Version;
|
||||
|
||||
foreach (string name in feature.RequiresCommands.Distinct(StringComparer.Ordinal))
|
||||
{
|
||||
if (!_commands.ContainsKey(name) || ShouldSkip(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!history.TryGetValue(name, out List<CommandHistoryEntry>? list))
|
||||
{
|
||||
list = new List<CommandHistoryEntry>();
|
||||
history[name] = list;
|
||||
}
|
||||
|
||||
if (list.Count == 0 ||
|
||||
list[^1].Action != CommandHistoryAction.Added ||
|
||||
list[^1].Version != version) {
|
||||
list.Add(new CommandHistoryEntry(version, CommandHistoryAction.Added));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string name in feature.RemovedCommands.Distinct(StringComparer.Ordinal))
|
||||
{
|
||||
if (!_commands.ContainsKey(name) || ShouldSkip(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!history.TryGetValue(name, out List<CommandHistoryEntry>? list))
|
||||
{
|
||||
list = new List<CommandHistoryEntry>();
|
||||
history[name] = list;
|
||||
}
|
||||
|
||||
if (list.Count == 0 ||
|
||||
list[^1].Action != CommandHistoryAction.Removed ||
|
||||
list[^1].Version != version) {
|
||||
list.Add(new CommandHistoryEntry(version, CommandHistoryAction.Removed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return history;
|
||||
}
|
||||
|
||||
private IReadOnlyList<GlCommand> CollectCommandsUpToVersion(
|
||||
string version
|
||||
)
|
||||
{
|
||||
Version target = Version.Parse(version);
|
||||
IEnumerable<GlFeature> ordered = _features.Where(f => Version.TryParse(f.Version, out Version? fv) &&
|
||||
fv <= target)
|
||||
.OrderBy(f => Version.Parse(f.Version));
|
||||
|
||||
HashSet<string> active = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
foreach (GlFeature feature in ordered)
|
||||
{
|
||||
foreach (string name in feature.RequiresCommands.Distinct(StringComparer.Ordinal))
|
||||
{
|
||||
if (_commands.ContainsKey(name)) {
|
||||
active.Add(name);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string name in feature.RemovedCommands.Distinct(StringComparer.Ordinal)) {
|
||||
active.Remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
return active.Select(name => _commands.TryGetValue(name, out GlCommand? c) ? c : null)
|
||||
.Where(c => c != null)!
|
||||
.Cast<GlCommand>()
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static string DelegateSignature(
|
||||
string ret,
|
||||
IReadOnlyList<string> paramTypes
|
||||
)
|
||||
{
|
||||
if (paramTypes.Count == 0) {
|
||||
return $"delegate*<{ret}>";
|
||||
}
|
||||
return $"delegate*<{string.Join(", ", paramTypes)}, {ret}>";
|
||||
}
|
||||
|
||||
private static string SafeName(
|
||||
string name
|
||||
)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name)) {
|
||||
return "arg";
|
||||
}
|
||||
|
||||
if (ReservedNames.TryGetValue(name, out string? mapped)) {
|
||||
return mapped;
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
private static bool ShouldSkip(
|
||||
string name
|
||||
)
|
||||
{
|
||||
// No skipping; include legacy/fixed-function APIs as well.
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string TrimGlPrefix(
|
||||
string name
|
||||
)
|
||||
{
|
||||
if (name.StartsWith("gl", StringComparison.Ordinal) && name.Length > 2) {
|
||||
return name.Substring(2);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
private void WriteCommandHistoryFile(
|
||||
IReadOnlyDictionary<string, List<CommandHistoryEntry>> history
|
||||
)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("// <auto-generated>");
|
||||
sb.AppendLine($"// Generated by StgSharp.GenerateGL on {DateTime.UtcNow.ToString("u", CultureInfo.InvariantCulture)}");
|
||||
sb.AppendLine("// Command availability history");
|
||||
sb.AppendLine("// </auto-generated>");
|
||||
sb.AppendLine("using System;\nusing System.Collections.Frozen;\nusing System.Collections.Generic;\n");
|
||||
sb.AppendLine("namespace StgSharp.Graphics.OpenGL");
|
||||
sb.AppendLine("{");
|
||||
sb.AppendLine(" internal enum CommandHistoryAction { Added, Removed }");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(" internal readonly record struct CommandHistoryEntry(string Version, CommandHistoryAction Action);");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine(" internal static class GlCommandHistory");
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" internal static readonly FrozenDictionary<string, CommandHistoryEntry[]> History = new Dictionary<string, CommandHistoryEntry[]>(StringComparer.Ordinal)");
|
||||
sb.AppendLine(" {");
|
||||
|
||||
foreach (KeyValuePair<string, List<CommandHistoryEntry>> kvp in history.OrderBy(k => k.Key, StringComparer.Ordinal))
|
||||
{
|
||||
string events = string.Join(", ", kvp.Value
|
||||
.OrderBy(v => Version.Parse(v.Version))
|
||||
.Select(v => $"new CommandHistoryEntry(\"{v.Version}\", CommandHistoryAction.{v.Action})"));
|
||||
sb.AppendLine($" {{ \"{kvp.Key}\", new CommandHistoryEntry[] {{ {events} }} }},");
|
||||
}
|
||||
|
||||
sb.AppendLine(" }.ToFrozenDictionary(StringComparer.Ordinal);");
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine("}");
|
||||
|
||||
string fileName = Path.Combine(_outputRoot, "GlCommandHistory.g.cs");
|
||||
File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
|
||||
private void WriteMergedGlContextFile(
|
||||
IReadOnlyList<GlCommand> commands
|
||||
)
|
||||
{
|
||||
List<GlCommand> distinct = commands.Where(c => !ShouldSkip(c.Name))
|
||||
.GroupBy(c => c.Name, StringComparer.Ordinal)
|
||||
.Select(g => g.First())
|
||||
.OrderBy(c => c.Name, StringComparer.Ordinal)
|
||||
.ToList();
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("// <auto-generated>");
|
||||
sb.AppendLine($"// Generated by StgSharp.GenerateGL on {DateTime.UtcNow.ToString("u", CultureInfo.InvariantCulture)}");
|
||||
sb.AppendLine("// Aggregated GL3+ commands");
|
||||
sb.AppendLine("// </auto-generated>");
|
||||
sb.AppendLine("using System;\nusing System.Runtime.CompilerServices;\n");
|
||||
sb.AppendLine("namespace StgSharp.Graphics.OpenGL");
|
||||
sb.AppendLine("{");
|
||||
sb.AppendLine(" public unsafe partial struct OpenglContext");
|
||||
sb.AppendLine(" {");
|
||||
foreach (GlCommand cmd in distinct)
|
||||
{
|
||||
string ret = CsTypeMapper.MapDelegateReturn(cmd.ReturnType, cmd.ReturnPointerLevel);
|
||||
List<string> paramTypes = new List<string>();
|
||||
foreach (GlParam p in cmd.Parameters)
|
||||
{
|
||||
string mapped = CsTypeMapper.MapDelegateParameter(p);
|
||||
paramTypes.Add(mapped);
|
||||
}
|
||||
string decl = DelegateSignature(ret, paramTypes);
|
||||
sb.AppendLine($" internal unsafe {decl} {cmd.Name};");
|
||||
}
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine("}");
|
||||
|
||||
string fileName = Path.Combine(_outputRoot, "OpenglContext.g.cs");
|
||||
File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
|
||||
private void WriteOpenGLFunctionFile(
|
||||
string version,
|
||||
IReadOnlyList<GlCommand> commands,
|
||||
IReadOnlyDictionary<string, string> managedNames
|
||||
)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("// <auto-generated>");
|
||||
sb.AppendLine($"// Generated by StgSharp.GenerateGL on {DateTime.UtcNow.ToString("u", CultureInfo.InvariantCulture)}");
|
||||
sb.AppendLine($"// Version: {version}");
|
||||
sb.AppendLine("// </auto-generated>");
|
||||
sb.AppendLine("using System;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\nusing StgSharp.Graphics.OpenGL;\n");
|
||||
sb.AppendLine("namespace StgSharp.Graphics.OpenGL");
|
||||
sb.AppendLine("{");
|
||||
sb.AppendLine(" public unsafe partial class OpenGLFunction");
|
||||
sb.AppendLine(" {");
|
||||
foreach (GlCommand cmd in commands.Where(ShouldGenerateWrapper)
|
||||
.OrderBy(c => c!.Name, StringComparer.Ordinal))
|
||||
{
|
||||
bool returnsHandle = CsTypeMapper.IsHandleReturn(cmd);
|
||||
string ret = returnsHandle
|
||||
? "GlHandle"
|
||||
: CsTypeMapper.MapReturn(cmd.ReturnType, cmd.ReturnPointerLevel);
|
||||
string rawName = cmd.Name; // original glXxx
|
||||
string methodName = managedNames[rawName];
|
||||
ManagedCommandPlan commandPlan = ManagedCommandPlan.Create(cmd);
|
||||
List<string> paramList = new List<string>();
|
||||
List<string> callArgs = new List<string>();
|
||||
List<(string Type,string Name,bool IsOut)> pinned = new();
|
||||
foreach (ManagedParameterPlan parameterPlan in commandPlan.PublicParameters)
|
||||
{
|
||||
GlParam p = parameterPlan.Source;
|
||||
string pname = SafeName(p.Name);
|
||||
paramList.Add($"{parameterPlan.PublicType} {pname}");
|
||||
if (parameterPlan.IsSpan)
|
||||
{
|
||||
pinned.Add((parameterPlan.ElementType!, pname, false));
|
||||
} else if (parameterPlan.Kind == ManagedParameterKind.Out) {
|
||||
pinned.Add((parameterPlan.ElementType!, pname, true));
|
||||
}
|
||||
}
|
||||
foreach (GlParam p in cmd.Parameters)
|
||||
{
|
||||
string pname = SafeName(p.Name);
|
||||
if (commandPlan.DerivedLengthSources.TryGetValue(
|
||||
p.Name, out string? sourceSpanName))
|
||||
{
|
||||
string nativeType = CsTypeMapper.MapParameter(p);
|
||||
callArgs.Add($"checked(({nativeType}){SafeName(sourceSpanName)}.Length)");
|
||||
continue;
|
||||
}
|
||||
|
||||
ManagedParameterPlan parameterPlan = commandPlan.GetParameter(p.Name);
|
||||
if (parameterPlan.IsSpan || parameterPlan.Kind == ManagedParameterKind.Out)
|
||||
{
|
||||
callArgs.Add($"{pname}Ptr");
|
||||
} else if (parameterPlan.PublicType == "GlHandle")
|
||||
{
|
||||
callArgs.Add($"{pname}.Value");
|
||||
} else
|
||||
{
|
||||
callArgs.Add(pname);
|
||||
}
|
||||
}
|
||||
string signature = string.Join(", ", paramList);
|
||||
string call = string.Join(", ", callArgs);
|
||||
sb.AppendLine($" [MethodImpl(MethodImplOptions.AggressiveInlining)]");
|
||||
sb.AppendLine($" public {ret} {methodName}({signature})");
|
||||
sb.AppendLine(" {");
|
||||
foreach ((string _, string name, bool isOut) in pinned.Where(p => p.IsOut)) {
|
||||
sb.AppendLine($" {name} = default;");
|
||||
}
|
||||
AppendSpanLengthGuards(sb, cmd, commandPlan);
|
||||
string prefix = ret == "void" ? string.Empty : "return ";
|
||||
string callExpression = $"Context.{rawName}({call})";
|
||||
if (returnsHandle) {
|
||||
callExpression = $"GlHandle.Create({callExpression})";
|
||||
}
|
||||
if (pinned.Count == 0)
|
||||
{
|
||||
sb.AppendLine($" {prefix}{callExpression};");
|
||||
} else
|
||||
{
|
||||
string indent = " ";
|
||||
foreach ((string Type, string Name, bool IsOut) pin in pinned)
|
||||
{
|
||||
string pinSource = pin.IsOut ? $"&{pin.Name}" : pin.Name;
|
||||
sb.AppendLine($"{indent}fixed ({pin.Type}* {pin.Name}Ptr = {pinSource})");
|
||||
sb.AppendLine($"{indent}{{");
|
||||
indent += " ";
|
||||
}
|
||||
sb.AppendLine($"{indent}{prefix}{callExpression};");
|
||||
for (int i = 0; i < pinned.Count; i++)
|
||||
{
|
||||
indent = indent.Substring(0, indent.Length - 4);
|
||||
sb.AppendLine($"{indent}}}");
|
||||
}
|
||||
}
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine();
|
||||
}
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine("}");
|
||||
|
||||
string fileName = Path.Combine(
|
||||
_outputRoot,
|
||||
$"OpenGLFunction.Raw.v{version.Replace('.', '_')}.g.cs");
|
||||
File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
|
||||
private static void AppendSpanLengthGuards(
|
||||
StringBuilder sb,
|
||||
GlCommand command,
|
||||
ManagedCommandPlan plan
|
||||
)
|
||||
{
|
||||
foreach ((string lengthName, string sourceName) in plan.DerivedLengthSources)
|
||||
{
|
||||
foreach (ManagedParameterPlan related in command.Parameters
|
||||
.Select(p => plan.GetParameter(p.Name))
|
||||
.Where(p => p.IsSpan && p.Source.Length == lengthName &&
|
||||
p.Source.Name != sourceName))
|
||||
{
|
||||
string relatedName = SafeName(related.Source.Name);
|
||||
string safeSourceName = SafeName(sourceName);
|
||||
sb.AppendLine($" if ({relatedName}.Length != {safeSourceName}.Length) {{");
|
||||
sb.AppendLine($" throw new ArgumentException(\"Span lengths controlled by {lengthName} must match.\", nameof({relatedName}));");
|
||||
sb.AppendLine(" }");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (ManagedParameterPlan parameter in command.Parameters
|
||||
.Select(p => plan.GetParameter(p.Name)).Where(p => p.IsSpan))
|
||||
{
|
||||
string? expectedLength = BuildExpectedLengthExpression(parameter.Source, plan);
|
||||
if (expectedLength is null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
string parameterName = SafeName(parameter.Source.Name);
|
||||
sb.AppendLine($" if ({parameterName}.Length < {expectedLength}) {{");
|
||||
sb.AppendLine($" throw new ArgumentException(\"Span is shorter than the OpenGL length expression '{parameter.Source.Length}'.\", nameof({parameterName}));");
|
||||
sb.AppendLine(" }");
|
||||
}
|
||||
}
|
||||
|
||||
private static string? BuildExpectedLengthExpression(
|
||||
GlParam parameter,
|
||||
ManagedCommandPlan plan
|
||||
)
|
||||
{
|
||||
string length = parameter.Length?.Replace(" ", string.Empty,
|
||||
StringComparison.Ordinal) ?? string.Empty;
|
||||
if (length.Length == 0 || length.StartsWith("COMPSIZE(", StringComparison.Ordinal) ||
|
||||
plan.DerivedLengthSources.ContainsKey(length)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (int.TryParse(length, NumberStyles.None, CultureInfo.InvariantCulture,
|
||||
out int constantLength)) {
|
||||
return constantLength.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
ManagedParameterPlan? scalar = plan.PublicParameters.FirstOrDefault(p =>
|
||||
p.Source.PointerLevel == 0 && p.Source.Name == length);
|
||||
if (scalar is not null) {
|
||||
return $"checked((int){SafeName(length)})";
|
||||
}
|
||||
|
||||
Match multiply = Regex.Match(
|
||||
length, "^(?<name>[A-Za-z_][A-Za-z0-9_]*)\\*(?<factor>[0-9]+)$",
|
||||
RegexOptions.CultureInvariant);
|
||||
if (!multiply.Success) {
|
||||
multiply = Regex.Match(
|
||||
length, "^(?<factor>[0-9]+)\\*(?<name>[A-Za-z_][A-Za-z0-9_]*)$",
|
||||
RegexOptions.CultureInvariant);
|
||||
}
|
||||
if (multiply.Success) {
|
||||
return $"checked((int){SafeName(multiply.Groups["name"].Value)} * {multiply.Groups["factor"].Value})";
|
||||
}
|
||||
|
||||
Match divide = Regex.Match(
|
||||
length, "^(?<name>[A-Za-z_][A-Za-z0-9_]*)/(?<divisor>[0-9]+)$",
|
||||
RegexOptions.CultureInvariant);
|
||||
return divide.Success
|
||||
? $"checked((int){SafeName(divide.Groups["name"].Value)} / {divide.Groups["divisor"].Value})"
|
||||
: null;
|
||||
}
|
||||
|
||||
private bool ShouldGenerateWrapper(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
if (UniformOverloadEmitter.IsSetterCommand(command)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !IsRedundantVertexAttribVectorCommand(command);
|
||||
}
|
||||
|
||||
private bool IsRedundantVertexAttribVectorCommand(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
string name = command.Name;
|
||||
if (!name.StartsWith("glVertexAttrib", StringComparison.Ordinal) ||
|
||||
!name.EndsWith('v')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
string scalarCommandName = name.Substring(0, name.Length - 1);
|
||||
return _commands.ContainsKey(scalarCommandName);
|
||||
}
|
||||
|
||||
private enum CommandHistoryAction
|
||||
{
|
||||
|
||||
Added,
|
||||
Removed
|
||||
|
||||
}
|
||||
|
||||
private readonly record struct CommandHistoryEntry(
|
||||
string Version,
|
||||
CommandHistoryAction Action
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,185 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="GlXmlParser"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace GenerateGL.CodeGen
|
||||
{
|
||||
internal static class GlXmlParser
|
||||
{
|
||||
|
||||
public static (IReadOnlyDictionary<string, GlCommand> Commands, IReadOnlyList<GlFeature> Features) Parse(
|
||||
string xmlPath
|
||||
)
|
||||
{
|
||||
XDocument doc = XDocument.Load(xmlPath, LoadOptions.PreserveWhitespace);
|
||||
Dictionary<string, GlCommand> commands = ParseCommands(doc);
|
||||
List<GlFeature> features = ParseFeatures(doc);
|
||||
return (commands, features);
|
||||
}
|
||||
|
||||
private static string BuildCType(
|
||||
XElement element
|
||||
)
|
||||
{
|
||||
return BuildCType(element, out _, out _, out _);
|
||||
}
|
||||
|
||||
private static string BuildCType(
|
||||
XElement element,
|
||||
out int pointerLevel,
|
||||
out bool isPointer,
|
||||
out bool isConst
|
||||
)
|
||||
{
|
||||
// CType is usually text parts + <ptype>
|
||||
IEnumerable<string> parts = element.Nodes()
|
||||
.Select(n => n switch
|
||||
{
|
||||
XText t => t.Value,
|
||||
XElement el when el.Name == "ptype" => el.Value,
|
||||
_ => string.Empty
|
||||
});
|
||||
string raw = string.Concat(parts).Trim();
|
||||
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)
|
||||
.Trim();
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
private static Dictionary<string, GlCommand> ParseCommands(
|
||||
XDocument doc
|
||||
)
|
||||
{
|
||||
Dictionary<string, GlCommand> dict = new Dictionary<string, GlCommand>(StringComparer.Ordinal);
|
||||
IEnumerable<XElement> commandElements = doc.Root?.Element("commands")?.Elements("command") ??
|
||||
Enumerable.Empty<XElement>();
|
||||
foreach (XElement cmd in commandElements)
|
||||
{
|
||||
XElement? proto = cmd.Element("proto");
|
||||
if (proto is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string name = proto.Element("name")?.Value ?? string.Empty;
|
||||
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 int pointerLevel, out _, out bool isConst);
|
||||
string? length = p.Attribute("len")?.Value;
|
||||
parameters.Add(new GlParam(pName, cType, pointerLevel, isConst, length));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(name)) {
|
||||
dict[name] = new GlCommand(name, returnType, retPtrLevel, retIsConst,
|
||||
parameters);
|
||||
}
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
|
||||
private static List<GlFeature> ParseFeatures(
|
||||
XDocument doc
|
||||
)
|
||||
{
|
||||
List<GlFeature> list = new List<GlFeature>();
|
||||
IEnumerable<XElement> featureElements = doc.Root?.Elements("feature") ??
|
||||
Enumerable.Empty<XElement>();
|
||||
foreach (XElement feature in featureElements)
|
||||
{
|
||||
string? api = feature.Attribute("api")?.Value;
|
||||
if (!string.Equals(api, "gl", StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string? profile = feature.Attribute("profile")?.Value;
|
||||
|
||||
// Only core (or no profile for legacy) to stay aligned with core profile
|
||||
if (!string.IsNullOrEmpty(profile) &&
|
||||
!string.Equals(profile, "core", StringComparison.Ordinal))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
string version = feature.Attribute("number")?.Value ?? string.Empty;
|
||||
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;
|
||||
if (!string.IsNullOrEmpty(name)) {
|
||||
requires.Add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ManagedNameResolver"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace GenerateGL.CodeGen
|
||||
{
|
||||
internal static partial class ManagedNameResolver
|
||||
{
|
||||
|
||||
private static readonly HashSet<string> TypedSuffixFamilies = new(
|
||||
StringComparer.Ordinal) {
|
||||
"ClearBuffer", "ClearNamedFramebuffer", "GetBufferParameter",
|
||||
"GetNamedBufferParameter", "GetQueryBufferObject", "GetQueryObject",
|
||||
"GetSamplerParameter", "GetTexLevelParameter", "GetTexParameter",
|
||||
"GetTextureLevelParameter", "GetTextureParameter", "GetUniform", "GetnUniform",
|
||||
"GetVertexAttrib", "PatchParameter", "PixelStore", "PointParameter",
|
||||
"SamplerParameter", "TexParameter", "TextureParameter"
|
||||
};
|
||||
|
||||
private static readonly Dictionary<string, string[]> ExactCandidates =
|
||||
new Dictionary<string, string[]>(StringComparer.Ordinal) {
|
||||
{ "BlendEquationi", [ "BlendEquation" ] },
|
||||
{ "BlendEquationSeparatei", [ "BlendEquationSeparate" ] },
|
||||
{ "BlendFunci", [ "BlendFunc" ] },
|
||||
{ "BlendFuncSeparatei", [ "BlendFuncSeparate" ] },
|
||||
{ "ClearDepthf", [ "ClearDepth" ] },
|
||||
{ "ColorMaski", [ "ColorMask" ] },
|
||||
{ "DepthRangef", [ "DepthRange" ] },
|
||||
{ "Disablei", [ "Disable" ] },
|
||||
{ "Enablei", [ "Enable" ] },
|
||||
{ "FramebufferParameteri", [ "FramebufferParameter" ] },
|
||||
{ "GetStringi", [ "GetString" ] },
|
||||
{ "IsEnabledi", [ "IsEnabled" ] },
|
||||
{ "NamedFramebufferParameteri", [ "NamedFramebufferParameter" ] },
|
||||
{ "ProgramParameteri", [ "ProgramParameter" ] },
|
||||
{ "ScissorIndexedv", [ "ScissorIndexed" ] },
|
||||
{ "ViewportIndexedf", [ "ViewportIndexed" ] },
|
||||
{ "ViewportIndexedfv", [ "ViewportIndexed" ] }
|
||||
};
|
||||
|
||||
public static IReadOnlyDictionary<string, string> Resolve(
|
||||
IEnumerable<GlCommand> commands
|
||||
)
|
||||
{
|
||||
Dictionary<string, string> result = new(StringComparer.Ordinal);
|
||||
HashSet<string> usedSignatures = new(StringComparer.Ordinal);
|
||||
|
||||
foreach (GlCommand command in commands.OrderBy(c => c.Name, StringComparer.Ordinal))
|
||||
{
|
||||
string signature = BuildParameterSignature(command);
|
||||
foreach (string candidate in GetCandidates(command.Name))
|
||||
{
|
||||
if (usedSignatures.Add($"{candidate}({signature})"))
|
||||
{
|
||||
result.Add(command.Name, candidate);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private static string BuildParameterSignature(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
ManagedCommandPlan plan = ManagedCommandPlan.Create(command);
|
||||
return string.Join(",", plan.PublicParameters.Select(p => p.PublicType));
|
||||
}
|
||||
|
||||
private static IEnumerable<string> GetCandidates(
|
||||
string glName
|
||||
)
|
||||
{
|
||||
string name = TrimGlPrefix(glName);
|
||||
|
||||
Match vertexAttrib = VertexAttribRegex().Match(name);
|
||||
if (vertexAttrib.Success)
|
||||
{
|
||||
string stem = vertexAttrib.Groups[1].Value;
|
||||
string dimension = vertexAttrib.Groups[2].Value;
|
||||
bool normalized = vertexAttrib.Groups[3].Success;
|
||||
yield return normalized ? $"{stem}Normalized" : stem;
|
||||
yield return normalized ? $"{stem}{dimension}Normalized" : $"{stem}{dimension}";
|
||||
yield return name;
|
||||
yield break;
|
||||
}
|
||||
|
||||
Match typed = TypedSuffixRegex().Match(name);
|
||||
if (typed.Success && TypedSuffixFamilies.Contains(typed.Groups[1].Value))
|
||||
{
|
||||
string stem = typed.Groups[1].Value;
|
||||
string suffix = typed.Groups[2].Value;
|
||||
if (suffix.StartsWith('I')) {
|
||||
yield return $"{stem}I";
|
||||
}
|
||||
yield return stem;
|
||||
yield return name;
|
||||
yield break;
|
||||
}
|
||||
|
||||
if (ExactCandidates.TryGetValue(name, out string[]? candidates))
|
||||
{
|
||||
foreach (string candidate in candidates) {
|
||||
yield return candidate;
|
||||
}
|
||||
}
|
||||
|
||||
yield return name;
|
||||
}
|
||||
|
||||
private static string TrimGlPrefix(
|
||||
string name
|
||||
)
|
||||
{
|
||||
return name.StartsWith("gl", StringComparison.Ordinal) && name.Length > 2
|
||||
? name.Substring(2)
|
||||
: name;
|
||||
}
|
||||
|
||||
[GeneratedRegex("^(VertexAttrib(?:I|L|P)?)([1-4])(N)?(?:ui|ub|us|i|b|s|f|d)(v)?$",
|
||||
RegexOptions.CultureInvariant)]
|
||||
private static partial Regex VertexAttribRegex();
|
||||
|
||||
[GeneratedRegex("^(.+?)(Iuiv|Iiv|ui64v|i64v|uiv|ui|iv|fi|i|fv|f|dv|d)$",
|
||||
RegexOptions.CultureInvariant)]
|
||||
private static partial Regex TypedSuffixRegex();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="ManagedParameterPlanner"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace GenerateGL.CodeGen
|
||||
{
|
||||
internal enum ManagedParameterKind
|
||||
{
|
||||
|
||||
Value,
|
||||
RawPointer,
|
||||
ReadOnlySpan,
|
||||
Span,
|
||||
Out
|
||||
|
||||
}
|
||||
|
||||
internal sealed record ManagedParameterPlan(
|
||||
GlParam Source,
|
||||
string PublicType,
|
||||
ManagedParameterKind Kind,
|
||||
string? ElementType
|
||||
)
|
||||
{
|
||||
|
||||
public bool IsSpan => Kind is ManagedParameterKind.ReadOnlySpan or
|
||||
ManagedParameterKind.Span;
|
||||
|
||||
}
|
||||
|
||||
internal sealed class ManagedCommandPlan
|
||||
{
|
||||
|
||||
private readonly Dictionary<string, ManagedParameterPlan> _allParameters;
|
||||
private readonly Dictionary<string, string> _derivedLengthSources;
|
||||
|
||||
private ManagedCommandPlan(
|
||||
IReadOnlyList<ManagedParameterPlan> publicParameters,
|
||||
Dictionary<string, ManagedParameterPlan> allParameters,
|
||||
Dictionary<string, string> derivedLengthSources
|
||||
)
|
||||
{
|
||||
PublicParameters = publicParameters;
|
||||
_allParameters = allParameters;
|
||||
_derivedLengthSources = derivedLengthSources;
|
||||
}
|
||||
|
||||
public IReadOnlyList<ManagedParameterPlan> PublicParameters { get; }
|
||||
|
||||
public IReadOnlyDictionary<string, string> DerivedLengthSources =>
|
||||
_derivedLengthSources;
|
||||
|
||||
public static ManagedCommandPlan Create(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
Dictionary<string, ManagedParameterPlan> all = new(StringComparer.Ordinal);
|
||||
foreach (GlParam parameter in command.Parameters)
|
||||
{
|
||||
ManagedParameterPlan plan;
|
||||
if (CsTypeMapper.TryMapPointerElement(parameter, out string elementType) &&
|
||||
(parameter.IsConst || !string.IsNullOrWhiteSpace(parameter.Length) ||
|
||||
command.Name.StartsWith("glGet", StringComparison.Ordinal)))
|
||||
{
|
||||
if (!parameter.IsConst && parameter.Length == "1")
|
||||
{
|
||||
plan = new ManagedParameterPlan(
|
||||
parameter, $"out {elementType}", ManagedParameterKind.Out,
|
||||
elementType);
|
||||
} else
|
||||
{
|
||||
ManagedParameterKind kind = parameter.IsConst
|
||||
? ManagedParameterKind.ReadOnlySpan
|
||||
: ManagedParameterKind.Span;
|
||||
string container = parameter.IsConst ? "ReadOnlySpan" : "Span";
|
||||
plan = new ManagedParameterPlan(
|
||||
parameter, $"{container}<{elementType}>", kind, elementType);
|
||||
}
|
||||
} else
|
||||
{
|
||||
string mapped = CsTypeMapper.MapParameter(parameter);
|
||||
ManagedParameterKind kind = parameter.PointerLevel == 0
|
||||
? ManagedParameterKind.Value
|
||||
: ManagedParameterKind.RawPointer;
|
||||
plan = new ManagedParameterPlan(parameter, mapped, kind, null);
|
||||
}
|
||||
all.Add(parameter.Name, plan);
|
||||
}
|
||||
|
||||
Dictionary<string, string> derivedLengths = new(StringComparer.Ordinal);
|
||||
foreach (GlParam scalar in command.Parameters.Where(p => p.PointerLevel == 0))
|
||||
{
|
||||
List<ManagedParameterPlan> spans = command.Parameters
|
||||
.Select(p => all[p.Name])
|
||||
.Where(p => p.IsSpan &&
|
||||
string.Equals(p.Source.Length, scalar.Name,
|
||||
StringComparison.Ordinal))
|
||||
.ToList();
|
||||
if (spans.Count == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool lengthAlsoControlsRawPointer = command.Parameters
|
||||
.Select(p => all[p.Name]).Any(p =>
|
||||
p.Kind == ManagedParameterKind.RawPointer &&
|
||||
string.Equals(p.Source.Length, scalar.Name, StringComparison.Ordinal));
|
||||
if (lengthAlsoControlsRawPointer) {
|
||||
continue;
|
||||
}
|
||||
|
||||
string scalarType = all[scalar.Name].PublicType;
|
||||
if (scalarType is not ("int" or "uint" or "nint" or "nuint")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
derivedLengths.Add(scalar.Name, spans[0].Source.Name);
|
||||
}
|
||||
|
||||
IReadOnlyList<ManagedParameterPlan> publicParameters = command.Parameters
|
||||
.Where(p => !derivedLengths.ContainsKey(p.Name))
|
||||
.Select(p => all[p.Name])
|
||||
.ToArray();
|
||||
return new ManagedCommandPlan(publicParameters, all, derivedLengths);
|
||||
}
|
||||
|
||||
public ManagedParameterPlan GetParameter(
|
||||
string name
|
||||
) => _allParameters[name];
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Models"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GenerateGL.CodeGen
|
||||
{
|
||||
internal sealed record GlCommand(
|
||||
string Name,
|
||||
string ReturnType,
|
||||
int ReturnPointerLevel,
|
||||
bool ReturnIsConst,
|
||||
IReadOnlyList<GlParam> Parameters
|
||||
);
|
||||
|
||||
internal sealed record GlParam(
|
||||
string Name,
|
||||
string CType,
|
||||
int PointerLevel,
|
||||
bool IsConst,
|
||||
string? Length
|
||||
)
|
||||
{
|
||||
|
||||
public bool IsPointer => PointerLevel > 0;
|
||||
|
||||
}
|
||||
|
||||
internal sealed record GlFeature(
|
||||
string Version,
|
||||
IReadOnlyList<string> RequiresCommands,
|
||||
IReadOnlyList<string> RemovedCommands
|
||||
);
|
||||
}
|
||||
@@ -1,219 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="UniformOverloadEmitter"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#pragma warning disable CA1305
|
||||
|
||||
namespace GenerateGL.CodeGen
|
||||
{
|
||||
internal static partial class UniformOverloadEmitter
|
||||
{
|
||||
|
||||
public static bool IsValueCommand(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
return ValueCommandRegex().IsMatch(command.Name);
|
||||
}
|
||||
|
||||
public static bool IsSetterCommand(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
return IsValueCommand(command) || MatrixCommandRegex().IsMatch(command.Name);
|
||||
}
|
||||
|
||||
public static void Write(
|
||||
string outputRoot,
|
||||
string version,
|
||||
IReadOnlyList<GlCommand> commands
|
||||
)
|
||||
{
|
||||
List<GlCommand> valueCommands = commands.Where(IsValueCommand)
|
||||
.OrderBy(c => c.Name, StringComparer.Ordinal)
|
||||
.ToList();
|
||||
List<GlCommand> matrixConvenienceCommands = commands
|
||||
.Where(c => Matrix4FloatCommandRegex().IsMatch(c.Name))
|
||||
.OrderBy(c => c.Name, StringComparer.Ordinal)
|
||||
.ToList();
|
||||
|
||||
if (valueCommands.Count == 0 && matrixConvenienceCommands.Count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new();
|
||||
sb.AppendLine("// <auto-generated>");
|
||||
sb.AppendLine($"// Generated by StgSharp.GenerateGL on {DateTime.UtcNow.ToString("u", CultureInfo.InvariantCulture)}");
|
||||
sb.AppendLine($"// Uniform overloads introduced in OpenGL {version}");
|
||||
sb.AppendLine("// </auto-generated>");
|
||||
sb.AppendLine("using System;");
|
||||
sb.AppendLine("using System.Runtime.CompilerServices;");
|
||||
sb.AppendLine("using StgSharp.Mathematics.Graphics;");
|
||||
sb.AppendLine();
|
||||
sb.AppendLine("namespace StgSharp.Graphics.OpenGL");
|
||||
sb.AppendLine("{");
|
||||
sb.AppendLine(" public unsafe partial class OpenGLFunction");
|
||||
sb.AppendLine(" {");
|
||||
|
||||
foreach (GlCommand command in valueCommands) {
|
||||
EmitValueOverload(sb, command);
|
||||
}
|
||||
foreach (GlCommand command in valueCommands.Where(IsFloatVectorCommand)) {
|
||||
EmitVectorConvenienceOverload(sb, command);
|
||||
}
|
||||
foreach (GlCommand command in matrixConvenienceCommands) {
|
||||
EmitMatrixConvenienceOverload(sb, command);
|
||||
}
|
||||
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine("}");
|
||||
|
||||
string fileName = Path.Combine(
|
||||
outputRoot,
|
||||
$"OpenGLFunction.Uniform.v{version.Replace('.', '_')}.g.cs");
|
||||
File.WriteAllText(fileName, sb.ToString(), Encoding.UTF8);
|
||||
}
|
||||
|
||||
private static void EmitValueOverload(
|
||||
StringBuilder sb,
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
Match match = ValueCommandRegex().Match(command.Name);
|
||||
bool hasProgram = match.Groups[1].Success;
|
||||
int dimension = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture);
|
||||
string scalarType = MapScalarType(match.Groups[3].Value);
|
||||
bool isVector = match.Groups[4].Success;
|
||||
string uniformType = $"Uniform<{string.Join(", ", Enumerable.Repeat(scalarType, dimension))}>";
|
||||
|
||||
sb.AppendLine(" [MethodImpl(MethodImplOptions.AggressiveInlining)]");
|
||||
if (isVector)
|
||||
{
|
||||
string programParameter = hasProgram ? "GlHandle program, " : string.Empty;
|
||||
sb.AppendLine($" public void SetUniformValue({programParameter}{uniformType} uniform, ReadOnlySpan<{scalarType}> values)");
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" ArgumentNullException.ThrowIfNull(uniform);");
|
||||
if (dimension > 1)
|
||||
{
|
||||
sb.AppendLine($" if ((values.Length % {dimension}) != 0) {{");
|
||||
sb.AppendLine($" throw new ArgumentException(\"Uniform data length must be divisible by {dimension}.\", nameof(values));");
|
||||
sb.AppendLine(" }");
|
||||
}
|
||||
sb.AppendLine($" fixed ({scalarType}* valuesPtr = values) {{");
|
||||
string count = dimension == 1 ? "values.Length" : $"values.Length / {dimension}";
|
||||
sb.AppendLine($" Context.{command.Name}({BuildPrefixArguments(hasProgram)}{count}, valuesPtr);");
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine(" }");
|
||||
} else
|
||||
{
|
||||
string programParameter = hasProgram ? "GlHandle program, " : string.Empty;
|
||||
string values = string.Join(", ", Enumerable.Range(0, dimension)
|
||||
.Select(i => $"{scalarType} v{i}"));
|
||||
string valueArguments = string.Join(", ", Enumerable.Range(0, dimension)
|
||||
.Select(i => $"v{i}"));
|
||||
sb.AppendLine($" public void SetUniformValue({programParameter}{uniformType} uniform, {values})");
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" ArgumentNullException.ThrowIfNull(uniform);");
|
||||
sb.AppendLine($" Context.{command.Name}({BuildPrefixArguments(hasProgram)}{valueArguments});");
|
||||
sb.AppendLine(" }");
|
||||
}
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
private static void EmitVectorConvenienceOverload(
|
||||
StringBuilder sb,
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
Match match = ValueCommandRegex().Match(command.Name);
|
||||
bool hasProgram = match.Groups[1].Success;
|
||||
int dimension = int.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture);
|
||||
if (dimension < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
string vectorType = $"Vec{dimension}";
|
||||
string programParameter = hasProgram ? "GlHandle program, " : string.Empty;
|
||||
sb.AppendLine(" [MethodImpl(MethodImplOptions.AggressiveInlining)]");
|
||||
sb.AppendLine($" public void SetUniformValue({programParameter}Uniform<{vectorType}> uniform, {vectorType} value)");
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" ArgumentNullException.ThrowIfNull(uniform);");
|
||||
sb.AppendLine($" Context.{command.Name}({BuildPrefixArguments(hasProgram)}1, (float*)&value);");
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
private static void EmitMatrixConvenienceOverload(
|
||||
StringBuilder sb,
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
bool hasProgram = command.Name.StartsWith("glProgram", StringComparison.Ordinal);
|
||||
string programParameter = hasProgram ? "GlHandle program, " : string.Empty;
|
||||
sb.AppendLine(" [MethodImpl(MethodImplOptions.AggressiveInlining)]");
|
||||
sb.AppendLine($" public void SetUniformValue({programParameter}Uniform<GraphicsMatrix> uniform, GraphicsMatrix value, bool transpose = false)");
|
||||
sb.AppendLine(" {");
|
||||
sb.AppendLine(" ArgumentNullException.ThrowIfNull(uniform);");
|
||||
sb.AppendLine($" Context.{command.Name}({BuildPrefixArguments(hasProgram)}1, transpose ? (byte)1 : (byte)0, (float*)&value);");
|
||||
sb.AppendLine(" }");
|
||||
sb.AppendLine();
|
||||
}
|
||||
|
||||
private static string BuildPrefixArguments(
|
||||
bool hasProgram
|
||||
)
|
||||
{
|
||||
return hasProgram
|
||||
? "program.Value, uniform.id.SignedValue, "
|
||||
: "uniform.id.SignedValue, ";
|
||||
}
|
||||
|
||||
private static bool IsFloatVectorCommand(
|
||||
GlCommand command
|
||||
)
|
||||
{
|
||||
Match match = ValueCommandRegex().Match(command.Name);
|
||||
return match.Success && match.Groups[3].Value == "f" && match.Groups[4].Success;
|
||||
}
|
||||
|
||||
private static string MapScalarType(
|
||||
string suffix
|
||||
)
|
||||
{
|
||||
return suffix switch
|
||||
{
|
||||
"f" => "float",
|
||||
"d" => "double",
|
||||
"i" => "int",
|
||||
"ui" => "uint",
|
||||
_ => throw new InvalidOperationException($"Unsupported uniform suffix: {suffix}")
|
||||
};
|
||||
}
|
||||
|
||||
[GeneratedRegex("^gl(Program)?Uniform([1-4])(ui|[fdi])(v)?$",
|
||||
RegexOptions.CultureInvariant)]
|
||||
private static partial Regex ValueCommandRegex();
|
||||
|
||||
[GeneratedRegex("^gl(?:Program)?UniformMatrix4fv$", RegexOptions.CultureInvariant)]
|
||||
private static partial Regex Matrix4FloatCommandRegex();
|
||||
|
||||
[GeneratedRegex("^gl(?:Program)?UniformMatrix[234](?:x[234])?[fd]v$",
|
||||
RegexOptions.CultureInvariant)]
|
||||
private static partial Regex MatrixCommandRegex();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#pragma warning restore CA1305
|
||||
@@ -1,691 +0,0 @@
|
||||
# GenerateGL 与 StgSharp.Graphics OpenGL 绑定架构评估
|
||||
|
||||
评估日期:2026-08-24
|
||||
|
||||
## 实施状态(2026-08-25)
|
||||
|
||||
已完成第一轮无公开 API 破坏的文件整理:
|
||||
|
||||
- 手写 `OpenGLFunction` 已拆分到 `src/StgSharp.Graphics/OpenGL/Api`;
|
||||
- 版本 Raw wrapper 已移动到 `src/StgSharp.Graphics/OpenGL/Generated` 并使用 `.g.cs` 后缀;
|
||||
- `OpenglContext` 已移动为 `Generated/OpenglContext.g.cs`;
|
||||
- `SetUniformValue` 已从 Uniform 模型文件移动到 `Api/OpenGLFunction.Uniform.cs`;
|
||||
- Texture Unit 状态已移动到 `Api/OpenGLFunction.TextureUnits.cs`;
|
||||
- 已修复两个 `Vec4` overload 对 `glUniform1fv` 的错误调用,现调用 `glUniform4fv(location, 1, ...)`;
|
||||
- GenerateGL 已改为只生成一个合并 Context,Raw wrapper 继续按版本输出;
|
||||
- GenerateGL 输出文件名已与新的 `Generated` 目录约定对齐。
|
||||
|
||||
第二轮生成器实验已经完成并输出到 `test/StgSharp.GenerateGL/Generated`:
|
||||
|
||||
- `glUniform1/2/3/4[f|i|ui|d][v]` 与 `glProgramUniform*` 已生成为 `SetUniformValue(...)` 重载;
|
||||
- 已生成 scalar、`ReadOnlySpan<T>`、`Vec2/3/4` 和 `GraphicsMatrix` 入口;
|
||||
- 所有 uniform setter 已从 Raw wrapper 排除;没有对应托管矩阵类型的形状暂时只存在于 `OpenglContext`;
|
||||
- TexParameter、SamplerParameter、VertexAttrib、ClearBuffer 及 indexed API 等可由 C# 参数签名区分的函数已归并重载;
|
||||
- 归并发生签名冲突时,生成器会保留必要的维度或语义尾缀;
|
||||
- `OpenglContext` 仍保持纯 ABI 函数指针表,`GlHandle` 暂不拆分;
|
||||
- 已移除“参数名为 type 就映射为 ShaderType”的不安全启发式规则。
|
||||
|
||||
Loader/ContextShadow 合并、BufferObject 专项生成和生成快照测试尚未实施。
|
||||
|
||||
## 1. 评估目的
|
||||
|
||||
本文评估 `StgSharp.GenerateGL` 与 `src/StgSharp.Graphics` 当前 OpenGL 绑定代码之间的关系,重点回答以下问题:
|
||||
|
||||
- GenerateGL 为什么会生成大量保留 C 命名风格的方法;
|
||||
- Uniform 系列应如何生成符合 C# 使用习惯的方法重载;
|
||||
- 现有手写封装散落在哪些文件中;
|
||||
- 修改生成器时还需要同步调整哪些类型、加载器和调用方;
|
||||
- 如何在保留现有功能的前提下逐步完成迁移。
|
||||
|
||||
本次评估基于静态代码检查,不包含代码重构或 API 变更。
|
||||
|
||||
## 2. 总体结论
|
||||
|
||||
当前 GenerateGL 完成的是“将 Khronos OpenGL C API 转换为可调用的 C# 代码”,尚未建立从 C API 函数族到惯用 C# API 的语义映射。
|
||||
|
||||
`glUniform1f`、`glUniform2f`、`glUniform4fv` 等名称中的数字和后缀分别编码了分量数、元素类型和指针形式。当前生成器只删除 `gl` 前缀,因此得到的仍然是 C 风格方法,而不是 C# 重载。
|
||||
|
||||
解决该问题不能只修改方法命名。当前 OpenGL 代码同时存在以下结构性问题:
|
||||
|
||||
1. 原始函数指针、自动生成的薄封装和手写高级封装没有清晰分层;
|
||||
2. `Uniform.cs` 同时定义 Uniform 类型和 `partial OpenGLFunction` 方法;
|
||||
3. `ShaderStruct.cs` 绕过 `OpenGLFunction`,直接调用原始函数指针;
|
||||
4. uniform location 被建模为通用 `GlHandle`,语义不正确;
|
||||
5. Context、ContextShadow、Loader 和 Wrapper 分别维护,已经出现函数清单漂移;
|
||||
6. OpenGL 版本能力判断存在错误,可能加载当前上下文不支持的函数;
|
||||
7. GenerateGL 文档描述的是增量源生成器,但当前实现是独立控制台代码生成程序。
|
||||
|
||||
建议将架构拆分为四个明确层次:
|
||||
|
||||
1. Registry 模型层:解析 `gl.xml` 并建立函数、版本和类型模型;
|
||||
2. ABI 层:生成原始函数指针和加载代码;
|
||||
3. Raw API 层:提供与 OpenGL 一一对应的薄封装;
|
||||
4. Idiomatic API 层:按函数族生成 C# 重载,并使用 StgSharp 的向量、矩阵和资源类型。
|
||||
|
||||
## 3. 当前 GenerateGL 行为
|
||||
|
||||
### 3.1 输入
|
||||
|
||||
GenerateGL 从 `xml/gl.xml` 读取 Khronos OpenGL Registry。
|
||||
|
||||
当前解析内容包括:
|
||||
|
||||
- `<commands>` 中的函数名、返回值和参数;
|
||||
- `<feature>` 中各 OpenGL 版本新增的命令;
|
||||
- Core Profile 中删除的命令。
|
||||
|
||||
当前未完整实现:
|
||||
|
||||
- 枚举和常量生成;
|
||||
- 扩展 API 生成;
|
||||
- Roslyn Incremental Generator;
|
||||
- 自动写入或接入 `StgSharp.Graphics` 项目。
|
||||
|
||||
### 3.2 输出
|
||||
|
||||
当前生成器针对 OpenGL 3.3 至 4.6 生成:
|
||||
|
||||
- 分版本 `OpenglContext` 函数指针字段;
|
||||
- 分版本 `OpenGLFunction` 薄封装方法;
|
||||
- 合并后的 `glContext.cs`;
|
||||
- OpenGL 命令新增和删除历史。
|
||||
|
||||
输出目录为 GenerateGL 可执行文件所在目录下的 `Generated`,而不是 `src/StgSharp.Graphics`。
|
||||
|
||||
### 3.3 当前生成策略的限制
|
||||
|
||||
生成器对公开方法的处理主要包括:
|
||||
|
||||
- 删除 `gl` 前缀;
|
||||
- 将部分 `GLuint` 参数启发式转换为 `GlHandle`;
|
||||
- 将部分 `const T*` 转换为 `ReadOnlySpan<T>`;
|
||||
- 对 C# 保留字进行转义。
|
||||
|
||||
它没有分析 OpenGL 函数族,因此下列函数会被当作互不相关的方法:
|
||||
|
||||
```text
|
||||
glUniform1f
|
||||
glUniform2f
|
||||
glUniform3f
|
||||
glUniform4f
|
||||
glUniform1fv
|
||||
glUniform2fv
|
||||
glUniform3fv
|
||||
glUniform4fv
|
||||
```
|
||||
|
||||
## 4. StgSharp.Graphics 当前代码分布
|
||||
|
||||
### 4.1 原始函数指针
|
||||
|
||||
`src/StgSharp.Graphics/OpenGL/glContext.cs` 定义 `OpenglContext`,当前包含 657 个函数指针字段。
|
||||
|
||||
这些字段是 OpenGL ABI 的核心,应完全由生成器维护,不应与手写高级 API 混合。
|
||||
|
||||
### 4.2 ContextShadow
|
||||
|
||||
`src/StgSharp.Graphics/OpenGL/glContextShadow.cs` 使用 657 个 `IntPtr` 字段镜像 `OpenglContext`。
|
||||
|
||||
加载器将 `OpenglContext*` 强制转换为 `glContextShadow*` 后写入函数地址。因此两个结构体必须始终满足:
|
||||
|
||||
- 字段数量一致;
|
||||
- 字段顺序一致;
|
||||
- 每个字段占用相同大小。
|
||||
|
||||
当前两者字段数量和顺序一致,但这种设计非常脆弱。生成器目前不生成 ContextShadow,任何一侧发生变化都可能破坏内存布局。
|
||||
|
||||
### 4.3 函数加载器
|
||||
|
||||
`src/StgSharp.Graphics/OpenGL/glApiManager.Load.cs` 按 OpenGL 版本加载函数。
|
||||
|
||||
静态检查结果:
|
||||
|
||||
- `OpenglContext` 字段数:657;
|
||||
- `glContextShadow` 字段数:657;
|
||||
- 实际 Loader 赋值数:655。
|
||||
|
||||
当前未被实际加载的字段:
|
||||
|
||||
- `glGetPointerv`;
|
||||
- `glVertexAttribLFormat`。
|
||||
|
||||
这说明 Context、Shadow 和 Loader 已经发生漂移。
|
||||
|
||||
### 4.4 自动生成的公开薄封装
|
||||
|
||||
以下文件定义 `partial OpenGLFunction`:
|
||||
|
||||
- `glFunction.v3_3.cs`;
|
||||
- `glFunction.v4_0.cs`;
|
||||
- `glFunction.v4_1.cs`;
|
||||
- `glFunction.v4_2.cs`;
|
||||
- `glFunction.v4_3.cs`;
|
||||
- `glFunction.v4_4.cs`;
|
||||
- `glFunction.v4_5.cs`;
|
||||
- `glFunction.v4_6.cs`。
|
||||
|
||||
这些文件合计约 656 个公开方法。它们已经进行了一部分 C# 类型转换,但函数名和参数模型仍基本对应 C API。
|
||||
|
||||
这使它们处于不稳定的中间层:
|
||||
|
||||
- 不再是完全精确的 Raw ABI;
|
||||
- 又没有形成惯用的 C# API;
|
||||
- `count` 与 `ReadOnlySpan<T>` 长度可能不一致;
|
||||
- `byte`、裸 `uint` 和裸指针仍大量暴露;
|
||||
- 资源句柄识别依赖参数名启发式规则。
|
||||
|
||||
### 4.5 手写 OpenGLFunction 方法
|
||||
|
||||
`src/StgSharp.Graphics/OpenGL/glFunction.cs` 约 795 行,包含约 55 个手写公开方法,职责包括:
|
||||
|
||||
- Context 与 `OpenGLFunction` 实例管理;
|
||||
- Buffer 创建、删除和数据上传;
|
||||
- Texture 创建和上传;
|
||||
- Framebuffer 和 Renderbuffer 操作;
|
||||
- Shader 创建、源码上传和状态检查;
|
||||
- Draw 调用;
|
||||
- 错误检查;
|
||||
- Vertex Attribute 配置。
|
||||
|
||||
这些方法与版本文件中的公开方法并存。例如同时存在:
|
||||
|
||||
- `ActiveTextureUnit` 与 `ActiveTexture`;
|
||||
- `BindFrameBuffer` 与 `BindFramebuffer`;
|
||||
- `FrameBufferTexture2d` 与 `FramebufferTexture2D`;
|
||||
- `TextureImage2d` 与 `TexImage2D`;
|
||||
- `SetBufferData` 与 `BufferData`。
|
||||
|
||||
这种重复不是编译错误,但会让调用者无法判断哪一层是推荐 API,也会妨碍生成器安全地产生新重载。
|
||||
|
||||
### 4.6 Uniform 类型与方法
|
||||
|
||||
`src/StgSharp.Graphics/OpenGL/ShaderEdit/Uniform.cs` 同时包含:
|
||||
|
||||
- `Uniform` 基类;
|
||||
- `Uniform<T>`;
|
||||
- `Uniform<T, U>`;
|
||||
- `Uniform<T, U, V>`;
|
||||
- `Uniform<T, U, V, W>`;
|
||||
- `partial OpenGLFunction` 的 `SetUniformValue` 重载。
|
||||
|
||||
代码位置本身不影响编译,但该文件跨越了两个职责边界:
|
||||
|
||||
- Uniform 数据模型;
|
||||
- OpenGL 命令封装。
|
||||
|
||||
这会导致生成器无法拥有 Uniform 方法的明确输出区域。
|
||||
|
||||
### 4.7 Shader 相关代码
|
||||
|
||||
`src/StgSharp.Graphics/OpenGL/ShaderEdit/Shader.cs` 同时定义:
|
||||
|
||||
- `partial glRender` 的 Shader 工厂方法;
|
||||
- `Shader`;
|
||||
- `ShaderStatus`;
|
||||
- `ShaderProgram`;
|
||||
- `ShaderProgram.GetUniform<T...>`。
|
||||
|
||||
此外还存在 `src/StgSharp.Graphics/ShaderEdit`,其中包含另一套 Shader 抽象。`OpenGL/ShaderEdit/IglConvertable.cs` 的文件路径位于 OpenGL 子目录,但命名空间是 `StgSharp.Graphics.ShaderEdit`。
|
||||
|
||||
当前文件位置和命名空间没有形成一致边界。
|
||||
|
||||
### 4.8 绕过公开封装的调用
|
||||
|
||||
除 Loader 和绑定实现外,发现 `src/StgSharp.Graphics/ShaderEdit/ShaderStruct.cs` 直接获取:
|
||||
|
||||
```csharp
|
||||
OpenglContext* gl =
|
||||
(OpenglContext*)OpenGLFunction.CurrentGL.ContextHandle;
|
||||
```
|
||||
|
||||
随后直接调用 `glUniform*`。
|
||||
|
||||
这是高级代码对 ABI 层的越层依赖。新的 Uniform API 建立后,这里应只调用 `OpenGLFunction.SetUniformValue` 或对应的 Uniform 对象方法。
|
||||
|
||||
## 5. 已确认的正确性问题
|
||||
|
||||
### 5.1 Vec4 使用了错误的 OpenGL 函数
|
||||
|
||||
当前 `Uniform.cs` 中,`Vec4` 被传给:
|
||||
|
||||
```csharp
|
||||
glUniform1fv(location, 4, pointer);
|
||||
```
|
||||
|
||||
该调用表示上传 4 个标量 uniform,而不是上传 1 个四分量向量。
|
||||
|
||||
正确调用应为:
|
||||
|
||||
```csharp
|
||||
glUniform4fv(location, 1, pointer);
|
||||
```
|
||||
|
||||
### 5.2 整数 Uniform 调用了浮点函数
|
||||
|
||||
`ShaderStruct.SetAllUniforms` 的整数分支调用 `glUniform1f`,应调用 `glUniform1i`。
|
||||
|
||||
### 5.3 Uniform location 被错误建模为 GlHandle
|
||||
|
||||
OpenGL uniform location 的原始类型是有符号 `GLint`,并允许 `-1` 表示未找到。
|
||||
|
||||
当前实现使用 `GlHandle` 保存 uniform location。`GlHandle` 同时被用于 Buffer、Texture、Program 和 Shader 等 `GLuint` 对象名称,因此无法表达 uniform location 的不同语义和有效性规则。
|
||||
|
||||
建议引入:
|
||||
|
||||
```csharp
|
||||
public readonly record struct UniformLocation(int Value)
|
||||
{
|
||||
public bool IsValid => Value >= 0;
|
||||
}
|
||||
```
|
||||
|
||||
### 5.4 版本判断错误
|
||||
|
||||
`glManager.CheckCoreVersion` 当前使用类似以下判断:
|
||||
|
||||
```csharp
|
||||
majorVersion >= 4 ||
|
||||
(majorVersion == 4 && minorVersion == requiredMinor)
|
||||
```
|
||||
|
||||
当上下文版本为 OpenGL 4.0 时,`majorVersion >= 4` 对 4.1 至 4.6 的检查也全部为真。
|
||||
|
||||
正确判断应为:
|
||||
|
||||
```csharp
|
||||
majorVersion > requiredMajor ||
|
||||
(majorVersion == requiredMajor && minorVersion >= requiredMinor)
|
||||
```
|
||||
|
||||
版本和扩展能力还应保存在每个 OpenGL context 中,而不是静态全局字段中。
|
||||
|
||||
### 5.5 上下文内存没有完整清零
|
||||
|
||||
`glRender.InitializeContext` 通过 `Marshal.AllocHGlobal` 分配 `OpenglContext`,但只将 `glGetString` 设置为零。
|
||||
|
||||
如果当前版本不加载某些较新函数,其字段可能保留未初始化值。公开版本方法仍然存在,错误调用时可能跳转到无效地址。
|
||||
|
||||
上下文分配后应完整清零,并通过 capability 检查限制不受支持的方法调用。
|
||||
|
||||
### 5.6 函数指针调用约定需要统一审计
|
||||
|
||||
GLFW 返回的是非托管函数地址。当前 `OpenglContext` 多数使用 `delegate*<...>`,没有显式标记 `unmanaged` 调用约定。
|
||||
|
||||
生成器应根据目标平台统一生成并验证函数指针调用约定,例如:
|
||||
|
||||
```csharp
|
||||
delegate* unmanaged<...>
|
||||
```
|
||||
|
||||
或在确有需要时生成平台对应的显式调用约定。
|
||||
|
||||
## 6. Uniform 函数族的推荐建模
|
||||
|
||||
### 6.1 函数名解析
|
||||
|
||||
生成器应将以下函数族解析为结构化模型:
|
||||
|
||||
```text
|
||||
glUniform{1|2|3|4}{f|d|i|ui}{v?}
|
||||
glProgramUniform{1|2|3|4}{f|d|i|ui}{v?}
|
||||
glUniformMatrix{2|3|4|2x3|2x4|3x2|3x4|4x2|4x3}{f|d}v
|
||||
glProgramUniformMatrix{...}{f|d}v
|
||||
```
|
||||
|
||||
建议模型至少包含:
|
||||
|
||||
```text
|
||||
Operation = Uniform | ProgramUniform
|
||||
Shape = Scalar | Vector | Matrix
|
||||
Columns = 1..4
|
||||
Rows = 1..4
|
||||
ElementType = Float | Double | Int | UInt
|
||||
InputForm = Components | Array
|
||||
NativeCommand = glUniform4fv 等原始名称
|
||||
IntroducedIn = OpenGL 版本
|
||||
```
|
||||
|
||||
不要直接在字符串 emitter 中通过多组 `StartsWith` 和 `EndsWith` 拼接逻辑。应先完成函数族识别,再根据统一模型生成代码。
|
||||
|
||||
### 6.2 推荐的 Uniform 类型
|
||||
|
||||
建议保留单泛型参数:
|
||||
|
||||
```csharp
|
||||
public readonly struct Uniform<T> where T : unmanaged
|
||||
{
|
||||
public UniformLocation Location { get; }
|
||||
}
|
||||
```
|
||||
|
||||
向量和矩阵形状由 `T` 表达:
|
||||
|
||||
```text
|
||||
Uniform<float>
|
||||
Uniform<Vec2>
|
||||
Uniform<Vec3>
|
||||
Uniform<Vec4>
|
||||
Uniform<GraphicsMatrix>
|
||||
```
|
||||
|
||||
不建议继续使用 `Uniform<T, U, V, W>` 表达四分量值。
|
||||
|
||||
要完整支持 `double`、`int` 和 `uint` 向量,数学库还需要提供对应的向量类型,或者 OpenGL 层需要定义布局稳定的专用值类型,例如:
|
||||
|
||||
```text
|
||||
DVec2 / DVec3 / DVec4
|
||||
IVec2 / IVec3 / IVec4
|
||||
UVec2 / UVec3 / UVec4
|
||||
```
|
||||
|
||||
### 6.3 推荐重载
|
||||
|
||||
标量与向量:
|
||||
|
||||
```csharp
|
||||
void SetUniformValue(Uniform<float> uniform, float value);
|
||||
void SetUniformValue(Uniform<Vec2> uniform, Vec2 value);
|
||||
void SetUniformValue(Uniform<Vec3> uniform, Vec3 value);
|
||||
void SetUniformValue(Uniform<Vec4> uniform, Vec4 value);
|
||||
```
|
||||
|
||||
数组:
|
||||
|
||||
```csharp
|
||||
void SetUniformValue(
|
||||
Uniform<float> uniform,
|
||||
ReadOnlySpan<float> values);
|
||||
|
||||
void SetUniformValue(
|
||||
Uniform<Vec4> uniform,
|
||||
ReadOnlySpan<Vec4> values);
|
||||
```
|
||||
|
||||
矩阵:
|
||||
|
||||
```csharp
|
||||
void SetUniformValue(
|
||||
Uniform<GraphicsMatrix> uniform,
|
||||
in GraphicsMatrix value,
|
||||
bool transpose = false);
|
||||
```
|
||||
|
||||
调用者不应手工传入 `count`。生成方法应根据 Span 长度和元素形状计算 OpenGL 的 `count` 参数。
|
||||
|
||||
### 6.4 Raw API 的处理
|
||||
|
||||
建议保留与 OpenGL 一一对应的 Raw 方法,至少在迁移期内不要立即删除。
|
||||
|
||||
可选策略:
|
||||
|
||||
1. 将 Raw 方法改为 `internal`;
|
||||
2. 放入单独的 `OpenGLRaw` 类型;
|
||||
3. 暂时保持 `public`,但使用 `EditorBrowsable(Never)` 降低 IntelliSense 噪音;
|
||||
4. 为旧 API 提供一个兼容周期,再逐步弃用。
|
||||
|
||||
Idiomatic API 不应与 Raw API 写入同一生成文件。
|
||||
|
||||
## 7. 推荐目录结构
|
||||
|
||||
```text
|
||||
src/StgSharp.Graphics/OpenGL/
|
||||
Generated/
|
||||
OpenglContext.g.cs
|
||||
OpenglLoader.v33.g.cs
|
||||
OpenGLFunction.Raw.v33.g.cs
|
||||
OpenGLFunction.Raw.v40.g.cs
|
||||
OpenGLFunction.Uniform.g.cs
|
||||
OpenGLFunction.ProgramUniform.g.cs
|
||||
|
||||
Api/
|
||||
OpenGLFunction.Context.cs
|
||||
OpenGLFunction.Diagnostics.cs
|
||||
OpenGLFunction.Buffer.cs
|
||||
OpenGLFunction.Texture.cs
|
||||
OpenGLFunction.Drawing.cs
|
||||
OpenGLFunction.Shader.cs
|
||||
|
||||
Objects/
|
||||
Uniform.cs
|
||||
UniformLocation.cs
|
||||
Shader.cs
|
||||
ShaderProgram.cs
|
||||
ShaderStatus.cs
|
||||
Buffer/
|
||||
Texture/
|
||||
|
||||
Rendering/
|
||||
GlRender.cs
|
||||
GlRender.Resources.cs
|
||||
GlRender.Threading.cs
|
||||
```
|
||||
|
||||
具体目录名称可以调整,但必须保持以下边界:
|
||||
|
||||
- `Generated` 中的文件可以被完整覆盖;
|
||||
- 手写文件永远不写入 `Generated`;
|
||||
- Uniform 类型定义和 Uniform 调用方法分离;
|
||||
- Shader 资源对象不直接访问 `OpenglContext*`;
|
||||
- Loader 与 Context 来自同一个生成模型。
|
||||
|
||||
## 8. 建议的文件迁移
|
||||
|
||||
### 8.1 `Uniform.cs`
|
||||
|
||||
保留:
|
||||
|
||||
- `Uniform<T>`;
|
||||
- uniform location;
|
||||
- 与 uniform 数据模型直接相关的成员。
|
||||
|
||||
移出:
|
||||
|
||||
- 所有 `partial OpenGLFunction` 方法。
|
||||
|
||||
### 8.2 `Shader.cs`
|
||||
|
||||
拆分为:
|
||||
|
||||
- `Shader.cs`;
|
||||
- `ShaderProgram.cs`;
|
||||
- `ShaderStatus.cs`;
|
||||
- `ShaderProgram.Uniform.cs`;
|
||||
- `GlRender.ShaderFactory.cs`。
|
||||
|
||||
### 8.3 `ShaderStruct.cs`
|
||||
|
||||
移除:
|
||||
|
||||
- `ContextHandle` 访问;
|
||||
- `OpenglContext*` 转换;
|
||||
- 直接 `glUniform*` 调用。
|
||||
|
||||
改为通过类型安全的 Uniform API 分发。
|
||||
|
||||
### 8.4 `glFunction.cs`
|
||||
|
||||
保留 Context 生命周期和实例管理,然后按功能拆分手写便利方法:
|
||||
|
||||
```text
|
||||
OpenGLFunction.Context.cs
|
||||
OpenGLFunction.Diagnostics.cs
|
||||
OpenGLFunction.Buffer.cs
|
||||
OpenGLFunction.Texture.cs
|
||||
OpenGLFunction.Framebuffer.cs
|
||||
OpenGLFunction.Drawing.cs
|
||||
OpenGLFunction.Shader.cs
|
||||
```
|
||||
|
||||
### 8.5 `glFunction.SourceManager.cs`
|
||||
|
||||
该文件实际管理 Texture Unit,而不是 Source。建议重命名为:
|
||||
|
||||
```text
|
||||
OpenGLFunction.TextureUnits.cs
|
||||
```
|
||||
|
||||
进一步可以将 Texture Unit 分配状态移出函数绑定类,放入每个 Render Context 的资源管理对象。
|
||||
|
||||
### 8.6 `IglConvertable.cs`
|
||||
|
||||
该文件位于 `OpenGL/ShaderEdit`,命名空间却是 `StgSharp.Graphics.ShaderEdit`。应移动到与命名空间一致的 `ShaderEdit` 目录。
|
||||
|
||||
## 9. GenerateGL 推荐内部结构
|
||||
|
||||
建议将当前单一 `Generator` 拆分为以下阶段。
|
||||
|
||||
### 9.1 Registry 解析
|
||||
|
||||
```text
|
||||
GlXmlParser
|
||||
-> RegistryModel
|
||||
```
|
||||
|
||||
负责准确保留:
|
||||
|
||||
- C 类型;
|
||||
- 指针层级;
|
||||
- const;
|
||||
- 参数组信息;
|
||||
- feature/profile/version;
|
||||
- alias;
|
||||
- enum group。
|
||||
|
||||
### 9.2 ABI 类型映射
|
||||
|
||||
```text
|
||||
RegistryModel
|
||||
-> AbiCommandModel
|
||||
```
|
||||
|
||||
这里只做精确映射,不做 `GlHandle`、Span 或 ShaderType 等高级推断。
|
||||
|
||||
### 9.3 函数族分析
|
||||
|
||||
```text
|
||||
AbiCommandModel
|
||||
-> CommandFamilyModel
|
||||
```
|
||||
|
||||
由专门规则识别:
|
||||
|
||||
- Uniform;
|
||||
- ProgramUniform;
|
||||
- UniformMatrix;
|
||||
- VertexAttrib;
|
||||
- TexParameter;
|
||||
- Get 系列;
|
||||
- Gen/Delete/Create 系列。
|
||||
|
||||
无法识别的命令仍可生成 Raw API,但不得用不确定的启发式规则擅自改变资源类型。
|
||||
|
||||
### 9.4 Emitters
|
||||
|
||||
建议拆分:
|
||||
|
||||
```text
|
||||
ContextEmitter
|
||||
LoaderEmitter
|
||||
RawFunctionEmitter
|
||||
UniformEmitter
|
||||
ProgramUniformEmitter
|
||||
ConstantEmitter
|
||||
HistoryEmitter
|
||||
```
|
||||
|
||||
每个 emitter 只负责一种输出,便于单独进行 golden-file 测试。
|
||||
|
||||
## 10. 迁移计划
|
||||
|
||||
### 阶段一:建立安全的生成边界
|
||||
|
||||
1. 新增 `OpenGL/Generated`;
|
||||
2. 所有生成文件使用 `.g.cs` 后缀;
|
||||
3. 生成器直接生成 `OpenglContext` 和 Loader;
|
||||
4. 移除或自动生成 `glContextShadow`;
|
||||
5. 增加函数数量、名称和版本一致性测试。
|
||||
|
||||
此阶段不改变现有公开 API。
|
||||
|
||||
### 阶段二:修复 Uniform 模型
|
||||
|
||||
1. 新增 `UniformLocation`;
|
||||
2. 将 `GetUniformLocation` 返回类型改为 `UniformLocation`;
|
||||
3. 将 Uniform 简化为 `Uniform<T>`;
|
||||
4. 修复 Vec4 和整数 uniform 的错误调用;
|
||||
5. 迁移 Camera、ShaderProgram 和 ShaderStruct。
|
||||
|
||||
### 阶段三:生成 Uniform 重载
|
||||
|
||||
1. 实现 Uniform 函数族解析;
|
||||
2. 生成 scalar/vector/matrix overload;
|
||||
3. 自动计算 Span 对应的 count;
|
||||
4. 生成 ProgramUniform 对应重载;
|
||||
5. 使用 golden-file 测试验证每个原始命令映射到正确 overload。
|
||||
|
||||
### 阶段四:整理其他手写便利 API
|
||||
|
||||
1. 拆分 `glFunction.cs`;
|
||||
2. 统一 Buffer、Texture、Framebuffer 方法命名;
|
||||
3. 明确 Raw API 的可见性和兼容策略;
|
||||
4. 逐步为 VertexAttrib、TexParameter 等函数族生成重载。
|
||||
|
||||
### 阶段五:清理旧 API
|
||||
|
||||
1. 标记旧 C 风格 public wrapper 为 obsolete 或隐藏;
|
||||
2. 提供迁移说明;
|
||||
3. 在约定的兼容版本后删除旧入口。
|
||||
|
||||
## 11. 测试与验收标准
|
||||
|
||||
### 11.1 Registry 一致性
|
||||
|
||||
- 每个 Context 字段必须有对应 Loader 赋值;
|
||||
- 每个 Raw wrapper 必须对应一个 Context 字段;
|
||||
- 不允许 Loader 引用不存在的字段;
|
||||
- Context、Loader 和 Wrapper 的版本归属必须一致。
|
||||
|
||||
### 11.2 Uniform golden tests
|
||||
|
||||
至少验证:
|
||||
|
||||
```text
|
||||
float -> glUniform1f
|
||||
Vec2 -> glUniform2fv(count = 1)
|
||||
Vec3 -> glUniform3fv(count = 1)
|
||||
Vec4 -> glUniform4fv(count = 1)
|
||||
ReadOnlySpan<Vec4> -> glUniform4fv(count = span.Length)
|
||||
GraphicsMatrix -> glUniformMatrix4fv(count = 1)
|
||||
```
|
||||
|
||||
同时覆盖 `double`、`int`、`uint`、非方阵矩阵和 ProgramUniform。
|
||||
|
||||
### 11.3 API 约束
|
||||
|
||||
- 高级代码不得访问 `OpenglContext*`;
|
||||
- 高级代码不得手工传入可由 Span 推导的 count;
|
||||
- uniform location 不得使用 `GlHandle`;
|
||||
- 生成文件不得包含手写区域;
|
||||
- 手写文件不得依赖生成字段的布局顺序;
|
||||
- 不支持的 OpenGL 版本方法不得调用未初始化函数指针。
|
||||
|
||||
### 11.4 构建验证
|
||||
|
||||
GenerateGL 当前可以成功构建,但存在代码分析警告。
|
||||
|
||||
本次检查中,单独构建 `StgSharp.Graphics` 时,MSBuild 在项目引用 `StgSharp.Mathematics` 的 `GetTargetFrameworks` 阶段失败,最终显示 0 个 C# 错误和 0 个警告。该失败发生在 C# 编译前,因此本次评估不将其视为 Graphics 源码编译结果。
|
||||
|
||||
## 12. 推荐的第一批实际改动
|
||||
|
||||
为了控制改动规模,第一批建议只完成以下内容:
|
||||
|
||||
1. 新增 `UniformLocation`;
|
||||
2. 将 `Uniform<T, ...>` 收敛到 `Uniform<T>`;
|
||||
3. 把 `SetUniformValue` 从 `Uniform.cs` 移到独立 partial 文件;
|
||||
4. 修复 `Vec4` 与整数 uniform 调用;
|
||||
5. 让 `ShaderStruct` 不再访问 `OpenglContext*`;
|
||||
6. 给 GenerateGL 增加 `UniformFamilyModel` 和 `UniformEmitter`;
|
||||
7. 同时生成 Context 与 Loader,并消除 ContextShadow 的手工同步;
|
||||
8. 增加 Context/Loader/Wrapper 集合一致性测试。
|
||||
|
||||
完成这一批后,再决定是否立即重构全部 `glFunction.cs`。这样可以先解决 Uniform API 和生成同步问题,同时避免一次性扩大到整个 Graphics 框架。
|
||||
@@ -1,93 +0,0 @@
|
||||
# StgSharp.GenerateGL 源生成器技术文档
|
||||
|
||||
## 目标与范围
|
||||
- **输入**:Khronos OpenGL Registry `gl.xml`(Core Profile 为主,版本 3.3→4.6,可选扩展)。
|
||||
- **输出**:合并的 partial `OpenglContext`(`delegate*` 字段)、分版本 `OpenGLFunction` 薄包装方法,以及按版本生成的 Uniform 语义重载。生成结果最终对应 `src\StgSharp.Graphics\OpenGL\Generated\`,评审时可以通过命令行参数输出到独立目录。
|
||||
- **风格**:保持现有函数指针字段 + 薄封装方法模式;兼容现有命名和类型定义(如 `GlHandle`)。
|
||||
|
||||
---
|
||||
|
||||
## 阶段 1:输入解析(XML 读取与过滤)
|
||||
- 将 `gl.xml` 作为 AdditionalFile 或 EmbeddedResource,使用 `XmlReader` 流式解析。
|
||||
- 解析节点:
|
||||
- `<commands><command>`:函数名、返回类型、参数。
|
||||
- `<enums>`:常量。
|
||||
- `<feature profile="core">`:按 `version` 收录命令/常量。
|
||||
- `<extensions>`:可选扩展(ARB/KHR/EXT/NV)。
|
||||
- 过滤策略:仅 Core Profile 且版本 ≥ 3.3(3.3→4.6 递进);扩展按启用列表追加。
|
||||
|
||||
---
|
||||
|
||||
## 阶段 2:类型映射与句柄规则
|
||||
- 整数:`GLenum`/`GLbitfield`→`uint`;`GLint`/`GLsizei`/`GLfixed`→`int`;`GLuint`→`uint`;`GLboolean`→`byte`(包装层可 bool→byte)。
|
||||
- 浮点:`GLfloat`→`float`;`GLdouble`→`double`。
|
||||
- 指针与尺寸:`void*`/`const void*`→`void*`;`GLintptr`、`GLsizeiptr`→`nint`;`GLsync`→现有 `glSync` 包装。`GLint64`/`GLuint64` 分别映射为 `long`/`ulong`。回调类型 `GLDEBUGPROC` 暂以指针大小的 `IntPtr` 表示。
|
||||
- 未知 C 类型直接终止生成,不再静默回退为 `IntPtr`。这可以防止 typedef 漏映射后生成 ABI 不兼容的函数指针。
|
||||
- 字符串:函数表中的 `GLchar*` 保持 `byte*` ABI;包装层的 const 单指针使用 UTF-8 `ReadOnlySpan<byte>`,后续可另行提供 `string` 重载。
|
||||
- 参数长度:解析并保留 registry `<param len="...">`。包装层以该表达式判断数组方向、固定长度和关联的 `count`/`bufSize` 参数;底层函数表不使用这些托管规则。
|
||||
- 调用约定:OpenGL APIENTRY 通常 stdcall(Windows);保持与现有 `glContext` 字段一致(`delegate* unmanaged[Stdcall]` 或 `unmanaged[Cdecl]`,需与 loader 对齐)。
|
||||
- 句柄识别:包含 program/shader/buffer/texture/framebuffer/renderbuffer/vertexarray/query/sampler/transformfeedback 等对象名的 `GLuint` 参数 → 包装层使用 `GlHandle`,内部传 `handle.Value`。`glCreateProgram`、`glCreateShader` 等明确返回 object name 的命令返回 `GlHandle`。
|
||||
- `GLenum` 不再仅凭参数名 `type` 推断为 `ShaderType`;低层包装保持 `uint`,避免把像素类型、索引类型等无关参数错误分类。
|
||||
- glGet* 输出:保留指针签名,或另行生成 unsafe Span/stackalloc 适配器;核心先生成指针版。
|
||||
|
||||
---
|
||||
|
||||
## 阶段 3:版本分组与文件组织
|
||||
- 目标目录:`src\StgSharp.Graphics\OpenGL\Generated\`
|
||||
- Context 生成一个合并文件:
|
||||
- `OpenglContext.g.cs`:所有目标 Core 版本需要的 `delegate*` 字段。
|
||||
- Raw 包装按版本生成独立 partial:
|
||||
- `OpenGLFunction.Raw.v3_3.g.cs`, …:包装方法 `public void Foo(...) => Context.glFoo(...);`
|
||||
- Uniform 重载按首次引入版本生成:
|
||||
- `OpenGLFunction.Uniform.v3_3.g.cs`、`v4_0`、`v4_1`。
|
||||
- 不再同时生成分版本 Context 与合并 Context,避免同一字段被 partial struct 重复定义。
|
||||
- 常量/枚举:`glConst.generated.cs`(或分版本补丁),避免与现有重复,先查已有定义再生成。
|
||||
- 命名空间:`StgSharp.Graphics.OpenGL`;类声明:`partial struct/partial class glContext`(按现有定义),`partial class OpenGLFunction`。
|
||||
|
||||
---
|
||||
|
||||
## 阶段 4:生成规则(函数表与包装)
|
||||
- `OpenglContext` 字段:`internal unsafe delegate*<converted_sig> glFoo;`
|
||||
- `OpenGLFunction` 包装:薄封装直接转发;句柄参数用 `GlHandle`,内部传 `handle.Value`;`bool` 参数按底层 `GLboolean` 需要转换为 `byte/uint`。
|
||||
- 指针包装:带长度的 `const T*` 生成 `ReadOnlySpan<T>`,输出 `T*` 生成 `Span<T>`,`len="1"` 的输出生成 `out T`。可由单个 Span 唯一决定的 `count`/`n`/`bufSize` 从 `Span.Length` 推导;共享同一长度的输入 Span 会检查长度一致。简单常量、乘法和除法长度表达式会生成下限检查。
|
||||
- registry 中省略 `len` 的零结尾 const 字符指针仍生成 `ReadOnlySpan<byte>`;省略 `len` 的 `glGet*` 数值单指针按未知长度输出生成 `Span<T>`。`void*`、二级指针、驱动拥有的返回指针以及表示 Buffer 偏移的指针继续保留原始形式。
|
||||
- 可重载的 C 类型尾缀会折叠为同一 C# 方法名,例如 `TexParameterf/i/fv/iv` → `TexParameter(...)`,`BlendEquation/BlendEquationi` → `BlendEquation(...)`。生成器以最终 C# 参数签名检测冲突;无法区分时保留最少的维度或语义尾缀。
|
||||
- `glUniform1/2/3/4[f|i|ui|d][v]` 和 `glProgramUniform*` 不再作为一组公开的 C 风格方法生成,而是生成 `SetUniformValue(...)` 重载。location 从 `Uniform<T...>.id.SignedValue` 取得;数组版本接受 `ReadOnlySpan<T>` 并自动计算 count。
|
||||
- float vector 额外生成 `Vec2`、`Vec3`、`Vec4` 重载,4×4 float matrix 生成 `GraphicsMatrix` 重载。所有 uniform setter(包括 matrix)都不进入 Raw wrapper;项目暂时没有对应托管类型的其他矩阵形状只保留底层 `OpenglContext` 函数指针,待类型齐备后再生成公开重载。
|
||||
- `glVertexAttribN*v` 若存在对应的标量命令 `glVertexAttribN*`,不再生成重复的 Span wrapper;公开 API 使用 `VertexAttrib(index, x, y, z, w)` 形式的固定分量重载。只有不存在标量等价命令的特殊整数/归一化形式才暂时保留独立入口。
|
||||
- `FramebufferTexture1D/2D/3D` 表示不同 OpenGL API,不参与维度重载归并。
|
||||
- 去重:若同名字段/方法已存在,跳过或比对签名避免重复生成。
|
||||
|
||||
---
|
||||
|
||||
## 阶段 5:增量源生成器结构
|
||||
- 步骤:
|
||||
1. 收集 AdditionalFiles(`gl.xml`)。
|
||||
2. 解析→建模(CommandModel, EnumModel, FeatureModel)。
|
||||
3. 按版本/profile 过滤。
|
||||
4. Emit:分文件输出(`SourceProductionContext.AddSource`)。
|
||||
- 配置建议:`LangVersion=preview`(支持 `delegate* unmanaged[Stdcall]`);仅引用必要的 XML 解析库。
|
||||
|
||||
---
|
||||
|
||||
## 阶段 6:兼容性与发布注意
|
||||
- 不改动现有手写文件,仅追加 partial。
|
||||
- 常量值需与现有 `glConst` 保持一致,生成前检查重复。
|
||||
- 大 `gl.xml` 使用流式解析避免内存压力。
|
||||
- Loader(`wglGetProcAddress/glXGetProcAddress/eglGetProcAddress`)不在本轮生成,字段调用约定需与 loader 对齐。
|
||||
|
||||
---
|
||||
|
||||
## 下一步实施建议
|
||||
1. 将 `gl.xml` 添加为 AdditionalFile。
|
||||
2. 搭建增量生成器骨架:Parse → Filter → Emit。
|
||||
3. 先生成 3.3 子集验证编译,再扩展到 4.6。
|
||||
4. 按需追加扩展(ARB/KHR),保持可配置启用列表。
|
||||
|
||||
## 本地评审输出
|
||||
|
||||
可把首个命令行参数作为输出目录:
|
||||
|
||||
```powershell
|
||||
dotnet run --project test\StgSharp.GenerateGL\GenerateGL.csproj -- test\StgSharp.GenerateGL\Generated
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Generated\**\*.cs" />
|
||||
<None Include="Generated\**\*.cs" />
|
||||
<None Update="xml\**" CopyToOutputDirectory="Always" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,238 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Version: 4.0
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BeginQueryIndexed(uint target, uint index, uint id)
|
||||
{
|
||||
Context.glBeginQueryIndexed(target, index, id);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindTransformFeedback(uint target, uint id)
|
||||
{
|
||||
Context.glBindTransformFeedback(target, id);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BlendEquationSeparate(uint buf, uint modeRGB, uint modeAlpha)
|
||||
{
|
||||
Context.glBlendEquationSeparatei(buf, modeRGB, modeAlpha);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BlendEquation(uint buf, uint mode)
|
||||
{
|
||||
Context.glBlendEquationi(buf, mode);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BlendFuncSeparate(uint buf, uint srcRGB, uint dstRGB, uint srcAlpha, uint dstAlpha)
|
||||
{
|
||||
Context.glBlendFuncSeparatei(buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BlendFunc(uint buf, uint src, uint dst)
|
||||
{
|
||||
Context.glBlendFunci(buf, src, dst);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DeleteTransformFeedbacks(ReadOnlySpan<uint> ids)
|
||||
{
|
||||
fixed (uint* idsPtr = ids)
|
||||
{
|
||||
Context.glDeleteTransformFeedbacks(checked((int)ids.Length), idsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawArraysIndirect(uint mode, void* indirect)
|
||||
{
|
||||
Context.glDrawArraysIndirect(mode, indirect);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawElementsIndirect(uint mode, uint type, void* indirect)
|
||||
{
|
||||
Context.glDrawElementsIndirect(mode, type, indirect);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawTransformFeedback(uint mode, uint id)
|
||||
{
|
||||
Context.glDrawTransformFeedback(mode, id);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawTransformFeedbackStream(uint mode, uint id, uint stream)
|
||||
{
|
||||
Context.glDrawTransformFeedbackStream(mode, id, stream);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void EndQueryIndexed(uint target, uint index)
|
||||
{
|
||||
Context.glEndQueryIndexed(target, index);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GenTransformFeedbacks(Span<uint> ids)
|
||||
{
|
||||
fixed (uint* idsPtr = ids)
|
||||
{
|
||||
Context.glGenTransformFeedbacks(checked((int)ids.Length), idsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetActiveSubroutineName(GlHandle program, uint shadertype, uint index, out int length, Span<byte> name)
|
||||
{
|
||||
length = default;
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
Context.glGetActiveSubroutineName(program.Value, shadertype, index, checked((int)name.Length), lengthPtr, namePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetActiveSubroutineUniformName(GlHandle program, uint shadertype, uint index, out int length, Span<byte> name)
|
||||
{
|
||||
length = default;
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
Context.glGetActiveSubroutineUniformName(program.Value, shadertype, index, checked((int)name.Length), lengthPtr, namePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetActiveSubroutineUniformiv(GlHandle program, uint shadertype, uint index, uint pname, Span<int> values)
|
||||
{
|
||||
fixed (int* valuesPtr = values)
|
||||
{
|
||||
Context.glGetActiveSubroutineUniformiv(program.Value, shadertype, index, pname, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetProgramStageiv(GlHandle program, uint shadertype, uint pname, out int values)
|
||||
{
|
||||
values = default;
|
||||
fixed (int* valuesPtr = &values)
|
||||
{
|
||||
Context.glGetProgramStageiv(program.Value, shadertype, pname, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetQueryIndexediv(uint target, uint index, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetQueryIndexediv(target, index, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint GetSubroutineIndex(GlHandle program, uint shadertype, ReadOnlySpan<byte> name)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
return Context.glGetSubroutineIndex(program.Value, shadertype, namePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int GetSubroutineUniformLocation(GlHandle program, uint shadertype, ReadOnlySpan<byte> name)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
return Context.glGetSubroutineUniformLocation(program.Value, shadertype, namePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetUniformSubroutineuiv(uint shadertype, int location, out uint @params)
|
||||
{
|
||||
@params = default;
|
||||
fixed (uint* @paramsPtr = &@params)
|
||||
{
|
||||
Context.glGetUniformSubroutineuiv(shadertype, location, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetUniform(GlHandle program, int location, Span<double> @params)
|
||||
{
|
||||
fixed (double* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetUniformdv(program.Value, location, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte IsTransformFeedback(uint id)
|
||||
{
|
||||
return Context.glIsTransformFeedback(id);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void MinSampleShading(float value)
|
||||
{
|
||||
Context.glMinSampleShading(value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void PatchParameter(uint pname, ReadOnlySpan<float> values)
|
||||
{
|
||||
fixed (float* valuesPtr = values)
|
||||
{
|
||||
Context.glPatchParameterfv(pname, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void PatchParameter(uint pname, int value)
|
||||
{
|
||||
Context.glPatchParameteri(pname, value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void PauseTransformFeedback()
|
||||
{
|
||||
Context.glPauseTransformFeedback();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ResumeTransformFeedback()
|
||||
{
|
||||
Context.glResumeTransformFeedback();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void UniformSubroutinesuiv(uint shadertype, ReadOnlySpan<uint> indices)
|
||||
{
|
||||
fixed (uint* indicesPtr = indices)
|
||||
{
|
||||
Context.glUniformSubroutinesuiv(shadertype, checked((int)indices.Length), indicesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,286 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Version: 4.1
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ActiveShaderProgram(uint pipeline, GlHandle program)
|
||||
{
|
||||
Context.glActiveShaderProgram(pipeline, program.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindProgramPipeline(uint pipeline)
|
||||
{
|
||||
Context.glBindProgramPipeline(pipeline);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearDepth(float d)
|
||||
{
|
||||
Context.glClearDepthf(d);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public GlHandle CreateShaderProgramv(uint type, int count, byte** strings)
|
||||
{
|
||||
return GlHandle.Create(Context.glCreateShaderProgramv(type, count, strings));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DeleteProgramPipelines(ReadOnlySpan<uint> pipelines)
|
||||
{
|
||||
fixed (uint* pipelinesPtr = pipelines)
|
||||
{
|
||||
Context.glDeleteProgramPipelines(checked((int)pipelines.Length), pipelinesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DepthRangeArrayv(uint first, int count, ReadOnlySpan<double> v)
|
||||
{
|
||||
fixed (double* vPtr = v)
|
||||
{
|
||||
Context.glDepthRangeArrayv(first, count, vPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DepthRangeIndexed(uint index, double n, double f)
|
||||
{
|
||||
Context.glDepthRangeIndexed(index, n, f);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DepthRange(float n, float f)
|
||||
{
|
||||
Context.glDepthRangef(n, f);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GenProgramPipelines(Span<uint> pipelines)
|
||||
{
|
||||
fixed (uint* pipelinesPtr = pipelines)
|
||||
{
|
||||
Context.glGenProgramPipelines(checked((int)pipelines.Length), pipelinesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetDoublei_v(uint target, uint index, Span<double> data)
|
||||
{
|
||||
fixed (double* dataPtr = data)
|
||||
{
|
||||
Context.glGetDoublei_v(target, index, dataPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetFloati_v(uint target, uint index, Span<float> data)
|
||||
{
|
||||
fixed (float* dataPtr = data)
|
||||
{
|
||||
Context.glGetFloati_v(target, index, dataPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetProgramBinary(GlHandle program, int bufSize, out int length, out uint binaryFormat, void* binary)
|
||||
{
|
||||
length = default;
|
||||
binaryFormat = default;
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (uint* binaryFormatPtr = &binaryFormat)
|
||||
{
|
||||
Context.glGetProgramBinary(program.Value, bufSize, lengthPtr, binaryFormatPtr, binary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetProgramPipelineInfoLog(uint pipeline, out int length, Span<byte> infoLog)
|
||||
{
|
||||
length = default;
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (byte* infoLogPtr = infoLog)
|
||||
{
|
||||
Context.glGetProgramPipelineInfoLog(pipeline, checked((int)infoLog.Length), lengthPtr, infoLogPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetProgramPipelineiv(uint pipeline, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetProgramPipelineiv(pipeline, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetShaderPrecisionFormat(uint shadertype, uint precisiontype, Span<int> range, out int precision)
|
||||
{
|
||||
precision = default;
|
||||
if (range.Length < 2) {
|
||||
throw new ArgumentException("Span is shorter than the OpenGL length expression '2'.", nameof(range));
|
||||
}
|
||||
fixed (int* rangePtr = range)
|
||||
{
|
||||
fixed (int* precisionPtr = &precision)
|
||||
{
|
||||
Context.glGetShaderPrecisionFormat(shadertype, precisiontype, rangePtr, precisionPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetVertexAttribLdv(uint index, uint pname, Span<double> @params)
|
||||
{
|
||||
fixed (double* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetVertexAttribLdv(index, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte IsProgramPipeline(uint pipeline)
|
||||
{
|
||||
return Context.glIsProgramPipeline(pipeline);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ProgramBinary(GlHandle program, uint binaryFormat, void* binary, int length)
|
||||
{
|
||||
Context.glProgramBinary(program.Value, binaryFormat, binary, length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ProgramParameter(GlHandle program, uint pname, int value)
|
||||
{
|
||||
Context.glProgramParameteri(program.Value, pname, value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReleaseShaderCompiler()
|
||||
{
|
||||
Context.glReleaseShaderCompiler();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ScissorArrayv(uint first, int count, ReadOnlySpan<int> v)
|
||||
{
|
||||
fixed (int* vPtr = v)
|
||||
{
|
||||
Context.glScissorArrayv(first, count, vPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ScissorIndexed(uint index, int left, int bottom, int width, int height)
|
||||
{
|
||||
Context.glScissorIndexed(index, left, bottom, width, height);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ScissorIndexed(uint index, ReadOnlySpan<int> v)
|
||||
{
|
||||
if (v.Length < 4) {
|
||||
throw new ArgumentException("Span is shorter than the OpenGL length expression '4'.", nameof(v));
|
||||
}
|
||||
fixed (int* vPtr = v)
|
||||
{
|
||||
Context.glScissorIndexedv(index, vPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ShaderBinary(ReadOnlySpan<uint> shaders, uint binaryFormat, void* binary, int length)
|
||||
{
|
||||
fixed (uint* shadersPtr = shaders)
|
||||
{
|
||||
Context.glShaderBinary(checked((int)shaders.Length), shadersPtr, binaryFormat, binary, length);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void UseProgramStages(uint pipeline, uint stages, GlHandle program)
|
||||
{
|
||||
Context.glUseProgramStages(pipeline, stages, program.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ValidateProgramPipeline(uint pipeline)
|
||||
{
|
||||
Context.glValidateProgramPipeline(pipeline);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribL(uint index, double x)
|
||||
{
|
||||
Context.glVertexAttribL1d(index, x);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribL(uint index, double x, double y)
|
||||
{
|
||||
Context.glVertexAttribL2d(index, x, y);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribL(uint index, double x, double y, double z)
|
||||
{
|
||||
Context.glVertexAttribL3d(index, x, y, z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribL(uint index, double x, double y, double z, double w)
|
||||
{
|
||||
Context.glVertexAttribL4d(index, x, y, z, w);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribLPointer(uint index, int size, uint type, int stride, void* pointer)
|
||||
{
|
||||
Context.glVertexAttribLPointer(index, size, type, stride, pointer);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ViewportArrayv(uint first, int count, ReadOnlySpan<float> v)
|
||||
{
|
||||
fixed (float* vPtr = v)
|
||||
{
|
||||
Context.glViewportArrayv(first, count, vPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ViewportIndexed(uint index, float x, float y, float w, float h)
|
||||
{
|
||||
Context.glViewportIndexedf(index, x, y, w, h);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ViewportIndexed(uint index, ReadOnlySpan<float> v)
|
||||
{
|
||||
if (v.Length < 4) {
|
||||
throw new ArgumentException("Span is shorter than the OpenGL length expression '4'.", nameof(v));
|
||||
}
|
||||
fixed (float* vPtr = v)
|
||||
{
|
||||
Context.glViewportIndexedfv(index, vPtr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Version: 4.2
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindImageTexture(uint unit, GlHandle texture, int level, byte layered, int layer, uint access, uint format)
|
||||
{
|
||||
Context.glBindImageTexture(unit, texture.Value, level, layered, layer, access, format);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawArraysInstancedBaseInstance(uint mode, int first, int count, int instancecount, uint baseinstance)
|
||||
{
|
||||
Context.glDrawArraysInstancedBaseInstance(mode, first, count, instancecount, baseinstance);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawElementsInstancedBaseInstance(uint mode, int count, uint type, void* indices, int instancecount, uint baseinstance)
|
||||
{
|
||||
Context.glDrawElementsInstancedBaseInstance(mode, count, type, indices, instancecount, baseinstance);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawElementsInstancedBaseVertexBaseInstance(uint mode, int count, uint type, void* indices, int instancecount, int basevertex, uint baseinstance)
|
||||
{
|
||||
Context.glDrawElementsInstancedBaseVertexBaseInstance(mode, count, type, indices, instancecount, basevertex, baseinstance);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawTransformFeedbackInstanced(uint mode, uint id, int instancecount)
|
||||
{
|
||||
Context.glDrawTransformFeedbackInstanced(mode, id, instancecount);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawTransformFeedbackStreamInstanced(uint mode, uint id, uint stream, int instancecount)
|
||||
{
|
||||
Context.glDrawTransformFeedbackStreamInstanced(mode, id, stream, instancecount);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetActiveAtomicCounterBufferiv(GlHandle program, GlHandle bufferIndex, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetActiveAtomicCounterBufferiv(program.Value, bufferIndex.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetInternalformativ(uint target, uint internalformat, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetInternalformativ(target, internalformat, pname, checked((int)@params.Length), @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void MemoryBarrier(uint barriers)
|
||||
{
|
||||
Context.glMemoryBarrier(barriers);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TexStorage1D(uint target, int levels, uint internalformat, int width)
|
||||
{
|
||||
Context.glTexStorage1D(target, levels, internalformat, width);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TexStorage2D(uint target, int levels, uint internalformat, int width, int height)
|
||||
{
|
||||
Context.glTexStorage2D(target, levels, internalformat, width, height);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TexStorage3D(uint target, int levels, uint internalformat, int width, int height, int depth)
|
||||
{
|
||||
Context.glTexStorage3D(target, levels, internalformat, width, height, depth);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,379 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Version: 4.3
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindVertexBuffer(uint bindingindex, GlHandle buffer, nint offset, int stride)
|
||||
{
|
||||
Context.glBindVertexBuffer(bindingindex, buffer.Value, offset, stride);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearBufferData(uint target, uint internalformat, uint format, uint type, void* data)
|
||||
{
|
||||
Context.glClearBufferData(target, internalformat, format, type, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearBufferSubData(uint target, uint internalformat, nint offset, nint size, uint format, uint type, void* data)
|
||||
{
|
||||
Context.glClearBufferSubData(target, internalformat, offset, size, format, type, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CopyImageSubData(uint srcName, uint srcTarget, int srcLevel, int srcX, int srcY, int srcZ, uint dstName, uint dstTarget, int dstLevel, int dstX, int dstY, int dstZ, int srcWidth, int srcHeight, int srcDepth)
|
||||
{
|
||||
Context.glCopyImageSubData(srcName, srcTarget, srcLevel, srcX, srcY, srcZ, dstName, dstTarget, dstLevel, dstX, dstY, dstZ, srcWidth, srcHeight, srcDepth);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DebugMessageCallback(IntPtr callback, void* userParam)
|
||||
{
|
||||
Context.glDebugMessageCallback(callback, userParam);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DebugMessageControl(uint source, uint type, uint severity, ReadOnlySpan<uint> ids, byte enabled)
|
||||
{
|
||||
fixed (uint* idsPtr = ids)
|
||||
{
|
||||
Context.glDebugMessageControl(source, type, severity, checked((int)ids.Length), idsPtr, enabled);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DebugMessageInsert(uint source, uint type, uint id, uint severity, int length, ReadOnlySpan<byte> buf)
|
||||
{
|
||||
fixed (byte* bufPtr = buf)
|
||||
{
|
||||
Context.glDebugMessageInsert(source, type, id, severity, length, bufPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DispatchCompute(uint num_groups_x, uint num_groups_y, uint num_groups_z)
|
||||
{
|
||||
Context.glDispatchCompute(num_groups_x, num_groups_y, num_groups_z);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DispatchComputeIndirect(nint indirect)
|
||||
{
|
||||
Context.glDispatchComputeIndirect(indirect);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void FramebufferParameter(uint target, uint pname, int param)
|
||||
{
|
||||
Context.glFramebufferParameteri(target, pname, param);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint GetDebugMessageLog(Span<uint> sources, Span<uint> types, Span<uint> ids, Span<uint> severities, Span<int> lengths, Span<byte> messageLog)
|
||||
{
|
||||
if (types.Length != sources.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(types));
|
||||
}
|
||||
if (ids.Length != sources.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(ids));
|
||||
}
|
||||
if (severities.Length != sources.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(severities));
|
||||
}
|
||||
if (lengths.Length != sources.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(lengths));
|
||||
}
|
||||
fixed (uint* sourcesPtr = sources)
|
||||
{
|
||||
fixed (uint* typesPtr = types)
|
||||
{
|
||||
fixed (uint* idsPtr = ids)
|
||||
{
|
||||
fixed (uint* severitiesPtr = severities)
|
||||
{
|
||||
fixed (int* lengthsPtr = lengths)
|
||||
{
|
||||
fixed (byte* messageLogPtr = messageLog)
|
||||
{
|
||||
return Context.glGetDebugMessageLog(checked((uint)sources.Length), checked((int)messageLog.Length), sourcesPtr, typesPtr, idsPtr, severitiesPtr, lengthsPtr, messageLogPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetFramebufferParameteriv(uint target, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetFramebufferParameteriv(target, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetInternalformati64v(uint target, uint internalformat, uint pname, Span<long> @params)
|
||||
{
|
||||
fixed (long* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetInternalformati64v(target, internalformat, pname, checked((int)@params.Length), @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetObjectLabel(uint identifier, uint name, out int length, Span<byte> label)
|
||||
{
|
||||
length = default;
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (byte* labelPtr = label)
|
||||
{
|
||||
Context.glGetObjectLabel(identifier, name, checked((int)label.Length), lengthPtr, labelPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetObjectPtrLabel(void* ptr, out int length, Span<byte> label)
|
||||
{
|
||||
length = default;
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (byte* labelPtr = label)
|
||||
{
|
||||
Context.glGetObjectPtrLabel(ptr, checked((int)label.Length), lengthPtr, labelPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetPointerv(uint pname, void** @params)
|
||||
{
|
||||
Context.glGetPointerv(pname, @params);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetProgramInterfaceiv(GlHandle program, uint programInterface, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetProgramInterfaceiv(program.Value, programInterface, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint GetProgramResourceIndex(GlHandle program, uint programInterface, ReadOnlySpan<byte> name)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
return Context.glGetProgramResourceIndex(program.Value, programInterface, namePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int GetProgramResourceLocation(GlHandle program, uint programInterface, ReadOnlySpan<byte> name)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
return Context.glGetProgramResourceLocation(program.Value, programInterface, namePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int GetProgramResourceLocationIndex(GlHandle program, uint programInterface, ReadOnlySpan<byte> name)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
return Context.glGetProgramResourceLocationIndex(program.Value, programInterface, namePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetProgramResourceName(GlHandle program, uint programInterface, uint index, out int length, Span<byte> name)
|
||||
{
|
||||
length = default;
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (byte* namePtr = name)
|
||||
{
|
||||
Context.glGetProgramResourceName(program.Value, programInterface, index, checked((int)name.Length), lengthPtr, namePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetProgramResourceiv(GlHandle program, uint programInterface, uint index, ReadOnlySpan<uint> props, out int length, Span<int> @params)
|
||||
{
|
||||
length = default;
|
||||
fixed (uint* propsPtr = props)
|
||||
{
|
||||
fixed (int* lengthPtr = &length)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetProgramResourceiv(program.Value, programInterface, index, checked((int)props.Length), propsPtr, checked((int)@params.Length), lengthPtr, @paramsPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateBufferData(GlHandle buffer)
|
||||
{
|
||||
Context.glInvalidateBufferData(buffer.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateBufferSubData(GlHandle buffer, nint offset, nint length)
|
||||
{
|
||||
Context.glInvalidateBufferSubData(buffer.Value, offset, length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateFramebuffer(uint target, ReadOnlySpan<uint> attachments)
|
||||
{
|
||||
fixed (uint* attachmentsPtr = attachments)
|
||||
{
|
||||
Context.glInvalidateFramebuffer(target, checked((int)attachments.Length), attachmentsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateSubFramebuffer(uint target, ReadOnlySpan<uint> attachments, int x, int y, int width, int height)
|
||||
{
|
||||
fixed (uint* attachmentsPtr = attachments)
|
||||
{
|
||||
Context.glInvalidateSubFramebuffer(target, checked((int)attachments.Length), attachmentsPtr, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateTexImage(GlHandle texture, int level)
|
||||
{
|
||||
Context.glInvalidateTexImage(texture.Value, level);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateTexSubImage(GlHandle texture, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth)
|
||||
{
|
||||
Context.glInvalidateTexSubImage(texture.Value, level, xoffset, yoffset, zoffset, width, height, depth);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void MultiDrawArraysIndirect(uint mode, void* indirect, int drawcount, int stride)
|
||||
{
|
||||
Context.glMultiDrawArraysIndirect(mode, indirect, drawcount, stride);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void MultiDrawElementsIndirect(uint mode, uint type, void* indirect, int drawcount, int stride)
|
||||
{
|
||||
Context.glMultiDrawElementsIndirect(mode, type, indirect, drawcount, stride);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ObjectLabel(uint identifier, uint name, int length, ReadOnlySpan<byte> label)
|
||||
{
|
||||
fixed (byte* labelPtr = label)
|
||||
{
|
||||
Context.glObjectLabel(identifier, name, length, labelPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ObjectPtrLabel(void* ptr, int length, ReadOnlySpan<byte> label)
|
||||
{
|
||||
fixed (byte* labelPtr = label)
|
||||
{
|
||||
Context.glObjectPtrLabel(ptr, length, labelPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void PopDebugGroup()
|
||||
{
|
||||
Context.glPopDebugGroup();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void PushDebugGroup(uint source, uint id, int length, ReadOnlySpan<byte> message)
|
||||
{
|
||||
fixed (byte* messagePtr = message)
|
||||
{
|
||||
Context.glPushDebugGroup(source, id, length, messagePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ShaderStorageBlockBinding(GlHandle program, uint storageBlockIndex, uint storageBlockBinding)
|
||||
{
|
||||
Context.glShaderStorageBlockBinding(program.Value, storageBlockIndex, storageBlockBinding);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TexBufferRange(uint target, uint internalformat, GlHandle buffer, nint offset, nint size)
|
||||
{
|
||||
Context.glTexBufferRange(target, internalformat, buffer.Value, offset, size);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TexStorage2DMultisample(uint target, int samples, uint internalformat, int width, int height, byte fixedsamplelocations)
|
||||
{
|
||||
Context.glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TexStorage3DMultisample(uint target, int samples, uint internalformat, int width, int height, int depth, byte fixedsamplelocations)
|
||||
{
|
||||
Context.glTexStorage3DMultisample(target, samples, internalformat, width, height, depth, fixedsamplelocations);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureView(GlHandle texture, uint target, GlHandle origtexture, uint internalformat, uint minlevel, uint numlevels, uint minlayer, uint numlayers)
|
||||
{
|
||||
Context.glTextureView(texture.Value, target, origtexture.Value, internalformat, minlevel, numlevels, minlayer, numlayers);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribBinding(uint attribindex, uint bindingindex)
|
||||
{
|
||||
Context.glVertexAttribBinding(attribindex, bindingindex);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribFormat(uint attribindex, int size, uint type, byte normalized, uint relativeoffset)
|
||||
{
|
||||
Context.glVertexAttribFormat(attribindex, size, type, normalized, relativeoffset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribIFormat(uint attribindex, int size, uint type, uint relativeoffset)
|
||||
{
|
||||
Context.glVertexAttribIFormat(attribindex, size, type, relativeoffset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexAttribLFormat(uint attribindex, int size, uint type, uint relativeoffset)
|
||||
{
|
||||
Context.glVertexAttribLFormat(attribindex, size, type, relativeoffset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexBindingDivisor(uint bindingindex, uint divisor)
|
||||
{
|
||||
Context.glVertexBindingDivisor(bindingindex, divisor);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Version: 4.4
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindBuffersBase(uint target, uint first, ReadOnlySpan<uint> buffers)
|
||||
{
|
||||
fixed (uint* buffersPtr = buffers)
|
||||
{
|
||||
Context.glBindBuffersBase(target, first, checked((int)buffers.Length), buffersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindBuffersRange(uint target, uint first, ReadOnlySpan<uint> buffers, ReadOnlySpan<nint> offsets, ReadOnlySpan<nint> sizes)
|
||||
{
|
||||
if (offsets.Length != buffers.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(offsets));
|
||||
}
|
||||
if (sizes.Length != buffers.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(sizes));
|
||||
}
|
||||
fixed (uint* buffersPtr = buffers)
|
||||
{
|
||||
fixed (nint* offsetsPtr = offsets)
|
||||
{
|
||||
fixed (nint* sizesPtr = sizes)
|
||||
{
|
||||
Context.glBindBuffersRange(target, first, checked((int)buffers.Length), buffersPtr, offsetsPtr, sizesPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindImageTextures(uint first, ReadOnlySpan<uint> textures)
|
||||
{
|
||||
fixed (uint* texturesPtr = textures)
|
||||
{
|
||||
Context.glBindImageTextures(first, checked((int)textures.Length), texturesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindSamplers(uint first, ReadOnlySpan<uint> samplers)
|
||||
{
|
||||
fixed (uint* samplersPtr = samplers)
|
||||
{
|
||||
Context.glBindSamplers(first, checked((int)samplers.Length), samplersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindTextures(uint first, ReadOnlySpan<uint> textures)
|
||||
{
|
||||
fixed (uint* texturesPtr = textures)
|
||||
{
|
||||
Context.glBindTextures(first, checked((int)textures.Length), texturesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindVertexBuffers(uint first, ReadOnlySpan<uint> buffers, ReadOnlySpan<nint> offsets, ReadOnlySpan<int> strides)
|
||||
{
|
||||
if (offsets.Length != buffers.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(offsets));
|
||||
}
|
||||
if (strides.Length != buffers.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(strides));
|
||||
}
|
||||
fixed (uint* buffersPtr = buffers)
|
||||
{
|
||||
fixed (nint* offsetsPtr = offsets)
|
||||
{
|
||||
fixed (int* stridesPtr = strides)
|
||||
{
|
||||
Context.glBindVertexBuffers(first, checked((int)buffers.Length), buffersPtr, offsetsPtr, stridesPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BufferStorage(uint target, nint size, void* data, uint flags)
|
||||
{
|
||||
Context.glBufferStorage(target, size, data, flags);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearTexImage(GlHandle texture, int level, uint format, uint type, void* data)
|
||||
{
|
||||
Context.glClearTexImage(texture.Value, level, format, type, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearTexSubImage(GlHandle texture, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, uint type, void* data)
|
||||
{
|
||||
Context.glClearTexSubImage(texture.Value, level, xoffset, yoffset, zoffset, width, height, depth, format, type, data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,822 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Version: 4.5
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindTextureUnit(uint unit, GlHandle texture)
|
||||
{
|
||||
Context.glBindTextureUnit(unit, texture.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BlitNamedFramebuffer(GlHandle readFramebuffer, GlHandle drawFramebuffer, int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0, int dstX1, int dstY1, uint mask, uint filter)
|
||||
{
|
||||
Context.glBlitNamedFramebuffer(readFramebuffer.Value, drawFramebuffer.Value, srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint CheckNamedFramebufferStatus(GlHandle framebuffer, uint target)
|
||||
{
|
||||
return Context.glCheckNamedFramebufferStatus(framebuffer.Value, target);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearNamedBufferData(GlHandle buffer, uint internalformat, uint format, uint type, void* data)
|
||||
{
|
||||
Context.glClearNamedBufferData(buffer.Value, internalformat, format, type, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearNamedBufferSubData(GlHandle buffer, uint internalformat, nint offset, nint size, uint format, uint type, void* data)
|
||||
{
|
||||
Context.glClearNamedBufferSubData(buffer.Value, internalformat, offset, size, format, type, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearNamedFramebuffer(GlHandle framebuffer, uint buffer, int drawbuffer, float depth, int stencil)
|
||||
{
|
||||
Context.glClearNamedFramebufferfi(framebuffer.Value, buffer, drawbuffer, depth, stencil);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearNamedFramebuffer(GlHandle framebuffer, uint buffer, int drawbuffer, ReadOnlySpan<float> value)
|
||||
{
|
||||
fixed (float* valuePtr = value)
|
||||
{
|
||||
Context.glClearNamedFramebufferfv(framebuffer.Value, buffer, drawbuffer, valuePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearNamedFramebuffer(GlHandle framebuffer, uint buffer, int drawbuffer, ReadOnlySpan<int> value)
|
||||
{
|
||||
fixed (int* valuePtr = value)
|
||||
{
|
||||
Context.glClearNamedFramebufferiv(framebuffer.Value, buffer, drawbuffer, valuePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClearNamedFramebuffer(GlHandle framebuffer, uint buffer, int drawbuffer, ReadOnlySpan<uint> value)
|
||||
{
|
||||
fixed (uint* valuePtr = value)
|
||||
{
|
||||
Context.glClearNamedFramebufferuiv(framebuffer.Value, buffer, drawbuffer, valuePtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ClipControl(uint origin, uint depth)
|
||||
{
|
||||
Context.glClipControl(origin, depth);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CompressedTextureSubImage1D(GlHandle texture, int level, int xoffset, int width, uint format, int imageSize, void* data)
|
||||
{
|
||||
Context.glCompressedTextureSubImage1D(texture.Value, level, xoffset, width, format, imageSize, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CompressedTextureSubImage2D(GlHandle texture, int level, int xoffset, int yoffset, int width, int height, uint format, int imageSize, void* data)
|
||||
{
|
||||
Context.glCompressedTextureSubImage2D(texture.Value, level, xoffset, yoffset, width, height, format, imageSize, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CompressedTextureSubImage3D(GlHandle texture, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, int imageSize, void* data)
|
||||
{
|
||||
Context.glCompressedTextureSubImage3D(texture.Value, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CopyNamedBufferSubData(GlHandle readBuffer, GlHandle writeBuffer, nint readOffset, nint writeOffset, nint size)
|
||||
{
|
||||
Context.glCopyNamedBufferSubData(readBuffer.Value, writeBuffer.Value, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CopyTextureSubImage1D(GlHandle texture, int level, int xoffset, int x, int y, int width)
|
||||
{
|
||||
Context.glCopyTextureSubImage1D(texture.Value, level, xoffset, x, y, width);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CopyTextureSubImage2D(GlHandle texture, int level, int xoffset, int yoffset, int x, int y, int width, int height)
|
||||
{
|
||||
Context.glCopyTextureSubImage2D(texture.Value, level, xoffset, yoffset, x, y, width, height);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CopyTextureSubImage3D(GlHandle texture, int level, int xoffset, int yoffset, int zoffset, int x, int y, int width, int height)
|
||||
{
|
||||
Context.glCopyTextureSubImage3D(texture.Value, level, xoffset, yoffset, zoffset, x, y, width, height);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateBuffers(Span<uint> buffers)
|
||||
{
|
||||
fixed (uint* buffersPtr = buffers)
|
||||
{
|
||||
Context.glCreateBuffers(checked((int)buffers.Length), buffersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateFramebuffers(Span<uint> framebuffers)
|
||||
{
|
||||
fixed (uint* framebuffersPtr = framebuffers)
|
||||
{
|
||||
Context.glCreateFramebuffers(checked((int)framebuffers.Length), framebuffersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateProgramPipelines(Span<uint> pipelines)
|
||||
{
|
||||
fixed (uint* pipelinesPtr = pipelines)
|
||||
{
|
||||
Context.glCreateProgramPipelines(checked((int)pipelines.Length), pipelinesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateQueries(uint target, Span<uint> ids)
|
||||
{
|
||||
fixed (uint* idsPtr = ids)
|
||||
{
|
||||
Context.glCreateQueries(target, checked((int)ids.Length), idsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateRenderbuffers(Span<uint> renderbuffers)
|
||||
{
|
||||
fixed (uint* renderbuffersPtr = renderbuffers)
|
||||
{
|
||||
Context.glCreateRenderbuffers(checked((int)renderbuffers.Length), renderbuffersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateSamplers(Span<uint> samplers)
|
||||
{
|
||||
fixed (uint* samplersPtr = samplers)
|
||||
{
|
||||
Context.glCreateSamplers(checked((int)samplers.Length), samplersPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateTextures(uint target, Span<uint> textures)
|
||||
{
|
||||
fixed (uint* texturesPtr = textures)
|
||||
{
|
||||
Context.glCreateTextures(target, checked((int)textures.Length), texturesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateTransformFeedbacks(Span<uint> ids)
|
||||
{
|
||||
fixed (uint* idsPtr = ids)
|
||||
{
|
||||
Context.glCreateTransformFeedbacks(checked((int)ids.Length), idsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CreateVertexArrays(Span<uint> arrays)
|
||||
{
|
||||
fixed (uint* arraysPtr = arrays)
|
||||
{
|
||||
Context.glCreateVertexArrays(checked((int)arrays.Length), arraysPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DisableVertexArrayAttrib(uint vaobj, uint index)
|
||||
{
|
||||
Context.glDisableVertexArrayAttrib(vaobj, index);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void EnableVertexArrayAttrib(uint vaobj, uint index)
|
||||
{
|
||||
Context.glEnableVertexArrayAttrib(vaobj, index);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void FlushMappedNamedBufferRange(GlHandle buffer, nint offset, nint length)
|
||||
{
|
||||
Context.glFlushMappedNamedBufferRange(buffer.Value, offset, length);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GenerateTextureMipmap(GlHandle texture)
|
||||
{
|
||||
Context.glGenerateTextureMipmap(texture.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetCompressedTextureImage(GlHandle texture, int level, int bufSize, void* pixels)
|
||||
{
|
||||
Context.glGetCompressedTextureImage(texture.Value, level, bufSize, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetCompressedTextureSubImage(GlHandle texture, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int bufSize, void* pixels)
|
||||
{
|
||||
Context.glGetCompressedTextureSubImage(texture.Value, level, xoffset, yoffset, zoffset, width, height, depth, bufSize, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint GetGraphicsResetStatus()
|
||||
{
|
||||
return Context.glGetGraphicsResetStatus();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetNamedBufferParameter(GlHandle buffer, uint pname, Span<long> @params)
|
||||
{
|
||||
fixed (long* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetNamedBufferParameteri64v(buffer.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetNamedBufferParameter(GlHandle buffer, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetNamedBufferParameteriv(buffer.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetNamedBufferPointerv(GlHandle buffer, uint pname, void** @params)
|
||||
{
|
||||
Context.glGetNamedBufferPointerv(buffer.Value, pname, @params);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetNamedBufferSubData(GlHandle buffer, nint offset, nint size, void* data)
|
||||
{
|
||||
Context.glGetNamedBufferSubData(buffer.Value, offset, size, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetNamedFramebufferAttachmentParameteriv(GlHandle framebuffer, uint attachment, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetNamedFramebufferAttachmentParameteriv(framebuffer.Value, attachment, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetNamedFramebufferParameteriv(GlHandle framebuffer, uint pname, Span<int> param)
|
||||
{
|
||||
fixed (int* paramPtr = param)
|
||||
{
|
||||
Context.glGetNamedFramebufferParameteriv(framebuffer.Value, pname, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetNamedRenderbufferParameteriv(GlHandle renderbuffer, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetNamedRenderbufferParameteriv(renderbuffer.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetQueryBufferObject(uint id, GlHandle buffer, uint pname, nint offset)
|
||||
{
|
||||
Context.glGetQueryBufferObjecti64v(id, buffer.Value, pname, offset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetQueryBufferObjectiv(uint id, GlHandle buffer, uint pname, nint offset)
|
||||
{
|
||||
Context.glGetQueryBufferObjectiv(id, buffer.Value, pname, offset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetQueryBufferObjectui64v(uint id, GlHandle buffer, uint pname, nint offset)
|
||||
{
|
||||
Context.glGetQueryBufferObjectui64v(id, buffer.Value, pname, offset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetQueryBufferObjectuiv(uint id, GlHandle buffer, uint pname, nint offset)
|
||||
{
|
||||
Context.glGetQueryBufferObjectuiv(id, buffer.Value, pname, offset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureImage(GlHandle texture, int level, uint format, uint type, int bufSize, void* pixels)
|
||||
{
|
||||
Context.glGetTextureImage(texture.Value, level, format, type, bufSize, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureLevelParameter(GlHandle texture, int level, uint pname, Span<float> @params)
|
||||
{
|
||||
fixed (float* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetTextureLevelParameterfv(texture.Value, level, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureLevelParameter(GlHandle texture, int level, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetTextureLevelParameteriv(texture.Value, level, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureParameterI(GlHandle texture, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetTextureParameterIiv(texture.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureParameterI(GlHandle texture, uint pname, Span<uint> @params)
|
||||
{
|
||||
fixed (uint* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetTextureParameterIuiv(texture.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureParameter(GlHandle texture, uint pname, Span<float> @params)
|
||||
{
|
||||
fixed (float* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetTextureParameterfv(texture.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureParameter(GlHandle texture, uint pname, Span<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetTextureParameteriv(texture.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureSubImage(GlHandle texture, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, uint type, int bufSize, void* pixels)
|
||||
{
|
||||
Context.glGetTextureSubImage(texture.Value, level, xoffset, yoffset, zoffset, width, height, depth, format, type, bufSize, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTransformFeedbacki64_v(uint xfb, uint pname, uint index, Span<long> param)
|
||||
{
|
||||
fixed (long* paramPtr = param)
|
||||
{
|
||||
Context.glGetTransformFeedbacki64_v(xfb, pname, index, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTransformFeedbacki_v(uint xfb, uint pname, uint index, Span<int> param)
|
||||
{
|
||||
fixed (int* paramPtr = param)
|
||||
{
|
||||
Context.glGetTransformFeedbacki_v(xfb, pname, index, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTransformFeedbackiv(uint xfb, uint pname, Span<int> param)
|
||||
{
|
||||
fixed (int* paramPtr = param)
|
||||
{
|
||||
Context.glGetTransformFeedbackiv(xfb, pname, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetVertexArrayIndexed64iv(uint vaobj, uint index, uint pname, Span<long> param)
|
||||
{
|
||||
fixed (long* paramPtr = param)
|
||||
{
|
||||
Context.glGetVertexArrayIndexed64iv(vaobj, index, pname, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetVertexArrayIndexediv(uint vaobj, uint index, uint pname, Span<int> param)
|
||||
{
|
||||
fixed (int* paramPtr = param)
|
||||
{
|
||||
Context.glGetVertexArrayIndexediv(vaobj, index, pname, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetVertexArrayiv(uint vaobj, uint pname, Span<int> param)
|
||||
{
|
||||
fixed (int* paramPtr = param)
|
||||
{
|
||||
Context.glGetVertexArrayiv(vaobj, pname, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetnCompressedTexImage(uint target, int lod, int bufSize, void* pixels)
|
||||
{
|
||||
Context.glGetnCompressedTexImage(target, lod, bufSize, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetnTexImage(uint target, int level, uint format, uint type, int bufSize, void* pixels)
|
||||
{
|
||||
Context.glGetnTexImage(target, level, format, type, bufSize, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetnUniform(GlHandle program, int location, int bufSize, Span<double> @params)
|
||||
{
|
||||
if (@params.Length < checked((int)bufSize / 8)) {
|
||||
throw new ArgumentException("Span is shorter than the OpenGL length expression 'bufSize / 8'.", nameof(@params));
|
||||
}
|
||||
fixed (double* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetnUniformdv(program.Value, location, bufSize, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetnUniform(GlHandle program, int location, int bufSize, Span<float> @params)
|
||||
{
|
||||
if (@params.Length < checked((int)bufSize / 4)) {
|
||||
throw new ArgumentException("Span is shorter than the OpenGL length expression 'bufSize / 4'.", nameof(@params));
|
||||
}
|
||||
fixed (float* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetnUniformfv(program.Value, location, bufSize, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetnUniform(GlHandle program, int location, int bufSize, Span<int> @params)
|
||||
{
|
||||
if (@params.Length < checked((int)bufSize / 4)) {
|
||||
throw new ArgumentException("Span is shorter than the OpenGL length expression 'bufSize / 4'.", nameof(@params));
|
||||
}
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetnUniformiv(program.Value, location, bufSize, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetnUniform(GlHandle program, int location, int bufSize, Span<uint> @params)
|
||||
{
|
||||
if (@params.Length < checked((int)bufSize / 4)) {
|
||||
throw new ArgumentException("Span is shorter than the OpenGL length expression 'bufSize / 4'.", nameof(@params));
|
||||
}
|
||||
fixed (uint* @paramsPtr = @params)
|
||||
{
|
||||
Context.glGetnUniformuiv(program.Value, location, bufSize, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateNamedFramebufferData(GlHandle framebuffer, ReadOnlySpan<uint> attachments)
|
||||
{
|
||||
fixed (uint* attachmentsPtr = attachments)
|
||||
{
|
||||
Context.glInvalidateNamedFramebufferData(framebuffer.Value, checked((int)attachments.Length), attachmentsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void InvalidateNamedFramebufferSubData(GlHandle framebuffer, ReadOnlySpan<uint> attachments, int x, int y, int width, int height)
|
||||
{
|
||||
fixed (uint* attachmentsPtr = attachments)
|
||||
{
|
||||
Context.glInvalidateNamedFramebufferSubData(framebuffer.Value, checked((int)attachments.Length), attachmentsPtr, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void* MapNamedBuffer(GlHandle buffer, uint access)
|
||||
{
|
||||
return Context.glMapNamedBuffer(buffer.Value, access);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void* MapNamedBufferRange(GlHandle buffer, nint offset, nint length, uint access)
|
||||
{
|
||||
return Context.glMapNamedBufferRange(buffer.Value, offset, length, access);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void MemoryBarrierByRegion(uint barriers)
|
||||
{
|
||||
Context.glMemoryBarrierByRegion(barriers);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedBufferData(GlHandle buffer, nint size, void* data, uint usage)
|
||||
{
|
||||
Context.glNamedBufferData(buffer.Value, size, data, usage);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedBufferStorage(GlHandle buffer, nint size, void* data, uint flags)
|
||||
{
|
||||
Context.glNamedBufferStorage(buffer.Value, size, data, flags);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedBufferSubData(GlHandle buffer, nint offset, nint size, void* data)
|
||||
{
|
||||
Context.glNamedBufferSubData(buffer.Value, offset, size, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedFramebufferDrawBuffer(GlHandle framebuffer, uint buf)
|
||||
{
|
||||
Context.glNamedFramebufferDrawBuffer(framebuffer.Value, buf);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedFramebufferDrawBuffers(GlHandle framebuffer, ReadOnlySpan<uint> bufs)
|
||||
{
|
||||
fixed (uint* bufsPtr = bufs)
|
||||
{
|
||||
Context.glNamedFramebufferDrawBuffers(framebuffer.Value, checked((int)bufs.Length), bufsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedFramebufferParameter(GlHandle framebuffer, uint pname, int param)
|
||||
{
|
||||
Context.glNamedFramebufferParameteri(framebuffer.Value, pname, param);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedFramebufferReadBuffer(GlHandle framebuffer, uint src)
|
||||
{
|
||||
Context.glNamedFramebufferReadBuffer(framebuffer.Value, src);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedFramebufferRenderbuffer(GlHandle framebuffer, uint attachment, uint renderbuffertarget, GlHandle renderbuffer)
|
||||
{
|
||||
Context.glNamedFramebufferRenderbuffer(framebuffer.Value, attachment, renderbuffertarget, renderbuffer.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedFramebufferTexture(GlHandle framebuffer, uint attachment, GlHandle texture, int level)
|
||||
{
|
||||
Context.glNamedFramebufferTexture(framebuffer.Value, attachment, texture.Value, level);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedFramebufferTextureLayer(GlHandle framebuffer, uint attachment, GlHandle texture, int level, int layer)
|
||||
{
|
||||
Context.glNamedFramebufferTextureLayer(framebuffer.Value, attachment, texture.Value, level, layer);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedRenderbufferStorage(GlHandle renderbuffer, uint internalformat, int width, int height)
|
||||
{
|
||||
Context.glNamedRenderbufferStorage(renderbuffer.Value, internalformat, width, height);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void NamedRenderbufferStorageMultisample(GlHandle renderbuffer, int samples, uint internalformat, int width, int height)
|
||||
{
|
||||
Context.glNamedRenderbufferStorageMultisample(renderbuffer.Value, samples, internalformat, width, height);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void ReadnPixels(int x, int y, int width, int height, uint format, uint type, int bufSize, void* data)
|
||||
{
|
||||
Context.glReadnPixels(x, y, width, height, format, type, bufSize, data);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureBarrier()
|
||||
{
|
||||
Context.glTextureBarrier();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureBuffer(GlHandle texture, uint internalformat, GlHandle buffer)
|
||||
{
|
||||
Context.glTextureBuffer(texture.Value, internalformat, buffer.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureBufferRange(GlHandle texture, uint internalformat, GlHandle buffer, nint offset, nint size)
|
||||
{
|
||||
Context.glTextureBufferRange(texture.Value, internalformat, buffer.Value, offset, size);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureParameterI(GlHandle texture, uint pname, ReadOnlySpan<int> @params)
|
||||
{
|
||||
fixed (int* @paramsPtr = @params)
|
||||
{
|
||||
Context.glTextureParameterIiv(texture.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureParameterI(GlHandle texture, uint pname, ReadOnlySpan<uint> @params)
|
||||
{
|
||||
fixed (uint* @paramsPtr = @params)
|
||||
{
|
||||
Context.glTextureParameterIuiv(texture.Value, pname, @paramsPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureParameter(GlHandle texture, uint pname, float param)
|
||||
{
|
||||
Context.glTextureParameterf(texture.Value, pname, param);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureParameter(GlHandle texture, uint pname, ReadOnlySpan<float> param)
|
||||
{
|
||||
fixed (float* paramPtr = param)
|
||||
{
|
||||
Context.glTextureParameterfv(texture.Value, pname, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureParameter(GlHandle texture, uint pname, int param)
|
||||
{
|
||||
Context.glTextureParameteri(texture.Value, pname, param);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureParameter(GlHandle texture, uint pname, ReadOnlySpan<int> param)
|
||||
{
|
||||
fixed (int* paramPtr = param)
|
||||
{
|
||||
Context.glTextureParameteriv(texture.Value, pname, paramPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureStorage1D(GlHandle texture, int levels, uint internalformat, int width)
|
||||
{
|
||||
Context.glTextureStorage1D(texture.Value, levels, internalformat, width);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureStorage2D(GlHandle texture, int levels, uint internalformat, int width, int height)
|
||||
{
|
||||
Context.glTextureStorage2D(texture.Value, levels, internalformat, width, height);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureStorage2DMultisample(GlHandle texture, int samples, uint internalformat, int width, int height, byte fixedsamplelocations)
|
||||
{
|
||||
Context.glTextureStorage2DMultisample(texture.Value, samples, internalformat, width, height, fixedsamplelocations);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureStorage3D(GlHandle texture, int levels, uint internalformat, int width, int height, int depth)
|
||||
{
|
||||
Context.glTextureStorage3D(texture.Value, levels, internalformat, width, height, depth);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureStorage3DMultisample(GlHandle texture, int samples, uint internalformat, int width, int height, int depth, byte fixedsamplelocations)
|
||||
{
|
||||
Context.glTextureStorage3DMultisample(texture.Value, samples, internalformat, width, height, depth, fixedsamplelocations);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureSubImage1D(GlHandle texture, int level, int xoffset, int width, uint format, uint type, void* pixels)
|
||||
{
|
||||
Context.glTextureSubImage1D(texture.Value, level, xoffset, width, format, type, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureSubImage2D(GlHandle texture, int level, int xoffset, int yoffset, int width, int height, uint format, uint type, void* pixels)
|
||||
{
|
||||
Context.glTextureSubImage2D(texture.Value, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TextureSubImage3D(GlHandle texture, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, uint format, uint type, void* pixels)
|
||||
{
|
||||
Context.glTextureSubImage3D(texture.Value, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TransformFeedbackBufferBase(uint xfb, uint index, GlHandle buffer)
|
||||
{
|
||||
Context.glTransformFeedbackBufferBase(xfb, index, buffer.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void TransformFeedbackBufferRange(uint xfb, uint index, GlHandle buffer, nint offset, nint size)
|
||||
{
|
||||
Context.glTransformFeedbackBufferRange(xfb, index, buffer.Value, offset, size);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public byte UnmapNamedBuffer(GlHandle buffer)
|
||||
{
|
||||
return Context.glUnmapNamedBuffer(buffer.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayAttribBinding(uint vaobj, uint attribindex, uint bindingindex)
|
||||
{
|
||||
Context.glVertexArrayAttribBinding(vaobj, attribindex, bindingindex);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayAttribFormat(uint vaobj, uint attribindex, int size, uint type, byte normalized, uint relativeoffset)
|
||||
{
|
||||
Context.glVertexArrayAttribFormat(vaobj, attribindex, size, type, normalized, relativeoffset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayAttribIFormat(uint vaobj, uint attribindex, int size, uint type, uint relativeoffset)
|
||||
{
|
||||
Context.glVertexArrayAttribIFormat(vaobj, attribindex, size, type, relativeoffset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayAttribLFormat(uint vaobj, uint attribindex, int size, uint type, uint relativeoffset)
|
||||
{
|
||||
Context.glVertexArrayAttribLFormat(vaobj, attribindex, size, type, relativeoffset);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayBindingDivisor(uint vaobj, uint bindingindex, uint divisor)
|
||||
{
|
||||
Context.glVertexArrayBindingDivisor(vaobj, bindingindex, divisor);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayElementBuffer(uint vaobj, GlHandle buffer)
|
||||
{
|
||||
Context.glVertexArrayElementBuffer(vaobj, buffer.Value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayVertexBuffer(uint vaobj, uint bindingindex, GlHandle buffer, nint offset, int stride)
|
||||
{
|
||||
Context.glVertexArrayVertexBuffer(vaobj, bindingindex, buffer.Value, offset, stride);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void VertexArrayVertexBuffers(uint vaobj, uint first, ReadOnlySpan<uint> buffers, ReadOnlySpan<nint> offsets, ReadOnlySpan<int> strides)
|
||||
{
|
||||
if (offsets.Length != buffers.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(offsets));
|
||||
}
|
||||
if (strides.Length != buffers.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by count must match.", nameof(strides));
|
||||
}
|
||||
fixed (uint* buffersPtr = buffers)
|
||||
{
|
||||
fixed (nint* offsetsPtr = offsets)
|
||||
{
|
||||
fixed (int* stridesPtr = strides)
|
||||
{
|
||||
Context.glVertexArrayVertexBuffers(vaobj, first, checked((int)buffers.Length), buffersPtr, offsetsPtr, stridesPtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Version: 4.6
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void MultiDrawArraysIndirectCount(uint mode, void* indirect, nint drawcount, int maxdrawcount, int stride)
|
||||
{
|
||||
Context.glMultiDrawArraysIndirectCount(mode, indirect, drawcount, maxdrawcount, stride);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void MultiDrawElementsIndirectCount(uint mode, uint type, void* indirect, nint drawcount, int maxdrawcount, int stride)
|
||||
{
|
||||
Context.glMultiDrawElementsIndirectCount(mode, type, indirect, drawcount, maxdrawcount, stride);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void PolygonOffsetClamp(float factor, float units, float clamp)
|
||||
{
|
||||
Context.glPolygonOffsetClamp(factor, units, clamp);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SpecializeShader(GlHandle shader, ReadOnlySpan<byte> pEntryPoint, ReadOnlySpan<uint> pConstantIndex, ReadOnlySpan<uint> pConstantValue)
|
||||
{
|
||||
if (pConstantValue.Length != pConstantIndex.Length) {
|
||||
throw new ArgumentException("Span lengths controlled by numSpecializationConstants must match.", nameof(pConstantValue));
|
||||
}
|
||||
fixed (byte* pEntryPointPtr = pEntryPoint)
|
||||
{
|
||||
fixed (uint* pConstantIndexPtr = pConstantIndex)
|
||||
{
|
||||
fixed (uint* pConstantValuePtr = pConstantValue)
|
||||
{
|
||||
Context.glSpecializeShader(shader.Value, pEntryPointPtr, checked((uint)pConstantIndex.Length), pConstantIndexPtr, pConstantValuePtr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,261 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Uniform overloads introduced in OpenGL 3.3
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float> uniform, float v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform1f(uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glUniform1fv(uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int> uniform, int v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform1i(uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glUniform1iv(uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint> uniform, uint v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform1ui(uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glUniform1uiv(uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float, float> uniform, float v0, float v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform2f(uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float, float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glUniform2fv(uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int, int> uniform, int v0, int v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform2i(uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int, int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glUniform2iv(uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint, uint> uniform, uint v0, uint v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform2ui(uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint, uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glUniform2uiv(uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform3f(uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float, float, float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glUniform3fv(uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int, int, int> uniform, int v0, int v1, int v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform3i(uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int, int, int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glUniform3iv(uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint, uint, uint> uniform, uint v0, uint v1, uint v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform3ui(uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint, uint, uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glUniform3uiv(uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform4f(uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<float, float, float, float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glUniform4fv(uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int, int, int, int> uniform, int v0, int v1, int v2, int v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform4i(uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<int, int, int, int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glUniform4iv(uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint, uint, uint, uint> uniform, uint v0, uint v1, uint v2, uint v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform4ui(uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<uint, uint, uint, uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glUniform4uiv(uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<Vec2> uniform, Vec2 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform2fv(uniform.id.SignedValue, 1, (float*)&value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<Vec3> uniform, Vec3 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform3fv(uniform.id.SignedValue, 1, (float*)&value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<Vec4> uniform, Vec4 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform4fv(uniform.id.SignedValue, 1, (float*)&value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<GraphicsMatrix> uniform, GraphicsMatrix value, bool transpose = false)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniformMatrix4fv(uniform.id.SignedValue, 1, transpose ? (byte)1 : (byte)0, (float*)&value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Uniform overloads introduced in OpenGL 4.0
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double> uniform, double v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform1d(uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glUniform1dv(uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double, double> uniform, double v0, double v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform2d(uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double, double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glUniform2dv(uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double, double, double> uniform, double v0, double v1, double v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform3d(uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double, double, double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glUniform3dv(uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double, double, double, double> uniform, double v0, double v1, double v2, double v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glUniform4d(uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(Uniform<double, double, double, double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glUniform4dv(uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,334 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Uniform overloads introduced in OpenGL 4.1
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using StgSharp.Mathematics.Graphics;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial class OpenGLFunction
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double> uniform, double v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform1d(program.Value, uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glProgramUniform1dv(program.Value, uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float> uniform, float v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform1f(program.Value, uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glProgramUniform1fv(program.Value, uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int> uniform, int v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform1i(program.Value, uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glProgramUniform1iv(program.Value, uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint> uniform, uint v0)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform1ui(program.Value, uniform.id.SignedValue, v0);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glProgramUniform1uiv(program.Value, uniform.id.SignedValue, values.Length, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double, double> uniform, double v0, double v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform2d(program.Value, uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double, double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glProgramUniform2dv(program.Value, uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float, float> uniform, float v0, float v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform2f(program.Value, uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float, float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glProgramUniform2fv(program.Value, uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int, int> uniform, int v0, int v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform2i(program.Value, uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int, int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glProgramUniform2iv(program.Value, uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint, uint> uniform, uint v0, uint v1)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform2ui(program.Value, uniform.id.SignedValue, v0, v1);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint, uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 2) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 2.", nameof(values));
|
||||
}
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glProgramUniform2uiv(program.Value, uniform.id.SignedValue, values.Length / 2, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double, double, double> uniform, double v0, double v1, double v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform3d(program.Value, uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double, double, double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glProgramUniform3dv(program.Value, uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float, float, float> uniform, float v0, float v1, float v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform3f(program.Value, uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float, float, float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glProgramUniform3fv(program.Value, uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int, int, int> uniform, int v0, int v1, int v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform3i(program.Value, uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int, int, int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glProgramUniform3iv(program.Value, uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint, uint, uint> uniform, uint v0, uint v1, uint v2)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform3ui(program.Value, uniform.id.SignedValue, v0, v1, v2);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint, uint, uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 3) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 3.", nameof(values));
|
||||
}
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glProgramUniform3uiv(program.Value, uniform.id.SignedValue, values.Length / 3, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double, double, double, double> uniform, double v0, double v1, double v2, double v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform4d(program.Value, uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<double, double, double, double> uniform, ReadOnlySpan<double> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (double* valuesPtr = values) {
|
||||
Context.glProgramUniform4dv(program.Value, uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform4f(program.Value, uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<float, float, float, float> uniform, ReadOnlySpan<float> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (float* valuesPtr = values) {
|
||||
Context.glProgramUniform4fv(program.Value, uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int, int, int, int> uniform, int v0, int v1, int v2, int v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform4i(program.Value, uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<int, int, int, int> uniform, ReadOnlySpan<int> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (int* valuesPtr = values) {
|
||||
Context.glProgramUniform4iv(program.Value, uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint, uint, uint, uint> uniform, uint v0, uint v1, uint v2, uint v3)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform4ui(program.Value, uniform.id.SignedValue, v0, v1, v2, v3);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<uint, uint, uint, uint> uniform, ReadOnlySpan<uint> values)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
if ((values.Length % 4) != 0) {
|
||||
throw new ArgumentException("Uniform data length must be divisible by 4.", nameof(values));
|
||||
}
|
||||
fixed (uint* valuesPtr = values) {
|
||||
Context.glProgramUniform4uiv(program.Value, uniform.id.SignedValue, values.Length / 4, valuesPtr);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<Vec2> uniform, Vec2 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform2fv(program.Value, uniform.id.SignedValue, 1, (float*)&value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<Vec3> uniform, Vec3 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform3fv(program.Value, uniform.id.SignedValue, 1, (float*)&value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<Vec4> uniform, Vec4 value)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniform4fv(program.Value, uniform.id.SignedValue, 1, (float*)&value);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetUniformValue(GlHandle program, Uniform<GraphicsMatrix> uniform, GraphicsMatrix value, bool transpose = false)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(uniform);
|
||||
Context.glProgramUniformMatrix4fv(program.Value, uniform.id.SignedValue, 1, transpose ? (byte)1 : (byte)0, (float*)&value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,670 +0,0 @@
|
||||
// <auto-generated>
|
||||
// Generated by StgSharp.GenerateGL on 2026-08-25 09:22:55Z
|
||||
// Aggregated GL3+ commands
|
||||
// </auto-generated>
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public unsafe partial struct OpenglContext
|
||||
{
|
||||
internal unsafe delegate*<uint, uint, void> glActiveShaderProgram;
|
||||
internal unsafe delegate*<uint, void> glActiveTexture;
|
||||
internal unsafe delegate*<uint, uint, void> glAttachShader;
|
||||
internal unsafe delegate*<uint, uint, void> glBeginConditionalRender;
|
||||
internal unsafe delegate*<uint, uint, void> glBeginQuery;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glBeginQueryIndexed;
|
||||
internal unsafe delegate*<uint, void> glBeginTransformFeedback;
|
||||
internal unsafe delegate*<uint, uint, byte*, void> glBindAttribLocation;
|
||||
internal unsafe delegate*<uint, uint, void> glBindBuffer;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glBindBufferBase;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, nint, void> glBindBufferRange;
|
||||
internal unsafe delegate*<uint, uint, int, uint*, void> glBindBuffersBase;
|
||||
internal unsafe delegate*<uint, uint, int, uint*, nint*, nint*, void> glBindBuffersRange;
|
||||
internal unsafe delegate*<uint, uint, byte*, void> glBindFragDataLocation;
|
||||
internal unsafe delegate*<uint, uint, uint, byte*, void> glBindFragDataLocationIndexed;
|
||||
internal unsafe delegate*<uint, uint, void> glBindFramebuffer;
|
||||
internal unsafe delegate*<uint, uint, int, byte, int, uint, uint, void> glBindImageTexture;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glBindImageTextures;
|
||||
internal unsafe delegate*<uint, void> glBindProgramPipeline;
|
||||
internal unsafe delegate*<uint, uint, void> glBindRenderbuffer;
|
||||
internal unsafe delegate*<uint, uint, void> glBindSampler;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glBindSamplers;
|
||||
internal unsafe delegate*<uint, uint, void> glBindTexture;
|
||||
internal unsafe delegate*<uint, uint, void> glBindTextureUnit;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glBindTextures;
|
||||
internal unsafe delegate*<uint, uint, void> glBindTransformFeedback;
|
||||
internal unsafe delegate*<uint, void> glBindVertexArray;
|
||||
internal unsafe delegate*<uint, uint, nint, int, void> glBindVertexBuffer;
|
||||
internal unsafe delegate*<uint, int, uint*, nint*, int*, void> glBindVertexBuffers;
|
||||
internal unsafe delegate*<float, float, float, float, void> glBlendColor;
|
||||
internal unsafe delegate*<uint, void> glBlendEquation;
|
||||
internal unsafe delegate*<uint, uint, void> glBlendEquationSeparate;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glBlendEquationSeparatei;
|
||||
internal unsafe delegate*<uint, uint, void> glBlendEquationi;
|
||||
internal unsafe delegate*<uint, uint, void> glBlendFunc;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void> glBlendFuncSeparate;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint, void> glBlendFuncSeparatei;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glBlendFunci;
|
||||
internal unsafe delegate*<int, int, int, int, int, int, int, int, uint, uint, void> glBlitFramebuffer;
|
||||
internal unsafe delegate*<uint, uint, int, int, int, int, int, int, int, int, uint, uint, void> glBlitNamedFramebuffer;
|
||||
internal unsafe delegate*<uint, nint, void*, uint, void> glBufferData;
|
||||
internal unsafe delegate*<uint, nint, void*, uint, void> glBufferStorage;
|
||||
internal unsafe delegate*<uint, nint, nint, void*, void> glBufferSubData;
|
||||
internal unsafe delegate*<uint, uint> glCheckFramebufferStatus;
|
||||
internal unsafe delegate*<uint, uint, uint> glCheckNamedFramebufferStatus;
|
||||
internal unsafe delegate*<uint, uint, void> glClampColor;
|
||||
internal unsafe delegate*<uint, void> glClear;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void*, void> glClearBufferData;
|
||||
internal unsafe delegate*<uint, uint, nint, nint, uint, uint, void*, void> glClearBufferSubData;
|
||||
internal unsafe delegate*<uint, int, float, int, void> glClearBufferfi;
|
||||
internal unsafe delegate*<uint, int, float*, void> glClearBufferfv;
|
||||
internal unsafe delegate*<uint, int, int*, void> glClearBufferiv;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glClearBufferuiv;
|
||||
internal unsafe delegate*<float, float, float, float, void> glClearColor;
|
||||
internal unsafe delegate*<double, void> glClearDepth;
|
||||
internal unsafe delegate*<float, void> glClearDepthf;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void*, void> glClearNamedBufferData;
|
||||
internal unsafe delegate*<uint, uint, nint, nint, uint, uint, void*, void> glClearNamedBufferSubData;
|
||||
internal unsafe delegate*<uint, uint, int, float, int, void> glClearNamedFramebufferfi;
|
||||
internal unsafe delegate*<uint, uint, int, float*, void> glClearNamedFramebufferfv;
|
||||
internal unsafe delegate*<uint, uint, int, int*, void> glClearNamedFramebufferiv;
|
||||
internal unsafe delegate*<uint, uint, int, uint*, void> glClearNamedFramebufferuiv;
|
||||
internal unsafe delegate*<int, void> glClearStencil;
|
||||
internal unsafe delegate*<uint, int, uint, uint, void*, void> glClearTexImage;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, uint, uint, void*, void> glClearTexSubImage;
|
||||
internal unsafe delegate*<glSync, uint, ulong, uint> glClientWaitSync;
|
||||
internal unsafe delegate*<uint, uint, void> glClipControl;
|
||||
internal unsafe delegate*<byte, byte, byte, byte, void> glColorMask;
|
||||
internal unsafe delegate*<uint, byte, byte, byte, byte, void> glColorMaski;
|
||||
internal unsafe delegate*<uint, void> glCompileShader;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, void*, void> glCompressedTexImage1D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, int, void*, void> glCompressedTexImage2D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, int, int, void*, void> glCompressedTexImage3D;
|
||||
internal unsafe delegate*<uint, int, int, int, uint, int, void*, void> glCompressedTexSubImage1D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, uint, int, void*, void> glCompressedTexSubImage2D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, uint, int, void*, void> glCompressedTexSubImage3D;
|
||||
internal unsafe delegate*<uint, int, int, int, uint, int, void*, void> glCompressedTextureSubImage1D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, uint, int, void*, void> glCompressedTextureSubImage2D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, uint, int, void*, void> glCompressedTextureSubImage3D;
|
||||
internal unsafe delegate*<uint, uint, nint, nint, nint, void> glCopyBufferSubData;
|
||||
internal unsafe delegate*<uint, uint, int, int, int, int, uint, uint, int, int, int, int, int, int, int, void> glCopyImageSubData;
|
||||
internal unsafe delegate*<uint, uint, nint, nint, nint, void> glCopyNamedBufferSubData;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, int, void> glCopyTexImage1D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, int, int, void> glCopyTexImage2D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, void> glCopyTexSubImage1D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, void> glCopyTexSubImage2D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, int, void> glCopyTexSubImage3D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, void> glCopyTextureSubImage1D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, void> glCopyTextureSubImage2D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, int, void> glCopyTextureSubImage3D;
|
||||
internal unsafe delegate*<int, uint*, void> glCreateBuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glCreateFramebuffers;
|
||||
internal unsafe delegate*<uint> glCreateProgram;
|
||||
internal unsafe delegate*<int, uint*, void> glCreateProgramPipelines;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glCreateQueries;
|
||||
internal unsafe delegate*<int, uint*, void> glCreateRenderbuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glCreateSamplers;
|
||||
internal unsafe delegate*<uint, uint> glCreateShader;
|
||||
internal unsafe delegate*<uint, int, byte**, uint> glCreateShaderProgramv;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glCreateTextures;
|
||||
internal unsafe delegate*<int, uint*, void> glCreateTransformFeedbacks;
|
||||
internal unsafe delegate*<int, uint*, void> glCreateVertexArrays;
|
||||
internal unsafe delegate*<uint, void> glCullFace;
|
||||
internal unsafe delegate*<IntPtr, void*, void> glDebugMessageCallback;
|
||||
internal unsafe delegate*<uint, uint, uint, int, uint*, byte, void> glDebugMessageControl;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, int, byte*, void> glDebugMessageInsert;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteBuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteFramebuffers;
|
||||
internal unsafe delegate*<uint, void> glDeleteProgram;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteProgramPipelines;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteQueries;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteRenderbuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteSamplers;
|
||||
internal unsafe delegate*<uint, void> glDeleteShader;
|
||||
internal unsafe delegate*<glSync, void> glDeleteSync;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteTextures;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteTransformFeedbacks;
|
||||
internal unsafe delegate*<int, uint*, void> glDeleteVertexArrays;
|
||||
internal unsafe delegate*<uint, void> glDepthFunc;
|
||||
internal unsafe delegate*<byte, void> glDepthMask;
|
||||
internal unsafe delegate*<double, double, void> glDepthRange;
|
||||
internal unsafe delegate*<uint, int, double*, void> glDepthRangeArrayv;
|
||||
internal unsafe delegate*<uint, double, double, void> glDepthRangeIndexed;
|
||||
internal unsafe delegate*<float, float, void> glDepthRangef;
|
||||
internal unsafe delegate*<uint, uint, void> glDetachShader;
|
||||
internal unsafe delegate*<uint, void> glDisable;
|
||||
internal unsafe delegate*<uint, uint, void> glDisableVertexArrayAttrib;
|
||||
internal unsafe delegate*<uint, void> glDisableVertexAttribArray;
|
||||
internal unsafe delegate*<uint, uint, void> glDisablei;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glDispatchCompute;
|
||||
internal unsafe delegate*<nint, void> glDispatchComputeIndirect;
|
||||
internal unsafe delegate*<uint, int, int, void> glDrawArrays;
|
||||
internal unsafe delegate*<uint, void*, void> glDrawArraysIndirect;
|
||||
internal unsafe delegate*<uint, int, int, int, void> glDrawArraysInstanced;
|
||||
internal unsafe delegate*<uint, int, int, int, uint, void> glDrawArraysInstancedBaseInstance;
|
||||
internal unsafe delegate*<uint, void> glDrawBuffer;
|
||||
internal unsafe delegate*<int, uint*, void> glDrawBuffers;
|
||||
internal unsafe delegate*<uint, int, uint, void*, void> glDrawElements;
|
||||
internal unsafe delegate*<uint, int, uint, void*, int, void> glDrawElementsBaseVertex;
|
||||
internal unsafe delegate*<uint, uint, void*, void> glDrawElementsIndirect;
|
||||
internal unsafe delegate*<uint, int, uint, void*, int, void> glDrawElementsInstanced;
|
||||
internal unsafe delegate*<uint, int, uint, void*, int, uint, void> glDrawElementsInstancedBaseInstance;
|
||||
internal unsafe delegate*<uint, int, uint, void*, int, int, void> glDrawElementsInstancedBaseVertex;
|
||||
internal unsafe delegate*<uint, int, uint, void*, int, int, uint, void> glDrawElementsInstancedBaseVertexBaseInstance;
|
||||
internal unsafe delegate*<uint, uint, uint, int, uint, void*, void> glDrawRangeElements;
|
||||
internal unsafe delegate*<uint, uint, uint, int, uint, void*, int, void> glDrawRangeElementsBaseVertex;
|
||||
internal unsafe delegate*<uint, uint, void> glDrawTransformFeedback;
|
||||
internal unsafe delegate*<uint, uint, int, void> glDrawTransformFeedbackInstanced;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glDrawTransformFeedbackStream;
|
||||
internal unsafe delegate*<uint, uint, uint, int, void> glDrawTransformFeedbackStreamInstanced;
|
||||
internal unsafe delegate*<uint, void> glEnable;
|
||||
internal unsafe delegate*<uint, uint, void> glEnableVertexArrayAttrib;
|
||||
internal unsafe delegate*<uint, void> glEnableVertexAttribArray;
|
||||
internal unsafe delegate*<uint, uint, void> glEnablei;
|
||||
internal unsafe delegate*<void> glEndConditionalRender;
|
||||
internal unsafe delegate*<uint, void> glEndQuery;
|
||||
internal unsafe delegate*<uint, uint, void> glEndQueryIndexed;
|
||||
internal unsafe delegate*<void> glEndTransformFeedback;
|
||||
internal unsafe delegate*<uint, uint, glSync> glFenceSync;
|
||||
internal unsafe delegate*<void> glFinish;
|
||||
internal unsafe delegate*<void> glFlush;
|
||||
internal unsafe delegate*<uint, nint, nint, void> glFlushMappedBufferRange;
|
||||
internal unsafe delegate*<uint, nint, nint, void> glFlushMappedNamedBufferRange;
|
||||
internal unsafe delegate*<uint, uint, int, void> glFramebufferParameteri;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void> glFramebufferRenderbuffer;
|
||||
internal unsafe delegate*<uint, uint, uint, int, void> glFramebufferTexture;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, int, void> glFramebufferTexture1D;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, int, void> glFramebufferTexture2D;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, int, int, void> glFramebufferTexture3D;
|
||||
internal unsafe delegate*<uint, uint, uint, int, int, void> glFramebufferTextureLayer;
|
||||
internal unsafe delegate*<uint, void> glFrontFace;
|
||||
internal unsafe delegate*<int, uint*, void> glGenBuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glGenFramebuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glGenProgramPipelines;
|
||||
internal unsafe delegate*<int, uint*, void> glGenQueries;
|
||||
internal unsafe delegate*<int, uint*, void> glGenRenderbuffers;
|
||||
internal unsafe delegate*<int, uint*, void> glGenSamplers;
|
||||
internal unsafe delegate*<int, uint*, void> glGenTextures;
|
||||
internal unsafe delegate*<int, uint*, void> glGenTransformFeedbacks;
|
||||
internal unsafe delegate*<int, uint*, void> glGenVertexArrays;
|
||||
internal unsafe delegate*<uint, void> glGenerateMipmap;
|
||||
internal unsafe delegate*<uint, void> glGenerateTextureMipmap;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetActiveAtomicCounterBufferiv;
|
||||
internal unsafe delegate*<uint, uint, int, int*, int*, uint*, byte*, void> glGetActiveAttrib;
|
||||
internal unsafe delegate*<uint, uint, uint, int, int*, byte*, void> glGetActiveSubroutineName;
|
||||
internal unsafe delegate*<uint, uint, uint, int, int*, byte*, void> glGetActiveSubroutineUniformName;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, int*, void> glGetActiveSubroutineUniformiv;
|
||||
internal unsafe delegate*<uint, uint, int, int*, int*, uint*, byte*, void> glGetActiveUniform;
|
||||
internal unsafe delegate*<uint, uint, int, int*, byte*, void> glGetActiveUniformBlockName;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetActiveUniformBlockiv;
|
||||
internal unsafe delegate*<uint, uint, int, int*, byte*, void> glGetActiveUniformName;
|
||||
internal unsafe delegate*<uint, int, uint*, uint, int*, void> glGetActiveUniformsiv;
|
||||
internal unsafe delegate*<uint, int, int*, uint*, void> glGetAttachedShaders;
|
||||
internal unsafe delegate*<uint, byte*, int> glGetAttribLocation;
|
||||
internal unsafe delegate*<uint, uint, byte*, void> glGetBooleani_v;
|
||||
internal unsafe delegate*<uint, byte*, void> glGetBooleanv;
|
||||
internal unsafe delegate*<uint, uint, long*, void> glGetBufferParameteri64v;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetBufferParameteriv;
|
||||
internal unsafe delegate*<uint, uint, void**, void> glGetBufferPointerv;
|
||||
internal unsafe delegate*<uint, nint, nint, void*, void> glGetBufferSubData;
|
||||
internal unsafe delegate*<uint, int, void*, void> glGetCompressedTexImage;
|
||||
internal unsafe delegate*<uint, int, int, void*, void> glGetCompressedTextureImage;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, int, void*, void> glGetCompressedTextureSubImage;
|
||||
internal unsafe delegate*<uint, int, uint*, uint*, uint*, uint*, int*, byte*, uint> glGetDebugMessageLog;
|
||||
internal unsafe delegate*<uint, uint, double*, void> glGetDoublei_v;
|
||||
internal unsafe delegate*<uint, double*, void> glGetDoublev;
|
||||
internal unsafe delegate*<uint> glGetError;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetFloati_v;
|
||||
internal unsafe delegate*<uint, float*, void> glGetFloatv;
|
||||
internal unsafe delegate*<uint, byte*, int> glGetFragDataIndex;
|
||||
internal unsafe delegate*<uint, byte*, int> glGetFragDataLocation;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetFramebufferAttachmentParameteriv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetFramebufferParameteriv;
|
||||
internal unsafe delegate*<uint> glGetGraphicsResetStatus;
|
||||
internal unsafe delegate*<uint, uint, long*, void> glGetInteger64i_v;
|
||||
internal unsafe delegate*<uint, long*, void> glGetInteger64v;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetIntegeri_v;
|
||||
internal unsafe delegate*<uint, int*, void> glGetIntegerv;
|
||||
internal unsafe delegate*<uint, uint, uint, int, long*, void> glGetInternalformati64v;
|
||||
internal unsafe delegate*<uint, uint, uint, int, int*, void> glGetInternalformativ;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetMultisamplefv;
|
||||
internal unsafe delegate*<uint, uint, long*, void> glGetNamedBufferParameteri64v;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetNamedBufferParameteriv;
|
||||
internal unsafe delegate*<uint, uint, void**, void> glGetNamedBufferPointerv;
|
||||
internal unsafe delegate*<uint, nint, nint, void*, void> glGetNamedBufferSubData;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetNamedFramebufferAttachmentParameteriv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetNamedFramebufferParameteriv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetNamedRenderbufferParameteriv;
|
||||
internal unsafe delegate*<uint, uint, int, int*, byte*, void> glGetObjectLabel;
|
||||
internal unsafe delegate*<void*, int, int*, byte*, void> glGetObjectPtrLabel;
|
||||
internal unsafe delegate*<uint, void**, void> glGetPointerv;
|
||||
internal unsafe delegate*<uint, int, int*, uint*, void*, void> glGetProgramBinary;
|
||||
internal unsafe delegate*<uint, int, int*, byte*, void> glGetProgramInfoLog;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetProgramInterfaceiv;
|
||||
internal unsafe delegate*<uint, int, int*, byte*, void> glGetProgramPipelineInfoLog;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetProgramPipelineiv;
|
||||
internal unsafe delegate*<uint, uint, byte*, uint> glGetProgramResourceIndex;
|
||||
internal unsafe delegate*<uint, uint, byte*, int> glGetProgramResourceLocation;
|
||||
internal unsafe delegate*<uint, uint, byte*, int> glGetProgramResourceLocationIndex;
|
||||
internal unsafe delegate*<uint, uint, uint, int, int*, byte*, void> glGetProgramResourceName;
|
||||
internal unsafe delegate*<uint, uint, uint, int, uint*, int, int*, int*, void> glGetProgramResourceiv;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetProgramStageiv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetProgramiv;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, void> glGetQueryBufferObjecti64v;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, void> glGetQueryBufferObjectiv;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, void> glGetQueryBufferObjectui64v;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, void> glGetQueryBufferObjectuiv;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetQueryIndexediv;
|
||||
internal unsafe delegate*<uint, uint, long*, void> glGetQueryObjecti64v;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetQueryObjectiv;
|
||||
internal unsafe delegate*<uint, uint, ulong*, void> glGetQueryObjectui64v;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glGetQueryObjectuiv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetQueryiv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetRenderbufferParameteriv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetSamplerParameterIiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glGetSamplerParameterIuiv;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetSamplerParameterfv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetSamplerParameteriv;
|
||||
internal unsafe delegate*<uint, int, int*, byte*, void> glGetShaderInfoLog;
|
||||
internal unsafe delegate*<uint, uint, int*, int*, void> glGetShaderPrecisionFormat;
|
||||
internal unsafe delegate*<uint, int, int*, byte*, void> glGetShaderSource;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetShaderiv;
|
||||
internal unsafe delegate*<uint, byte*> glGetString;
|
||||
internal unsafe delegate*<uint, uint, byte*> glGetStringi;
|
||||
internal unsafe delegate*<uint, uint, byte*, uint> glGetSubroutineIndex;
|
||||
internal unsafe delegate*<uint, uint, byte*, int> glGetSubroutineUniformLocation;
|
||||
internal unsafe delegate*<glSync, uint, int, int*, int*, void> glGetSynciv;
|
||||
internal unsafe delegate*<uint, int, uint, uint, void*, void> glGetTexImage;
|
||||
internal unsafe delegate*<uint, int, uint, float*, void> glGetTexLevelParameterfv;
|
||||
internal unsafe delegate*<uint, int, uint, int*, void> glGetTexLevelParameteriv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetTexParameterIiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glGetTexParameterIuiv;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetTexParameterfv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetTexParameteriv;
|
||||
internal unsafe delegate*<uint, int, uint, uint, int, void*, void> glGetTextureImage;
|
||||
internal unsafe delegate*<uint, int, uint, float*, void> glGetTextureLevelParameterfv;
|
||||
internal unsafe delegate*<uint, int, uint, int*, void> glGetTextureLevelParameteriv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetTextureParameterIiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glGetTextureParameterIuiv;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetTextureParameterfv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetTextureParameteriv;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, uint, uint, int, void*, void> glGetTextureSubImage;
|
||||
internal unsafe delegate*<uint, uint, int, int*, int*, uint*, byte*, void> glGetTransformFeedbackVarying;
|
||||
internal unsafe delegate*<uint, uint, uint, long*, void> glGetTransformFeedbacki64_v;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetTransformFeedbacki_v;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetTransformFeedbackiv;
|
||||
internal unsafe delegate*<uint, byte*, uint> glGetUniformBlockIndex;
|
||||
internal unsafe delegate*<uint, int, byte**, uint*, void> glGetUniformIndices;
|
||||
internal unsafe delegate*<uint, byte*, int> glGetUniformLocation;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glGetUniformSubroutineuiv;
|
||||
internal unsafe delegate*<uint, int, double*, void> glGetUniformdv;
|
||||
internal unsafe delegate*<uint, int, float*, void> glGetUniformfv;
|
||||
internal unsafe delegate*<uint, int, int*, void> glGetUniformiv;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glGetUniformuiv;
|
||||
internal unsafe delegate*<uint, uint, uint, long*, void> glGetVertexArrayIndexed64iv;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetVertexArrayIndexediv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetVertexArrayiv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetVertexAttribIiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glGetVertexAttribIuiv;
|
||||
internal unsafe delegate*<uint, uint, double*, void> glGetVertexAttribLdv;
|
||||
internal unsafe delegate*<uint, uint, void**, void> glGetVertexAttribPointerv;
|
||||
internal unsafe delegate*<uint, uint, double*, void> glGetVertexAttribdv;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetVertexAttribfv;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetVertexAttribiv;
|
||||
internal unsafe delegate*<uint, int, int, void*, void> glGetnCompressedTexImage;
|
||||
internal unsafe delegate*<uint, int, uint, uint, int, void*, void> glGetnTexImage;
|
||||
internal unsafe delegate*<uint, int, int, double*, void> glGetnUniformdv;
|
||||
internal unsafe delegate*<uint, int, int, float*, void> glGetnUniformfv;
|
||||
internal unsafe delegate*<uint, int, int, int*, void> glGetnUniformiv;
|
||||
internal unsafe delegate*<uint, int, int, uint*, void> glGetnUniformuiv;
|
||||
internal unsafe delegate*<uint, uint, void> glHint;
|
||||
internal unsafe delegate*<uint, void> glInvalidateBufferData;
|
||||
internal unsafe delegate*<uint, nint, nint, void> glInvalidateBufferSubData;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glInvalidateFramebuffer;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glInvalidateNamedFramebufferData;
|
||||
internal unsafe delegate*<uint, int, uint*, int, int, int, int, void> glInvalidateNamedFramebufferSubData;
|
||||
internal unsafe delegate*<uint, int, uint*, int, int, int, int, void> glInvalidateSubFramebuffer;
|
||||
internal unsafe delegate*<uint, int, void> glInvalidateTexImage;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, void> glInvalidateTexSubImage;
|
||||
internal unsafe delegate*<uint, byte> glIsBuffer;
|
||||
internal unsafe delegate*<uint, byte> glIsEnabled;
|
||||
internal unsafe delegate*<uint, uint, byte> glIsEnabledi;
|
||||
internal unsafe delegate*<uint, byte> glIsFramebuffer;
|
||||
internal unsafe delegate*<uint, byte> glIsProgram;
|
||||
internal unsafe delegate*<uint, byte> glIsProgramPipeline;
|
||||
internal unsafe delegate*<uint, byte> glIsQuery;
|
||||
internal unsafe delegate*<uint, byte> glIsRenderbuffer;
|
||||
internal unsafe delegate*<uint, byte> glIsSampler;
|
||||
internal unsafe delegate*<uint, byte> glIsShader;
|
||||
internal unsafe delegate*<glSync, byte> glIsSync;
|
||||
internal unsafe delegate*<uint, byte> glIsTexture;
|
||||
internal unsafe delegate*<uint, byte> glIsTransformFeedback;
|
||||
internal unsafe delegate*<uint, byte> glIsVertexArray;
|
||||
internal unsafe delegate*<float, void> glLineWidth;
|
||||
internal unsafe delegate*<uint, void> glLinkProgram;
|
||||
internal unsafe delegate*<uint, void> glLogicOp;
|
||||
internal unsafe delegate*<uint, uint, void*> glMapBuffer;
|
||||
internal unsafe delegate*<uint, nint, nint, uint, void*> glMapBufferRange;
|
||||
internal unsafe delegate*<uint, uint, void*> glMapNamedBuffer;
|
||||
internal unsafe delegate*<uint, nint, nint, uint, void*> glMapNamedBufferRange;
|
||||
internal unsafe delegate*<uint, void> glMemoryBarrier;
|
||||
internal unsafe delegate*<uint, void> glMemoryBarrierByRegion;
|
||||
internal unsafe delegate*<float, void> glMinSampleShading;
|
||||
internal unsafe delegate*<uint, int*, int*, int, void> glMultiDrawArrays;
|
||||
internal unsafe delegate*<uint, void*, int, int, void> glMultiDrawArraysIndirect;
|
||||
internal unsafe delegate*<uint, void*, nint, int, int, void> glMultiDrawArraysIndirectCount;
|
||||
internal unsafe delegate*<uint, int*, uint, void**, int, void> glMultiDrawElements;
|
||||
internal unsafe delegate*<uint, int*, uint, void**, int, int*, void> glMultiDrawElementsBaseVertex;
|
||||
internal unsafe delegate*<uint, uint, void*, int, int, void> glMultiDrawElementsIndirect;
|
||||
internal unsafe delegate*<uint, uint, void*, nint, int, int, void> glMultiDrawElementsIndirectCount;
|
||||
internal unsafe delegate*<uint, nint, void*, uint, void> glNamedBufferData;
|
||||
internal unsafe delegate*<uint, nint, void*, uint, void> glNamedBufferStorage;
|
||||
internal unsafe delegate*<uint, nint, nint, void*, void> glNamedBufferSubData;
|
||||
internal unsafe delegate*<uint, uint, void> glNamedFramebufferDrawBuffer;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glNamedFramebufferDrawBuffers;
|
||||
internal unsafe delegate*<uint, uint, int, void> glNamedFramebufferParameteri;
|
||||
internal unsafe delegate*<uint, uint, void> glNamedFramebufferReadBuffer;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void> glNamedFramebufferRenderbuffer;
|
||||
internal unsafe delegate*<uint, uint, uint, int, void> glNamedFramebufferTexture;
|
||||
internal unsafe delegate*<uint, uint, uint, int, int, void> glNamedFramebufferTextureLayer;
|
||||
internal unsafe delegate*<uint, uint, int, int, void> glNamedRenderbufferStorage;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, void> glNamedRenderbufferStorageMultisample;
|
||||
internal unsafe delegate*<uint, uint, int, byte*, void> glObjectLabel;
|
||||
internal unsafe delegate*<void*, int, byte*, void> glObjectPtrLabel;
|
||||
internal unsafe delegate*<uint, float*, void> glPatchParameterfv;
|
||||
internal unsafe delegate*<uint, int, void> glPatchParameteri;
|
||||
internal unsafe delegate*<void> glPauseTransformFeedback;
|
||||
internal unsafe delegate*<uint, float, void> glPixelStoref;
|
||||
internal unsafe delegate*<uint, int, void> glPixelStorei;
|
||||
internal unsafe delegate*<uint, float, void> glPointParameterf;
|
||||
internal unsafe delegate*<uint, float*, void> glPointParameterfv;
|
||||
internal unsafe delegate*<uint, int, void> glPointParameteri;
|
||||
internal unsafe delegate*<uint, int*, void> glPointParameteriv;
|
||||
internal unsafe delegate*<float, void> glPointSize;
|
||||
internal unsafe delegate*<uint, uint, void> glPolygonMode;
|
||||
internal unsafe delegate*<float, float, void> glPolygonOffset;
|
||||
internal unsafe delegate*<float, float, float, void> glPolygonOffsetClamp;
|
||||
internal unsafe delegate*<void> glPopDebugGroup;
|
||||
internal unsafe delegate*<uint, void> glPrimitiveRestartIndex;
|
||||
internal unsafe delegate*<uint, uint, void*, int, void> glProgramBinary;
|
||||
internal unsafe delegate*<uint, uint, int, void> glProgramParameteri;
|
||||
internal unsafe delegate*<uint, int, double, void> glProgramUniform1d;
|
||||
internal unsafe delegate*<uint, int, int, double*, void> glProgramUniform1dv;
|
||||
internal unsafe delegate*<uint, int, float, void> glProgramUniform1f;
|
||||
internal unsafe delegate*<uint, int, int, float*, void> glProgramUniform1fv;
|
||||
internal unsafe delegate*<uint, int, int, void> glProgramUniform1i;
|
||||
internal unsafe delegate*<uint, int, int, int*, void> glProgramUniform1iv;
|
||||
internal unsafe delegate*<uint, int, uint, void> glProgramUniform1ui;
|
||||
internal unsafe delegate*<uint, int, int, uint*, void> glProgramUniform1uiv;
|
||||
internal unsafe delegate*<uint, int, double, double, void> glProgramUniform2d;
|
||||
internal unsafe delegate*<uint, int, int, double*, void> glProgramUniform2dv;
|
||||
internal unsafe delegate*<uint, int, float, float, void> glProgramUniform2f;
|
||||
internal unsafe delegate*<uint, int, int, float*, void> glProgramUniform2fv;
|
||||
internal unsafe delegate*<uint, int, int, int, void> glProgramUniform2i;
|
||||
internal unsafe delegate*<uint, int, int, int*, void> glProgramUniform2iv;
|
||||
internal unsafe delegate*<uint, int, uint, uint, void> glProgramUniform2ui;
|
||||
internal unsafe delegate*<uint, int, int, uint*, void> glProgramUniform2uiv;
|
||||
internal unsafe delegate*<uint, int, double, double, double, void> glProgramUniform3d;
|
||||
internal unsafe delegate*<uint, int, int, double*, void> glProgramUniform3dv;
|
||||
internal unsafe delegate*<uint, int, float, float, float, void> glProgramUniform3f;
|
||||
internal unsafe delegate*<uint, int, int, float*, void> glProgramUniform3fv;
|
||||
internal unsafe delegate*<uint, int, int, int, int, void> glProgramUniform3i;
|
||||
internal unsafe delegate*<uint, int, int, int*, void> glProgramUniform3iv;
|
||||
internal unsafe delegate*<uint, int, uint, uint, uint, void> glProgramUniform3ui;
|
||||
internal unsafe delegate*<uint, int, int, uint*, void> glProgramUniform3uiv;
|
||||
internal unsafe delegate*<uint, int, double, double, double, double, void> glProgramUniform4d;
|
||||
internal unsafe delegate*<uint, int, int, double*, void> glProgramUniform4dv;
|
||||
internal unsafe delegate*<uint, int, float, float, float, float, void> glProgramUniform4f;
|
||||
internal unsafe delegate*<uint, int, int, float*, void> glProgramUniform4fv;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, void> glProgramUniform4i;
|
||||
internal unsafe delegate*<uint, int, int, int*, void> glProgramUniform4iv;
|
||||
internal unsafe delegate*<uint, int, uint, uint, uint, uint, void> glProgramUniform4ui;
|
||||
internal unsafe delegate*<uint, int, int, uint*, void> glProgramUniform4uiv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix2dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix2fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix2x3dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix2x3fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix2x4dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix2x4fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix3dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix3fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix3x2dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix3x2fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix3x4dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix3x4fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix4dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix4fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix4x2dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix4x2fv;
|
||||
internal unsafe delegate*<uint, int, int, byte, double*, void> glProgramUniformMatrix4x3dv;
|
||||
internal unsafe delegate*<uint, int, int, byte, float*, void> glProgramUniformMatrix4x3fv;
|
||||
internal unsafe delegate*<uint, void> glProvokingVertex;
|
||||
internal unsafe delegate*<uint, uint, int, byte*, void> glPushDebugGroup;
|
||||
internal unsafe delegate*<uint, uint, void> glQueryCounter;
|
||||
internal unsafe delegate*<uint, void> glReadBuffer;
|
||||
internal unsafe delegate*<int, int, int, int, uint, uint, void*, void> glReadPixels;
|
||||
internal unsafe delegate*<int, int, int, int, uint, uint, int, void*, void> glReadnPixels;
|
||||
internal unsafe delegate*<void> glReleaseShaderCompiler;
|
||||
internal unsafe delegate*<uint, uint, int, int, void> glRenderbufferStorage;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, void> glRenderbufferStorageMultisample;
|
||||
internal unsafe delegate*<void> glResumeTransformFeedback;
|
||||
internal unsafe delegate*<float, byte, void> glSampleCoverage;
|
||||
internal unsafe delegate*<uint, uint, void> glSampleMaski;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glSamplerParameterIiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glSamplerParameterIuiv;
|
||||
internal unsafe delegate*<uint, uint, float, void> glSamplerParameterf;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glSamplerParameterfv;
|
||||
internal unsafe delegate*<uint, uint, int, void> glSamplerParameteri;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glSamplerParameteriv;
|
||||
internal unsafe delegate*<int, int, int, int, void> glScissor;
|
||||
internal unsafe delegate*<uint, int, int*, void> glScissorArrayv;
|
||||
internal unsafe delegate*<uint, int, int, int, int, void> glScissorIndexed;
|
||||
internal unsafe delegate*<uint, int*, void> glScissorIndexedv;
|
||||
internal unsafe delegate*<int, uint*, uint, void*, int, void> glShaderBinary;
|
||||
internal unsafe delegate*<uint, int, byte**, int*, void> glShaderSource;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glShaderStorageBlockBinding;
|
||||
internal unsafe delegate*<uint, byte*, uint, uint*, uint*, void> glSpecializeShader;
|
||||
internal unsafe delegate*<uint, int, uint, void> glStencilFunc;
|
||||
internal unsafe delegate*<uint, uint, int, uint, void> glStencilFuncSeparate;
|
||||
internal unsafe delegate*<uint, void> glStencilMask;
|
||||
internal unsafe delegate*<uint, uint, void> glStencilMaskSeparate;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glStencilOp;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void> glStencilOpSeparate;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glTexBuffer;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, nint, void> glTexBufferRange;
|
||||
internal unsafe delegate*<uint, int, int, int, int, uint, uint, void*, void> glTexImage1D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, uint, uint, void*, void> glTexImage2D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, byte, void> glTexImage2DMultisample;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, uint, uint, void*, void> glTexImage3D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, byte, void> glTexImage3DMultisample;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glTexParameterIiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glTexParameterIuiv;
|
||||
internal unsafe delegate*<uint, uint, float, void> glTexParameterf;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glTexParameterfv;
|
||||
internal unsafe delegate*<uint, uint, int, void> glTexParameteri;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glTexParameteriv;
|
||||
internal unsafe delegate*<uint, int, uint, int, void> glTexStorage1D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, void> glTexStorage2D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, byte, void> glTexStorage2DMultisample;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, void> glTexStorage3D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, byte, void> glTexStorage3DMultisample;
|
||||
internal unsafe delegate*<uint, int, int, int, uint, uint, void*, void> glTexSubImage1D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, uint, uint, void*, void> glTexSubImage2D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, uint, uint, void*, void> glTexSubImage3D;
|
||||
internal unsafe delegate*<void> glTextureBarrier;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glTextureBuffer;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, nint, void> glTextureBufferRange;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glTextureParameterIiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glTextureParameterIuiv;
|
||||
internal unsafe delegate*<uint, uint, float, void> glTextureParameterf;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glTextureParameterfv;
|
||||
internal unsafe delegate*<uint, uint, int, void> glTextureParameteri;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glTextureParameteriv;
|
||||
internal unsafe delegate*<uint, int, uint, int, void> glTextureStorage1D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, void> glTextureStorage2D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, byte, void> glTextureStorage2DMultisample;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, void> glTextureStorage3D;
|
||||
internal unsafe delegate*<uint, int, uint, int, int, int, byte, void> glTextureStorage3DMultisample;
|
||||
internal unsafe delegate*<uint, int, int, int, uint, uint, void*, void> glTextureSubImage1D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, uint, uint, void*, void> glTextureSubImage2D;
|
||||
internal unsafe delegate*<uint, int, int, int, int, int, int, int, uint, uint, void*, void> glTextureSubImage3D;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint, uint, uint, uint, void> glTextureView;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glTransformFeedbackBufferBase;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, nint, void> glTransformFeedbackBufferRange;
|
||||
internal unsafe delegate*<uint, int, byte**, uint, void> glTransformFeedbackVaryings;
|
||||
internal unsafe delegate*<int, double, void> glUniform1d;
|
||||
internal unsafe delegate*<int, int, double*, void> glUniform1dv;
|
||||
internal unsafe delegate*<int, float, void> glUniform1f;
|
||||
internal unsafe delegate*<int, int, float*, void> glUniform1fv;
|
||||
internal unsafe delegate*<int, int, void> glUniform1i;
|
||||
internal unsafe delegate*<int, int, int*, void> glUniform1iv;
|
||||
internal unsafe delegate*<int, uint, void> glUniform1ui;
|
||||
internal unsafe delegate*<int, int, uint*, void> glUniform1uiv;
|
||||
internal unsafe delegate*<int, double, double, void> glUniform2d;
|
||||
internal unsafe delegate*<int, int, double*, void> glUniform2dv;
|
||||
internal unsafe delegate*<int, float, float, void> glUniform2f;
|
||||
internal unsafe delegate*<int, int, float*, void> glUniform2fv;
|
||||
internal unsafe delegate*<int, int, int, void> glUniform2i;
|
||||
internal unsafe delegate*<int, int, int*, void> glUniform2iv;
|
||||
internal unsafe delegate*<int, uint, uint, void> glUniform2ui;
|
||||
internal unsafe delegate*<int, int, uint*, void> glUniform2uiv;
|
||||
internal unsafe delegate*<int, double, double, double, void> glUniform3d;
|
||||
internal unsafe delegate*<int, int, double*, void> glUniform3dv;
|
||||
internal unsafe delegate*<int, float, float, float, void> glUniform3f;
|
||||
internal unsafe delegate*<int, int, float*, void> glUniform3fv;
|
||||
internal unsafe delegate*<int, int, int, int, void> glUniform3i;
|
||||
internal unsafe delegate*<int, int, int*, void> glUniform3iv;
|
||||
internal unsafe delegate*<int, uint, uint, uint, void> glUniform3ui;
|
||||
internal unsafe delegate*<int, int, uint*, void> glUniform3uiv;
|
||||
internal unsafe delegate*<int, double, double, double, double, void> glUniform4d;
|
||||
internal unsafe delegate*<int, int, double*, void> glUniform4dv;
|
||||
internal unsafe delegate*<int, float, float, float, float, void> glUniform4f;
|
||||
internal unsafe delegate*<int, int, float*, void> glUniform4fv;
|
||||
internal unsafe delegate*<int, int, int, int, int, void> glUniform4i;
|
||||
internal unsafe delegate*<int, int, int*, void> glUniform4iv;
|
||||
internal unsafe delegate*<int, uint, uint, uint, uint, void> glUniform4ui;
|
||||
internal unsafe delegate*<int, int, uint*, void> glUniform4uiv;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glUniformBlockBinding;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix2dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix2fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix2x3dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix2x3fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix2x4dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix2x4fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix3dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix3fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix3x2dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix3x2fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix3x4dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix3x4fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix4dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix4fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix4x2dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix4x2fv;
|
||||
internal unsafe delegate*<int, int, byte, double*, void> glUniformMatrix4x3dv;
|
||||
internal unsafe delegate*<int, int, byte, float*, void> glUniformMatrix4x3fv;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glUniformSubroutinesuiv;
|
||||
internal unsafe delegate*<uint, byte> glUnmapBuffer;
|
||||
internal unsafe delegate*<uint, byte> glUnmapNamedBuffer;
|
||||
internal unsafe delegate*<uint, void> glUseProgram;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glUseProgramStages;
|
||||
internal unsafe delegate*<uint, void> glValidateProgram;
|
||||
internal unsafe delegate*<uint, void> glValidateProgramPipeline;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glVertexArrayAttribBinding;
|
||||
internal unsafe delegate*<uint, uint, int, uint, byte, uint, void> glVertexArrayAttribFormat;
|
||||
internal unsafe delegate*<uint, uint, int, uint, uint, void> glVertexArrayAttribIFormat;
|
||||
internal unsafe delegate*<uint, uint, int, uint, uint, void> glVertexArrayAttribLFormat;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glVertexArrayBindingDivisor;
|
||||
internal unsafe delegate*<uint, uint, void> glVertexArrayElementBuffer;
|
||||
internal unsafe delegate*<uint, uint, uint, nint, int, void> glVertexArrayVertexBuffer;
|
||||
internal unsafe delegate*<uint, uint, int, uint*, nint*, int*, void> glVertexArrayVertexBuffers;
|
||||
internal unsafe delegate*<uint, double, void> glVertexAttrib1d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttrib1dv;
|
||||
internal unsafe delegate*<uint, float, void> glVertexAttrib1f;
|
||||
internal unsafe delegate*<uint, float*, void> glVertexAttrib1fv;
|
||||
internal unsafe delegate*<uint, short, void> glVertexAttrib1s;
|
||||
internal unsafe delegate*<uint, short*, void> glVertexAttrib1sv;
|
||||
internal unsafe delegate*<uint, double, double, void> glVertexAttrib2d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttrib2dv;
|
||||
internal unsafe delegate*<uint, float, float, void> glVertexAttrib2f;
|
||||
internal unsafe delegate*<uint, float*, void> glVertexAttrib2fv;
|
||||
internal unsafe delegate*<uint, short, short, void> glVertexAttrib2s;
|
||||
internal unsafe delegate*<uint, short*, void> glVertexAttrib2sv;
|
||||
internal unsafe delegate*<uint, double, double, double, void> glVertexAttrib3d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttrib3dv;
|
||||
internal unsafe delegate*<uint, float, float, float, void> glVertexAttrib3f;
|
||||
internal unsafe delegate*<uint, float*, void> glVertexAttrib3fv;
|
||||
internal unsafe delegate*<uint, short, short, short, void> glVertexAttrib3s;
|
||||
internal unsafe delegate*<uint, short*, void> glVertexAttrib3sv;
|
||||
internal unsafe delegate*<uint, sbyte*, void> glVertexAttrib4Nbv;
|
||||
internal unsafe delegate*<uint, int*, void> glVertexAttrib4Niv;
|
||||
internal unsafe delegate*<uint, short*, void> glVertexAttrib4Nsv;
|
||||
internal unsafe delegate*<uint, byte, byte, byte, byte, void> glVertexAttrib4Nub;
|
||||
internal unsafe delegate*<uint, byte*, void> glVertexAttrib4Nubv;
|
||||
internal unsafe delegate*<uint, uint*, void> glVertexAttrib4Nuiv;
|
||||
internal unsafe delegate*<uint, ushort*, void> glVertexAttrib4Nusv;
|
||||
internal unsafe delegate*<uint, sbyte*, void> glVertexAttrib4bv;
|
||||
internal unsafe delegate*<uint, double, double, double, double, void> glVertexAttrib4d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttrib4dv;
|
||||
internal unsafe delegate*<uint, float, float, float, float, void> glVertexAttrib4f;
|
||||
internal unsafe delegate*<uint, float*, void> glVertexAttrib4fv;
|
||||
internal unsafe delegate*<uint, int*, void> glVertexAttrib4iv;
|
||||
internal unsafe delegate*<uint, short, short, short, short, void> glVertexAttrib4s;
|
||||
internal unsafe delegate*<uint, short*, void> glVertexAttrib4sv;
|
||||
internal unsafe delegate*<uint, byte*, void> glVertexAttrib4ubv;
|
||||
internal unsafe delegate*<uint, uint*, void> glVertexAttrib4uiv;
|
||||
internal unsafe delegate*<uint, ushort*, void> glVertexAttrib4usv;
|
||||
internal unsafe delegate*<uint, uint, void> glVertexAttribBinding;
|
||||
internal unsafe delegate*<uint, uint, void> glVertexAttribDivisor;
|
||||
internal unsafe delegate*<uint, int, uint, byte, uint, void> glVertexAttribFormat;
|
||||
internal unsafe delegate*<uint, int, void> glVertexAttribI1i;
|
||||
internal unsafe delegate*<uint, int*, void> glVertexAttribI1iv;
|
||||
internal unsafe delegate*<uint, uint, void> glVertexAttribI1ui;
|
||||
internal unsafe delegate*<uint, uint*, void> glVertexAttribI1uiv;
|
||||
internal unsafe delegate*<uint, int, int, void> glVertexAttribI2i;
|
||||
internal unsafe delegate*<uint, int*, void> glVertexAttribI2iv;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glVertexAttribI2ui;
|
||||
internal unsafe delegate*<uint, uint*, void> glVertexAttribI2uiv;
|
||||
internal unsafe delegate*<uint, int, int, int, void> glVertexAttribI3i;
|
||||
internal unsafe delegate*<uint, int*, void> glVertexAttribI3iv;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void> glVertexAttribI3ui;
|
||||
internal unsafe delegate*<uint, uint*, void> glVertexAttribI3uiv;
|
||||
internal unsafe delegate*<uint, sbyte*, void> glVertexAttribI4bv;
|
||||
internal unsafe delegate*<uint, int, int, int, int, void> glVertexAttribI4i;
|
||||
internal unsafe delegate*<uint, int*, void> glVertexAttribI4iv;
|
||||
internal unsafe delegate*<uint, short*, void> glVertexAttribI4sv;
|
||||
internal unsafe delegate*<uint, byte*, void> glVertexAttribI4ubv;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint, void> glVertexAttribI4ui;
|
||||
internal unsafe delegate*<uint, uint*, void> glVertexAttribI4uiv;
|
||||
internal unsafe delegate*<uint, ushort*, void> glVertexAttribI4usv;
|
||||
internal unsafe delegate*<uint, int, uint, uint, void> glVertexAttribIFormat;
|
||||
internal unsafe delegate*<uint, int, uint, int, void*, void> glVertexAttribIPointer;
|
||||
internal unsafe delegate*<uint, double, void> glVertexAttribL1d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttribL1dv;
|
||||
internal unsafe delegate*<uint, double, double, void> glVertexAttribL2d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttribL2dv;
|
||||
internal unsafe delegate*<uint, double, double, double, void> glVertexAttribL3d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttribL3dv;
|
||||
internal unsafe delegate*<uint, double, double, double, double, void> glVertexAttribL4d;
|
||||
internal unsafe delegate*<uint, double*, void> glVertexAttribL4dv;
|
||||
internal unsafe delegate*<uint, int, uint, uint, void> glVertexAttribLFormat;
|
||||
internal unsafe delegate*<uint, int, uint, int, void*, void> glVertexAttribLPointer;
|
||||
internal unsafe delegate*<uint, uint, byte, uint, void> glVertexAttribP1ui;
|
||||
internal unsafe delegate*<uint, uint, byte, uint*, void> glVertexAttribP1uiv;
|
||||
internal unsafe delegate*<uint, uint, byte, uint, void> glVertexAttribP2ui;
|
||||
internal unsafe delegate*<uint, uint, byte, uint*, void> glVertexAttribP2uiv;
|
||||
internal unsafe delegate*<uint, uint, byte, uint, void> glVertexAttribP3ui;
|
||||
internal unsafe delegate*<uint, uint, byte, uint*, void> glVertexAttribP3uiv;
|
||||
internal unsafe delegate*<uint, uint, byte, uint, void> glVertexAttribP4ui;
|
||||
internal unsafe delegate*<uint, uint, byte, uint*, void> glVertexAttribP4uiv;
|
||||
internal unsafe delegate*<uint, int, uint, byte, int, void*, void> glVertexAttribPointer;
|
||||
internal unsafe delegate*<uint, uint, void> glVertexBindingDivisor;
|
||||
internal unsafe delegate*<int, int, int, int, void> glViewport;
|
||||
internal unsafe delegate*<uint, int, float*, void> glViewportArrayv;
|
||||
internal unsafe delegate*<uint, float, float, float, float, void> glViewportIndexedf;
|
||||
internal unsafe delegate*<uint, float*, void> glViewportIndexedfv;
|
||||
internal unsafe delegate*<glSync, uint, ulong, void> glWaitSync;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="Program"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload
|
||||
// Copyright (c) Nitload. All rights reserved.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using GenerateGL.CodeGen;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace GenerateGL
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
|
||||
private static void Main(
|
||||
string[] args
|
||||
)
|
||||
{
|
||||
string baseDir = AppContext.BaseDirectory;
|
||||
string xmlPath = Path.GetFullPath(Path.Combine(baseDir, "xml", "gl.xml"));
|
||||
string outputRoot = args.Length > 0
|
||||
? Path.GetFullPath(args[0])
|
||||
: Path.GetFullPath(Path.Combine(baseDir, "Generated"));
|
||||
|
||||
Console.WriteLine($"[GenerateGL] Loading registry: {xmlPath}");
|
||||
var (commands, features) = GlXmlParser.Parse(xmlPath);
|
||||
Console.WriteLine($"[GenerateGL] Commands: {commands.Count}, Features: {features.Count}");
|
||||
|
||||
Generator generator = new Generator(commands, features, outputRoot);
|
||||
generator.Run();
|
||||
|
||||
Console.WriteLine($"[GenerateGL] Generated files under: {outputRoot}");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ using StgSharp.Timing;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -23,12 +24,10 @@ namespace StgSharp
|
||||
public class ParticleRenderStream : glRender
|
||||
{
|
||||
|
||||
private AutoTextureGL autoT;
|
||||
|
||||
private ElementBuffer ebo;
|
||||
private ElementBuffer f_ebo;
|
||||
private FrameBuffer fbo;
|
||||
private Image i;
|
||||
private Image<Rgba8> i;
|
||||
|
||||
private int temp = 0;
|
||||
private PlainInstancingBuffer<ParticleOnPlain> buffer;
|
||||
@@ -37,6 +36,7 @@ namespace StgSharp
|
||||
private ShaderProgram s;
|
||||
private TextureGL f_t;
|
||||
private TextureGL t;
|
||||
private Uniform<GraphicsMatrix> cameraUniform;
|
||||
private Uniform<int> texUniform;
|
||||
private Uniform<float> time;
|
||||
private VertexArray f_vao;
|
||||
@@ -64,16 +64,21 @@ namespace StgSharp
|
||||
GL.ClearColor(0.4f, TimePassed % 1.0f, 0f, 1.0f); /*GL.Assert(true);/**/
|
||||
GL.Clear(MaskBufferBit.COLOR /**/ | MaskBufferBit.DEPTH/**/); /*GL.Assert(true);/**/
|
||||
|
||||
f_vao.Bind(0); //GL.Assert(true);
|
||||
GL.BindVertexArray(f_vao[0]); //GL.Assert(true);
|
||||
|
||||
foreach (PlainGeometryMesh mesh in items)
|
||||
{
|
||||
// autoT.SelectTextureAndBind(mesh.TextureImage);
|
||||
f_t.LoadTexture(0, mesh.TextureImage);
|
||||
GL.ActiveTextureUnit((uint)TextureUnit.Unit1);
|
||||
GL.BindTexture(glConst.TEXTURE_2D, f_t[0]);
|
||||
GL.TextureImage2d(Texture2DTarget.Texture2D, 0, glConst.RGBA8,
|
||||
mesh.TextureImage.Width, mesh.TextureImage.Height,
|
||||
FrameBufferChannel.RGBA, PixelChannelLayout.UByte,
|
||||
mesh.TextureImage.ReadOnlyPixels);
|
||||
GL.GenerateMipmap(glConst.TEXTURE_2D);
|
||||
|
||||
// GL.Assert(true);
|
||||
|
||||
frameMainShader.Use(); //GL.Assert(true);
|
||||
GL.UseProgram(frameMainShader.Handle); //GL.Assert(true);
|
||||
|
||||
GL.DrawElements(GeometryType.TRIANGLES, 6, TypeCode.UInt32, IntPtr.Zero);
|
||||
}
|
||||
@@ -94,17 +99,17 @@ namespace StgSharp
|
||||
|
||||
// Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.All));
|
||||
|
||||
fbo.Bind(0); //GL.Assert(true);
|
||||
vao.Bind(0); //GL.Assert(true);
|
||||
t.Bind2D(0); //GL.Assert(false);
|
||||
GL.BindFrameBuffer(FrameBufferTarget.All, fbo[0]); //GL.Assert(true);
|
||||
GL.BindVertexArray(vao[0]); //GL.Assert(true);
|
||||
GL.ActiveTextureUnit((uint)TextureUnit.Unit0);
|
||||
GL.BindTexture(glConst.TEXTURE_2D, t[0]); //GL.Assert(false);
|
||||
|
||||
GL.Viewport(0, 0, Width, Height);
|
||||
|
||||
/**/
|
||||
|
||||
GL.TextureImage2d<byte>(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel,
|
||||
Width, Height, ImageChannel.WithAlphaChannel,
|
||||
PixelChannelLayout.Byte, null);
|
||||
GL.TextureImage2d(Texture2DTarget.Texture2D, 0, glConst.RGBA8, Width, Height,
|
||||
FrameBufferChannel.RGBA, PixelChannelLayout.UByte);
|
||||
/**/
|
||||
|
||||
// GL.Assert(false);
|
||||
@@ -120,12 +125,13 @@ namespace StgSharp
|
||||
|
||||
// GL.Assert(false);
|
||||
|
||||
vbo.Bind(1);
|
||||
vbo.WriteVectorData<Vec4>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw);
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, vbo[1]);
|
||||
GL.SetBufferData<Vec4>(BufferType.ArrayBuffer, buffer.CoordAndRotationSpan,
|
||||
BufferUsage.StreamDraw);
|
||||
|
||||
|
||||
s.Use();
|
||||
NativeCamera.SetAllUniforms();
|
||||
GL.UseProgram(s.Handle);
|
||||
GL.SetUniformValue(cameraUniform, NativeCamera.CameraMatrix());
|
||||
GL.SetUniformValue(time, TimePassed);
|
||||
|
||||
GL.DrawElementsInstanced(GeometryType.TRIANGLES, 6, TypeCode.UInt32, IntPtr.Zero, 100);
|
||||
@@ -139,22 +145,26 @@ namespace StgSharp
|
||||
|
||||
// GL.Assert(true);
|
||||
|
||||
ImageHelper.Resize(i, Width, Height, ImageMovement.Discard);
|
||||
if (i.Size != (Width, Height))
|
||||
{
|
||||
i = new Image<Rgba8>(Width, Height);
|
||||
ButtonTextureProvider.Image = i;
|
||||
}
|
||||
|
||||
// GL.ClearError();
|
||||
// Console.Write($"Size set to {Height},{Width}");
|
||||
// Console.WriteLine($"Image resized to {i.Height} {i.Width}");
|
||||
GL.GetTextureImage(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel,
|
||||
PixelChannelLayout.Byte, i.PixelBuffer);
|
||||
GL.GetTextureImage(Texture2DTarget.Texture2D, 0, FrameBufferChannel.RGBA,
|
||||
PixelChannelLayout.UByte, i.Bytes);
|
||||
/*
|
||||
for (int num = 0; num < i.PixelBuffer.Length; num+=10000)
|
||||
for (int num = 0; num < i.Bytes.Length; num+=10000)
|
||||
{
|
||||
Console.Write($"{i.PixelBuffer[num]}\t");
|
||||
Console.Write($"{i.Bytes[num]}\t");
|
||||
}
|
||||
/**/
|
||||
|
||||
// GL.Assert(true);
|
||||
// Array.Fill<byte>(i.PixelBuffer, 24);
|
||||
// i.Bytes.Fill(24);
|
||||
|
||||
GL.BindFrameBuffer(FrameBufferTarget.All, GlHandle.Zero);
|
||||
|
||||
@@ -192,7 +202,114 @@ namespace StgSharp
|
||||
0)) * rotation;
|
||||
}
|
||||
|
||||
protected override void CustomizeDeinit() { }
|
||||
private Shader CreateShaderSet(
|
||||
ShaderType type,
|
||||
int count
|
||||
)
|
||||
{
|
||||
GlHandle[] handles = new GlHandle[count];
|
||||
for (int index = 0; index < handles.Length; index++) {
|
||||
handles[index] = GL.CreateShader((uint)type);
|
||||
}
|
||||
return new Shader(handles, type);
|
||||
}
|
||||
|
||||
private void CompileShaderFromFile(
|
||||
GlHandle shader,
|
||||
string path
|
||||
)
|
||||
{
|
||||
byte[] source = File.ReadAllBytes(path);
|
||||
if (source.Length == 0) {
|
||||
throw new InvalidOperationException($"Shader source is empty: {path}");
|
||||
}
|
||||
|
||||
GL.ShaderSource(shader, source);
|
||||
GL.CompileShader(shader);
|
||||
|
||||
Span<int> status = stackalloc int[1];
|
||||
GL.GetShaderiv(shader, glConst.COMPILE_STATUS, status);
|
||||
if (status[0] != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException(
|
||||
$"Failed to compile shader '{path}'.{Environment.NewLine}{GetShaderInfoLog(shader)}");
|
||||
}
|
||||
|
||||
private void LinkShaderProgram(
|
||||
GlHandle program
|
||||
)
|
||||
{
|
||||
GL.LinkProgram(program);
|
||||
|
||||
Span<int> status = stackalloc int[1];
|
||||
GL.GetProgramiv(program, glConst.LINK_STATUS, status);
|
||||
if (status[0] != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new InvalidOperationException(
|
||||
$"Failed to link shader program.{Environment.NewLine}{GetProgramInfoLog(program)}");
|
||||
}
|
||||
|
||||
private string GetShaderInfoLog(
|
||||
GlHandle shader
|
||||
)
|
||||
{
|
||||
Span<int> requiredLength = stackalloc int[1];
|
||||
GL.GetShaderiv(shader, glConst.INFO_LOG_LENGTH, requiredLength);
|
||||
if (requiredLength[0] <= 1) {
|
||||
return "OpenGL did not provide a shader info log.";
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[requiredLength[0]];
|
||||
GL.GetShaderInfoLog(shader, out int written, bytes);
|
||||
return Encoding.UTF8.GetString(bytes, 0, Math.Clamp(written, 0, bytes.Length))
|
||||
.TrimEnd('\0');
|
||||
}
|
||||
|
||||
private string GetProgramInfoLog(
|
||||
GlHandle program
|
||||
)
|
||||
{
|
||||
Span<int> requiredLength = stackalloc int[1];
|
||||
GL.GetProgramiv(program, glConst.INFO_LOG_LENGTH, requiredLength);
|
||||
if (requiredLength[0] <= 1) {
|
||||
return "OpenGL did not provide a program info log.";
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[requiredLength[0]];
|
||||
GL.GetProgramInfoLog(program, out int written, bytes);
|
||||
return Encoding.UTF8.GetString(bytes, 0, Math.Clamp(written, 0, bytes.Length))
|
||||
.TrimEnd('\0');
|
||||
}
|
||||
|
||||
private void DeleteShaderSet(
|
||||
Shader shaderSet
|
||||
)
|
||||
{
|
||||
for (int index = 0; index < shaderSet.Count; index++) {
|
||||
GL.DeleteShader(shaderSet[index]);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CustomizeDeinit()
|
||||
{
|
||||
GL.DeleteProgram(s.Handle);
|
||||
GL.DeleteProgram(frameMainShader.Handle);
|
||||
|
||||
GL.DeleteBuffers(vbo.Handles);
|
||||
GL.DeleteBuffers(ebo.Handles);
|
||||
GL.DeleteBuffers(f_vbo.Handles);
|
||||
GL.DeleteBuffers(f_ebo.Handles);
|
||||
GL.DeleteVertexArrays(vao.Handles);
|
||||
GL.DeleteVertexArrays(f_vao.Handles);
|
||||
GL.DeleteFramebuffers(fbo.Handles);
|
||||
GL.DeleteRenderbuffers(rbo.Handles);
|
||||
GL.DeleteTextures(t.Handles);
|
||||
GL.DeleteTextures(f_t.Handles);
|
||||
}
|
||||
|
||||
protected override void CustomizeInit()
|
||||
{
|
||||
@@ -221,59 +338,69 @@ namespace StgSharp
|
||||
|
||||
// SetSizeLimit(800, 800, 800, 800);
|
||||
|
||||
s = CreateShaderProgram();
|
||||
frameMainShader = CreateShaderProgram();
|
||||
Shader pvs = CreateShaderSegment(ShaderType.Vertex, 2);
|
||||
Shader pfs = CreateShaderSegment(ShaderType.Fragment, 2);
|
||||
s = new ShaderProgram(GL.CreateProgram());
|
||||
frameMainShader = new ShaderProgram(GL.CreateProgram());
|
||||
Shader pvs = CreateShaderSet(ShaderType.Vertex, 2);
|
||||
Shader pfs = CreateShaderSet(ShaderType.Fragment, 2);
|
||||
|
||||
// GL.Assert(true);
|
||||
pvs.Compile(0, Shader.FromCodeFile("Shader\\particle.vert"));
|
||||
CompileShaderFromFile(pvs[0], Path.Combine("Shader", "particle.vert"));
|
||||
|
||||
// GL.Assert(true);
|
||||
pvs.AttachTo(0, s);
|
||||
GL.AttachShader(s.Handle, pvs[0]);
|
||||
|
||||
// GL.Assert(true);
|
||||
pfs.Compile(0, Shader.FromCodeFile("Shader\\particle.frag"));
|
||||
pfs.AttachTo(0, s);
|
||||
s.Link();
|
||||
CompileShaderFromFile(pfs[0], Path.Combine("Shader", "particle.frag"));
|
||||
GL.AttachShader(s.Handle, pfs[0]);
|
||||
LinkShaderProgram(s.Handle);
|
||||
|
||||
// GL.Assert(true);
|
||||
|
||||
pvs.Compile(1, Shader.FromCodeFile("Shader\\fbo.vert"));
|
||||
pvs.AttachTo(1, frameMainShader);
|
||||
pfs.Compile(1, Shader.FromCodeFile("Shader\\fbo.frag"));
|
||||
pfs.AttachTo(1, frameMainShader);
|
||||
frameMainShader.Link();
|
||||
CompileShaderFromFile(pvs[1], Path.Combine("Shader", "fbo.vert"));
|
||||
GL.AttachShader(frameMainShader.Handle, pvs[1]);
|
||||
CompileShaderFromFile(pfs[1], Path.Combine("Shader", "fbo.frag"));
|
||||
GL.AttachShader(frameMainShader.Handle, pfs[1]);
|
||||
LinkShaderProgram(frameMainShader.Handle);
|
||||
|
||||
DeleteShaderSet(pvs);
|
||||
DeleteShaderSet(pfs);
|
||||
|
||||
// GL.Assert(true);
|
||||
vbo = CreateVertexBuffer(3);
|
||||
vao = CreateVertexArray(1);
|
||||
ebo = CreateElementBuffer(1);
|
||||
vbo.Bind(0);
|
||||
vbo = new VertexBuffer(GL.GenBuffers(3));
|
||||
vao = new VertexArray(GL.GenVertexArrays(1));
|
||||
ebo = new ElementBuffer(GL.GenBuffers(1));
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, vbo[0]);
|
||||
|
||||
Rectangle rec = new Rectangle(0.05f, 0.05f, 0.05f, -0.05f, -0.05f, -0.05f, -0.05f,
|
||||
0.05f);
|
||||
|
||||
// GL.Assert(true);
|
||||
vao.Bind(0);
|
||||
vbo.WriteVectorData(0, rec.VertexStream, BufferUsage.StaticDraw);
|
||||
ebo.SetValue(0, rec.VertexIndices, BufferUsage.StaticDraw);
|
||||
vao.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
GL.BindVertexArray(vao[0]);
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, vbo[0]);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, rec.VertexStream, BufferUsage.StaticDraw);
|
||||
GL.BindBuffer(BufferType.ElementArrayBuffer, ebo[0]);
|
||||
GL.SetBufferData(BufferType.ElementArrayBuffer, rec.VertexIndices,
|
||||
BufferUsage.StaticDraw);
|
||||
GL.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
|
||||
vbo.WriteVectorData<Vec4>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw);
|
||||
vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
vao.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float),
|
||||
3 * sizeof(float));
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, vbo[1]);
|
||||
GL.SetBufferData<Vec4>(BufferType.ArrayBuffer, buffer.CoordAndRotationSpan,
|
||||
BufferUsage.StreamDraw);
|
||||
GL.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
GL.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float),
|
||||
3 * sizeof(float));
|
||||
|
||||
GL.VertexAttributeDivisor(1, 1);
|
||||
GL.VertexAttributeDivisor(2, 1);
|
||||
|
||||
vbo.WriteScalerData<float>(2, buffer.ScalingSpan, BufferUsage.StaticDraw);
|
||||
vao.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0);
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, vbo[2]);
|
||||
GL.SetBufferData<float>(BufferType.ArrayBuffer, buffer.ScalingSpan,
|
||||
BufferUsage.StaticDraw);
|
||||
GL.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0);
|
||||
|
||||
GL.VertexAttributeDivisor(3, 1);
|
||||
|
||||
vbo.Unbind();
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, GlHandle.Zero);
|
||||
GL.BindVertexArray(GlHandle.Zero);
|
||||
|
||||
NativeCameraViewTarget([
|
||||
@@ -290,23 +417,31 @@ namespace StgSharp
|
||||
0f
|
||||
]);
|
||||
NativeCameraViewRange(new Degree(1.5f), Vec2.Zero, (50, 50));
|
||||
NativeCameraUniform(s, "Camera");
|
||||
cameraUniform = GL.GetUniform<GraphicsMatrix>(s.Handle, "Camera");
|
||||
|
||||
s.Use();
|
||||
GL.UseProgram(s.Handle);
|
||||
|
||||
fbo = CreateFrameBuffer(1);
|
||||
rbo = CreateRenderBuffer(1);
|
||||
fbo.Bind(0);
|
||||
rbo.Bind(0);
|
||||
GlHandle[] frameBufferHandles = new GlHandle[1];
|
||||
GL.GenFrameBuffers(frameBufferHandles);
|
||||
fbo = new FrameBuffer(frameBufferHandles);
|
||||
rbo = new RenderBuffer(GL.GenRenderBuffer(1));
|
||||
GL.BindFrameBuffer(FrameBufferTarget.All, fbo[0]);
|
||||
GL.BindRenderBuffer(rbo[0]);
|
||||
|
||||
// GL.Assert(true);
|
||||
t = CreateTexture(1);
|
||||
t.Bind2D(0);
|
||||
GL.TextureImage2d<byte>(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel,
|
||||
Width, Height, ImageChannel.WithAlphaChannel,
|
||||
PixelChannelLayout.Byte, null!);
|
||||
t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
|
||||
t.Set2dFilterProperty(0, TextureFilter.Linear, TextureFilter.Linear);
|
||||
t = new TextureGL(GL.GenTextures(1));
|
||||
GL.ActiveTextureUnit((uint)TextureUnit.Unit0);
|
||||
GL.BindTexture(glConst.TEXTURE_2D, t[0]);
|
||||
GL.TextureImage2d(Texture2DTarget.Texture2D, 0, glConst.RGBA8, Width, Height,
|
||||
FrameBufferChannel.RGBA, PixelChannelLayout.UByte);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_S,
|
||||
(int)TextureWrap.Repeat);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_T,
|
||||
(int)TextureWrap.Repeat);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_MIN_FILTER,
|
||||
(int)TextureFilter.Linear);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_MAG_FILTER,
|
||||
(int)TextureFilter.Linear);
|
||||
|
||||
// GL.Assert(true);
|
||||
GL.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
|
||||
@@ -317,15 +452,13 @@ namespace StgSharp
|
||||
|
||||
Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.All));
|
||||
|
||||
FrameBuffer.BindNull();
|
||||
GL.BindFrameBuffer(FrameBufferTarget.All, GlHandle.Zero);
|
||||
|
||||
// GL.Assert(true);
|
||||
int streamLength = this.Width * this.Height * 4;
|
||||
byte[] imageStream = new byte[streamLength];
|
||||
i = Image.FromMemory(this.Size, ImageChannel.WithAlphaChannel, imageStream);
|
||||
i = new Image<Rgba8>(this.Size);
|
||||
|
||||
|
||||
time = s.GetUniform<float>("time");
|
||||
time = GL.GetUniform<float>(s.Handle, "time");
|
||||
|
||||
Vec2[] buttonTextureCoordArray = {
|
||||
(0f, 1f),
|
||||
@@ -338,45 +471,46 @@ namespace StgSharp
|
||||
// GL.Assert(true);
|
||||
ButtonTextureProvider = new TextureProvider(i, buttonTextureCoordArray);
|
||||
|
||||
f_vao = CreateVertexArray(1);
|
||||
f_vbo = CreateVertexBuffer(2);
|
||||
f_ebo = CreateElementBuffer(1);
|
||||
f_vao = new VertexArray(GL.GenVertexArrays(1));
|
||||
f_vbo = new VertexBuffer(GL.GenBuffers(2));
|
||||
f_ebo = new ElementBuffer(GL.GenBuffers(1));
|
||||
|
||||
// GL.Assert(true);
|
||||
f_vao.Bind(0);
|
||||
GL.BindVertexArray(f_vao[0]);
|
||||
|
||||
f_ebo.Bind(0);
|
||||
f_ebo.SetValue(0, ButtonBounding.VertexIndices, BufferUsage.StaticDraw);
|
||||
GL.BindBuffer(BufferType.ElementArrayBuffer, f_ebo[0]);
|
||||
GL.SetBufferData(BufferType.ElementArrayBuffer, ButtonBounding.VertexIndices,
|
||||
BufferUsage.StaticDraw);
|
||||
|
||||
// GL.Assert(true);
|
||||
f_vbo.Bind(0);
|
||||
f_vbo.WriteVectorData(0, ButtonBounding.VertexStream, BufferUsage.StaticDraw);
|
||||
f_vao.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, f_vbo[0]);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, ButtonBounding.VertexStream,
|
||||
BufferUsage.StaticDraw);
|
||||
GL.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
|
||||
// GL.Assert(true);
|
||||
f_vbo.Bind(1);
|
||||
f_vbo.WriteVectorData(1, buttonTextureCoordArray, BufferUsage.StaticDraw);
|
||||
f_vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, f_vbo[1]);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, buttonTextureCoordArray,
|
||||
BufferUsage.StaticDraw);
|
||||
GL.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
|
||||
// GL.Assert(true);
|
||||
|
||||
autoT = CreateAutoTexture(4);
|
||||
autoT.DefaultTextureProperty = new TextureProperty(TextureFilter.Nearest,
|
||||
TextureFilter.Nearest,
|
||||
TextureWrap.Repeat,
|
||||
TextureWrap.Repeat);
|
||||
|
||||
f_t = CreateTexture(1);
|
||||
f_t.Bind2D(0);
|
||||
f_t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
|
||||
f_t.Set2dFilterProperty(0, TextureFilter.Nearest, TextureFilter.Nearest);
|
||||
f_t = new TextureGL(GL.GenTextures(1));
|
||||
GL.ActiveTextureUnit((uint)TextureUnit.Unit1);
|
||||
GL.BindTexture(glConst.TEXTURE_2D, f_t[0]);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_S,
|
||||
(int)TextureWrap.Repeat);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_T,
|
||||
(int)TextureWrap.Repeat);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_MIN_FILTER,
|
||||
(int)TextureFilter.Nearest);
|
||||
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_MAG_FILTER,
|
||||
(int)TextureFilter.Nearest);
|
||||
|
||||
// GL.Assert(true);
|
||||
f_t.ActivateAs(TextureUnit.Unit1);
|
||||
|
||||
// GL.Assert(true);
|
||||
frameMainShader.Use();
|
||||
texUniform = frameMainShader.GetUniform<int>("tex");
|
||||
GL.UseProgram(frameMainShader.Handle);
|
||||
texUniform = GL.GetUniform<int>(frameMainShader.Handle, "tex");
|
||||
|
||||
// GL.Assert(true);
|
||||
GL.SetUniformValue(texUniform, 1);
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace StgSharp
|
||||
|
||||
public static void TestRender()
|
||||
{
|
||||
// World.InitGL(4, 6);
|
||||
World.GlobalSetting.VSyncActivated = false;
|
||||
|
||||
ViewPort vp = new ViewPort(800, 600, "Hello StgSharp!", IntPtr.Zero);
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="GenerateCli"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using StgSharp.GenerateGL.Generation;
|
||||
using StgSharp.GenerateGL.Registry;
|
||||
|
||||
namespace StgSharp.GenerateGL
|
||||
{
|
||||
/// <summary>
|
||||
/// Owns the command-line boundary of the future code generation pipeline.
|
||||
/// </summary>
|
||||
internal static class GenerateCli
|
||||
{
|
||||
|
||||
private const int QueryErrorExitCode = 1;
|
||||
private const int SuccessExitCode = 0;
|
||||
private const int UsageErrorExitCode = 2;
|
||||
|
||||
public static int Generate(
|
||||
GlRegistryModel registry,
|
||||
IReadOnlyList<string> arguments,
|
||||
out GeneratedFileSet? generatedFiles
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(registry);
|
||||
ArgumentNullException.ThrowIfNull(arguments);
|
||||
generatedFiles = null;
|
||||
|
||||
if (arguments.Count == 1 && arguments[0] is "--help" or "-h")
|
||||
{
|
||||
WriteHelp();
|
||||
return SuccessExitCode;
|
||||
}
|
||||
|
||||
if (arguments.Count != 0)
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"error: unknown generate option '{arguments[0]}'.");
|
||||
Console.Error.WriteLine("Run 'generate --help' for command information.");
|
||||
return UsageErrorExitCode;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
generatedFiles = OpenGlGenerator.Generate(registry);
|
||||
}
|
||||
catch (InvalidDataException exception)
|
||||
{
|
||||
Console.Error.WriteLine($"error: {exception.Message}");
|
||||
return QueryErrorExitCode;
|
||||
}
|
||||
catch (InvalidOperationException exception)
|
||||
{
|
||||
Console.Error.WriteLine($"error: {exception.Message}");
|
||||
return QueryErrorExitCode;
|
||||
}
|
||||
|
||||
Console.WriteLine(
|
||||
$"Generated {generatedFiles.Files.Count} file(s) in memory.");
|
||||
Console.WriteLine("Use 'list files' and 'preview <filename>' to inspect them.");
|
||||
Console.WriteLine("No files were written to disk.");
|
||||
return SuccessExitCode;
|
||||
}
|
||||
|
||||
public static int ListFiles(
|
||||
GeneratedFileSet files,
|
||||
IReadOnlyList<string> arguments
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(files);
|
||||
ArgumentNullException.ThrowIfNull(arguments);
|
||||
if (arguments.Count != 0)
|
||||
{
|
||||
Console.Error.WriteLine("error: list files does not accept arguments.");
|
||||
return UsageErrorExitCode;
|
||||
}
|
||||
|
||||
if (files.Files.Count == 0)
|
||||
{
|
||||
Console.Error.WriteLine("No generated files are held in this session.");
|
||||
Console.Error.WriteLine("Run 'generate' first.");
|
||||
return QueryErrorExitCode;
|
||||
}
|
||||
|
||||
Console.WriteLine("Generated files (memory only)");
|
||||
for (int index = 0; index < files.Files.Count; index++)
|
||||
{
|
||||
GeneratedFile file = files.Files[index];
|
||||
Console.WriteLine(
|
||||
$" [{index + 1}] {file.Name} ({file.Content.Length} characters)");
|
||||
}
|
||||
|
||||
return SuccessExitCode;
|
||||
}
|
||||
|
||||
public static int Preview(
|
||||
GeneratedFileSet files,
|
||||
IReadOnlyList<string> arguments
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(files);
|
||||
ArgumentNullException.ThrowIfNull(arguments);
|
||||
if (arguments.Count != 1)
|
||||
{
|
||||
Console.Error.WriteLine("error: preview requires one generated file name.");
|
||||
return UsageErrorExitCode;
|
||||
}
|
||||
|
||||
if (!files.TryGetFile(arguments[0], out GeneratedFile file))
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"No generated file named '{arguments[0]}' is held in this session.");
|
||||
if (files.Files.Count == 0)
|
||||
{
|
||||
Console.Error.WriteLine("Run 'generate' first.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.Error.WriteLine(
|
||||
$"Available files: {string.Join(", ", files.Files.Select(value => value.Name))}");
|
||||
}
|
||||
|
||||
return QueryErrorExitCode;
|
||||
}
|
||||
|
||||
Console.Write(file.Content);
|
||||
return SuccessExitCode;
|
||||
}
|
||||
|
||||
public static void WriteHelp()
|
||||
{
|
||||
Console.WriteLine("Generate C# bindings from the loaded OpenGL registry.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Usage:");
|
||||
Console.WriteLine(" generate");
|
||||
Console.WriteLine(" generate --help");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Status:");
|
||||
Console.WriteLine(" Output is retained in the current process only.");
|
||||
Console.WriteLine(" Running 'generate' does not create or modify disk files.");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("Inspection:");
|
||||
Console.WriteLine(" list files");
|
||||
Console.WriteLine(" preview <filename>");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="CSharpAbiTypePolicy"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StgSharp.GenerateGL.Generation
|
||||
{
|
||||
/// <summary>
|
||||
/// Defines C ABI primitives and external Khronos platform types that cannot
|
||||
/// be inferred from gl.xml.
|
||||
/// </summary>
|
||||
internal static class CSharpAbiTypePolicy
|
||||
{
|
||||
|
||||
private static readonly Dictionary<string, string> _types = new Dictionary<string, string>(
|
||||
StringComparer.Ordinal)
|
||||
{
|
||||
["void"] = "void",
|
||||
["char"] = "byte",
|
||||
["signed char"] = "sbyte",
|
||||
["unsigned char"] = "byte",
|
||||
["short"] = "short",
|
||||
["short int"] = "short",
|
||||
["signed short"] = "short",
|
||||
["signed short int"] = "short",
|
||||
["unsigned short"] = "ushort",
|
||||
["unsigned short int"] = "ushort",
|
||||
["int"] = "int",
|
||||
["signed"] = "int",
|
||||
["signed int"] = "int",
|
||||
["unsigned"] = "uint",
|
||||
["unsigned int"] = "uint",
|
||||
["float"] = "float",
|
||||
["double"] = "double",
|
||||
["khronos_int8_t"] = "sbyte",
|
||||
["khronos_uint8_t"] = "byte",
|
||||
["khronos_int16_t"] = "short",
|
||||
["khronos_uint16_t"] = "ushort",
|
||||
["khronos_int32_t"] = "int",
|
||||
["khronos_uint32_t"] = "uint",
|
||||
["khronos_int64_t"] = "long",
|
||||
["khronos_uint64_t"] = "ulong",
|
||||
["khronos_intptr_t"] = "nint",
|
||||
["khronos_uintptr_t"] = "nuint",
|
||||
["khronos_ssize_t"] = "nint",
|
||||
["khronos_usize_t"] = "nuint",
|
||||
["khronos_float_t"] = "float",
|
||||
};
|
||||
|
||||
public static bool TryResolve(
|
||||
string typeName,
|
||||
out string equivalentType
|
||||
)
|
||||
{
|
||||
return _types.TryGetValue(typeName, out equivalentType!);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="GeneratedFileSet"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
|
||||
namespace StgSharp.GenerateGL.Generation
|
||||
{
|
||||
internal sealed record GeneratedFile(
|
||||
string Name,
|
||||
string Content
|
||||
);
|
||||
|
||||
internal sealed class GeneratedFileSet
|
||||
{
|
||||
|
||||
public static GeneratedFileSet Empty { get; } = new GeneratedFileSet(
|
||||
Array.Empty<GeneratedFile>());
|
||||
|
||||
private readonly ReadOnlyDictionary<string, GeneratedFile> _filesByName;
|
||||
|
||||
public GeneratedFileSet(
|
||||
IEnumerable<GeneratedFile> files
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(files);
|
||||
|
||||
ReadOnlyCollection<GeneratedFile> values = Array.AsReadOnly(files.ToArray());
|
||||
Dictionary<string, GeneratedFile> index = new Dictionary<string, GeneratedFile>(
|
||||
StringComparer.OrdinalIgnoreCase);
|
||||
foreach (GeneratedFile file in values)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(file.Name);
|
||||
if (!index.TryAdd(file.Name, file))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Generated file name '{file.Name}' is duplicated.");
|
||||
}
|
||||
}
|
||||
|
||||
Files = values;
|
||||
_filesByName = new ReadOnlyDictionary<string, GeneratedFile>(index);
|
||||
}
|
||||
|
||||
public IReadOnlyList<GeneratedFile> Files { get; }
|
||||
|
||||
public bool TryGetFile(
|
||||
string name,
|
||||
out GeneratedFile file
|
||||
)
|
||||
{
|
||||
ArgumentException.ThrowIfNullOrWhiteSpace(name);
|
||||
return _filesByName.TryGetValue(name, out file!);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="GlEquivalentTypeMapper"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using StgSharp.GenerateGL.Registry;
|
||||
|
||||
namespace StgSharp.GenerateGL.Generation
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves OpenGL typedef declarations recursively to equivalent C# ABI types.
|
||||
/// </summary>
|
||||
internal sealed class GlEquivalentTypeMapper
|
||||
{
|
||||
|
||||
private readonly Dictionary<string, string> _resolvedTypes = new Dictionary<string, string>(
|
||||
StringComparer.Ordinal);
|
||||
private readonly GlRegistryModel _registry;
|
||||
|
||||
public GlEquivalentTypeMapper(
|
||||
GlRegistryModel registry
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(registry);
|
||||
_registry = registry;
|
||||
}
|
||||
|
||||
public string ReadReturnType(
|
||||
GlCommandDefinition command
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
return ReadDeclarationType(
|
||||
command.Return.TypeName,
|
||||
command.Return.DeclarationText,
|
||||
command.Name);
|
||||
}
|
||||
|
||||
public string ReadParameterType(
|
||||
GlParameterDefinition parameter
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(parameter);
|
||||
return ReadDeclarationType(
|
||||
parameter.TypeName,
|
||||
parameter.DeclarationText,
|
||||
parameter.Name);
|
||||
}
|
||||
|
||||
private string ReadDeclarationType(
|
||||
string? typeName,
|
||||
string declaration,
|
||||
string identifier
|
||||
)
|
||||
{
|
||||
if (typeName is null)
|
||||
{
|
||||
return ResolveTypeExpression(RemoveIdentifier(declaration, identifier));
|
||||
}
|
||||
|
||||
string equivalentType = ResolveNamedType(
|
||||
typeName,
|
||||
new HashSet<string>(StringComparer.Ordinal));
|
||||
int pointerDepth = declaration.Count(value => value == '*');
|
||||
if (declaration.Contains('[', StringComparison.Ordinal))
|
||||
{
|
||||
pointerDepth++;
|
||||
}
|
||||
|
||||
return equivalentType + new string('*', pointerDepth);
|
||||
}
|
||||
|
||||
private string ResolveNamedType(
|
||||
string typeName,
|
||||
HashSet<string> resolving
|
||||
)
|
||||
{
|
||||
if (CSharpAbiTypePolicy.TryResolve(typeName, out string abiType))
|
||||
{
|
||||
return abiType;
|
||||
}
|
||||
|
||||
if (_resolvedTypes.TryGetValue(typeName, out string? resolvedType))
|
||||
{
|
||||
return resolvedType;
|
||||
}
|
||||
|
||||
if (!resolving.Add(typeName))
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"OpenGL type alias cycle contains '{typeName}'.");
|
||||
}
|
||||
|
||||
if (!_registry.TypesByName.TryGetValue(
|
||||
typeName,
|
||||
out IReadOnlyList<GlTypeDefinition>? definitions) ||
|
||||
definitions.Count != 1)
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"OpenGL type '{typeName}' does not have one registry definition.");
|
||||
}
|
||||
|
||||
GlTypeDefinition definition = definitions[0];
|
||||
string declaration = NormalizeWhitespace(definition.DeclarationText);
|
||||
string value;
|
||||
if (TryReadCallbackType(typeName, declaration, resolving, out string callbackType))
|
||||
{
|
||||
value = callbackType;
|
||||
}
|
||||
else
|
||||
{
|
||||
MatchCollection aliases = Regex.Matches(
|
||||
declaration,
|
||||
$@"typedef\s+(?<target>.+?)\s*\b{Regex.Escape(typeName)}\b\s*;",
|
||||
RegexOptions.CultureInvariant);
|
||||
if (aliases.Count == 1)
|
||||
{
|
||||
value = ResolveTypeExpression(
|
||||
aliases[0].Groups["target"].Value,
|
||||
resolving);
|
||||
}
|
||||
else if (declaration == $"{typeName};" || declaration.StartsWith(
|
||||
"struct ",
|
||||
StringComparison.Ordinal))
|
||||
{
|
||||
value = "void";
|
||||
}
|
||||
else if (aliases.Count > 1)
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"OpenGL type '{typeName}' has platform-dependent typedefs and " +
|
||||
"requires an explicit target policy.");
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"Cannot read typedef declaration '{definition.DeclarationText}'.");
|
||||
}
|
||||
}
|
||||
|
||||
resolving.Remove(typeName);
|
||||
_resolvedTypes.Add(typeName, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
private bool TryReadCallbackType(
|
||||
string typeName,
|
||||
string declaration,
|
||||
HashSet<string> resolving,
|
||||
out string type
|
||||
)
|
||||
{
|
||||
Match match = Regex.Match(
|
||||
declaration,
|
||||
$@"^typedef\s+(?<return>.+?)\s*\(\s*\*\s*{Regex.Escape(typeName)}\s*\)" +
|
||||
@"\s*\((?<parameters>.*)\)\s*;$",
|
||||
RegexOptions.CultureInvariant);
|
||||
if (!match.Success)
|
||||
{
|
||||
type = string.Empty;
|
||||
return false;
|
||||
}
|
||||
|
||||
List<string> types = new List<string>();
|
||||
string parameters = match.Groups["parameters"].Value.Trim();
|
||||
if (parameters.Length != 0 && parameters != "void")
|
||||
{
|
||||
foreach (string parameter in parameters.Split(','))
|
||||
{
|
||||
types.Add(ResolveTypeExpression(RemoveLastIdentifier(parameter), resolving));
|
||||
}
|
||||
}
|
||||
|
||||
types.Add(ResolveTypeExpression(match.Groups["return"].Value, resolving));
|
||||
type = $"delegate* unmanaged<{string.Join(", ", types)}>";
|
||||
return true;
|
||||
}
|
||||
|
||||
private string ResolveTypeExpression(
|
||||
string expression,
|
||||
HashSet<string>? resolving = null
|
||||
)
|
||||
{
|
||||
resolving ??= new HashSet<string>(StringComparer.Ordinal);
|
||||
string value = Regex.Replace(
|
||||
NormalizeWhitespace(expression),
|
||||
@"\b(?:const|volatile|restrict)\b",
|
||||
string.Empty,
|
||||
RegexOptions.CultureInvariant).Trim();
|
||||
int pointerDepth = value.Count(character => character == '*');
|
||||
value = value.Replace("*", string.Empty, StringComparison.Ordinal).Trim();
|
||||
if (value.StartsWith("struct ", StringComparison.Ordinal))
|
||||
{
|
||||
value = "void";
|
||||
}
|
||||
|
||||
string equivalentType = ResolveNamedType(value, resolving);
|
||||
return equivalentType + new string('*', pointerDepth);
|
||||
}
|
||||
|
||||
private static string RemoveIdentifier(
|
||||
string declaration,
|
||||
string identifier
|
||||
)
|
||||
{
|
||||
int index = declaration.LastIndexOf(identifier, StringComparison.Ordinal);
|
||||
return index < 0
|
||||
? declaration
|
||||
: declaration.Remove(index, identifier.Length);
|
||||
}
|
||||
|
||||
private static string RemoveLastIdentifier(
|
||||
string declaration
|
||||
)
|
||||
{
|
||||
Match match = Regex.Match(
|
||||
declaration.Trim(),
|
||||
@"^(?<type>.+?)(?<name>[A-Za-z_][A-Za-z0-9_]*)$",
|
||||
RegexOptions.CultureInvariant);
|
||||
return match.Success ? match.Groups["type"].Value.Trim() : declaration.Trim();
|
||||
}
|
||||
|
||||
private static string NormalizeWhitespace(
|
||||
string value
|
||||
)
|
||||
{
|
||||
return Regex.Replace(
|
||||
value,
|
||||
@"\s+",
|
||||
" ",
|
||||
RegexOptions.CultureInvariant).Trim();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,422 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="OpenGlGenerator"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
using StgSharp.GenerateGL.Registry;
|
||||
|
||||
namespace StgSharp.GenerateGL.Generation
|
||||
{
|
||||
/// <summary>
|
||||
/// Produces the first in-memory desktop OpenGL binding files.
|
||||
/// </summary>
|
||||
internal static class OpenGlGenerator
|
||||
{
|
||||
|
||||
private const string ApiName = "gl";
|
||||
private const string CoreProfile = "core";
|
||||
|
||||
private static readonly HashSet<string> _csharpKeywords = new HashSet<string>(
|
||||
new[]
|
||||
{
|
||||
"abstract", "as", "base", "bool", "break", "byte", "case", "catch",
|
||||
"char", "checked", "class", "const", "continue", "decimal", "default",
|
||||
"delegate", "do", "double", "else", "enum", "event", "explicit", "extern",
|
||||
"false", "finally", "fixed", "float", "for", "foreach", "goto", "if",
|
||||
"implicit", "in", "int", "interface", "internal", "is", "lock", "long",
|
||||
"namespace", "new", "null", "object", "operator", "out", "override",
|
||||
"params", "private", "protected", "public", "readonly", "ref", "return",
|
||||
"sbyte", "sealed", "short", "sizeof", "stackalloc", "static", "string",
|
||||
"struct", "switch", "this", "throw", "true", "try", "typeof", "uint",
|
||||
"ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void",
|
||||
"volatile", "while",
|
||||
},
|
||||
StringComparer.Ordinal);
|
||||
|
||||
public static GeneratedFileSet Generate(
|
||||
GlRegistryModel registry
|
||||
)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(registry);
|
||||
|
||||
IReadOnlyList<GlCommandDefinition> commands = ReadCoreCommands(registry);
|
||||
GlEquivalentTypeMapper typeMapper = new GlEquivalentTypeMapper(registry);
|
||||
return new GeneratedFileSet(
|
||||
new[]
|
||||
{
|
||||
new GeneratedFile("glconst.cs", GenerateConstants(registry)),
|
||||
new GeneratedFile(
|
||||
"OpenglContext.g.cs",
|
||||
GenerateContext(commands, typeMapper)),
|
||||
new GeneratedFile(
|
||||
"OpenGLFunction.Raw.g.cs",
|
||||
GenerateFunctions(commands, typeMapper)),
|
||||
});
|
||||
}
|
||||
|
||||
private static ReadOnlyCollection<GlCommandDefinition> ReadCoreCommands(
|
||||
GlRegistryModel registry
|
||||
)
|
||||
{
|
||||
Dictionary<string, GlCommandDefinition> definitions = new Dictionary<string, GlCommandDefinition>(
|
||||
StringComparer.Ordinal);
|
||||
foreach (GlCommandDefinition command in registry.Commands)
|
||||
{
|
||||
if (!definitions.TryAdd(command.Name, command))
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"Command '{command.Name}' has more than one definition.");
|
||||
}
|
||||
}
|
||||
|
||||
List<string> order = new List<string>();
|
||||
HashSet<string> known = new HashSet<string>(StringComparer.Ordinal);
|
||||
HashSet<string> active = new HashSet<string>(StringComparer.Ordinal);
|
||||
foreach (GlFeatureDefinition feature in registry.Features.Where(
|
||||
value => string.Equals(value.Api, ApiName, StringComparison.Ordinal)))
|
||||
{
|
||||
foreach (GlRequirementBlock block in feature.Requirements.Where(AppliesToCoreGl))
|
||||
{
|
||||
foreach (GlRegistryReference reference in block.References.Where(
|
||||
value => value.Kind == GlRegistryReferenceKind.Command))
|
||||
{
|
||||
if (!definitions.ContainsKey(reference.Name))
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"Feature '{feature.Name}' references undefined command " +
|
||||
$"'{reference.Name}'.");
|
||||
}
|
||||
|
||||
if (block.Operation == GlRequirementOperation.Require)
|
||||
{
|
||||
active.Add(reference.Name);
|
||||
if (known.Add(reference.Name))
|
||||
{
|
||||
order.Add(reference.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
active.Remove(reference.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Array.AsReadOnly(
|
||||
order.Where(active.Contains).Select(value => definitions[value]).ToArray());
|
||||
}
|
||||
|
||||
private static bool AppliesToCoreGl(
|
||||
GlRequirementBlock block
|
||||
)
|
||||
{
|
||||
bool matchesApi = block.Api is null || string.Equals(
|
||||
block.Api,
|
||||
ApiName,
|
||||
StringComparison.Ordinal);
|
||||
bool matchesProfile = block.Profile is null || string.Equals(
|
||||
block.Profile,
|
||||
CoreProfile,
|
||||
StringComparison.Ordinal);
|
||||
return matchesApi && matchesProfile;
|
||||
}
|
||||
|
||||
private static string GenerateConstants(
|
||||
GlRegistryModel registry
|
||||
)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(512 * 1024);
|
||||
AppendGeneratedHeader(builder, "Desktop OpenGL constants");
|
||||
builder.Append("namespace StgSharp.Graphics.OpenGL\n");
|
||||
builder.Append("{\n");
|
||||
builder.Append(" public static class glConst\n");
|
||||
builder.Append(" {\n\n");
|
||||
|
||||
Dictionary<string, GlEnumDefinition> emitted = new Dictionary<string, GlEnumDefinition>(
|
||||
StringComparer.Ordinal);
|
||||
foreach (GlEnumDefinition value in registry.EnumBlocks.SelectMany(
|
||||
block => block.Enums).Where(IsDesktopEnum))
|
||||
{
|
||||
if (value.Value is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (emitted.TryGetValue(value.Name, out GlEnumDefinition? previous))
|
||||
{
|
||||
if (!string.Equals(previous.Value, value.Value, StringComparison.Ordinal))
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"Desktop enum '{value.Name}' has conflicting values " +
|
||||
$"'{previous.Value}' and '{value.Value}'.");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
emitted.Add(value.Name, value);
|
||||
ConstantExpression expression = ReadConstantExpression(value);
|
||||
builder.Append(" public const ");
|
||||
builder.Append(expression.Type);
|
||||
builder.Append(' ');
|
||||
builder.Append(ReadConstantName(value.Name));
|
||||
builder.Append(" = ");
|
||||
builder.Append(expression.Literal);
|
||||
builder.Append(";\n");
|
||||
}
|
||||
|
||||
builder.Append("\n }\n");
|
||||
builder.Append("}\n");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static bool IsDesktopEnum(
|
||||
GlEnumDefinition value
|
||||
)
|
||||
{
|
||||
return value.Api is null || string.Equals(
|
||||
value.Api,
|
||||
ApiName,
|
||||
StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static ConstantExpression ReadConstantExpression(
|
||||
GlEnumDefinition value
|
||||
)
|
||||
{
|
||||
string source = value.Value!;
|
||||
bool isHex = source.StartsWith("0x", StringComparison.OrdinalIgnoreCase);
|
||||
BigInteger number = isHex
|
||||
? BigInteger.Parse(
|
||||
$"0{source[2..]}",
|
||||
NumberStyles.AllowHexSpecifier,
|
||||
CultureInfo.InvariantCulture)
|
||||
: BigInteger.Parse(source, NumberStyles.Integer, CultureInfo.InvariantCulture);
|
||||
|
||||
if (string.Equals(value.TypeSuffix, "ull", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
EnsureRange(number, BigInteger.Zero, ulong.MaxValue, value);
|
||||
return new ConstantExpression("ulong", ReadLiteral(source, isHex, "UL"));
|
||||
}
|
||||
|
||||
if (string.Equals(value.TypeSuffix, "u", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
EnsureRange(number, BigInteger.Zero, uint.MaxValue, value);
|
||||
return new ConstantExpression("uint", ReadLiteral(source, isHex, "u"));
|
||||
}
|
||||
|
||||
if (number >= int.MinValue && number <= int.MaxValue)
|
||||
{
|
||||
return new ConstantExpression("int", source);
|
||||
}
|
||||
|
||||
if (number >= BigInteger.Zero && number <= uint.MaxValue)
|
||||
{
|
||||
return new ConstantExpression("uint", ReadLiteral(source, isHex, "u"));
|
||||
}
|
||||
|
||||
if (number >= long.MinValue && number <= long.MaxValue)
|
||||
{
|
||||
return new ConstantExpression("long", ReadLiteral(source, isHex, "L"));
|
||||
}
|
||||
|
||||
if (number >= BigInteger.Zero && number <= ulong.MaxValue)
|
||||
{
|
||||
return new ConstantExpression("ulong", ReadLiteral(source, isHex, "UL"));
|
||||
}
|
||||
|
||||
throw new InvalidDataException(
|
||||
$"Enum '{value.Name}' value '{source}' does not fit a C# integral type.");
|
||||
}
|
||||
|
||||
private static void EnsureRange(
|
||||
BigInteger value,
|
||||
BigInteger minimum,
|
||||
BigInteger maximum,
|
||||
GlEnumDefinition definition
|
||||
)
|
||||
{
|
||||
if (value < minimum || value > maximum)
|
||||
{
|
||||
throw new InvalidDataException(
|
||||
$"Enum '{definition.Name}' value '{definition.Value}' is outside its " +
|
||||
"declared numeric suffix range.");
|
||||
}
|
||||
}
|
||||
|
||||
private static string ReadLiteral(
|
||||
string source,
|
||||
bool isHex,
|
||||
string suffix
|
||||
)
|
||||
{
|
||||
return isHex ? $"{source}{suffix}" : $"{source}{suffix}";
|
||||
}
|
||||
|
||||
private static string ReadConstantName(
|
||||
string name
|
||||
)
|
||||
{
|
||||
string value = name.StartsWith("GL_", StringComparison.Ordinal)
|
||||
? name[3..]
|
||||
: name;
|
||||
StringBuilder result = new StringBuilder(value.Length + 1);
|
||||
if (value.Length == 0 || char.IsDigit(value[0]))
|
||||
{
|
||||
result.Append('_');
|
||||
}
|
||||
|
||||
foreach (char character in value)
|
||||
{
|
||||
result.Append(char.IsLetterOrDigit(character) || character == '_'
|
||||
? character
|
||||
: '_');
|
||||
}
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
private static string GenerateContext(
|
||||
IReadOnlyList<GlCommandDefinition> commands,
|
||||
GlEquivalentTypeMapper typeMapper
|
||||
)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(128 * 1024);
|
||||
AppendGeneratedHeader(builder, "Desktop OpenGL core function pointer table");
|
||||
builder.Append("namespace StgSharp.Graphics.OpenGL\n");
|
||||
builder.Append("{\n");
|
||||
builder.Append(" public unsafe partial struct OpenglContext\n");
|
||||
builder.Append(" {\n");
|
||||
foreach (GlCommandDefinition command in commands)
|
||||
{
|
||||
builder.Append(" internal delegate* unmanaged<");
|
||||
foreach (GlParameterDefinition parameter in command.Parameters)
|
||||
{
|
||||
builder.Append(typeMapper.ReadParameterType(parameter));
|
||||
builder.Append(", ");
|
||||
}
|
||||
|
||||
builder.Append(typeMapper.ReadReturnType(command));
|
||||
builder.Append("> ");
|
||||
builder.Append(command.Name);
|
||||
builder.Append(";\n");
|
||||
}
|
||||
|
||||
builder.Append(" }\n");
|
||||
builder.Append("}\n");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static string GenerateFunctions(
|
||||
IReadOnlyList<GlCommandDefinition> commands,
|
||||
GlEquivalentTypeMapper typeMapper
|
||||
)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder(512 * 1024);
|
||||
AppendGeneratedHeader(builder, "Desktop OpenGL core forwarding methods");
|
||||
builder.Append("using System.Runtime.CompilerServices;\n\n");
|
||||
builder.Append("namespace StgSharp.Graphics.OpenGL\n");
|
||||
builder.Append("{\n");
|
||||
builder.Append(" public unsafe partial class OpenGLFunction\n");
|
||||
builder.Append(" {\n");
|
||||
builder.Append("\n private readonly OpenglContext* __context;\n");
|
||||
builder.Append("\n internal OpenGLFunction(OpenglContext* context)\n");
|
||||
builder.Append(" {\n");
|
||||
builder.Append(" __context = context;\n");
|
||||
builder.Append(" }\n");
|
||||
foreach (GlCommandDefinition command in commands)
|
||||
{
|
||||
string returnType = typeMapper.ReadReturnType(command);
|
||||
string methodName = ReadMethodName(command.Name);
|
||||
builder.Append("\n [MethodImpl(MethodImplOptions.AggressiveInlining)]\n");
|
||||
builder.Append(" public ");
|
||||
builder.Append(returnType);
|
||||
builder.Append(' ');
|
||||
builder.Append(methodName);
|
||||
builder.Append('(');
|
||||
for (int index = 0; index < command.Parameters.Count; index++)
|
||||
{
|
||||
if (index != 0)
|
||||
{
|
||||
builder.Append(", ");
|
||||
}
|
||||
|
||||
GlParameterDefinition parameter = command.Parameters[index];
|
||||
builder.Append(typeMapper.ReadParameterType(parameter));
|
||||
builder.Append(' ');
|
||||
builder.Append(EscapeIdentifier(parameter.Name));
|
||||
}
|
||||
|
||||
builder.Append(")\n");
|
||||
builder.Append(" {\n");
|
||||
builder.Append(" ");
|
||||
if (returnType != "void")
|
||||
{
|
||||
builder.Append("return ");
|
||||
}
|
||||
|
||||
builder.Append("__context->");
|
||||
builder.Append(command.Name);
|
||||
builder.Append('(');
|
||||
builder.Append(
|
||||
string.Join(
|
||||
", ",
|
||||
command.Parameters.Select(
|
||||
value => EscapeIdentifier(value.Name))));
|
||||
builder.Append(");\n");
|
||||
builder.Append(" }\n");
|
||||
}
|
||||
|
||||
builder.Append("\n }\n");
|
||||
builder.Append("}\n");
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
private static string ReadMethodName(
|
||||
string commandName
|
||||
)
|
||||
{
|
||||
return commandName.StartsWith("gl", StringComparison.Ordinal) &&
|
||||
commandName.Length > 2
|
||||
? commandName[2..]
|
||||
: commandName;
|
||||
}
|
||||
|
||||
private static string EscapeIdentifier(
|
||||
string value
|
||||
)
|
||||
{
|
||||
return _csharpKeywords.Contains(value) ? $"@{value}" : value;
|
||||
}
|
||||
|
||||
private static void AppendGeneratedHeader(
|
||||
StringBuilder builder,
|
||||
string description
|
||||
)
|
||||
{
|
||||
builder.Append("// <auto-generated>\n");
|
||||
builder.Append("// Generated by StgSharp.GenerateGL.\n");
|
||||
builder.Append("// ");
|
||||
builder.Append(description);
|
||||
builder.Append(".\n");
|
||||
builder.Append("// </auto-generated>\n\n");
|
||||
}
|
||||
|
||||
private sealed record ConstantExpression(
|
||||
string Type,
|
||||
string Literal
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="Program"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
|
||||
namespace StgSharp.GenerateGL
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
|
||||
private static int Main(
|
||||
string[] args
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
return XmlCli.Run(args);
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
return WriteError(exception);
|
||||
}
|
||||
catch (XmlException exception)
|
||||
{
|
||||
return WriteError(exception);
|
||||
}
|
||||
catch (InvalidDataException exception)
|
||||
{
|
||||
return WriteError(exception);
|
||||
}
|
||||
catch (UnauthorizedAccessException exception)
|
||||
{
|
||||
return WriteError(exception);
|
||||
}
|
||||
catch (ArgumentException exception)
|
||||
{
|
||||
return WriteError(exception);
|
||||
}
|
||||
catch (NotSupportedException exception)
|
||||
{
|
||||
return WriteError(exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static int WriteError(
|
||||
Exception exception
|
||||
)
|
||||
{
|
||||
Console.Error.WriteLine($"error: {exception.Message}");
|
||||
return XmlCli.LoadErrorExitCode;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="GlApiDefinition"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StgSharp.GenerateGL.Registry
|
||||
{
|
||||
internal sealed record GlFeatureDefinition(
|
||||
string Name,
|
||||
string Api,
|
||||
string Number,
|
||||
string? Protect,
|
||||
string? Comment,
|
||||
IReadOnlyList<GlRequirementBlock> Requirements,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlExtensionDefinition(
|
||||
string Name,
|
||||
string? SupportedApis,
|
||||
string? Protect,
|
||||
string? Comment,
|
||||
IReadOnlyList<GlRequirementBlock> Requirements,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlRequirementBlock(
|
||||
GlRequirementOperation Operation,
|
||||
string? Api,
|
||||
string? Profile,
|
||||
string? Comment,
|
||||
IReadOnlyList<GlRegistryReference> References,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlRegistryReference(
|
||||
GlRegistryReferenceKind Kind,
|
||||
string Name,
|
||||
string? Comment,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal enum GlRequirementOperation
|
||||
{
|
||||
Require,
|
||||
Remove,
|
||||
}
|
||||
|
||||
internal enum GlRegistryReferenceKind
|
||||
{
|
||||
Type,
|
||||
Enum,
|
||||
Command,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="GlCommandDefinition"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StgSharp.GenerateGL.Registry
|
||||
{
|
||||
internal sealed record GlCommandBlock(
|
||||
string? Namespace,
|
||||
IReadOnlyList<GlCommandDefinition> Commands,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlCommandDefinition(
|
||||
string Name,
|
||||
GlReturnDefinition Return,
|
||||
IReadOnlyList<GlParameterDefinition> Parameters,
|
||||
IReadOnlyList<GlNamedReference> Aliases,
|
||||
IReadOnlyList<GlNamedReference> VectorEquivalents,
|
||||
IReadOnlyList<GlCommandProtocol> Protocols,
|
||||
string? Comment,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlReturnDefinition(
|
||||
string DeclarationText,
|
||||
string? TypeName,
|
||||
string? Group,
|
||||
string? Kind,
|
||||
string? ObjectClass,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlParameterDefinition(
|
||||
string Name,
|
||||
string DeclarationText,
|
||||
string? TypeName,
|
||||
string? Group,
|
||||
string? Kind,
|
||||
string? ObjectClass,
|
||||
string? Length,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlCommandProtocol(
|
||||
string Type,
|
||||
string Opcode,
|
||||
string? Name,
|
||||
string? Comment,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="GlEnumDefinition"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace StgSharp.GenerateGL.Registry
|
||||
{
|
||||
internal sealed record GlEnumDefinition(
|
||||
string Name,
|
||||
string? Value,
|
||||
string? Api,
|
||||
string? TypeSuffix,
|
||||
string? Group,
|
||||
string? Alias,
|
||||
string? Comment,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlEnumBlock(
|
||||
string? Namespace,
|
||||
string? Group,
|
||||
string? Type,
|
||||
string? Start,
|
||||
string? End,
|
||||
string? Vendor,
|
||||
string? Comment,
|
||||
IReadOnlyList<GlEnumDefinition> Enums,
|
||||
IReadOnlyList<GlUnusedEnumRange> UnusedRanges,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlEnumGroup(
|
||||
string Name,
|
||||
string? Comment,
|
||||
IReadOnlyList<GlNamedReference> Members,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
|
||||
internal sealed record GlUnusedEnumRange(
|
||||
string Start,
|
||||
string? End,
|
||||
string? Vendor,
|
||||
string? Comment,
|
||||
GlRegistryElement Element
|
||||
);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user