42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using StgSharp.Graphics;
|
|
using StgSharp.Graphics.OpenGL;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel.Design;
|
|
using System.Text;
|
|
|
|
namespace StgSharp.Logic
|
|
{
|
|
public partial class ViewModelBase
|
|
{
|
|
private Dictionary<string,View> allView;
|
|
|
|
public T BuildNewView<T>(string name,(int x, int y, int z) unitCubeSize)
|
|
where T : View,new()
|
|
{
|
|
var ret = new T();
|
|
ret.SelfName = name;
|
|
ret.InternalInitialize(this);
|
|
allView.Add(name, ret);
|
|
return ret;
|
|
}
|
|
|
|
public T BuildRenderStream<T>(View view) where T : RenderStream
|
|
{
|
|
#nullable enable
|
|
T? ret = Activator.CreateInstance(typeof(T), view.Port, view.UnitCubeSize) as T;
|
|
#nullable restore
|
|
if (ret == null)
|
|
{
|
|
throw new InvalidOperationException(
|
|
$"Failed in creating a new {typeof(T).Name} instance when calling ShareContextWith."
|
|
);
|
|
}
|
|
ret.timeProvider = this.frameTimeProvider;
|
|
ret.PlatformSpecifiedInit();
|
|
return ret;
|
|
}
|
|
}
|
|
}
|