generate glenum, link glenum, add source gen for text regex

This commit is contained in:
Youmu Liu
2026-08-31 18:12:44 +08:00
parent 667b8d8e43
commit e52d0ac6f3
54 changed files with 4555 additions and 1596 deletions
@@ -52,8 +52,6 @@ namespace StgSharp
public Rectangle ButtonBounding { get; private set; }
public TextureProvider ButtonTextureProvider { get; private set; }
// render a controlling item
public void ButtonMain(
IEnumerable<PlainGeometryMesh> items
@@ -61,7 +59,7 @@ namespace StgSharp
{
// Console.WriteLine("Render Button Itself");
GL.BindFrameBuffer(FrameBufferTarget.All, GlHandle.Zero); /*GL.Assert(true);/**/
GL.BindFrameBuffer(FrameBufferTarget.FrameBuffer, GlHandle.Zero); /*GL.Assert(true);/**/
GL.ClearColor(0.4f, TimePassed % 1.0f, 0f, 1.0f); /*GL.Assert(true);/**/
GL.Clear(MaskBufferBit.COLOR /**/ | MaskBufferBit.DEPTH/**/); /*GL.Assert(true);/**/
@@ -69,7 +67,7 @@ namespace StgSharp
foreach (PlainGeometryMesh mesh in items)
{
GL.ActiveTextureUnit((uint)TextureUnit.Unit1);
GL.ActiveTextureUnit((uint)TextureUnit.Texture1);
GL.BindTexture(glConst.TEXTURE_2D, f_t[0]);
GL.TextureImage2d(Texture2DTarget.Texture2D, 0, glConst.RGBA8,
mesh.TextureImage.Width, mesh.TextureImage.Height,
@@ -98,11 +96,11 @@ namespace StgSharp
// Console.Clear();
buffer.UpdateAllParticles();
// Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.All));
// Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.FrameBuffer));
GL.BindFrameBuffer(FrameBufferTarget.All, fbo[0]); //GL.Assert(true);
GL.BindFrameBuffer(FrameBufferTarget.FrameBuffer, fbo[0]); //GL.Assert(true);
GL.BindVertexArray(vao[0]); //GL.Assert(true);
GL.ActiveTextureUnit((uint)TextureUnit.Unit0);
GL.ActiveTextureUnit((uint)TextureUnit.Texture0);
GL.BindTexture(glConst.TEXTURE_2D, t[0]); //GL.Assert(false);
GL.Viewport(0, 0, Width, Height);
@@ -114,13 +112,13 @@ namespace StgSharp
/**/
// GL.Assert(false);
// Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.All));
// Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.FrameBuffer));
GL.ClearColor((0.6f + TimePassed) % 1.0f, 0.1f, 0.3f, 1);
// GL.Assert( false );
// Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.All));
// Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.FrameBuffer));
GL.Clear(MaskBufferBit.COLOR /**/ | MaskBufferBit.DEPTH/**/);
@@ -149,7 +147,6 @@ namespace StgSharp
if (i.Size != (Width, Height))
{
i = new Image<Rgba8>(Width, Height);
ButtonTextureProvider.Image = i;
}
// GL.ClearError();
@@ -167,7 +164,7 @@ namespace StgSharp
// GL.Assert(true);
// i.Bytes.Fill(24);
GL.BindFrameBuffer(FrameBufferTarget.All, GlHandle.Zero);
GL.BindFrameBuffer(FrameBufferTarget.FrameBuffer, GlHandle.Zero);
// GL.Assert(true);
/**/
@@ -177,21 +174,11 @@ namespace StgSharp
{
GL.ClearError();
// GL.BindFrameBuffer(FrameBufferTarget.All, GlHandle.Zero);
// GL.BindFrameBuffer(FrameBufferTarget.FrameBuffer, GlHandle.Zero);
GL.ClearColor(0.5f, 0.2f, 0.3f, 1.0f);
GL.Assert(false);
}
/*
public void RenderButton(
ButtonStatus status,
float statusBegin,
in TextureProvider provider
)
{
provider.UpdateFromImage(i);
}
/**/
internal static Vec3 DefaultRotation(
TimeSpanProvider provider,
out float rotation
@@ -199,7 +186,7 @@ namespace StgSharp
{
rotation = 1.0f / 60;
float angle = (float)provider.CurrentSecond * 2;
return (new Vec3(MathF.Cos(angle), MathF.Sin(angle),
return (new Vec3<float>(MathF.Cos(angle), MathF.Sin(angle),
0)) * rotation;
}
@@ -214,8 +201,8 @@ namespace StgSharp
GL.DeleteBuffers(f_ebo.Handles);
GL.DeleteVertexArrays(vao.Handles);
GL.DeleteVertexArrays(f_vao.Handles);
GL.DeleteFramebuffers(fbo.Handles);
GL.DeleteRenderbuffers(rbo.Handles);
GL.DeleteFrameBuffers(fbo.Handles);
GL.DeleteRenderBuffers(rbo.Handles);
GL.DeleteTextures(t.Handles);
GL.DeleteTextures(f_t.Handles);
}
@@ -234,7 +221,7 @@ namespace StgSharp
float at = MathF.Abs(t - 5.0f);
ParticleOnPlain p = new ParticleOnPlain(buffer);
((IInstancing)p).Coord = new Vec3(
((IInstancing)p).Coord = new Vec3<float>(
(((-5) + i) * 0.2f) + 0.1f, (((-5) + t) * 0.2f) + 0.1f, 0);
((IInstancing)p).Scale =
float.Min(i, t) * 0.15f;
@@ -249,8 +236,8 @@ namespace StgSharp
s = new ShaderProgram(GL.CreateProgram());
frameMainShader = new ShaderProgram(GL.CreateProgram());
Shader pvs = CreateShaderSet(ShaderType.Vertex, 2);
Shader pfs = CreateShaderSet(ShaderType.Fragment, 2);
Shader pvs = CreateShaderSet(ShaderType.VertexShader, 2);
Shader pfs = CreateShaderSet(ShaderType.FragmentShader, 2);
// GL.Assert(true);
CompileShaderFromFile(pvs[0], Path.Combine("Shader", "particle.vert"));
@@ -288,12 +275,12 @@ namespace StgSharp
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,
GL.BufferData(BufferType.ElementArrayBuffer, rec.VertexIndices,
BufferUsage.StaticDraw);
GL.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
GL.VertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
GL.BindBuffer(BufferType.ArrayBuffer, vbo[1]);
GL.SetBufferData<Vec4>(BufferType.ArrayBuffer, buffer.CoordAndRotationSpan,
GL.SetBufferData<Vec4<float>>(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),
@@ -334,12 +321,12 @@ namespace StgSharp
GL.GenFrameBuffers(frameBufferHandles);
fbo = new FrameBuffer(frameBufferHandles);
rbo = new RenderBuffer(GL.GenRenderBuffer(1));
GL.BindFrameBuffer(FrameBufferTarget.All, fbo[0]);
GL.BindFrameBuffer(FrameBufferTarget.FrameBuffer, fbo[0]);
GL.BindRenderBuffer(rbo[0]);
// GL.Assert(true);
t = new TextureGL(GL.GenTextures(1));
GL.ActiveTextureUnit((uint)TextureUnit.Unit0);
GL.ActiveTextureUnit((uint)TextureUnit.Texture0);
GL.BindTexture(glConst.TEXTURE_2D, t[0]);
GL.TextureImage2d(Texture2DTarget.Texture2D, 0, glConst.RGBA8, Width, Height,
FrameBufferChannel.RGBA, PixelChannelLayout.UByte);
@@ -353,15 +340,15 @@ namespace StgSharp
(int)TextureFilter.Linear);
// GL.Assert(true);
GL.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
GL.FrameBufferTexture2d(FrameBufferTarget.FrameBuffer, glAttachment.Color(0),
Texture2DTarget.Texture2D, t[0], 0);
GL.SetRenderBufferStorage(RenderBufferInternalFormat.Depth24_Stencil8, this.Size);
GL.CombineFrameBufferRenderBuffer(FrameBufferAttachment.DepthAndStencil, rbo[0]);
GL.CombineFrameBufferRenderBuffer(FrameBufferAttachment.DepthStencilAttachment, rbo[0]);
Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.All));
Console.WriteLine(GL.CheckFrameBufferStatus(FrameBufferTarget.FrameBuffer));
GL.BindFrameBuffer(FrameBufferTarget.All, GlHandle.Zero);
GL.BindFrameBuffer(FrameBufferTarget.FrameBuffer, GlHandle.Zero);
// GL.Assert(true);
i = new Image<Rgba8>(this.Size);
@@ -377,9 +364,6 @@ namespace StgSharp
};
ButtonBounding = new Rectangle(-0.9f, 0.9f, 0.9f, 0.9f, 0.9f, -0.9f, -0.9f, -0.9f);
// GL.Assert(true);
ButtonTextureProvider = new TextureProvider(i, buttonTextureCoordArray);
f_vao = new VertexArray(GL.GenVertexArrays(1));
f_vbo = new VertexBuffer(GL.GenBuffers(2));
f_ebo = new ElementBuffer(GL.GenBuffers(1));
@@ -406,7 +390,7 @@ namespace StgSharp
// GL.Assert(true);
f_t = new TextureGL(GL.GenTextures(1));
GL.ActiveTextureUnit((uint)TextureUnit.Unit1);
GL.ActiveTextureUnit((uint)TextureUnit.Texture1);
GL.BindTexture(glConst.TEXTURE_2D, f_t[0]);
GL.TextureParameter(glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_S,
(int)TextureWrap.Repeat);
@@ -460,7 +444,7 @@ namespace StgSharp
{
GlHandle[] handles = new GlHandle[count];
for (int index = 0; index < handles.Length; index++) {
handles[index] = GL.CreateShader((uint)type);
handles[index] = GL.CreateShader(type);
}
return new Shader(handles, type);
}
+1 -1
View File
@@ -22,7 +22,7 @@ namespace StgSharp
{
World.GlobalSetting.VSyncActivated = false;
ViewPort vp = new ViewPort(800, 600, "Hello StgSharp!", IntPtr.Zero);
ViewSurface vp = new ViewSurface(800, 600, "Hello StgSharp!", IntPtr.Zero);
// throw new NotImplementedException();
/*