daily update on 20240610 by nitload youmu
This commit is contained in:
@@ -1,4 +1,35 @@
|
||||
using StgSharp.Geometries;
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="FBOframe.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. 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 StgSharp.Controls;
|
||||
using StgSharp.Geometries;
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.Graphics.GL;
|
||||
using StgSharp.Logic;
|
||||
@@ -13,9 +44,25 @@ namespace StgSharp
|
||||
{
|
||||
public class fboFrame : glRenderStream
|
||||
{
|
||||
public fboFrame(RenderStreamConstructArgs args):base(args)
|
||||
|
||||
ElementBuffer ebo;
|
||||
|
||||
TriggerButton button;
|
||||
|
||||
Rectangle tex;
|
||||
|
||||
ShaderProgram s;
|
||||
TextureGL t;
|
||||
|
||||
Uniform<int> texUniform;
|
||||
VertexArray vao;
|
||||
VertexBuffer vbo;
|
||||
|
||||
internal TimeSpanProvider spanProvider;
|
||||
|
||||
public fboFrame(ViewPort args, (int,int,int) cube) : base(args,cube)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected override string[] InputPortsName
|
||||
@@ -24,7 +71,7 @@ namespace StgSharp
|
||||
"TextureInput"
|
||||
];
|
||||
|
||||
protected override string[] OutputPortsName
|
||||
protected override string[] OutputPortsName
|
||||
=>
|
||||
[
|
||||
"Output"
|
||||
@@ -35,34 +82,27 @@ namespace StgSharp
|
||||
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);
|
||||
SetSizeLimit(800, 800, 800, 800);
|
||||
|
||||
FrameSizeCallback = new FrameBufferSizeHandler(
|
||||
(window, width,height) => {
|
||||
(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
|
||||
-0.9f, 0.9f,
|
||||
0.9f, 0.9f,
|
||||
0.9f, -0.9f,
|
||||
-0.9f, -0.9f
|
||||
);
|
||||
|
||||
/*
|
||||
@@ -75,39 +115,39 @@ namespace StgSharp
|
||||
|
||||
/**/
|
||||
/**/
|
||||
Rectangle tex = new Rectangle(
|
||||
0f, 1f, 0,
|
||||
1f, 1f, 0,
|
||||
1f, 0f, 0,
|
||||
0f, 0f, 0
|
||||
tex = new Rectangle(
|
||||
0f, 1f,
|
||||
1f, 1f,
|
||||
1f, 0f,
|
||||
0f, 0f
|
||||
);
|
||||
|
||||
/**/
|
||||
|
||||
s = CreateShaderProgram();
|
||||
Shader vert = CreateShaderSegment(ShaderType.Vertex, 1);
|
||||
Shader frag = CreateShaderSegment(ShaderType.Fragment,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);
|
||||
vert.AttachTo(0, s);
|
||||
frag.AttachTo(0, s);
|
||||
|
||||
s.Link();
|
||||
|
||||
vao.Bind(0);
|
||||
|
||||
ebo.Bind(0);
|
||||
ebo.SetValue(0,rec.VertexIndices,BufferUsage.StaticDraw);
|
||||
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.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);
|
||||
VertexArray.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||
|
||||
|
||||
t = CreateTexture(1);
|
||||
@@ -116,20 +156,32 @@ namespace StgSharp
|
||||
t.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
|
||||
|
||||
TextureGL.Activate(TextureUnit.Unit0);
|
||||
|
||||
|
||||
texUniform = s.GetUniform<int>("tex");
|
||||
glFunc.SetUniformValue(texUniform, 0);
|
||||
|
||||
ViewPortDesigner vpDesigner = new ViewPortDesigner();
|
||||
vpDesigner.CreateKeyboardButtonGroup(null,null,null,null,null);
|
||||
button = vpDesigner.CreateKeyboardButton(
|
||||
rec,null,false
|
||||
);
|
||||
}
|
||||
|
||||
Uniform<int> texUniform;
|
||||
|
||||
protected override void Main(
|
||||
in Dictionary<string, BlueprintPipeline> input,
|
||||
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;
|
||||
Image i = (p ?? throw new Exception("Pipeline has null value")).Value;
|
||||
|
||||
AnimationBuilder animation = new AnimationBuilder(
|
||||
(float f, out Polygon4 frame) =>
|
||||
{
|
||||
frame = tex;
|
||||
return i;
|
||||
}, TimeFunction.One);
|
||||
button.Enable(animation);
|
||||
|
||||
|
||||
FrameBuffer.BindNull();
|
||||
glFunc.ClearColor(0.4f, 0.1f, 0f, 1.0f);
|
||||
@@ -139,9 +191,12 @@ namespace StgSharp
|
||||
|
||||
vao.Bind(0);
|
||||
|
||||
t.LoadTexture(0, i);
|
||||
foreach (PlainGeometryMesh item in button)
|
||||
{
|
||||
t.LoadTexture(0, item.TextureImage);
|
||||
}
|
||||
|
||||
glFunc.DrawElements(GeometryType.TRIANGLES,6,TypeCode.UInt32,IntPtr.Zero);
|
||||
glFunc.DrawElements(GeometryType.TRIANGLES, 6, TypeCode.UInt32, IntPtr.Zero);
|
||||
//glFunc.DrawElements(GeometryType.LINES, 6, TypeCode.UInt32, IntPtr.Zero);
|
||||
BlueprintPipeline.SkipAll(output);
|
||||
|
||||
@@ -153,5 +208,6 @@ namespace StgSharp
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace StgSharp
|
||||
private VertexArray vao;
|
||||
private VertexBuffer vbo;
|
||||
|
||||
public MainRenderStream(RenderStreamConstructArgs args) : base(args)
|
||||
public MainRenderStream(ViewPort args) : base(args,(100,100,100))
|
||||
{
|
||||
|
||||
}
|
||||
@@ -89,23 +89,34 @@ namespace StgSharp
|
||||
fragment.Compile(0, Shader.FromCodeFile("Shader\\main.frag"));
|
||||
fragment.AttachTo(0, shader);
|
||||
shader.Link();
|
||||
|
||||
|
||||
|
||||
Triangle tri = new Triangle(
|
||||
-0.5f, -0.3f, 0.0f,
|
||||
0.5f, -0.5f, 0.0f,
|
||||
0.0f, 0.5f, 0.0f
|
||||
-0.5f, -0.3f,
|
||||
0.5f, -0.5f,
|
||||
0.0f, 0.5f
|
||||
);
|
||||
|
||||
PlainCoordinate p = new PlainCoordinate(
|
||||
PlainCoordinate.StandardPlainCoordination,
|
||||
new Point(0,0,0),
|
||||
new vec3d(1, 0, 130), new vec3d(0, 1, 130)
|
||||
);
|
||||
|
||||
Rectangle rec = new Rectangle(
|
||||
-0.3f, 0.3f, 130.0f,
|
||||
0.3f, 0.3f, 130.0f,
|
||||
0.3f, -0.3f, 130.0f,
|
||||
-0.3f, -0.3f, 130.0f
|
||||
p,
|
||||
-0.3f, 0.3f,
|
||||
0.3f, 0.3f,
|
||||
0.3f, -0.3f,
|
||||
-0.3f, -0.3f
|
||||
);
|
||||
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
|
||||
-0.4f, 0.5f,
|
||||
0.5f, 0.5f,
|
||||
0.6f, -0.5f,
|
||||
0, -1,
|
||||
-0.7f, -0.5f
|
||||
);
|
||||
vao = CreateVertexArray(1);
|
||||
vbo = CreateVertexBuffer(2);
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace StgSharp
|
||||
{
|
||||
public class ParticleStream : glRenderStream
|
||||
{
|
||||
public ParticleStream(RenderStreamConstructArgs args, bool isSharing) : base(args, isSharing)
|
||||
public ParticleStream(ViewPort args, (int,int,int) cube) : base(args, (100,100,100))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -94,10 +94,10 @@ namespace StgSharp
|
||||
|
||||
Rectangle rec = new Rectangle
|
||||
(
|
||||
0.05f,0.05f,0.0f,
|
||||
0.05f,-0.05f,0.0f,
|
||||
-0.05f,-0.05f,0.0f,
|
||||
-0.05f,0.05f,0.0f
|
||||
0.05f,0.05f,
|
||||
0.05f,-0.05f,
|
||||
-0.05f,-0.05f,
|
||||
-0.05f,0.05f
|
||||
);
|
||||
|
||||
vao.Bind(0);
|
||||
|
||||
@@ -9,8 +9,14 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
public class StgSharpDemoForm : ViewModel
|
||||
public class StgSharpDemoForm : ViewModelBase
|
||||
{
|
||||
public StgSharpDemoForm(int frameSpeed) : base(frameSpeed)
|
||||
{
|
||||
}
|
||||
public StgSharpDemoForm(ViewPort vp, int frameSpeed) : base(vp, frameSpeed)
|
||||
{
|
||||
}
|
||||
|
||||
public void Beep()
|
||||
{
|
||||
@@ -39,21 +45,27 @@ namespace StgSharp
|
||||
StgSharp.Init();
|
||||
StgSharp.InitGL(4, 6);
|
||||
StgSharp.GlobalSetting.VSyncActivated = false;
|
||||
StgSharpDemoForm demoForm = new StgSharpDemoForm();
|
||||
demoForm.Size = (800, 800);
|
||||
demoForm.name = "Hello, Stg#!";
|
||||
|
||||
|
||||
|
||||
var stream = demoForm.BuildMainRenderStream
|
||||
ViewPort vp = new ViewPort(
|
||||
name: "Hello, Stg#!",
|
||||
size: (800,600),
|
||||
monitor: IntPtr.Zero
|
||||
);
|
||||
StgSharpDemoForm demoForm = new StgSharpDemoForm(vp,60);
|
||||
|
||||
|
||||
|
||||
View v = demoForm.BuildNewView(null, (1,1,1));
|
||||
|
||||
var stream = demoForm.BuildRenderStream
|
||||
//<MainRenderStream>
|
||||
//<ParticleStream>
|
||||
<fboFrame>
|
||||
((1,1,1));
|
||||
(v, (1,1,1));
|
||||
|
||||
var rstream = RenderStream.ShareContextWith
|
||||
<fboFrame,ParticleStream>(stream);
|
||||
|
||||
Console.WriteLine(1);
|
||||
Blueprint blueprint = new Blueprint();
|
||||
|
||||
BlueprintNode node0 = new BlueprintNode("BufferGenerateStream", rstream);
|
||||
@@ -69,7 +81,7 @@ namespace StgSharp
|
||||
blueprint.AddNativeNode(node1);
|
||||
blueprint.Init(0);
|
||||
|
||||
//Console.WriteLine(2);
|
||||
Console.WriteLine(2);
|
||||
|
||||
demoForm.RenderLogic = blueprint;
|
||||
demoForm.Show();
|
||||
|
||||
Reference in New Issue
Block a user