MVVM rebuild complete
This commit is contained in:
@@ -31,6 +31,8 @@
|
||||
using StgSharp.Graphics.OpenGL;
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
using StgSharp.MVVM;
|
||||
using StgSharp.MVVM.View;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -45,16 +47,11 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public abstract class RenderStream
|
||||
{
|
||||
|
||||
private protected (int x, int y, int z) _coordStretch;
|
||||
|
||||
private Camera nativeCamera;
|
||||
|
||||
private protected ViewPort primeArgs;
|
||||
|
||||
internal TimeSpanProvider timeProvider;
|
||||
internal TimeSpanProvider _timeProvider;
|
||||
|
||||
|
||||
public (int width, int height) Size
|
||||
{
|
||||
get => (Width, Height);
|
||||
@@ -96,8 +93,11 @@ namespace StgSharp.Graphics
|
||||
|
||||
public vec2d GlobalCoordSize => ((Width * 1.0f) / _coordStretch.x, (Height * 1.0f) / _coordStretch.y);
|
||||
|
||||
public ViewPort Port => primeArgs;
|
||||
|
||||
public ViewPort Port
|
||||
{
|
||||
get => primeArgs;
|
||||
internal set => primeArgs = value;
|
||||
}
|
||||
internal IntPtr CanvasHandle { get => primeArgs.ViewPortID; }
|
||||
|
||||
|
||||
@@ -113,25 +113,24 @@ namespace StgSharp.Graphics
|
||||
internal set => nativeCamera = value;
|
||||
}
|
||||
|
||||
protected int Frames
|
||||
protected int PassedFrames
|
||||
{
|
||||
get => timeProvider.CurrentSpan;
|
||||
get => _timeProvider.CurrentSpan;
|
||||
}
|
||||
|
||||
|
||||
protected float TimePassed
|
||||
{
|
||||
get => timeProvider.CurrentSecond;
|
||||
get => _timeProvider.CurrentSecond;
|
||||
}
|
||||
|
||||
protected float FramePassed
|
||||
{
|
||||
get => timeProvider.CurrentSpan;
|
||||
get => _timeProvider.CurrentSpan;
|
||||
}
|
||||
|
||||
protected TimeSpanProvider TimeProvider
|
||||
{
|
||||
get => timeProvider;
|
||||
get => _timeProvider;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -146,19 +145,10 @@ namespace StgSharp.Graphics
|
||||
|
||||
public static TTarget ShareContextFrom<TSource, TTarget>(TSource source)
|
||||
where TSource : RenderStream
|
||||
where TTarget : RenderStream
|
||||
where TTarget : RenderStream, new()
|
||||
{
|
||||
#nullable enable
|
||||
TTarget? target = Activator.CreateInstance(typeof(TTarget), source.primeArgs, source._coordStretch) as TTarget;
|
||||
#nullable restore
|
||||
if (target == null)
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Failed in creating a new {typeof(TTarget).Name} instance when calling ShareContextWith."
|
||||
);
|
||||
}
|
||||
target.timeProvider = source.timeProvider;
|
||||
target.PlatformSpecifiedInit();
|
||||
TTarget target = new TTarget();
|
||||
target.Initialize(source.Port,source._coordStretch,source._timeProvider);
|
||||
return target;
|
||||
}
|
||||
|
||||
@@ -175,6 +165,7 @@ namespace StgSharp.Graphics
|
||||
#region native camera operation
|
||||
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}"/>(TView is <see cref="Matrix44"/>) uniform from a shader.
|
||||
/// This uniform will be used as projection matrix of this camera.
|
||||
@@ -193,21 +184,21 @@ namespace StgSharp.Graphics
|
||||
#region internal operation
|
||||
internal abstract void Draw();
|
||||
|
||||
public void Init(ViewPort v, (int, int, int) unitCubeSize)
|
||||
public void Initialize(ViewPort v, (int, int, int) unitCubeSize, TimeSpanProvider timeProvider)
|
||||
{
|
||||
if (v == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(v));
|
||||
}
|
||||
primeArgs = v;
|
||||
|
||||
this._timeProvider = timeProvider;
|
||||
_coordStretch = unitCubeSize;
|
||||
nativeCamera = new Camera();
|
||||
PlatformSpecifiedInit();
|
||||
PlatformSpecifiedInitialize();
|
||||
CustomizeInit();
|
||||
}
|
||||
|
||||
internal abstract void PlatformSpecifiedInit();
|
||||
internal abstract void PlatformSpecifiedInitialize();
|
||||
|
||||
internal abstract void Terminate();
|
||||
#endregion
|
||||
@@ -226,7 +217,6 @@ namespace StgSharp.Graphics
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user