rubuild file struct 2

This commit is contained in:
Nitload
2024-05-28 20:32:45 +08:00
parent 0cac40255b
commit 5033a6d50b
45 changed files with 886 additions and 618 deletions
@@ -31,6 +31,7 @@
using StgSharp;
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.Graphics.GL;
using StgSharp.Logic;
using StgSharp.Math;
@@ -48,7 +49,7 @@ namespace StgSharp
private ElementBuffer ebo;
private ShaderProgram shader;
private Texture texture;
private TextureGL texture;
private Uniform<float, float, float, float> color;
private Uniform<int> ourTexture;
private Uniform<int> ourTexture2;
@@ -77,16 +78,15 @@ namespace StgSharp
{
SetSizeLimit(800, 800, 800, 800);
FrameSizeCallback =
(IntPtr id, uint width, uint height) => GL.Viewport(0, 0, width, height);
(IntPtr id, uint width, uint height) => glFunc.Viewport(0, 0, width, height);
shader = CreateShaderProgram();
Shader vertex = CreateShaderSegment(ShaderType.Vertex, 1);
Shader fragment = CreateShaderSegment(ShaderType.Fragment, 1);
vertex.Compile(0, File.ReadAllText("Shader\\vertex.vert"));
vertex.Compile(0, Shader.FromCodeFile("Shader\\main.vert"));
vertex.AttachTo(0, shader);
fragment.Compile(0, File.ReadAllText("Shader\\fragment.frag"));
fragment.Compile(0, Shader.FromCodeFile("Shader\\main.frag"));
fragment.AttachTo(0, shader);
shader.Link();
Triangle tri = new Triangle(
@@ -119,35 +119,35 @@ namespace StgSharp
vao.Bind(0);
ebo.SetValue(0, rec.Indices, BufferUsage.STATIC_DRAW);
ebo.SetValue(0, rec.VertexIndices, BufferUsage.StaticDraw);
vbo.WriteMatrixData(0, rec.VertexBuffer, BufferUsage.STATIC_DRAW);
vao.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
vbo.WriteVectorData(0, rec.VertexStream, BufferUsage.StaticDraw);
VertexArray.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
vbo.WriteScalerData(1, texCoord, BufferUsage.STATIC_DRAW);
vao.SetVertexAttribute(2, 2, TypeCode.Single, false, 2 * sizeof(float), 0);
vbo.WriteScalerData(1, texCoord, BufferUsage.StaticDraw);
VertexArray.SetVertexAttribute(2, 2, TypeCode.Single, false, 2 * sizeof(float), 0);
/**/
vbo.Unbind();
vao.BindNull();
VertexArray.BindNull();
/**/
texture.Bind2D(0);
texture.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
texture.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
texture.LoadTexture(0, "Shader\\Image1.png", null);
texture.LoadTexture(0,Image.FromFile( "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);
texture.LoadTexture(1, Image.FromFile( "Shader\\awesomeface.png", null));
shader.Use();
/**/
color = shader.GetUniform<float, float, float, float>("color");
ourTexture = shader.GetUniform<int>("ourTexture");
GL.SetValue(ourTexture, 0);
glFunc.SetUniformValue(ourTexture, 0);
ourTexture2 = shader.GetUniform<int>("ourTexture2");
GL.SetValue(ourTexture2, 1);
glFunc.SetUniformValue(ourTexture2, 1);
/**/
NativeCameraViewTarget(
@@ -158,6 +158,12 @@ namespace StgSharp
NativeCameraViewRange(new Degree(10f), (0, 0), (50f, 50f));
NativeCameraUniform(shader, "camera");
TextureGL.Activate(TextureUnit.Unit0);
texture.Bind2D(0);
TextureGL.Activate(TextureUnit.Unit1);
texture.Bind2D(1);
}
protected override sealed void Main(
@@ -165,26 +171,22 @@ namespace StgSharp
in Dictionary<string, BlueprintPipeline> output
)
{
GL.ClearColor(0.333f, 0.555f, 0.555f, 1.0f);
glFunc.ClearColor(0.333f, 0.555f, 0.555f, 1.0f);
//Console.WriteLine(1);
GL.Clear(MaskBufferBit.COLOR /**/| MaskBufferBit.DEPTH /**/ );
glFunc.Clear(MaskBufferBit.COLOR /**/| MaskBufferBit.DEPTH /**/ );
/**/
vao.Bind(0);
shader.Use();
/**/
/**/
texture.Activate(TextureUnit.Unit0);
texture.Bind2D(0);
texture.Activate(TextureUnit.Unit1);
texture.Bind2D(1);
/**/
/**/
float time = /* CurrentFrameCount, / /**/ 60.0f;
float time = /* CurrentFrameCount, / /**/ 0.003f;
GL.SetValue(color,
glFunc.SetUniformValue(color,
0.5f + MathF.Cos(time),
0.5f + MathF.Sin((time * 0.66667f) + ((2 * Scaler.Pi) / 3)),
0.5f + MathF.Sin((time * 0.33333f) + (Scaler.Pi / 3)),
@@ -196,9 +198,9 @@ namespace StgSharp
//Console.WriteLine(NativeCamera.Projection);
GL.DrawElements(GeometryType.TRIANGLES, 6, TypeCode.UInt32, IntPtr.Zero);
glFunc.DrawElements(GeometryType.TRIANGLES, 6, TypeCode.UInt32, IntPtr.Zero);
vao.BindNull();
VertexArray.BindNull();
/**/
BlueprintPipeline.SkipAll(output);