daily update on 20240104 by nitload youmu, double threading not work

This commit is contained in:
Nitload
2024-01-04 08:58:12 +08:00
parent 14eaab455f
commit 2767c91293
138 changed files with 9692 additions and 11011 deletions
+172 -194
View File
@@ -13,182 +13,175 @@ using System.Text;
namespace StgSharp
{
// public class StgSharpDemoForm : Form
// {
// Uniform<float, float, float> color;
// ElementBuffer ebo;
// Uniform<int> ourTexture;
// Uniform<int> ourTexture2;
// Shader shader;
// Texture texture;
// VertexArray vao;
// VertexBuffer vbo;
//
// public static unsafe void ProcessInput(IntPtr windowPtr)
// {
// if (InternalIO.glfw.GetKey(windowPtr, (int)Operation.Key.ESCAPE)
// == KeyStatus.PRESS)
// {
// InternalIO.glfw.SetWindowShouldClose(windowPtr, 1);
// }
// }
//
// public override void Deinit(object[] args, IglFunc GL)
// {
// /**/
// vao.Dispose();
// vbo.Dispose();
// ebo.Dispose();
// /**/
//
// InternalIO.glfw.Terminate();
// }
//
// public unsafe void FormSizeCallback(IntPtr window, int width, int height)
// {
// GL.Viewport(0, 0, width, height);
// }
//
// public override void Init(object[] args)
// {
//
// InternalIO.InternalWriteLog("\n\n\n", "Program start", LogType.Info);
//
// Platform.InitGL(4, 6);
//
// InitForm(800, 600, "Hello, STG#!", IntPtr.Zero, null);
// MakeAsCurrentContext();
// SetSizeLimit(800, 600, 800, 600);
// GL.SetFrameBufferSizeCallback(windowID, FormSizeCallback);
//
// this.LoadGLapi(null);
//
// shader = CreateShader();
// shader.CompileVertexShader(
// File.ReadAllText("Shader\\vertex.vert")
// );
// shader.CompileFragmentShader(
// File.ReadAllText("Shader\\fragment.frag")
// );
// shader.Link();
//
// Triangle tri = new Triangle(
// -0.5f, -0.3f, 0.0f,
// 0.5f, -0.5f, 0.0f,
// 0.0f, 0.5f, 0.0f
// );
//
// Rectangle rec = new Rectangle(
// -0.5f, 0.5f, 0.0f,
// 0.5f, 0.5f, 0.0f,
// 0.5f, -0.5f, 0.0f,
// -0.5f, -0.5f, 0.0f
// );
//
// Polygon5 polygon = new Polygon5(
// -0.4f, 0.5f, 0.0f,
// 0.5f, 0.5f, 0.0f,
// 0.6f, -0.5f, 0.0f,
// 0, -1, 0,
// -0.7f, -0.5f, 0.0f
// );
//
//
// vao = new VertexArray(1);
// vbo = new VertexBuffer(2);
// ebo = new ElementBuffer(1);
// texture = CreateTexture(2);
//
//
// float[] texCoord = {
// 0.0f, 0.0f,
// 1.0f, 0.0f,
// 1.0f, 1.0f,
// 0.0f, 1.0f };
//
// GL.BindVertexArray(vao[0]);
//
// ebo.SetValue(0, rec.Indices, BufferUsage.STATIC_DRAW);
//
// vbo.SetValue(0, rec.VertexBuffer, BufferUsage.STATIC_DRAW);
// GL.SetVertexAttribute(0, 3, typeof(float), false, 4 * sizeof(float), 0);
//
// vbo.SetValueArray(1, texCoord, BufferUsage.STATIC_DRAW);
// GL.SetVertexAttribute(2, 2, typeof(float), false, 2 * sizeof(float), 0);
//
// /**/
// GL.BindBuffer(BufferType.ARRAY_BUFFER, 0);
// vao.BindNull();
// /**/
//
// texture.Bind2D(0);
// texture.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
// texture.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
// texture.LoadTexture(0, "Shader\\Image1.png", null);
//
// texture.Bind2D(1);
// texture.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
// texture.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
// texture.LoadTexture(1, "Shader\\awesomeface.png", null);
//
//
// //color = GetUniform<float, float, float>(shader, "color");
//
// shader.Use();
// /**/
// //ourTexture = GetUniform<int>(shader, "ourTexture");
// GL.SetValue(ourTexture, 0);
// //ourTexture2 = GetUniform<int>(shader, "ourTexture2");
// GL.SetValue(ourTexture2, 1);
// /**/
//
// }
//
// public override void OnRenderFrame(object[] args, IglFunc GL)
// {
// }
//
// public override void OnUpdateFrame(object[] args, IglFunc GL)
// {
//
// ProcessInput(windowID);
//
// GL.ClearColor(0.333f, 0.555f, 0.555f, 1.0f);
// //GL.api.Clear(GLconst.COLOR_BUFFER_BIT);
// GL.Clear(MaskBufferBit.COLOR);
//
// vao.Bind(0);
// shader.Use();
//
// /**/
// texture.Activate(TextureUnit.Unit0);
// texture.Bind2D(0);
// texture.Activate(TextureUnit.Unit1);
// texture.Bind2D(1);
// /**/
//
// float time = (float)InternalIO.glfw.GetTime();
// GL.SetValue(color,
// 0.5f + MathF.Sin(time),
// 0.5f + MathF.Sin(time/* + 0.667f * 3.14f/**/),
// 0.5f + MathF.Sin(time/* - 0.667f * 3.14f/**/)
// );
//
// vao.Bind(0);
//
//
// AlignFrame(this, () =>
// {
// GL.DrawElements(GepmetryType.TRIANGLES, 6, typeof(uint), IntPtr.Zero);
//
// vao.BindNull();
//
// InternalIO.glfw.SwapBuffers(windowID);
// InternalIO.glfw.PollEvents();
// });
//
// }
// }
public class StgSharpDemoForm : Form
{
Uniform<float, float, float> color;
ElementBuffer ebo;
Uniform<int> ourTexture;
Uniform<int> ourTexture2;
Shader shader;
Texture texture;
VertexArray vao;
VertexBuffer vbo;
public static unsafe void ProcessInput(IntPtr windowPtr)
{
if (InternalIO.glfw.GetKey(windowPtr, (int)Operation.Key.ESCAPE)
== KeyStatus.PRESS)
{
InternalIO.glfw.SetWindowShouldClose(windowPtr, 1);
}
}
public override void Deinit(object[] args)
{
/**/
vao.Dispose();
vbo.Dispose();
ebo.Dispose();
/**/
InternalIO.glfw.Terminate();
}
public unsafe void FormSizeCallback(IntPtr window, uint width, uint height)
{
gl.Viewport(0, 0, width, height);
}
public override void Init(object[] args)
{
InternalIO.InternalWriteLog("\n\n\n", "Program start", LogType.Info);
Platform.InitGL(4, 6);
SetRenderThreads(1);
SetMetadata(800, 600, "Hello, STG#!", IntPtr.Zero, null);
MakeAsCurrentContext();
SetSizeLimit(800, 600, 800, 600);
gl.SetFrameBufferSizeCallback(windowID, FormSizeCallback);
this.LoadGLapi(null);
shader = CreateShader();
shader.CompileVertexShader(
File.ReadAllText("Shader\\vertex.vert")
);
shader.CompileFragmentShader(
File.ReadAllText("Shader\\fragment.frag")
);
shader.Link();
Triangle tri = new Triangle(
-0.5f, -0.3f, 0.0f,
0.5f, -0.5f, 0.0f,
0.0f, 0.5f, 0.0f
);
Rectangle rec = new Rectangle(
-0.5f, 0.5f, 0.0f,
0.5f, 0.5f, 0.0f,
0.5f, -0.5f, 0.0f,
-0.5f, -0.5f, 0.0f
);
Polygon5 polygon = new Polygon5(
-0.4f, 0.5f, 0.0f,
0.5f, 0.5f, 0.0f,
0.6f, -0.5f, 0.0f,
0, -1, 0,
-0.7f, -0.5f, 0.0f
);
vao = CreateVertexArray(1);
vbo = CreateVertexBuffer(2);
ebo = CreateElementBuffer(1);
texture = CreateTexture(2);
float[] texCoord = {
0.0f, 0.0f,
1.0f, 0.0f,
1.0f, 1.0f,
0.0f, 1.0f };
gl.BindVertexArray(vao[0]);
ebo.SetValue(0, rec.Indices, BufferUsage.STATIC_DRAW);
vbo.SetValue(0, rec.VertexBuffer, BufferUsage.STATIC_DRAW);
gl.SetVertexAttribute(0, 3, typeof(float), false, 4 * sizeof(float), 0);
vbo.SetValueArray(1, texCoord, BufferUsage.STATIC_DRAW);
gl.SetVertexAttribute(2, 2, typeof(float), false, 2 * sizeof(float), 0);
/**/
gl.BindBuffer(BufferType.ARRAY_BUFFER, 0);
vao.BindNull();
/**/
texture.Bind2D(0);
texture.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
texture.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
texture.LoadTexture(0, "Shader\\Image1.png", null);
texture.Bind2D(1);
texture.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
texture.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
texture.LoadTexture(1, "Shader\\awesomeface.png", null);
//color = GetUniform<float, float, float>(shader, "color");
shader.Use();
/**/
color = shader.GetUniform<float, float, float>("color");
ourTexture = shader.GetUniform<int>("ourTexture");
gl.SetValue(ourTexture, 0);
ourTexture2 = shader.GetUniform<int>("ourTexture2");
gl.SetValue(ourTexture2, 1);
/**/
}
public override void Main(params object[] args)
{
ProcessInput(windowID);
gl.ClearColor(0.333f, 0.555f, 0.555f, 1.0f);
//GL.api.Clear(GLconst.COLOR_BUFFER_BIT);
gl.Clear(MaskBufferBit.COLOR);
vao.Bind(0);
shader.Use();
/**/
texture.Activate(TextureUnit.Unit0);
texture.Bind2D(0);
texture.Activate(TextureUnit.Unit1);
texture.Bind2D(1);
/**/
float time = (float)InternalIO.glfw.GetTime();
gl.SetValue(color,
0.5f + MathF.Sin(time),
0.5f + MathF.Sin(time/* + 0.667f * 3.14f/**/),
0.5f + MathF.Sin(time/* - 0.667f * 3.14f/**/)
);
vao.Bind(0);
gl.DrawElements(GepmetryType.TRIANGLES, 6, typeof(uint), IntPtr.Zero);
vao.BindNull();
InternalIO.glfw.SwapBuffers(windowID);
InternalIO.glfw.PollEvents();
}
}
internal static class Program
{
@@ -197,24 +190,9 @@ namespace StgSharp
{
try
{
DynamicArrayList<int> list = new DynamicArrayList<int>();
for (int i = 0; i < 100; i++)
{
list.Add(i + 1);
}
list.ShowStructure();
for (int i = 0; i < 100; i++)
{
Console.WriteLine(list[i]);
}
for (int i = 99; i >= 0; i--)
{
Console.WriteLine(list.Length);
list.RemoveAt(i);
}
Console.WriteLine(list.Length);
StgSharpDemoForm demoForm = new StgSharpDemoForm();
demoForm.Init();
demoForm.Show();
}
catch (Exception ex)
{