daily update on 20240613 by nitload youmu[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[D[C[4
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("OEM")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("OEM")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c0093f7b5c77291172cde7e3e38beabb126adf08")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be6c2e6b92a328d0b68af669d50e92dd9bbff42b")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("OEM")]
|
[assembly: System.Reflection.AssemblyProductAttribute("OEM")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("OEM")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("OEM")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -8,21 +8,22 @@ namespace StgSharp.Controlling.UsrActivity
|
|||||||
|
|
||||||
public struct KeyTrigger: ITrigger,IEquatable<KeyTrigger>
|
public struct KeyTrigger: ITrigger,IEquatable<KeyTrigger>
|
||||||
{
|
{
|
||||||
public KeyboardKey TargetKey;
|
private KeyboardKey _targetKey;
|
||||||
private KeyStatus _triggerStat;
|
private KeyStatus _triggerStat;
|
||||||
|
|
||||||
int ITrigger.TargetKeyOrButtonID => (int)TargetKey;
|
public int TargetKeyOrButtonID => (int)_targetKey;
|
||||||
|
|
||||||
KeyStatus ITrigger.TriggeredStatus => _triggerStat;
|
public KeyStatus TriggeredStatus => _triggerStat;
|
||||||
|
|
||||||
public KeyTrigger(KeyboardKey targetKey)
|
public KeyTrigger(KeyboardKey targetKey, KeyStatus targetStat)
|
||||||
{
|
{
|
||||||
this.TargetKey = targetKey;
|
this._targetKey = targetKey;
|
||||||
|
this._triggerStat = targetStat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(KeyTrigger left, KeyTrigger right)
|
public static bool operator ==(KeyTrigger left, KeyTrigger right)
|
||||||
{
|
{
|
||||||
return left._triggerStat == right._triggerStat && left.TargetKey == right.TargetKey;
|
return left._triggerStat == right._triggerStat && left._targetKey == right._targetKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator !=(KeyTrigger left, KeyTrigger right)
|
public static bool operator !=(KeyTrigger left, KeyTrigger right)
|
||||||
@@ -37,12 +38,12 @@ namespace StgSharp.Controlling.UsrActivity
|
|||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
return (int)TargetKey + 17 * (int)_triggerStat;
|
return (int)_targetKey + 17 * (int)_triggerStat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"Key {TargetKey} triggered when {_triggerStat}";
|
return $"Key {_targetKey} triggered when {_triggerStat}";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IEquatable<KeyTrigger>.Equals(KeyTrigger other)
|
bool IEquatable<KeyTrigger>.Equals(KeyTrigger other)
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ namespace StgSharp
|
|||||||
|
|
||||||
public static void Terminate()
|
public static void Terminate()
|
||||||
{
|
{
|
||||||
MainTimeProvider.Terminate();
|
MainTimeProvider.StopProvidingTime();
|
||||||
InternalIO.glfwTerminate();
|
InternalIO.glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,19 +39,17 @@ using System.Threading;
|
|||||||
|
|
||||||
namespace StgSharp
|
namespace StgSharp
|
||||||
{
|
{
|
||||||
public partial class StgSharp
|
public static partial class StgSharp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
internal static StgSharpTime mainTimeProvider = new StgSharpTime();
|
||||||
|
|
||||||
internal static StgSharpTime mainTimeProvider;
|
internal static TimeSourceProviderBase MainTimeProvider => mainTimeProvider;
|
||||||
|
|
||||||
internal static StgSharpTime MainTimeProvider => mainTimeProvider;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class StgSharpTime : TimeSourceProviderBase
|
public sealed class StgSharpTime : TimeSourceProviderBase
|
||||||
{
|
{
|
||||||
|
|
||||||
private static long accuracy;
|
private static long accuracy;
|
||||||
private static Stopwatch mainProvider = new Stopwatch();
|
private static Stopwatch mainProvider = new Stopwatch();
|
||||||
private static List<TimeSpanProvider> subscriberList = new List<TimeSpanProvider>();
|
private static List<TimeSpanProvider> subscriberList = new List<TimeSpanProvider>();
|
||||||
@@ -61,7 +59,7 @@ namespace StgSharp
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StgSharpTime OnlyInstance => StgSharp.MainTimeProvider;
|
public static TimeSourceProviderBase OnlyInstance => StgSharp.MainTimeProvider;
|
||||||
|
|
||||||
public override sealed void StartProvidingTime()
|
public override sealed void StartProvidingTime()
|
||||||
{
|
{
|
||||||
@@ -111,6 +109,14 @@ namespace StgSharp
|
|||||||
subscriberList.Remove(subscriber);
|
subscriberList.Remove(subscriber);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void StopProvidingTime()
|
||||||
|
{
|
||||||
|
lock (mainProvider)
|
||||||
|
{
|
||||||
|
mainProvider.Stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ProvideTime()
|
private void ProvideTime()
|
||||||
{
|
{
|
||||||
long totalMS, internalFrequncy = Stopwatch.Frequency;
|
long totalMS, internalFrequncy = Stopwatch.Frequency;
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace StgSharp.Graphics
|
||||||
|
{
|
||||||
|
public static class ImageProcessor
|
||||||
|
{
|
||||||
|
public static void Resize(Image i, int width, int height, ImageMovement move)
|
||||||
|
{
|
||||||
|
if (i == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(i));
|
||||||
|
}
|
||||||
|
Array.Resize(ref i.data, width * height * i.ChannelCount);
|
||||||
|
i.Height = height;
|
||||||
|
i.Width = width;
|
||||||
|
switch (move)
|
||||||
|
{
|
||||||
|
case ImageMovement.Discard:
|
||||||
|
break;
|
||||||
|
case ImageMovement.Top:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new NotSupportedException("Invalid or not supported data remanence");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum ImageMovement
|
||||||
|
{
|
||||||
|
#pragma warning disable CA1008
|
||||||
|
Discard = 0,
|
||||||
|
#pragma warning restore CA1008
|
||||||
|
Top = 1,
|
||||||
|
Bottom = 2,
|
||||||
|
Left = 4,
|
||||||
|
Right = 8,
|
||||||
|
TopLeft = Top | Left,
|
||||||
|
BottomLeft = Bottom | Left,
|
||||||
|
TopRight = Top | Right,
|
||||||
|
BottomRight = Bottom | Right,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -278,7 +278,7 @@ namespace StgSharp.Graphics
|
|||||||
double virtualCursorPosX, virtualCursorPosY;
|
double virtualCursorPosX, virtualCursorPosY;
|
||||||
bool rawMouseMotion;
|
bool rawMouseMotion;
|
||||||
|
|
||||||
// _GLFWcontext context; // 根据_GLFWcontext的定义转换
|
// _GLFWcontext viewPortDisplay; // 根据_GLFWcontext的定义转换
|
||||||
|
|
||||||
// Callbacks are represented as IntPtr since we don't need the actual function pointers in C#
|
// Callbacks are represented as IntPtr since we don't need the actual function pointers in C#
|
||||||
internal struct Callbacks
|
internal struct Callbacks
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ namespace StgSharp.Graphics.GL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Load an <see cref="Image"/> to certain texture.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="index"> </param>
|
/// <param name="index"> </param>
|
||||||
/// <param name="i"> </param>
|
/// <param name="i"> </param>
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ namespace StgSharp.Graphics.GL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Link the shader to current context.
|
/// Link the shader to current viewPortDisplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe void Link()
|
public unsafe void Link()
|
||||||
{
|
{
|
||||||
@@ -247,7 +247,7 @@ namespace StgSharp.Graphics.GL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Let the current context use this shader.
|
/// Let the current viewPortDisplay use this shader.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public unsafe void Use()
|
public unsafe void Use()
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ namespace StgSharp.Graphics.GL
|
|||||||
private static string glExtensionList;
|
private static string glExtensionList;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Load all supported OpenGL APIs and bind them to given <see cref="ViewPort"/> context.
|
/// Load all supported OpenGL APIs and bind them to given <see cref="ViewPort"/> viewPortDisplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="vp">The <see cref="ViewPort"/> used as current OpenGL context</param>
|
/// <param name="vp">The <see cref="ViewPort"/> used as current OpenGL viewPortDisplay</param>
|
||||||
public static unsafe void LoadGLapi(this ViewPort vp)
|
public static unsafe void LoadGLapi(this ViewPort vp)
|
||||||
{
|
{
|
||||||
GLcontext* context = (GLcontext*)vp.GraphicHandle;
|
GLcontext* context = (GLcontext*)vp.GraphicHandle;
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ namespace StgSharp.Graphics.GL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Init an OpenGl context if current form has not been binded to any context. and set the context binded to
|
/// Init an OpenGl viewPortDisplay if current form has not been binded to any viewPortDisplay. and set the viewPortDisplay binded to
|
||||||
/// current form as current OpenGL context.
|
/// current form as current OpenGL viewPortDisplay.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <exception cref="Exception">
|
/// <exception cref="Exception">
|
||||||
/// Something goes wrong and StgSharp fails in creating a new OpenGL context.
|
/// Something goes wrong and StgSharp fails in creating a new OpenGL viewPortDisplay.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public unsafe void MakeAsCurrentContext()
|
public unsafe void MakeAsCurrentContext()
|
||||||
{
|
{
|
||||||
@@ -73,7 +73,6 @@ namespace StgSharp.Graphics.GL
|
|||||||
if (glFunc.CurrentContextHandle != ContextHandle)
|
if (glFunc.CurrentContextHandle != ContextHandle)
|
||||||
{
|
{
|
||||||
glFunc.CurrentContextHandle = ContextHandle;
|
glFunc.CurrentContextHandle = ContextHandle;
|
||||||
//Console.WriteLine($"context set as {(ulong)glFunc.CurrentContextHandle}");
|
|
||||||
InternalIO.glfwMakeContextCurrent(CanvasHandle);
|
InternalIO.glfwMakeContextCurrent(CanvasHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,7 +88,6 @@ namespace StgSharp.Graphics.GL
|
|||||||
in Dictionary<string, BlueprintPipeline> output)
|
in Dictionary<string, BlueprintPipeline> output)
|
||||||
{
|
{
|
||||||
MakeAsCurrentContext();
|
MakeAsCurrentContext();
|
||||||
ProcessInput();
|
|
||||||
Main(in input, in output);
|
Main(in input, in output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace StgSharp.Graphics
|
|||||||
{
|
{
|
||||||
public class Image : ISSDSerializable, IImageProvider
|
public class Image : ISSDSerializable, IImageProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
internal byte[] data;
|
internal byte[] data;
|
||||||
internal ImageInfo info;
|
internal ImageInfo info;
|
||||||
|
|
||||||
@@ -55,27 +56,40 @@ namespace StgSharp.Graphics
|
|||||||
//int length = info.width * info.height * info.channel;
|
//int length = info.width * info.height * info.channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ref byte[] DataStream
|
|
||||||
{
|
|
||||||
get => ref data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public unsafe Image()
|
public unsafe Image()
|
||||||
{
|
{
|
||||||
info = new ImageInfo();
|
info = new ImageInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageChannel Channel => info.Channel;
|
public ref byte[] DataStream
|
||||||
public int ChannelCount => info.ChannelCount;
|
{
|
||||||
public int Height => info.Height;
|
get => ref data;
|
||||||
|
}
|
||||||
|
|
||||||
public (int width, int height) Size
|
public (int width, int height) Size
|
||||||
{
|
{
|
||||||
get => (info.Width, info.Height);
|
get => (info.Width, info.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ImageChannel Channel => info.Channel;
|
||||||
|
public int ChannelCount => info.ChannelCount;
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get => info.Height;
|
||||||
|
internal set => info.Height = value;
|
||||||
|
}
|
||||||
|
public int Width
|
||||||
|
{
|
||||||
|
get => info.Width;
|
||||||
|
internal set => info.Width = value;
|
||||||
|
}
|
||||||
|
|
||||||
public SerializableTypeCode SSDTypeCode => SerializableTypeCode.PixelImage;
|
public SerializableTypeCode SSDTypeCode => SerializableTypeCode.PixelImage;
|
||||||
public int Width => info.Width;
|
|
||||||
|
public void FromBytes(byte[] stream)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static unsafe Image FromFile(string route, ImageLoader loader)
|
public static unsafe Image FromFile(string route, ImageLoader loader)
|
||||||
{
|
{
|
||||||
@@ -139,11 +153,6 @@ namespace StgSharp.Graphics
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FromBytes(byte[] stream)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Image ProvideImage()
|
public Image ProvideImage()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
@@ -219,12 +228,6 @@ namespace StgSharp.Graphics
|
|||||||
set => height = value;
|
set => height = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr StreamPtr
|
|
||||||
{
|
|
||||||
get => pixelPtr;
|
|
||||||
internal set => pixelPtr = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int StreamSize
|
public int StreamSize
|
||||||
{
|
{
|
||||||
get => width * height * channelCount;
|
get => width * height * channelCount;
|
||||||
@@ -236,6 +239,12 @@ namespace StgSharp.Graphics
|
|||||||
set => width = value;
|
set => width = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IntPtr StreamPtr
|
||||||
|
{
|
||||||
|
get => pixelPtr;
|
||||||
|
internal set => pixelPtr = value;
|
||||||
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
return $"{channel}\t{width}\t{height}\t{(ulong)StreamPtr}";
|
return $"{channel}\t{width}\t{height}\t{(ulong)StreamPtr}";
|
||||||
|
|||||||
@@ -45,51 +45,17 @@ namespace StgSharp.Graphics
|
|||||||
{
|
{
|
||||||
public abstract class RenderStream : IConvertableToBlueprintNode
|
public abstract class RenderStream : IConvertableToBlueprintNode
|
||||||
{
|
{
|
||||||
private ViewPort primeArgs;
|
|
||||||
|
|
||||||
private protected (int x, int y, int z) _coordStretch;
|
private protected (int x, int y, int z) _coordStretch;
|
||||||
|
|
||||||
private Camera nativeCamera;
|
private Camera nativeCamera;
|
||||||
|
|
||||||
public ViewPort Port => primeArgs;
|
private ViewPort primeArgs;
|
||||||
|
|
||||||
internal IntPtr CanvasHandle { get => primeArgs.ViewPortID; }
|
|
||||||
|
|
||||||
|
|
||||||
internal IntPtr ContextHandle
|
|
||||||
{
|
|
||||||
get => primeArgs.GraphicHandle;
|
|
||||||
private protected set => primeArgs.GraphicHandle = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private IntPtr monitor;
|
|
||||||
private IntPtr sharedCanvas;
|
|
||||||
|
|
||||||
internal TimeSpanProvider timeProvider;
|
internal TimeSpanProvider timeProvider;
|
||||||
/*
|
|
||||||
protected RenderStream(View v, bool isSharing)
|
|
||||||
{
|
|
||||||
if (v == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(v));
|
|
||||||
}
|
|
||||||
if (isSharing)
|
|
||||||
{
|
|
||||||
primeArgs = v;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
View? newArgs = args.Clone() as View;
|
|
||||||
primeArgs = newArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
monitor = args.Monitor;
|
public RenderStream(ViewPort v, (int, int, int) unitCubeSize)
|
||||||
_coordStretch = args.UnitCubeSize;
|
|
||||||
NativeCamera = new Camera();
|
|
||||||
}
|
|
||||||
/**/
|
|
||||||
|
|
||||||
public RenderStream(ViewPort v, (int,int,int) unitCubeSize)
|
|
||||||
{
|
{
|
||||||
if (v == null)
|
if (v == null)
|
||||||
{
|
{
|
||||||
@@ -97,48 +63,8 @@ namespace StgSharp.Graphics
|
|||||||
}
|
}
|
||||||
primeArgs = v;
|
primeArgs = v;
|
||||||
|
|
||||||
monitor = v!.Monitor;
|
|
||||||
_coordStretch = unitCubeSize;
|
_coordStretch = unitCubeSize;
|
||||||
NativeCamera = new Camera();
|
nativeCamera = new Camera();
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public FrameBufferSizeHandler FrameSizeCallback
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
|
||||||
InternalIO.glfwSetFramebufferSizeCallback(CanvasHandle, handlerPtr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public vec2d GlobalCoordSize => ((Width * 1.0f) / _coordStretch.x, (Height * 1.0f) / _coordStretch.y);
|
|
||||||
|
|
||||||
public int Height
|
|
||||||
{
|
|
||||||
get => primeArgs.Height;
|
|
||||||
internal set
|
|
||||||
{
|
|
||||||
primeArgs.Height = value;
|
|
||||||
InternalIO.glfwSetWindowSize(this.CanvasHandle, Width, Height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr Monitor
|
|
||||||
{
|
|
||||||
get => monitor;
|
|
||||||
internal set => monitor = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get => primeArgs.Name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr SharedCanvas
|
|
||||||
{
|
|
||||||
get => sharedCanvas;
|
|
||||||
internal set => sharedCanvas = value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public (int width, int height) Size
|
public (int width, int height) Size
|
||||||
@@ -152,14 +78,55 @@ namespace StgSharp.Graphics
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public string[] InputInterfacesName => InputPortsName;
|
||||||
|
|
||||||
|
public string[] OutputInterfacesName => OutputPortsName;
|
||||||
|
|
||||||
|
|
||||||
|
public FrameBufferSizeHandler FrameSizeCallback
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
||||||
|
InternalIO.glfwSetFramebufferSizeCallback(CanvasHandle, handlerPtr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Height
|
||||||
|
{
|
||||||
|
get => primeArgs.Height;
|
||||||
|
internal set { primeArgs.Height = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public int Width
|
public int Width
|
||||||
{
|
{
|
||||||
get => primeArgs.Width;
|
get => primeArgs.Width;
|
||||||
internal set
|
internal set { primeArgs.Width = value; }
|
||||||
{
|
}
|
||||||
primeArgs.Width = value;
|
|
||||||
InternalIO.glfwSetWindowSize(this.CanvasHandle, Width, Height);
|
public IntPtr Monitor
|
||||||
}
|
{
|
||||||
|
get => primeArgs.Monitor;
|
||||||
|
internal set => primeArgs.Monitor = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => primeArgs.Name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public vec2d GlobalCoordSize => ((Width * 1.0f) / _coordStretch.x, (Height * 1.0f) / _coordStretch.y);
|
||||||
|
|
||||||
|
public ViewPort Port => primeArgs;
|
||||||
|
|
||||||
|
internal IntPtr CanvasHandle { get => primeArgs.ViewPortID; }
|
||||||
|
|
||||||
|
|
||||||
|
internal IntPtr ContextHandle
|
||||||
|
{
|
||||||
|
get => primeArgs.GraphicHandle;
|
||||||
|
private protected set => primeArgs.GraphicHandle = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internal Camera NativeCamera
|
protected internal Camera NativeCamera
|
||||||
@@ -200,7 +167,9 @@ namespace StgSharp.Graphics
|
|||||||
where TSource : RenderStream
|
where TSource : RenderStream
|
||||||
where TTarget : RenderStream
|
where TTarget : RenderStream
|
||||||
{
|
{
|
||||||
TTarget target = Activator.CreateInstance(typeof(TTarget), source.primeArgs, source._coordStretch) as TTarget;
|
#nullable enable
|
||||||
|
TTarget? target = Activator.CreateInstance(typeof(TTarget), source.primeArgs, source._coordStretch) as TTarget;
|
||||||
|
#nullable restore
|
||||||
if (target == null)
|
if (target == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
@@ -208,17 +177,12 @@ namespace StgSharp.Graphics
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
target.timeProvider = source.timeProvider;
|
target.timeProvider = source.timeProvider;
|
||||||
target.Init();
|
target.InternalInit();
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
string[] IConvertableToBlueprintNode.InputInterfacesName => InputPortsName;
|
|
||||||
|
|
||||||
BlueprintNodeAction IConvertableToBlueprintNode.MainExecution => InternalDraw;
|
BlueprintNodeAction IConvertableToBlueprintNode.MainExecution => InternalDraw;
|
||||||
|
|
||||||
string[] IConvertableToBlueprintNode.OutputInterfacesName => OutputPortsName;
|
|
||||||
|
|
||||||
#region native camera operation
|
#region native camera operation
|
||||||
protected abstract void NativeCameraViewRange(Radius fieldOfRange, vec2d offset, (float frontDepth, float backDepth) viewDepth);
|
protected abstract void NativeCameraViewRange(Radius fieldOfRange, vec2d offset, (float frontDepth, float backDepth) viewDepth);
|
||||||
protected abstract void NativeCameraViewTarget(vec3d position, vec3d direction, vec3d up);
|
protected abstract void NativeCameraViewTarget(vec3d position, vec3d direction, vec3d up);
|
||||||
@@ -251,7 +215,6 @@ namespace StgSharp.Graphics
|
|||||||
protected abstract void Main(
|
protected abstract void Main(
|
||||||
in Dictionary<string, BlueprintPipeline> input,
|
in Dictionary<string, BlueprintPipeline> input,
|
||||||
in Dictionary<string, BlueprintPipeline> output);
|
in Dictionary<string, BlueprintPipeline> output);
|
||||||
protected abstract void ProcessInput();
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ namespace StgSharp.Graphics
|
|||||||
{
|
{
|
||||||
public TexturePipeline(Image i)
|
public TexturePipeline(Image i)
|
||||||
{
|
{
|
||||||
value = i;
|
_value = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Image value;
|
private Image _value;
|
||||||
|
|
||||||
public Image Value
|
public new Image Value
|
||||||
{
|
{
|
||||||
get => value;
|
get => _value;
|
||||||
set => value = value ?? throw new ArgumentNullException(nameof(value));
|
set => _value = value ?? throw new ArgumentNullException(nameof(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,22 +49,15 @@ namespace StgSharp.Graphics
|
|||||||
public unsafe partial class View
|
public unsafe partial class View
|
||||||
{
|
{
|
||||||
|
|
||||||
private (int w, int h) sizeCache;
|
|
||||||
private (int x, int y, int z) unitCubeSize;
|
private (int x, int y, int z) unitCubeSize;
|
||||||
|
|
||||||
private ViewPort context;
|
private ViewPort context;
|
||||||
|
|
||||||
private ViewPortDesigner design;
|
private ViewPortDesigner design;
|
||||||
|
|
||||||
public ViewPort Port
|
|
||||||
{
|
|
||||||
get => context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public View(ViewPort vp, ViewPortDesigner design)
|
public View(ViewPort vp, ViewPortDesigner design)
|
||||||
{
|
{
|
||||||
context = vp;
|
context = vp;
|
||||||
sizeCache = (0, 0);
|
|
||||||
unitCubeSize = (1, 1, 1);
|
unitCubeSize = (1, 1, 1);
|
||||||
localLogic = new Logic.Blueprint();
|
localLogic = new Logic.Blueprint();
|
||||||
this.design = design;
|
this.design = design;
|
||||||
@@ -74,30 +67,27 @@ namespace StgSharp.Graphics
|
|||||||
public View(ViewPort vp, ViewPortDesigner design, (int, int, int) cubeSize)
|
public View(ViewPort vp, ViewPortDesigner design, (int, int, int) cubeSize)
|
||||||
{
|
{
|
||||||
context = vp;
|
context = vp;
|
||||||
sizeCache = (0, 0);
|
|
||||||
unitCubeSize = cubeSize;
|
unitCubeSize = cubeSize;
|
||||||
localLogic = new Logic.Blueprint();
|
localLogic = new Logic.Blueprint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public (int x, int y, int z) UnitCubeSize
|
||||||
|
{
|
||||||
|
get => unitCubeSize;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Activated { get; internal set; }
|
public bool Activated { get; internal set; }
|
||||||
|
|
||||||
public int Height
|
public int Height
|
||||||
{
|
{
|
||||||
get
|
get => context.Height;
|
||||||
{
|
internal set { context.Height = value; }
|
||||||
if (context.Height != sizeCache.h)
|
}
|
||||||
{
|
|
||||||
sizeCache.h = context.Height;
|
public int Width
|
||||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
{
|
||||||
}
|
get => context.Width;
|
||||||
return sizeCache.h;
|
internal set { context.Width = value; }
|
||||||
}
|
|
||||||
internal set
|
|
||||||
{
|
|
||||||
sizeCache.h = value;
|
|
||||||
context.Height = value;
|
|
||||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IntPtr Monitor => context.Monitor;
|
public IntPtr Monitor => context.Monitor;
|
||||||
@@ -108,28 +98,9 @@ namespace StgSharp.Graphics
|
|||||||
|
|
||||||
public string SelfName { get; set; }
|
public string SelfName { get; set; }
|
||||||
|
|
||||||
public (int x, int y, int z) UnitCubeSize
|
public ViewPort Port
|
||||||
{
|
{
|
||||||
get => unitCubeSize;
|
get => context;
|
||||||
}
|
|
||||||
|
|
||||||
public int Width
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (context.Width != sizeCache.w)
|
|
||||||
{
|
|
||||||
sizeCache.w = context.Width;
|
|
||||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
|
||||||
}
|
|
||||||
return sizeCache.h;
|
|
||||||
}
|
|
||||||
internal set
|
|
||||||
{
|
|
||||||
sizeCache.w = value;
|
|
||||||
context.Width = value;
|
|
||||||
InternalIO.glfwSetWindowSize(ViewHandle, context.Height, context.Width);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,38 @@
|
|||||||
using StgSharp.Math;
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="ViewPort.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.Math;
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -10,37 +41,82 @@ namespace StgSharp.Graphics
|
|||||||
{
|
{
|
||||||
public class ViewPort
|
public class ViewPort
|
||||||
{
|
{
|
||||||
public int Width { get; set; }
|
private int _width, _height;
|
||||||
public int Height { get; set; }
|
|
||||||
|
|
||||||
public string Name { get; set; }
|
internal ViewPort()
|
||||||
|
{
|
||||||
|
_height = 800;
|
||||||
|
_width = 600;
|
||||||
|
Name = new StackFrame(1, false).
|
||||||
|
GetMethod()!.DeclaringType!.Name;
|
||||||
|
Monitor = IntPtr.Zero;
|
||||||
|
ViewPortID = InternalIO.glfwCreateWindow(_width, _height,
|
||||||
|
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
||||||
|
);
|
||||||
|
if (ViewPortID == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Unable to create viewport handle.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ViewPort(vec2d size, string name, IntPtr monitor)
|
||||||
|
{
|
||||||
|
_width = (int)size.X;
|
||||||
|
_height = (int)size.Y;
|
||||||
|
Name = name;
|
||||||
|
Monitor = monitor;
|
||||||
|
ViewPortID = InternalIO.glfwCreateWindow(_width, _height,
|
||||||
|
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
||||||
|
);
|
||||||
|
if (ViewPortID == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Unable to create viewport handle.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe int Height
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _height;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
InternalIO.glfwSetWindowSize(this.ViewPortID, _width, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public unsafe int Width
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _width;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
InternalIO.glfwSetWindowSize(this.ViewPortID, value, _height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr GraphicHandle { get; internal set; }
|
||||||
|
|
||||||
public IntPtr Monitor { get; internal set; }
|
public IntPtr Monitor { get; internal set; }
|
||||||
|
|
||||||
public IntPtr ViewPortID { get; private set; }
|
public IntPtr ViewPortID { get; private set; }
|
||||||
public IntPtr GraphicHandle { get; internal set; }
|
|
||||||
|
|
||||||
internal ViewPort()
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public void Close()
|
||||||
{
|
{
|
||||||
Height = 800;
|
InternalIO.glfwSetWindowShouldClose(this.ViewPortID,1);
|
||||||
Width = 600;
|
|
||||||
Name = new StackFrame(1, false).
|
|
||||||
GetMethod()!.DeclaringType!.Name;
|
|
||||||
Monitor = IntPtr.Zero;
|
|
||||||
ViewPortID = InternalIO.glfwCreateWindow(Width,Height,
|
|
||||||
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewPort(vec2d size,string name, IntPtr monitor)
|
internal unsafe void FlushSize()
|
||||||
{
|
{
|
||||||
Height = (int) size.Y;
|
fixed (int* wptr = &_width, hptr = &_height)
|
||||||
Width = (int) size.X;
|
{
|
||||||
Name = name;
|
InternalIO.glfwGetWindowSize(ViewPortID, wptr, hptr);
|
||||||
Monitor = monitor;
|
}
|
||||||
ViewPortID = InternalIO.glfwCreateWindow(Width, Height,
|
|
||||||
Encoding.UTF8.GetBytes(Name), Monitor, IntPtr.Zero
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,72 +111,4 @@ namespace StgSharp.Logic
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public sealed class RouteHub : BlueprintNode
|
|
||||||
{
|
|
||||||
|
|
||||||
private Dictionary<string, (BlueprintPipeline pipeline, Func<bool> controllingFunc)> inputDictionary;
|
|
||||||
|
|
||||||
public RouteHub(string name, string[] inputPorts, string[] outputPorts) : base(name, inputPorts, outputPorts)
|
|
||||||
{
|
|
||||||
inputDictionary = new Dictionary<string, (BlueprintPipeline pipeline, Func<bool> controllingFunc)>();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public new int Level
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (levelAvailable)
|
|
||||||
{
|
|
||||||
return _level;
|
|
||||||
}
|
|
||||||
_level = 0;
|
|
||||||
foreach (KeyValuePair<string, BlueprintPipeline> item in _inputInterfaces)
|
|
||||||
{
|
|
||||||
if (item.Value == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (_level <= item.Value.Level)
|
|
||||||
{
|
|
||||||
_level = item.Value.Level;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return _level;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PrependNode(BlueprintNode node, string portName, Func<bool> usingRule)
|
|
||||||
{
|
|
||||||
if (node == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentNullException(nameof(node));
|
|
||||||
}
|
|
||||||
string indexName = $"{node.Name}.{portName}";
|
|
||||||
BlueprintPipeline p = new BlueprintPipeline(this, node);
|
|
||||||
node.InputInterfaces[portName] = p;
|
|
||||||
inputDictionary.Add(indexName, (p, usingRule));
|
|
||||||
}
|
|
||||||
|
|
||||||
public new void Run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
foreach (KeyValuePair<string, (BlueprintPipeline pipeline, Func<bool> controllingFunc)> item in inputDictionary)
|
|
||||||
{
|
|
||||||
item.Value.pipeline.WaitForStart();
|
|
||||||
if (item.Value.controllingFunc())
|
|
||||||
{
|
|
||||||
_outputInterfaces.First().Value.CompleteAndWriteData(item.Value.pipeline.Args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,9 @@ namespace StgSharp.Logic
|
|||||||
private SemaphoreSlim _addSubscriberSemaphore = new SemaphoreSlim(1, 1);
|
private SemaphoreSlim _addSubscriberSemaphore = new SemaphoreSlim(1, 1);
|
||||||
|
|
||||||
protected SemaphoreSlim CheckSubscriberSemaphore
|
protected SemaphoreSlim CheckSubscriberSemaphore
|
||||||
=> _addSubscriberSemaphore;
|
{
|
||||||
|
get => _addSubscriberSemaphore;
|
||||||
|
}
|
||||||
|
|
||||||
public void AddSubscriber(TimeSpanProvider subscriber)
|
public void AddSubscriber(TimeSpanProvider subscriber)
|
||||||
{
|
{
|
||||||
@@ -81,6 +83,8 @@ namespace StgSharp.Logic
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract void StartProvidingTime();
|
public abstract void StartProvidingTime();
|
||||||
|
public abstract void StopProvidingTime();
|
||||||
|
|
||||||
|
|
||||||
protected abstract void AddSubscriberUnsynced(TimeSpanProvider subscriber);
|
protected abstract void AddSubscriberUnsynced(TimeSpanProvider subscriber);
|
||||||
protected abstract void RemoveSubscriberUnsynced(TimeSpanProvider subscriber);
|
protected abstract void RemoveSubscriberUnsynced(TimeSpanProvider subscriber);
|
||||||
|
|||||||
@@ -130,12 +130,6 @@ namespace StgSharp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static TimeSourceProviderBase DefaultProvider => StgSharpTime.OnlyInstance;
|
public static TimeSourceProviderBase DefaultProvider => StgSharpTime.OnlyInstance;
|
||||||
|
|
||||||
public Action FrameUpdateMissCallback
|
|
||||||
{
|
|
||||||
get => _frameUpdateMissCallback;
|
|
||||||
set => _frameUpdateMissCallback = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double SpanLength
|
public double SpanLength
|
||||||
{
|
{
|
||||||
get => (_spanLength * 1.0) / (1000L * 1000L);
|
get => (_spanLength * 1.0) / (1000L * 1000L);
|
||||||
@@ -176,18 +170,20 @@ namespace StgSharp
|
|||||||
|
|
||||||
internal bool CheckTime(long microseconds)
|
internal bool CheckTime(long microseconds)
|
||||||
{
|
{
|
||||||
|
//Console.Write("1 ");
|
||||||
if (microseconds - _spanBegin < _spanLength)
|
if (microseconds - _spanBegin < _spanLength)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
//Console.Write("2 ");
|
||||||
_spanBegin = microseconds;
|
_spanBegin = microseconds;
|
||||||
timeSpanCount++;
|
timeSpanCount++;
|
||||||
|
//Console.Write("3 ");
|
||||||
if (_refreshCallback != null)
|
if (_refreshCallback != null)
|
||||||
{
|
{
|
||||||
_refreshCallback();
|
_refreshCallback();
|
||||||
}
|
}
|
||||||
|
//Console.Write("4 ");
|
||||||
if (_refreshSemaphore.CurrentCount == 0)
|
if (_refreshSemaphore.CurrentCount == 0)
|
||||||
{
|
{
|
||||||
_refreshSemaphore.Release();
|
_refreshSemaphore.Release();
|
||||||
@@ -199,17 +195,23 @@ namespace StgSharp
|
|||||||
_frameUpdateMissCallback();
|
_frameUpdateMissCallback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (timeSpanCount > _maxSpanCount)
|
//Console.Write("5 ");
|
||||||
{
|
//Console.WriteLine( $"{timeSpanCount}\n" );
|
||||||
return false;
|
return timeSpanCount < _maxSpanCount;
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator int(TimeSpanProvider provider)
|
public static implicit operator int(TimeSpanProvider provider)
|
||||||
{
|
{
|
||||||
return provider.timeSpanCount.Value;
|
if (provider == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return provider.ToInt32();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int ToInt32()
|
||||||
|
{
|
||||||
|
return (int)timeSpanCount.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,8 +27,18 @@ namespace StgSharp.Logic
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public unsafe void Show()
|
public unsafe void Show()
|
||||||
{
|
{
|
||||||
while(0 == InternalIO.glfwWindowShouldClose(this.context.ViewPortID))
|
BuildGlobalKeyControl();
|
||||||
|
while(0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
|
||||||
{
|
{
|
||||||
|
viewPortDisplay.FlushSize();
|
||||||
|
foreach (var item in this._globalKeyAction)
|
||||||
|
{
|
||||||
|
if (InternalIO.glfwGetKey(this.viewPortDisplay.ViewPortID, (int)item.Key.TargetKeyOrButtonID)
|
||||||
|
== item.Key.TriggeredStatus)
|
||||||
|
{
|
||||||
|
item.Value();
|
||||||
|
}
|
||||||
|
}
|
||||||
renderLogic.RunRepeatedly(() => ShouldClose);
|
renderLogic.RunRepeatedly(() => ShouldClose);
|
||||||
frameTimeProvider.WaitNextSpan();
|
frameTimeProvider.WaitNextSpan();
|
||||||
Interlocked.Add(ref _frameCount, 1);
|
Interlocked.Add(ref _frameCount, 1);
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ namespace StgSharp.Logic
|
|||||||
ViewPortDesigner designer, (int x, int y, int z) unitCubeSize
|
ViewPortDesigner designer, (int x, int y, int z) unitCubeSize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
View ret = new View(this.context, designer,unitCubeSize);
|
View ret = new View(this.viewPortDisplay, designer,unitCubeSize);
|
||||||
allView.Add(ret);
|
allView.Add(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T BuildRenderStream<T>(View v, (int, int, int) cube) where T : RenderStream
|
public T BuildRenderStream<T>(View view) where T : RenderStream
|
||||||
{
|
{
|
||||||
T ret = Activator.CreateInstance(typeof(T), v.Port, cube) as T ??
|
T ret = Activator.CreateInstance(typeof(T), view.Port, view.UnitCubeSize) as T ??
|
||||||
throw new InvalidOperationException("Cannot build new render stream.");
|
throw new InvalidOperationException("Cannot build new render stream.");
|
||||||
ret.timeProvider = this.frameTimeProvider;
|
ret.timeProvider = this.frameTimeProvider;
|
||||||
ret.InternalInit();
|
ret.InternalInit();
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
using StgSharp.Controlling.UsrActivity;
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Math;
|
using StgSharp.Math;
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ namespace StgSharp.Logic
|
|||||||
|
|
||||||
private int _frameCount;
|
private int _frameCount;
|
||||||
private int _frameSpeed;
|
private int _frameSpeed;
|
||||||
private ViewPort context;
|
private ViewPort viewPortDisplay;
|
||||||
|
|
||||||
internal IntPtr monitor;
|
internal IntPtr monitor;
|
||||||
|
|
||||||
@@ -57,7 +58,11 @@ namespace StgSharp.Logic
|
|||||||
|
|
||||||
protected ViewModelBase(int frameSpeed)
|
protected ViewModelBase(int frameSpeed)
|
||||||
{
|
{
|
||||||
context = new ViewPort();
|
viewPortDisplay = new ViewPort(
|
||||||
|
name: "Hello, Stg#!",
|
||||||
|
size: (800, 600),
|
||||||
|
monitor: IntPtr.Zero
|
||||||
|
);
|
||||||
allView = new List<View>();
|
allView = new List<View>();
|
||||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||||
_frameSpeed = 0;
|
_frameSpeed = 0;
|
||||||
@@ -76,11 +81,12 @@ namespace StgSharp.Logic
|
|||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
_globalKeyAction = new Dictionary<KeyTrigger, Action>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ViewModelBase(ViewPort vbinding, int framespeed)
|
public ViewModelBase(ViewPort vbinding, int framespeed)
|
||||||
{
|
{
|
||||||
context = vbinding;
|
viewPortDisplay = vbinding;
|
||||||
allView = new List<View>();
|
allView = new List<View>();
|
||||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||||
_frameSpeed = 0;
|
_frameSpeed = 0;
|
||||||
@@ -88,10 +94,14 @@ namespace StgSharp.Logic
|
|||||||
fpsCountProvider.SpanRefreshCallback =
|
fpsCountProvider.SpanRefreshCallback =
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine(FrameSpeed);
|
||||||
|
/**/
|
||||||
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
Interlocked.Exchange(ref _frameSpeed, _frameCount);
|
||||||
Interlocked.Exchange(ref _frameCount, 0);
|
Interlocked.Exchange(ref _frameCount, 0);
|
||||||
};
|
};
|
||||||
long frameLength = (FrameSpeed > 0) ? ((1000L * 1000L) / FrameSpeed) : 0;
|
long frameLength = (framespeed > 0) ? ((1000L * 1000L) / framespeed) : 0;
|
||||||
frameTimeProvider = new TimeSpanProvider(
|
frameTimeProvider = new TimeSpanProvider(
|
||||||
frameLength, TimeSpanProvider.DefaultProvider
|
frameLength, TimeSpanProvider.DefaultProvider
|
||||||
);
|
);
|
||||||
@@ -99,6 +109,7 @@ namespace StgSharp.Logic
|
|||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
_globalKeyAction = new Dictionary<KeyTrigger, Action>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
|
public int CurrentFrameCount => frameTimeProvider.CurrentSpan;
|
||||||
@@ -110,19 +121,19 @@ namespace StgSharp.Logic
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Height
|
public int Height
|
||||||
{
|
{
|
||||||
get => context.Height;
|
get => viewPortDisplay.Height;
|
||||||
set { context.Height = value; }
|
set { viewPortDisplay.Height = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
{
|
{
|
||||||
get => context.Name;
|
get => viewPortDisplay.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ShouldClose
|
public bool ShouldClose
|
||||||
{
|
{
|
||||||
get => InternalIO.glfwWindowShouldClose(context.ViewPortID) != 0;
|
get => InternalIO.glfwWindowShouldClose(viewPortDisplay.ViewPortID) != 0;
|
||||||
set => InternalIO.glfwSetWindowShouldClose(context.ViewPortID, value ? 1 : 0);
|
set => InternalIO.glfwSetWindowShouldClose(viewPortDisplay.ViewPortID, value ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -137,7 +148,7 @@ namespace StgSharp.Logic
|
|||||||
Height = (int)value.Y;
|
Height = (int)value.Y;
|
||||||
if (WindowID != IntPtr.Zero)
|
if (WindowID != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
InternalIO.glfwSetWindowSize(context.ViewPortID, Width, Height);
|
InternalIO.glfwSetWindowSize(viewPortDisplay.ViewPortID, Width, Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,20 +158,20 @@ namespace StgSharp.Logic
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int Width
|
public int Width
|
||||||
{
|
{
|
||||||
get => context.Width;
|
get => viewPortDisplay.Width;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
context.Width = value;
|
viewPortDisplay.Width = value;
|
||||||
if (WindowID != IntPtr.Zero)
|
if (WindowID != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
InternalIO.glfwSetWindowSize(context.ViewPortID, Width, Height);
|
InternalIO.glfwSetWindowSize(viewPortDisplay.ViewPortID, Width, Height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe IntPtr WindowID
|
public unsafe IntPtr WindowID
|
||||||
{
|
{
|
||||||
get => context.ViewPortID;
|
get => viewPortDisplay.ViewPortID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -170,7 +181,7 @@ namespace StgSharp.Logic
|
|||||||
set
|
set
|
||||||
{
|
{
|
||||||
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
|
||||||
InternalIO.glfwSetFramebufferSizeCallback(context.ViewPortID, handlerPtr);
|
InternalIO.glfwSetFramebufferSizeCallback(viewPortDisplay.ViewPortID, handlerPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma warning restore CA1044
|
#pragma warning restore CA1044
|
||||||
@@ -186,7 +197,7 @@ namespace StgSharp.Logic
|
|||||||
public void SetSize(vec2d size)
|
public void SetSize(vec2d size)
|
||||||
{
|
{
|
||||||
this.Size = size;
|
this.Size = size;
|
||||||
InternalIO.glfwSetWindowSize(this.context.ViewPortID, (int)size.X, (int)size.Y);
|
InternalIO.glfwSetWindowSize(this.viewPortDisplay.ViewPortID, (int)size.X, (int)size.Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -203,7 +214,7 @@ namespace StgSharp.Logic
|
|||||||
public void SetSizeLimit(vec2d minSize, vec2d maxSize)
|
public void SetSizeLimit(vec2d minSize, vec2d maxSize)
|
||||||
{
|
{
|
||||||
InternalIO.glfwSetWindowSizeLimits(
|
InternalIO.glfwSetWindowSizeLimits(
|
||||||
this.context.ViewPortID,
|
this.viewPortDisplay.ViewPortID,
|
||||||
(int)minSize.X,
|
(int)minSize.X,
|
||||||
(int)minSize.Y,
|
(int)minSize.Y,
|
||||||
(int)maxSize.X,
|
(int)maxSize.X,
|
||||||
@@ -221,7 +232,7 @@ namespace StgSharp.Logic
|
|||||||
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
|
public void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
|
||||||
{
|
{
|
||||||
//TODO 重做form的尺寸极限控制
|
//TODO 重做form的尺寸极限控制
|
||||||
InternalIO.glfwSetWindowSizeLimits(this.context.ViewPortID, minWidth, minHeight, maxWidth, maxHeight);
|
InternalIO.glfwSetWindowSizeLimits(this.viewPortDisplay.ViewPortID, minWidth, minHeight, maxWidth, maxHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Key Control
|
#region Key Control
|
||||||
@@ -243,7 +254,14 @@ namespace StgSharp.Logic
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
protected abstract void BuildGlobalKeyControl();
|
||||||
|
|
||||||
|
private Dictionary<KeyTrigger, Action> _globalKeyAction;
|
||||||
|
|
||||||
|
protected Dictionary<KeyTrigger, Action> GlobalKeyAction
|
||||||
|
{
|
||||||
|
get => _globalKeyAction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,10 +208,5 @@ namespace StgSharp.Stg
|
|||||||
VertexArray.BindNull();
|
VertexArray.BindNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ProcessInput()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c0093f7b5c77291172cde7e3e38beabb126adf08")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be6c2e6b92a328d0b68af669d50e92dd9bbff42b")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
|
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ SSCAPI void SSCDECL initGL(int majorVersion, int minorVersion)
|
|||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, majorVersion);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, majorVersion);
|
||||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minorVersion);
|
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minorVersion);
|
||||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||||
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSCAPI GLFWglproc SSCDECL loadGlfuncDefault(char* procName)
|
SSCAPI GLFWglproc SSCDECL loadGlfuncDefault(char* procName)
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC.dll.lastcodeanalysissucceeded
|
|
||||||
D:\NitloadIndustry\研究项目\1-Flagship\TH2020\ProjectFile\源代码\StgSharpC\x64\Debug\NativeCodeAnalysis.read.1.tlog
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"profiles": {
|
"profiles": {
|
||||||
"StgSharpDebug": {
|
"StgSharpDebug": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"nativeDebugging": true
|
"nativeDebugging": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,9 +84,7 @@ namespace StgSharp
|
|||||||
|
|
||||||
protected override void Init()
|
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(
|
FrameSizeCallback = new FrameBufferSizeHandler(
|
||||||
(window, width, height) =>
|
(window, width, height) =>
|
||||||
@@ -112,8 +110,8 @@ namespace StgSharp
|
|||||||
0.8f, -0.8f, 0,
|
0.8f, -0.8f, 0,
|
||||||
-0.8f, -0.8f, 0
|
-0.8f, -0.8f, 0
|
||||||
);
|
);
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
tex = new Rectangle(
|
tex = new Rectangle(
|
||||||
0f, 1f,
|
0f, 1f,
|
||||||
@@ -200,13 +198,8 @@ namespace StgSharp
|
|||||||
//glFunc.DrawElements(GeometryType.LINES, 6, TypeCode.UInt32, IntPtr.Zero);
|
//glFunc.DrawElements(GeometryType.LINES, 6, TypeCode.UInt32, IntPtr.Zero);
|
||||||
BlueprintPipeline.SkipAll(output);
|
BlueprintPipeline.SkipAll(output);
|
||||||
|
|
||||||
PollEvents();
|
|
||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
}
|
PollEvents();
|
||||||
|
|
||||||
protected override void ProcessInput()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace StgSharp
|
|||||||
|
|
||||||
protected override sealed void Init()
|
protected override sealed void Init()
|
||||||
{
|
{
|
||||||
SetSizeLimit(800, 800, 800, 800);
|
//SetSizeLimit(800, 800, 800, 800);
|
||||||
|
|
||||||
FrameSizeCallback =
|
FrameSizeCallback =
|
||||||
(IntPtr id, uint width, uint height) => glFunc.Viewport(0, 0, width, height);
|
(IntPtr id, uint width, uint height) => glFunc.Viewport(0, 0, width, height);
|
||||||
@@ -219,6 +219,7 @@ namespace StgSharp
|
|||||||
SwapBuffers();
|
SwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
protected override void ProcessInput()
|
protected override void ProcessInput()
|
||||||
{
|
{
|
||||||
float movement = 0.005f;
|
float movement = 0.005f;
|
||||||
@@ -255,6 +256,6 @@ namespace StgSharp
|
|||||||
NativeCamera.Yaw(new Radius(movement));
|
NativeCamera.Yaw(new Radius(movement));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,34 @@
|
|||||||
using StgSharp.Geometries;
|
//-----------------------------------------------------------------------
|
||||||
|
//-----------------------------------------------------------------------
|
||||||
|
// file="Particle.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.Geometries;
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Graphics.GL;
|
using StgSharp.Graphics.GL;
|
||||||
using StgSharp.Logic;
|
using StgSharp.Logic;
|
||||||
@@ -16,7 +46,21 @@ namespace StgSharp
|
|||||||
{
|
{
|
||||||
public class ParticleStream : glRenderStream
|
public class ParticleStream : glRenderStream
|
||||||
{
|
{
|
||||||
public ParticleStream(ViewPort args, (int,int,int) cube) : base(args, (100,100,100))
|
|
||||||
|
ElementBuffer ebo;
|
||||||
|
|
||||||
|
FrameBuffer fbo;
|
||||||
|
Image i;
|
||||||
|
PlainInstancingBuffer<ParticleOnPlain> buffer;
|
||||||
|
RenderBuffer rbo;
|
||||||
|
|
||||||
|
ShaderProgram s;
|
||||||
|
|
||||||
|
TextureGL t;
|
||||||
|
VertexArray vao;
|
||||||
|
VertexBuffer vbo;
|
||||||
|
|
||||||
|
public ParticleStream(ViewPort args, (int, int, int) cube) : base(args, (100, 100, 100))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,46 +68,36 @@ namespace StgSharp
|
|||||||
|
|
||||||
protected override string[] OutputPortsName => ["output_1"];
|
protected override string[] OutputPortsName => ["output_1"];
|
||||||
|
|
||||||
protected override void Deinit()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
ShaderProgram s;
|
|
||||||
PlainInstancingBuffer<ParticleOnPlain> buffer;
|
|
||||||
VertexBuffer vbo;
|
|
||||||
VertexArray vao;
|
|
||||||
ElementBuffer ebo;
|
|
||||||
|
|
||||||
FrameBuffer fbo;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
internal static vec3d DefaultRotation(TimeSpanProvider provider, out float rotation)
|
internal static vec3d DefaultRotation(TimeSpanProvider provider, out float rotation)
|
||||||
{
|
{
|
||||||
rotation = 0.1f;
|
rotation = 0.1f;
|
||||||
float angle = provider.CurrentSpan * 0.1f;
|
float angle = provider.CurrentSpan * 0.1f;
|
||||||
return new vec3d(
|
return new vec3d(
|
||||||
0.01f * Scaler.Cos(angle),
|
0.01f * Scaler.Cos(angle),
|
||||||
- 0.01f * Scaler.Sin(angle),
|
(-0.01f) * Scaler.Sin(angle),
|
||||||
0
|
0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Deinit()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Init()
|
protected override void Init()
|
||||||
{
|
{
|
||||||
buffer = new PlainInstancingBuffer<ParticleOnPlain>();
|
buffer = new PlainInstancingBuffer<ParticleOnPlain>();
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
{
|
{
|
||||||
float ai =Scaler.Abs(i - 5.0f);
|
float ai = Scaler.Abs(i - 5.0f);
|
||||||
for (int t = 0; t < 10; t++)
|
for (int t = 0; t < 10; t++)
|
||||||
{
|
{
|
||||||
float at = Scaler.Abs(t - 5.0f);
|
float at = Scaler.Abs(t - 5.0f);
|
||||||
|
|
||||||
ParticleOnPlain p = new ParticleOnPlain(buffer);
|
ParticleOnPlain p = new ParticleOnPlain(buffer);
|
||||||
((IInstancing)p).Coord = new vec3d(
|
((IInstancing)p).Coord = new vec3d(
|
||||||
(-5 + i) * 0.2f + 0.1f, (-5 + t) * 0.2f + 0.1f, 0);
|
(((-5) + i) * 0.2f) + 0.1f, (((-5) + t) * 0.2f) + 0.1f, 0);
|
||||||
((IInstancing)p).Scale =
|
((IInstancing)p).Scale =
|
||||||
Scaler.MinOf(i, t) * 0.15f;
|
Scaler.MinOf(i, t) * 0.15f;
|
||||||
((IInstancing)p).Motion = new GeometryMotion(
|
((IInstancing)p).Motion = new GeometryMotion(
|
||||||
true, this.timeProvider,
|
true, this.timeProvider,
|
||||||
@@ -72,19 +106,19 @@ namespace StgSharp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSizeLimit(800, 800, 800, 800);
|
//SetSizeLimit(800, 800, 800, 800);
|
||||||
|
|
||||||
FrameSizeCallback =
|
FrameSizeCallback =
|
||||||
(IntPtr id, uint width, uint height) => glFunc.Viewport(0, 0, width, height);
|
(IntPtr id, uint width, uint height) => glFunc.Viewport(0, 0, width, height);
|
||||||
|
|
||||||
s = CreateShaderProgram();
|
s = CreateShaderProgram();
|
||||||
Shader pvs = CreateShaderSegment(ShaderType.Vertex ,1);
|
Shader pvs = CreateShaderSegment(ShaderType.Vertex, 1);
|
||||||
Shader pfs = CreateShaderSegment(ShaderType.Fragment ,1);
|
Shader pfs = CreateShaderSegment(ShaderType.Fragment, 1);
|
||||||
|
|
||||||
pvs.Compile(0, Shader.FromCodeFile("Shader\\particle.vert"));
|
pvs.Compile(0, Shader.FromCodeFile("Shader\\particle.vert"));
|
||||||
pvs.AttachTo(0,s);
|
pvs.AttachTo(0, s);
|
||||||
pfs.Compile(0, Shader.FromCodeFile("Shader\\particle.frag"));
|
pfs.Compile(0, Shader.FromCodeFile("Shader\\particle.frag"));
|
||||||
pfs.AttachTo(0,s);
|
pfs.AttachTo(0, s);
|
||||||
s.Link();
|
s.Link();
|
||||||
|
|
||||||
vbo = CreateVertexBuffer(3);
|
vbo = CreateVertexBuffer(3);
|
||||||
@@ -94,18 +128,18 @@ namespace StgSharp
|
|||||||
|
|
||||||
Rectangle rec = new Rectangle
|
Rectangle rec = new Rectangle
|
||||||
(
|
(
|
||||||
0.05f,0.05f,
|
0.05f, 0.05f,
|
||||||
0.05f,-0.05f,
|
0.05f, -0.05f,
|
||||||
-0.05f,-0.05f,
|
-0.05f, -0.05f,
|
||||||
-0.05f,0.05f
|
-0.05f, 0.05f
|
||||||
);
|
);
|
||||||
|
|
||||||
vao.Bind(0);
|
vao.Bind(0);
|
||||||
vbo.WriteVectorData(0, rec.VertexStream, BufferUsage.StaticDraw);
|
vbo.WriteVectorData(0, rec.VertexStream, BufferUsage.StaticDraw);
|
||||||
ebo.SetValue(0, rec.VertexIndices, BufferUsage.StaticDraw);
|
ebo.SetValue(0, rec.VertexIndices, BufferUsage.StaticDraw);
|
||||||
VertexArray.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float),0);
|
VertexArray.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||||
|
|
||||||
vbo.WriteVectorData<vec4d>(1, buffer.CoordAndRotationSpan,BufferUsage.StreamDraw);
|
vbo.WriteVectorData<vec4d>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw);
|
||||||
VertexArray.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
VertexArray.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
|
||||||
VertexArray.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
|
VertexArray.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
|
||||||
|
|
||||||
@@ -113,23 +147,23 @@ namespace StgSharp
|
|||||||
glFunc.VertexAttributeDivisor(2, 1);
|
glFunc.VertexAttributeDivisor(2, 1);
|
||||||
|
|
||||||
vbo.WriteScalerData<float>(2, buffer.ScalingSpan, BufferUsage.StaticDraw);
|
vbo.WriteScalerData<float>(2, buffer.ScalingSpan, BufferUsage.StaticDraw);
|
||||||
VertexArray.SetVertexAttribute(3,1,TypeCode.Single,false,sizeof(float),0);
|
VertexArray.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0);
|
||||||
|
|
||||||
glFunc.VertexAttributeDivisor(3, 1);
|
glFunc.VertexAttributeDivisor(3, 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vbo.Unbind();
|
vbo.Unbind();
|
||||||
VertexArray.BindNull();
|
VertexArray.BindNull();
|
||||||
|
|
||||||
NativeCameraViewTarget
|
NativeCameraViewTarget
|
||||||
(
|
(
|
||||||
(0,0,-100),
|
(0, 0, -100),
|
||||||
(0,0,0),
|
(0, 0, 0),
|
||||||
(0,1,0)
|
(0, 1, 0)
|
||||||
);
|
);
|
||||||
NativeCameraViewRange(new Degree(1.5f),Vec2d.Zero,(50,50));
|
NativeCameraViewRange(new Degree(1.5f), Vec2d.Zero, (50, 50));
|
||||||
NativeCameraUniform(s,"Camera");
|
NativeCameraUniform(s, "Camera");
|
||||||
|
|
||||||
s.Use();
|
s.Use();
|
||||||
fbo = CreateFrameBuffer(1);
|
fbo = CreateFrameBuffer(1);
|
||||||
@@ -143,62 +177,63 @@ namespace StgSharp
|
|||||||
|
|
||||||
t = CreateTexture(1);
|
t = CreateTexture(1);
|
||||||
t.Bind2D(0);
|
t.Bind2D(0);
|
||||||
|
/**/
|
||||||
glFunc.TextureImage2d(Texture2DTarget.Texture2D, 0, (int)ImageChannel.WithAlphaChannel,
|
glFunc.TextureImage2d(Texture2DTarget.Texture2D, 0, (int)ImageChannel.WithAlphaChannel,
|
||||||
(uint)Width, (uint)Height, (int)ImageChannel.WithAlphaChannel, ImageChannelLayout.Byte, glHandle.ZeroHandle);
|
(uint)Width, (uint)Height, (int)ImageChannel.WithAlphaChannel, ImageChannelLayout.Byte, glHandle.ZeroHandle);
|
||||||
|
/**/
|
||||||
t.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
|
t.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
|
||||||
t.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
|
t.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
|
||||||
|
|
||||||
|
|
||||||
glFunc.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
|
glFunc.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
|
||||||
Texture2DTarget.Texture2D,t[0],0);
|
Texture2DTarget.Texture2D, t[0], 0);
|
||||||
|
|
||||||
glFunc.CombineFrameBufferRenderBuffer(fbo[0], rbo[0]);
|
glFunc.CombineFrameBufferRenderBuffer(fbo[0], rbo[0]);
|
||||||
|
|
||||||
int streamLength = this.Width * this.Height * 4;
|
int streamLength = this.Width * this.Height * 4;
|
||||||
byte[] imageStream = new byte[streamLength];
|
byte[] imageStream = new byte[streamLength];
|
||||||
i = Image.FromMemory(this.Size,4,imageStream);
|
i = Image.FromMemory(this.Size, 4, imageStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureGL t;
|
|
||||||
RenderBuffer rbo;
|
|
||||||
Image i;
|
|
||||||
|
|
||||||
protected override void Main(
|
protected override void Main(
|
||||||
in Dictionary<string, BlueprintPipeline> input,
|
in Dictionary<string, BlueprintPipeline> input,
|
||||||
in Dictionary<string, BlueprintPipeline> output)
|
in Dictionary<string, BlueprintPipeline> output)
|
||||||
{
|
{
|
||||||
|
//Console.WriteLine($"{Width} {Height}");
|
||||||
buffer.UpdateAllParticles();
|
buffer.UpdateAllParticles();
|
||||||
|
|
||||||
fbo.Bind(0);
|
fbo.Bind(0);
|
||||||
vao.Bind(0);
|
vao.Bind(0);
|
||||||
|
t.Bind2D(0);
|
||||||
|
/**/
|
||||||
|
glFunc.TextureImage2d(Texture2DTarget.Texture2D, 0, (int)ImageChannel.WithAlphaChannel,
|
||||||
|
(uint)Width, (uint)Height, (int)ImageChannel.WithAlphaChannel, ImageChannelLayout.Byte, glHandle.ZeroHandle);
|
||||||
|
/**/
|
||||||
|
|
||||||
|
glFunc.ClearColor(0.6f, 0.1f, 0.3f, 1);
|
||||||
glFunc.ClearColor(0.6f,0.1f,0.3f,1);
|
|
||||||
glFunc.Clear(MaskBufferBit.COLOR | MaskBufferBit.DEPTH);
|
glFunc.Clear(MaskBufferBit.COLOR | MaskBufferBit.DEPTH);
|
||||||
|
|
||||||
vbo.Bind(1);
|
vbo.Bind(1);
|
||||||
vbo.WriteVectorData<vec4d>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw);
|
vbo.WriteVectorData<vec4d>(1, buffer.CoordAndRotationSpan, BufferUsage.StreamDraw);
|
||||||
|
|
||||||
s.Use();
|
|
||||||
|
|
||||||
|
s.Use();
|
||||||
NativeCamera.SetAllUniforms();
|
NativeCamera.SetAllUniforms();
|
||||||
|
|
||||||
glFunc.DrawElementsInstanced(
|
glFunc.DrawElementsInstanced(
|
||||||
GeometryType.TRIANGLES, 6, TypeCode.UInt32,IntPtr.Zero,100
|
GeometryType.TRIANGLES, 6, TypeCode.UInt32, IntPtr.Zero, 100
|
||||||
);
|
);
|
||||||
glFunc.WaitAccomplishment();
|
glFunc.WaitAccomplishment();
|
||||||
VertexArray.BindNull();
|
VertexArray.BindNull();
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
t.Bind2D(0);
|
ImageProcessor.Resize(i, this.Width, this.Height, ImageMovement.Discard);
|
||||||
|
|
||||||
glFunc.GetTextureImage(Texture2DTarget.Texture2D, 0,ImageChannel.WithAlphaChannel,
|
glFunc.GetTextureImage(Texture2DTarget.Texture2D, 0, ImageChannel.WithAlphaChannel,
|
||||||
ImageChannelLayout.Byte,ref i.data);
|
ImageChannelLayout.Byte, ref i.data);
|
||||||
|
|
||||||
//Array.Fill<byte>(i.DataStream, 24);
|
//Array.Fill<byte>(i.DataStream, 24);
|
||||||
output["output_1"].CompleteAndWriteData( new TexturePipeline(i));
|
output["output_1"].CompleteAndWriteData(new TexturePipeline(i));
|
||||||
FrameBuffer.BindNull();
|
FrameBuffer.BindNull();
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
@@ -209,12 +244,5 @@ namespace StgSharp
|
|||||||
/**/
|
/**/
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ProcessInput()
|
|
||||||
{
|
|
||||||
if (CheckKey(KeyboardKey.ESCAPE) == KeyStatus.PRESS)
|
|
||||||
{
|
|
||||||
InternalIO.glfwSetWindowShouldClose(CanvasHandle, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
//using StgSharp.Environment.Win32;
|
//using StgSharp.Environment.Win32;
|
||||||
|
using StgSharp.Controlling.UsrActivity;
|
||||||
using StgSharp.Geometries;
|
using StgSharp.Geometries;
|
||||||
using StgSharp.Graphics;
|
using StgSharp.Graphics;
|
||||||
using StgSharp.Logic;
|
using StgSharp.Logic;
|
||||||
@@ -18,18 +19,13 @@ namespace StgSharp
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Beep()
|
protected sealed override void BuildGlobalKeyControl()
|
||||||
{
|
{
|
||||||
if (CurrentFrameCount%60==0)
|
GlobalKeyAction.Add(
|
||||||
{
|
new KeyTrigger(KeyboardKey.ESCAPE,KeyStatus.PRESS),
|
||||||
Console.Beep();
|
new Action(() => {
|
||||||
}
|
InternalIO.glfwSetWindowShouldClose(this.WindowID, 1);
|
||||||
}
|
}));
|
||||||
|
|
||||||
//[RenderActivity(RenderPriority.Pre_1)]
|
|
||||||
public void NoOp()
|
|
||||||
{
|
|
||||||
int a = 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,12 +42,12 @@ namespace StgSharp
|
|||||||
StgSharp.InitGL(4, 6);
|
StgSharp.InitGL(4, 6);
|
||||||
StgSharp.GlobalSetting.VSyncActivated = false;
|
StgSharp.GlobalSetting.VSyncActivated = false;
|
||||||
|
|
||||||
ViewPort vp = new ViewPort(
|
ViewPort viewport = new ViewPort(
|
||||||
name: "Hello, Stg#!",
|
name: "Hello, Stg#!",
|
||||||
size: (800,600),
|
size: (800,800),
|
||||||
monitor: IntPtr.Zero
|
monitor: IntPtr.Zero
|
||||||
);
|
);
|
||||||
StgSharpDemoForm demoForm = new StgSharpDemoForm(vp,60);
|
StgSharpDemoForm demoForm = new StgSharpDemoForm(vp: viewport,60);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -61,15 +57,15 @@ namespace StgSharp
|
|||||||
//<MainRenderStream>
|
//<MainRenderStream>
|
||||||
//<ParticleStream>
|
//<ParticleStream>
|
||||||
<fboFrame>
|
<fboFrame>
|
||||||
(v, (1,1,1));
|
(v);
|
||||||
|
|
||||||
var rstream = RenderStream.ShareContextWith
|
var rstream = RenderStream.ShareContextWith
|
||||||
<fboFrame,ParticleStream>(stream);
|
<fboFrame,ParticleStream>(stream);
|
||||||
Console.WriteLine(1);
|
|
||||||
Blueprint blueprint = new Blueprint();
|
Blueprint blueprint = new Blueprint();
|
||||||
|
|
||||||
BlueprintNode node0 = new BlueprintNode("BufferGenerateStream", rstream);
|
BlueprintNode node0 = new BlueprintNode("BufferGenerateStream", rstream);
|
||||||
BlueprintNode node1 = new BlueprintNode("MainRenderStream",stream);
|
BlueprintNode node1 = new BlueprintNode("MainRenderStream",stream);
|
||||||
|
|
||||||
node0.AddAfter(blueprint.BeginLayer,
|
node0.AddAfter(blueprint.BeginLayer,
|
||||||
"input_1", "input_1");
|
"input_1", "input_1");
|
||||||
node0.AddBefore(node1,
|
node0.AddBefore(node1,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharpDebug")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c0093f7b5c77291172cde7e3e38beabb126adf08")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be6c2e6b92a328d0b68af669d50e92dd9bbff42b")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
|
[assembly: System.Reflection.AssemblyProductAttribute("StgSharpDebug")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharpDebug")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/c0093f7b5c77291172cde7e3e38beabb126adf08/*"}}
|
{"documents":{"D:\\NitloadIndustry\\研究项目\\1-Flagship\\TH2020\\ProjectFile\\*":"https://raw.githubusercontent.com/Nitload-NSI/CCD_Github/be6c2e6b92a328d0b68af669d50e92dd9bbff42b/*"}}
|
||||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgsharpEnvDebug")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("StgsharpEnvDebug")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c0093f7b5c77291172cde7e3e38beabb126adf08")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+be6c2e6b92a328d0b68af669d50e92dd9bbff42b")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("StgsharpEnvDebug")]
|
[assembly: System.Reflection.AssemblyProductAttribute("StgsharpEnvDebug")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgsharpEnvDebug")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("StgsharpEnvDebug")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
Reference in New Issue
Block a user