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
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large Load Diff
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace StgSharp
{
internal class MainForm : Form
internal class MainForm : ViewModel
{
}
}
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("OEM")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+70890e3e339064993a7c905683c70a3ec5bd47f4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0cac40255bd414b81f65e12c37cd72a7adb12bf0")]
[assembly: System.Reflection.AssemblyProductAttribute("OEM")]
[assembly: System.Reflection.AssemblyTitleAttribute("OEM")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -0,0 +1,13 @@
#version 430 core
in vec3 texCoord;
out vec4 fragColor;
uniform sampler2D tex;
void main()
{
fragColor = texture(tex, texCoord.xy);
//fragColor = vec4(0.0f,0.0f,0.0f,0.0f);
}
@@ -0,0 +1,13 @@
#version 330 core
layout(location = 0)in vec3 coord;
layout(location = 1)in vec3 tCoord;
out vec3 texCoord;
void main()
{
gl_Position = vec4(coord.xyz,1.0f);
texCoord = tCoord;
}
@@ -0,0 +1,17 @@
#version 330 core
in vec2 TexCoord;
out vec4 FragColor;
uniform vec4 color;
uniform sampler2D ourTexture;
uniform sampler2D ourTexture2;
void main()
{
vec4 tex1 = texture(ourTexture, TexCoord);
vec4 tex2 = texture(ourTexture2,TexCoord);
FragColor = mix(tex1 * vec4( color.xyz, 1.0), tex2, 0.2) /* *vec4( TexColor,1.0) /**/;
}
@@ -0,0 +1,22 @@
#version 330 core
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec3 aColor;
layout(location = 2) in vec2 aTextCoord;
out vec2 TexCoord;
uniform mat4x4 camera;
void main()
{
TexCoord = aTextCoord;
vec4 temp = vec4(aPos.xyz,1.0);
gl_Position = /**/ camera * /**/ temp;
}
//struct
@@ -31,7 +31,9 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
@@ -40,7 +42,28 @@ namespace StgSharp
public static unsafe partial class StgSharp
{
static byte[] _currentHash;
private static bool _inited;
internal const int ssdSegmentLength = 16;
public static byte[] CurrentAssemblyHash
{
get
{
if (_currentHash == null)
{
string route = Assembly.GetExecutingAssembly().Location;
string time = DateTime.UtcNow.ToString();
using (SHA256 sh = SHA256.Create())
{
byte[] bytes = Encoding.UTF8.GetBytes(route);
_currentHash = sh.ComputeHash(bytes);
}
}
return _currentHash;
}
}
/// <summary>
/// Init an instance of OpenGL program,
@@ -76,5 +99,5 @@ namespace StgSharp
}
}
}//------------------------end of class------------------------//
}
+27 -1
View File
@@ -64,6 +64,8 @@ namespace StgSharp
VK
}
public static partial class StgSharp
{
@@ -83,6 +85,29 @@ namespace StgSharp
mainTimeProvider = new StgSharpTime();
MainTimeProvider.StartProvidingTime();
InternalIO.glfwInit();
InternalIO.InternalAppendLog("\n\n\n");
InternalIO.InternalWriteLog(
$"Program {Assembly.GetEntryAssembly()!.FullName} Started.",
LogType.Info);
}
public static void LogError(Exception ex)
{
InternalIO.InternalWriteLog(ex.Message, LogType.Error);
}
public static void LogWarning(string log)
{
InternalIO.InternalWriteLog(log, LogType.Warning);
}
public static void LogWarning(Exception notVerySeriesException)
{
InternalIO.InternalWriteLog(notVerySeriesException.Message, LogType.Warning);
}
public static void LogInfo(string log)
{
InternalIO.InternalWriteLog(log, LogType.Info);
}
public static void Mark(bool needConsole)
@@ -97,6 +122,7 @@ namespace StgSharp
public static void Terminate()
{
MainTimeProvider.Terminate();
InternalIO.glfwTerminate();
}
public static void Track(
@@ -129,7 +155,7 @@ namespace StgSharp
}
/// <summary>
/// Write a log message to log file, and mark the level of this message.
/// Write a log message to log file, and mark the _level of this message.
/// </summary>
/// <param name="message">A string contains information of how current evironment runs.</param>
/// <param name="logType">The severity of current message.</param>
@@ -28,7 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharpDebug.Logic;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
@@ -74,17 +74,17 @@ namespace StgSharp.Geometries
mutex = new Mutex();
}
List<IInstancing> IInstancingBuffer.InstanceList
public List<IInstancing> InstanceList
{
get => instanceList;
}
List<vec4d> IInstancingBuffer.CoordAndRotationList
public List<vec4d> CoordAndRotationList
{
get => coordList;
}
List<float> IInstancingBuffer.ScalingList
public List<float> ScalingList
{
get => scalingList;
}
+1 -1
View File
@@ -39,7 +39,7 @@ using System.Text;
namespace StgSharp.Graphics.GL
{
/// <summary>
/// A collection of handle to Element Buffer Object in OpenGL.
/// A collection of handle to Element Buffer Object in OpenglFunc.
/// Each <see langword="uint"/> value indexed from instance of this class this
/// is the only handle to one Element Buffer Object.
/// </summary>
@@ -73,7 +73,7 @@ namespace StgSharp.Graphics.GL
if (proc == IntPtr.Zero)
{
#if DEBUG
Console.WriteLine("Cannot load GL.");
Console.WriteLine("Cannot load glFunc.");
#endif
throw new Exception("Cannot load gl");
}
@@ -18,15 +18,15 @@ namespace StgSharp.Graphics.ShaderEdit
{
internal Dictionary<glSHandle, ShaderStructMember> uniformPair;
public ShaderStruct(params (glSHandle, ShaderStructMember)[] UniformPais)
public ShaderStruct(params (glSHandle, ShaderStructMember)[] uniformPairs)
{
uniformPair = new Dictionary<glSHandle, ShaderStructMember>();
if (UniformPais.Length == 0)
if (uniformPairs.Length == 0)
{
return;
}
foreach (var item in UniformPais)
foreach (var item in uniformPairs)
{
uniformPair.Add(item.Item1,item.Item2);
}
@@ -9,19 +9,6 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp
{
internal static partial class InternalIO
{
[DllImport(SSC_libName, EntryPoint = "normalize",
CallingConvention = CallingConvention.Cdecl)]
internal static extern unsafe void Normalize(M128* source, M128* target);
}
}
namespace StgSharp.Math
{
public static partial class Linear
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+70890e3e339064993a7c905683c70a3ec5bd47f4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0cac40255bd414b81f65e12c37cd72a7adb12bf0")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
+13
View File
@@ -0,0 +1,13 @@
#version 430 core
in vec3 texCoord;
out vec4 fragColor;
uniform sampler2D tex;
void main()
{
fragColor = texture(tex, texCoord.xy);
//fragColor = vec4(0.0f,0.0f,0.0f,0.0f);
}
+13
View File
@@ -0,0 +1,13 @@
#version 330 core
layout(location = 0)in vec3 coord;
layout(location = 1)in vec3 tCoord;
out vec3 texCoord;
void main()
{
gl_Position = vec4(coord.xyz,1.0f);
texCoord = tCoord;
}
+17
View File
@@ -0,0 +1,17 @@
#version 330 core
in vec2 TexCoord;
out vec4 FragColor;
uniform vec4 color;
uniform sampler2D ourTexture;
uniform sampler2D ourTexture2;
void main()
{
vec4 tex1 = texture(ourTexture, TexCoord);
vec4 tex2 = texture(ourTexture2,TexCoord);
FragColor = mix(tex1 * vec4( color.xyz, 1.0), tex2, 0.2) /* *vec4( TexColor,1.0) /**/;
}
+22
View File
@@ -0,0 +1,22 @@
#version 330 core
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec3 aColor;
layout(location = 2) in vec2 aTextCoord;
out vec2 TexCoord;
uniform mat4x4 camera;
void main()
{
TexCoord = aTextCoord;
vec4 temp = vec4(aPos.xyz,1.0);
gl_Position = /**/ camera * /**/ temp;
}
//struct
+10 -4
View File
@@ -98,21 +98,27 @@
<None Update="Shader\awesomeface.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\fragment.frag">
<None Update="Shader\fbo.frag">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\fbo.vert">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\Image1.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\main.frag">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\main.vert">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\particle.vert">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\particle.frag">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Shader\vertex.vert">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
+157
View File
@@ -0,0 +1,157 @@
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.Graphics.GL;
using StgSharp.Logic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp
{
public class fboFrame : glRenderStream
{
public fboFrame(RenderStreamConstructArgs args):base(args)
{
}
protected override string[] InputPortsName
=>
[
"TextureInput"
];
protected override string[] OutputPortsName
=>
[
"Output"
];
protected override void Deinit()
{
throw new NotImplementedException();
}
ShaderProgram s;
TextureGL t;
VertexBuffer vbo;
VertexArray vao;
ElementBuffer ebo;
internal TimeSpanProvider spanProvider;
protected override void Init()
{
//spanProvider = new TimeSpanProvider(1 / 60.00f, TimeSpanProvider.DefaultProvider);
SetSizeLimit(800,800,800,800);
FrameSizeCallback = new FrameBufferSizeHandler(
(window, width,height) => {
glFunc.Viewport(0, 0, width, height);
});
vbo = CreateVertexBuffer(2);
vao = CreateVertexArray(1);
ebo = CreateElementBuffer(1);
Rectangle rec = new Rectangle(
-0.9f, 0.9f, 0,
0.9f, 0.9f, 0,
0.9f, -0.9f, 0,
-0.9f, -0.9f, 0
);
/*
Rectangle tex = new Rectangle(
-0.8f, 0.8f, 0,
0.8f, 0.8f, 0,
0.8f, -0.8f, 0,
-0.8f, -0.8f, 0
);
/**/
/**/
Rectangle tex = new Rectangle(
0f, 1f, 0,
1f, 1f, 0,
1f, 0f, 0,
0f, 0f, 0
);
/**/
s = CreateShaderProgram();
Shader vert = CreateShaderSegment(ShaderType.Vertex, 1);
Shader frag = CreateShaderSegment(ShaderType.Fragment,1);
vert.Compile(0, Shader.FromCodeFile("Shader\\fbo.vert"));
frag.Compile(0, Shader.FromCodeFile("Shader\\fbo.frag"));
vert.AttachTo(0,s);
frag.AttachTo(0,s);
s.Link();
vao.Bind(0);
ebo.Bind(0);
ebo.SetValue(0,rec.VertexIndices,BufferUsage.StaticDraw);
vbo.Bind(0);
vbo.WriteVectorData(0,rec.VertexStream, BufferUsage.StaticDraw);
VertexArray.SetVertexAttribute(0,3,TypeCode.Single,false,4*sizeof(float),0);
vbo.Bind(1);
vbo.WriteVectorData(1, tex.VertexStream, BufferUsage.StaticDraw);
VertexArray.SetVertexAttribute(1, 3, TypeCode.Single, false,4*sizeof(float),0);
t = CreateTexture(1);
t.Bind2D(0);
t.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
t.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
TextureGL.Activate(TextureUnit.Unit0);
texUniform = s.GetUniform<int>("tex");
glFunc.SetUniformValue(texUniform, 0);
}
Uniform<int> texUniform;
protected override void Main(
in Dictionary<string, BlueprintPipeline> input,
in Dictionary<string, BlueprintPipeline> output)
{
TexturePipeline p = input["TextureInput"].Args as TexturePipeline;
Image i = (p??throw new Exception("Pipeline has null value")).Value;
FrameBuffer.BindNull();
glFunc.ClearColor(0.4f, 0.1f, 0f, 1.0f);
glFunc.Clear(MaskBufferBit.COLOR | MaskBufferBit.DEPTH);
s.Use();
vao.Bind(0);
t.LoadTexture(0, i);
glFunc.DrawElements(GeometryType.TRIANGLES,6,TypeCode.UInt32,IntPtr.Zero);
//glFunc.DrawElements(GeometryType.LINES, 6, TypeCode.UInt32, IntPtr.Zero);
BlueprintPipeline.SkipAll(output);
PollEvents();
SwapBuffers();
}
protected override void ProcessInput()
{
}
}
}
@@ -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);
+85 -34
View File
@@ -1,21 +1,23 @@
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.Graphics.GL;
using StgSharp.Logic;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace StgSharp
{
public class ParticleStream : glRenderStream
{
public ParticleStream(RenderStreamConstructArgs args) : base(args)
public ParticleStream(RenderStreamConstructArgs args, bool isSharing) : base(args, isSharing)
{
}
protected override string[] InputPortsName => ["input_1"];
@@ -33,7 +35,9 @@ namespace StgSharp
VertexArray vao;
ElementBuffer ebo;
internal TimeSpanProvider spanProvider;
FrameBuffer fbo;
internal static vec3d DefaultRotation(TimeSpanProvider provider, out float rotation)
{
@@ -48,8 +52,6 @@ namespace StgSharp
protected override void Init()
{
spanProvider = new TimeSpanProvider(1 / 60.00f, TimeSpanProvider.DefaultProvider);
buffer = new PlainInstancingBuffer<ParticleOnPlain>();
for (int i = 0; i < 10; i++)
{
@@ -59,12 +61,12 @@ namespace StgSharp
float at = Scaler.Abs(t - 5.0f);
ParticleOnPlain p = new ParticleOnPlain(buffer);
((IInstancing<ParticleOnPlain>)p).Coord = new vec3d(
((IInstancing)p).Coord = new vec3d(
(-5 + i) * 0.2f + 0.1f, (-5 + t) * 0.2f + 0.1f, 0);
((IInstancing<ParticleOnPlain>)p).Scale =
Scaler.MinOf(ai, at) * 0.4f + 0.1f;
((IInstancing<ParticleOnPlain>)p).Motion = new GeometryMotion(
true,spanProvider,
((IInstancing)p).Scale =
Scaler.MinOf(i, t) * 0.15f;
((IInstancing)p).Motion = new GeometryMotion(
true, this.timeProvider,
DefaultRotation)
;
}
@@ -73,7 +75,7 @@ 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);
s = CreateShaderProgram();
Shader pvs = CreateShaderSegment(ShaderType.Vertex ,1);
@@ -99,24 +101,26 @@ namespace StgSharp
);
vao.Bind(0);
vbo.WriteMatrixData(0, rec.vertexMat, BufferUsage.STATIC_DRAW);
ebo.SetValue(0, rec.Indices, BufferUsage.STATIC_DRAW);
vao.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float),0);
vbo.WriteVectorData(0, rec.VertexStream, BufferUsage.StaticDraw);
ebo.SetValue(0, rec.VertexIndices, BufferUsage.StaticDraw);
VertexArray.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float),0);
vbo.WriteVectorData(1, buffer.CoordSpan,BufferUsage.STREAM_DRAW);
vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
vao.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
vbo.WriteVectorData<vec4d>(1, buffer.CoordAndRotationSpan,BufferUsage.StreamDraw);
VertexArray.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
VertexArray.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
GL.VertexAttributeDivisor(1, 1);
GL.VertexAttributeDivisor(2, 1);
glFunc.VertexAttributeDivisor(1, 1);
glFunc.VertexAttributeDivisor(2, 1);
vbo.WriteScalerData<float>(2, buffer.ScalingSpan, BufferUsage.StaticDraw);
VertexArray.SetVertexAttribute(3,1,TypeCode.Single,false,sizeof(float),0);
glFunc.VertexAttributeDivisor(3, 1);
vbo.WriteScalerData(2, buffer.ScalingSpan, BufferUsage.STATIC_DRAW);
vao.SetVertexAttribute(3,1,TypeCode.Single,false,sizeof(float),0);
GL.VertexAttributeDivisor(3, 1);
vbo.Unbind();
vao.BindNull();
VertexArray.BindNull();
NativeCameraViewTarget
(
@@ -124,38 +128,85 @@ namespace StgSharp
(0,0,0),
(0,1,0)
);
NativeCameraViewRange(new Degree(1.7f),Vec2d.Zero,(50,50));
NativeCameraViewRange(new Degree(1.5f),Vec2d.Zero,(50,50));
NativeCameraUniform(s,"Camera");
s.Use();
fbo = CreateFrameBuffer(1);
rbo = CreateRenderBuffer(1);
fbo.Bind(0);
rbo.Bind(0);
glFunc.SetRenderBufferStorage(
RenderBufferInternalFormat.Depth24_Stencil8, this.Size);
t = CreateTexture(1);
t.Bind2D(0);
glFunc.TextureImage2d(Texture2DTarget.Texture2D, 0, (int)ImageChannel.WithAlphaChannel,
(uint)Width, (uint)Height, (int)ImageChannel.WithAlphaChannel, ImageChannelLayout.Byte, glHandle.ZeroHandle);
t.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
t.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
glFunc.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
Texture2DTarget.Texture2D,t[0],0);
glFunc.CombineFrameBufferRenderBuffer(fbo[0], rbo[0]);
int streamLength = this.Width * this.Height * 4;
byte[] imageStream = new byte[streamLength];
i = Image.FromMemory(this.Size,4,imageStream);
}
protected override void Main(in Dictionary<string, BlueprintPipeline> input, in Dictionary<string, BlueprintPipeline> output)
{
TextureGL t;
RenderBuffer rbo;
Image i;
protected override void Main(
in Dictionary<string, BlueprintPipeline> input,
in Dictionary<string, BlueprintPipeline> output)
{
buffer.UpdateAllParticles();
GL.ClearColor(0.6f,0.1f,0.3f,1);
GL.Clear(MaskBufferBit.COLOR | MaskBufferBit.DEPTH);
fbo.Bind(0);
vao.Bind(0);
glFunc.ClearColor(0.6f,0.1f,0.3f,1);
glFunc.Clear(MaskBufferBit.COLOR | MaskBufferBit.DEPTH);
vbo.Bind(1);
vbo.WriteVectorData(1, buffer.CoordSpan, BufferUsage.STREAM_DRAW);
vbo.WriteVectorData<vec4d>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw);
s.Use();
NativeCamera.SetAllUniforms();
GL.DrawElementsInstanced(
glFunc.DrawElementsInstanced(
GeometryType.TRIANGLES, 6, TypeCode.UInt32,IntPtr.Zero,100
);
glFunc.WaitAccomplishment();
VertexArray.BindNull();
vao.BindNull();
/**/
BlueprintPipeline.SkipAll(output);
t.Bind2D(0);
glFunc.GetTextureImage(Texture2DTarget.Texture2D, 0,ImageChannel.WithAlphaChannel,
ImageChannelLayout.Byte,ref i.data);
//Array.Fill<byte>(i.DataStream, 24);
output["output_1"].CompleteAndWriteData( new TexturePipeline(i));
FrameBuffer.BindNull();
/**/
/*
//BlueprintPipeline.SkipAll(output);
SwapBuffers();
PollEvents();
/**/
}
protected override void ProcessInput()
+19 -11
View File
@@ -9,7 +9,7 @@ using System.Runtime.CompilerServices;
namespace StgSharp
{
public class StgSharpDemoForm : Form
public class StgSharpDemoForm : ViewModel
{
public void Beep()
@@ -20,8 +20,6 @@ namespace StgSharp
}
}
//[RenderActivity(RenderPriority.Pre_1)]
public void NoOp()
{
@@ -45,20 +43,30 @@ namespace StgSharp
demoForm.Size = (800, 800);
demoForm.name = "Hello, Stg#!";
var stream = glRenderStream.AsMainStreamOf
var stream = demoForm.BuildMainRenderStream
//<MainRenderStream>
<ParticleStream>
(demoForm,(1,1,1));
//<ParticleStream>
<fboFrame>
((1,1,1));
var rstream = RenderStream.ShareContextWith
<fboFrame,ParticleStream>(stream);
Blueprint blueprint = new Blueprint();
BlueprintNode node = new BlueprintNode("MainRenderStream",stream);
node.AddAfter(blueprint.BeginLayer,
BlueprintNode node0 = new BlueprintNode("BufferGenerateStream", rstream);
BlueprintNode node1 = new BlueprintNode("MainRenderStream",stream);
node0.AddAfter(blueprint.BeginLayer,
"input_1", "input_1");
node.AddBefore(blueprint.EndLayer,
"output_1", "output_1");
node0.AddBefore(node1,
"output_1", "TextureInput");
node1.AddBefore(blueprint.EndLayer,
"Output", "output_1");
blueprint.AddNativeNode(node);
blueprint.AddNativeNode(node0);
blueprint.AddNativeNode(node1);
blueprint.Init(0);
//Console.WriteLine(2);
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+70890e3e339064993a7c905683c70a3ec5bd47f4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0cac40255bd414b81f65e12c37cd72a7adb12bf0")]
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -10,9 +10,7 @@ D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharp
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\StgSharpDebug.dll
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\StgSharpDebug.exe
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\awesomeface.png
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\fragment.frag
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\Image1.png
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\vertex.vert
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\StgSharpDebug.deps.json
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\StgSharpDebug.runtimeconfig.json
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\StgSharpDebug.pdb
@@ -28,3 +26,7 @@ D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharp
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpDebug\obj\x64\Debug\net6.0\StgSharpDebug.genruntimeconfig.cache
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\particle.frag
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\particle.vert
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\fbo.frag
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\fbo.vert
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\main.frag
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\Output\x64\Debug\net6.0\Shader\main.vert
@@ -1 +1 @@
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/a3506c96a3f6c7df608c22594ca2eaec41efa511/*"}}
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/0cac40255bd414b81f65e12c37cd72a7adb12bf0/*"}}
+1 -1
View File
@@ -25,7 +25,7 @@ namespace StgsharpEnvDebug
}
}
public sealed class DemoForm : Form
public sealed class DemoForm : ViewModel
{
}
@@ -14,7 +14,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("StgsharpEnvDebug")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+70890e3e339064993a7c905683c70a3ec5bd47f4")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+0cac40255bd414b81f65e12c37cd72a7adb12bf0")]
[assembly: System.Reflection.AssemblyProductAttribute("StgsharpEnvDebug")]
[assembly: System.Reflection.AssemblyTitleAttribute("StgsharpEnvDebug")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]