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;
///
/// Render logic for every frame with no relation to .
///
public Blueprint GeneralRenderLogic
{
get => renderLogic;
set => renderLogic = value;
}
///
/// Init this form and render it on screen, and respond with operation
///
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);
RenderStream.PollEvents();
frameTimeProvider.WaitNextSpan();
Interlocked.Add(ref _frameCount, 1);
}
}
private unsafe void PrivateShow()
{
if(0 == InternalIO.glfwWindowShouldClose(this.viewPortDisplay.ViewPortID))
{
frameTimeProvider.WaitNextSpan();
Interlocked.Add(ref _frameCount, 1);
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);
RenderStream.PollEvents();
}
}
public T BuildNewRenderStream(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;
}
}
}