68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using StgSharp.Graphics;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Threading;
|
|
|
|
namespace StgSharp.Logic
|
|
{
|
|
public abstract partial class ViewModelBase
|
|
{
|
|
public void ShowViewPort()
|
|
{
|
|
|
|
}
|
|
|
|
private Blueprint renderLogic;
|
|
|
|
/// <summary>
|
|
/// Render logic for every frame with no relation to <see cref="View"/>.
|
|
/// </summary>
|
|
public Blueprint GeneralRenderLogic
|
|
{
|
|
get => renderLogic;
|
|
set => renderLogic = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Init this form and render it on screen, and respond with operation
|
|
/// </summary>
|
|
public unsafe void Show()
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
BlueprintRunner.Run(renderLogic, ()=>ShouldClose);
|
|
frameTimeProvider.WaitNextSpan();
|
|
Interlocked.Add(ref _frameCount, 1);
|
|
}
|
|
}
|
|
|
|
public T BuildNewRenderStream<T>(View arg, (int x, int y, int z) unitCubeSize) where T : RenderStream
|
|
{
|
|
if (arg.ContextName == this.Name)
|
|
{
|
|
|
|
}
|
|
T? ret = Activator.CreateInstance(typeof(T), arg) as T;
|
|
if (ret == null)
|
|
{
|
|
throw new InvalidOperationException("Failed in building a new RenderStream when calling AsMainStreamOf");
|
|
}
|
|
ret!.InternalInit();
|
|
ret.timeProvider = this.frameTimeProvider;
|
|
return ret;
|
|
}
|
|
}
|
|
}
|