115 lines
3.7 KiB
C#
115 lines
3.7 KiB
C#
//using StgSharp.Environment.Win32;
|
|
using StgSharp.Controlling.UsrActivity;
|
|
using StgSharp.Geometries;
|
|
using StgSharp.Graphics;
|
|
using StgSharp.Logic;
|
|
using StgSharp.Math;
|
|
|
|
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Xml.XPath;
|
|
|
|
namespace StgSharp
|
|
{
|
|
public class StgSharpDemoForm : ViewModelBase
|
|
{
|
|
public StgSharpDemoForm(int frameSpeed) : base(frameSpeed)
|
|
{
|
|
}
|
|
public StgSharpDemoForm(ViewPort vp, int frameSpeed) : base(vp, frameSpeed)
|
|
{
|
|
}
|
|
|
|
protected sealed override void BuildGlobalKeyControl()
|
|
{
|
|
GlobalKeyAction.Add(
|
|
new KeyTrigger(KeyboardKey.ESCAPE,KeyStatus.PRESS),
|
|
new Action(() => {
|
|
InternalIO.glfwSetWindowShouldClose(this.WindowID, 1);
|
|
}));
|
|
}
|
|
}
|
|
|
|
internal static class Program
|
|
{
|
|
internal static unsafe void Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
//StgSharp.TryCreatWindow();
|
|
|
|
/**/
|
|
StgSharp.Init();
|
|
StgSharp.InitGL(4, 6);
|
|
StgSharp.GlobalSetting.VSyncActivated = false;
|
|
|
|
ViewPort viewport = new ViewPort(
|
|
name: "Hello, Stg#!",
|
|
size: (800,800),
|
|
monitor: IntPtr.Zero
|
|
);
|
|
StgSharpDemoForm demoForm = new StgSharpDemoForm(vp: viewport,60);
|
|
|
|
|
|
|
|
View v = demoForm.BuildNewView(null, (1,1,1));
|
|
|
|
var stream = demoForm.BuildRenderStream
|
|
//<MainRenderStream>
|
|
//<ParticleStream>
|
|
<fboFrame>
|
|
(v);
|
|
|
|
var rstream = RenderStream.ShareContextWith
|
|
<fboFrame,ParticleStream>(stream);
|
|
Blueprint blueprint = new Blueprint();
|
|
|
|
CrossFrameOperation cross = new CrossFrameOperation(() => Console.Beep(), 60 );
|
|
|
|
BlueprintNode node0 = new BlueprintNode("BufferGenerateStream", rstream,true);
|
|
BlueprintNode node1 = new BlueprintNode("MainRenderStream",stream,true);
|
|
BlueprintNode node2 = new BlueprintNode("Beep", cross,false);
|
|
|
|
node0.AddAfter(blueprint.BeginLayer,
|
|
"port_1", "input_1");
|
|
node0.AddBefore(node1,
|
|
"output_1", "TextureInput");
|
|
/**/
|
|
node1.AddBefore(blueprint.EndLayer,
|
|
"Output", "port2");
|
|
node2.AddAfter(blueprint.BeginLayer,
|
|
"port_2", CrossFrameOperation.InputInterfacesName);
|
|
/**/
|
|
/*
|
|
node1.AddBefore(node2,
|
|
"Output", CrossFrameOperation.InputInterfacesName);
|
|
node2.AddAfter(blueprint.BeginLayer,"input_2", CrossFrameOperation.InputInterfacesName);
|
|
/**/
|
|
node2.AddBefore(blueprint.EndLayer,
|
|
CrossFrameOperation.OutputInterfacesName, "port_1");
|
|
|
|
blueprint.AddNode(node0,true);
|
|
blueprint.AddNode(node1, true);
|
|
blueprint.AddNode(node2, false);
|
|
blueprint.Init();
|
|
|
|
BlueprintRunner.SetMaxTaskCount(1);
|
|
|
|
Console.WriteLine(2);
|
|
|
|
demoForm.GeneralRenderLogic = blueprint;
|
|
demoForm.Show();
|
|
StgSharp.Terminate();
|
|
/**/
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
|
|
InternalIO.InternalWriteLog(
|
|
ex.Message + "\n" + ex.StackTrace,
|
|
LogType.Error);
|
|
}
|
|
}
|
|
}
|
|
} |