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
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user