MVVM frame work done, under unit test
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Graphics.GL;
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
@@ -43,30 +43,18 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public abstract class RenderStream : IConvertableToBlueprintNode
|
||||
public abstract class RenderStream
|
||||
{
|
||||
|
||||
private protected (int x, int y, int z) _coordStretch;
|
||||
|
||||
private Camera nativeCamera;
|
||||
|
||||
private ViewPort primeArgs;
|
||||
private protected ViewPort primeArgs;
|
||||
|
||||
internal TimeSpanProvider timeProvider;
|
||||
|
||||
|
||||
public RenderStream(ViewPort v, (int, int, int) unitCubeSize)
|
||||
{
|
||||
if (v == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(v));
|
||||
}
|
||||
primeArgs = v;
|
||||
|
||||
_coordStretch = unitCubeSize;
|
||||
nativeCamera = new Camera();
|
||||
}
|
||||
|
||||
public (int width, int height) Size
|
||||
{
|
||||
get => (Width, Height);
|
||||
@@ -78,12 +66,6 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public string[] InputInterfacesName => InputPortsName;
|
||||
|
||||
public string[] OutputInterfacesName => OutputPortsName;
|
||||
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => primeArgs.Height;
|
||||
@@ -102,6 +84,11 @@ namespace StgSharp.Graphics
|
||||
internal set => primeArgs.Monitor = value;
|
||||
}
|
||||
|
||||
public abstract bool IsContextSharable
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => primeArgs.Name;
|
||||
@@ -131,10 +118,13 @@ namespace StgSharp.Graphics
|
||||
get => timeProvider.CurrentSpan;
|
||||
}
|
||||
|
||||
protected abstract string[] InputPortsName { get; }
|
||||
protected abstract string[] OutputPortsName { get; }
|
||||
|
||||
protected float TimePassed
|
||||
{
|
||||
get => timeProvider.CurrentSecond;
|
||||
}
|
||||
|
||||
protected float FramePassed
|
||||
{
|
||||
get => timeProvider.CurrentSpan;
|
||||
}
|
||||
@@ -154,7 +144,7 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public abstract void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight);
|
||||
|
||||
public static TTarget ShareContextWith<TSource, TTarget>(TSource source)
|
||||
public static TTarget ShareContextFrom<TSource, TTarget>(TSource source)
|
||||
where TSource : RenderStream
|
||||
where TTarget : RenderStream
|
||||
{
|
||||
@@ -168,15 +158,10 @@ namespace StgSharp.Graphics
|
||||
);
|
||||
}
|
||||
target.timeProvider = source.timeProvider;
|
||||
target.InternalInit();
|
||||
target.PlatformSpecifiedInit();
|
||||
return target;
|
||||
}
|
||||
|
||||
public void ExecuteMain(in Dictionary<string, BlueprintPipeline> input, in Dictionary<string, BlueprintPipeline> output)
|
||||
{
|
||||
InternalDraw(in input, in output);
|
||||
}
|
||||
|
||||
internal protected static void PollEvents()
|
||||
{
|
||||
InternalIO.glfwPollEvents();
|
||||
@@ -191,7 +176,7 @@ namespace StgSharp.Graphics
|
||||
protected abstract void NativeCameraViewRange(Radius fieldOfRange, vec2d offset, (float frontDepth, float backDepth) viewDepth);
|
||||
protected abstract void NativeCameraViewTarget(vec3d position, vec3d direction, vec3d up);
|
||||
/// <summary>
|
||||
/// Get <see cref="Uniform{T}"/>(T is <see cref="Matrix44"/>) uniform from a shader.
|
||||
/// Get <see cref="Uniform{T}"/>(TView is <see cref="Matrix44"/>) uniform from a shader.
|
||||
/// This uniform will be used as projection matrix of this camera.
|
||||
/// Additionally, for multi-shader rendering, each shader requires a uniform,
|
||||
/// so do not ignore return value of this method.
|
||||
@@ -199,26 +184,38 @@ namespace StgSharp.Graphics
|
||||
/// <param name="source">Shader using this camera</param>
|
||||
/// <param name="name">ContextName of projection camera named in shader</param>
|
||||
/// <returns>
|
||||
/// <see cref="Uniform{T}"/>(T is <see cref="Matrix44"/>) representing
|
||||
/// <see cref="Uniform{T}"/>(TView is <see cref="Matrix44"/>) representing
|
||||
/// projection matrix in shader program.
|
||||
/// </returns>
|
||||
protected abstract Uniform<Matrix44> NativeCameraUniform(ShaderProgram source, string name);
|
||||
#endregion
|
||||
|
||||
#region internal operation
|
||||
internal abstract void InternalDraw(
|
||||
in Dictionary<string, BlueprintPipeline> input,
|
||||
in Dictionary<string, BlueprintPipeline> output);
|
||||
internal abstract void InternalInit();
|
||||
internal abstract void InternalTerminate();
|
||||
internal abstract void Draw();
|
||||
|
||||
public void Init(ViewPort v, (int, int, int) unitCubeSize)
|
||||
{
|
||||
if (v == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(v));
|
||||
}
|
||||
primeArgs = v;
|
||||
|
||||
_coordStretch = unitCubeSize;
|
||||
nativeCamera = new Camera();
|
||||
PlatformSpecifiedInit();
|
||||
CustomizeInit();
|
||||
}
|
||||
|
||||
internal abstract void PlatformSpecifiedInit();
|
||||
|
||||
internal abstract void Terminate();
|
||||
#endregion
|
||||
|
||||
#region public operation
|
||||
protected abstract void Deinit();
|
||||
protected abstract void Init();
|
||||
protected abstract void Main(
|
||||
in Dictionary<string, BlueprintPipeline> input,
|
||||
in Dictionary<string, BlueprintPipeline> output);
|
||||
protected abstract void CustomizeDeinit();
|
||||
protected abstract void CustomizeInit();
|
||||
protected abstract void Main();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user