daily update on 20240828 by nitload youmu, autotexture added

This commit is contained in:
Nitload
2024-08-28 10:58:31 +08:00
parent d082071f2d
commit 1ee4e4a42f
586 changed files with 60910 additions and 123106 deletions
@@ -0,0 +1,62 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="OpenGLControllingItemRenderStream.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics.OpenGL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.MVVM
{
public class OpenGLControllingItemRenderStream : glRenderStream
{
public override bool IsContextSharable => true;
protected override void CustomizeDeinit()
{
throw new NotImplementedException();
}
protected override void CustomizeInit()
{
throw new NotImplementedException();
}
protected override void Main()
{
throw new NotImplementedException();
}
}
}
+4 -4
View File
@@ -29,7 +29,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Logic;
using StgSharp.Timing;
using StgSharp.Math;
using StgSharp.MVVM.ViewModel;
@@ -155,7 +155,7 @@ namespace StgSharp.MVVM.View
return InternalIO.glfwGetKey(context.ViewPortID, (int)key);
}
public void InternalInitialize(string name,(int,int,int) cubeSize, ViewModelBase viewModelBinding)
public void InternalInitialize(string name, (int, int, int) cubeSize, ViewModelBase viewModelBinding)
{
SelfName = name;
unitCubeSize = cubeSize;
@@ -175,7 +175,7 @@ namespace StgSharp.MVVM.View
if (!ValidateInitialization())
{
throw new InvalidOperationException("This view is not correctly initialized before rendering.");
}
}
}
Show();
}
@@ -183,7 +183,7 @@ namespace StgSharp.MVVM.View
public bool ValidateInitialization()
{
return (_design != null) && (_render != null) && (getDataBindingEntry != null) && (_responder != null)
&& (_design.ValidateInitializing()) && (_responder.ValidateInitializing()) && (_render.ValidateInitializing())
&& _design.ValidateInitializing() && _responder.ValidateInitializing() && _render.ValidateInitializing()
;
}
+3 -3
View File
@@ -46,9 +46,9 @@ namespace StgSharp.MVVM.View
{
public interface IViewDesigner<out TView> where TView : ViewBase
{
abstract void Initialize();
abstract void CustomizedInitialize();
abstract void Initialize();
abstract bool ValidateInitializing();
@@ -128,13 +128,13 @@ namespace StgSharp.MVVM.View
return ret;
}
public abstract void CustomizedInitialize();
public void Initialize()
{
CustomizedInitialize();
}
public abstract void CustomizedInitialize();
public abstract bool ValidateInitializing();
}//---------------------------------- End of Class -----------------------------------------
+15 -14
View File
@@ -29,7 +29,7 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Logic;
using StgSharp.Math;
using StgSharp.MVVM.ViewModel;
@@ -65,11 +65,6 @@ namespace StgSharp.MVVM.View
where TView : ViewBase
{
#pragma warning disable CS8618
private Dictionary<string, RenderStream> _render;
private TView _binding;
#pragma warning restore CS8618
protected ViewRender(TView binding)
{
_binding = binding;
@@ -77,7 +72,7 @@ namespace StgSharp.MVVM.View
public RenderStream this[string renderName]
{
get => _render.TryGetValue(renderName, out RenderStream stream) ? stream : null!;
get => _render.TryGetValue(renderName, out RenderStream stream) ? stream : (null!);
protected set
{
@@ -105,13 +100,6 @@ namespace StgSharp.MVVM.View
protected ViewResponder<TView> Responder => (_binding.Responder as ViewResponder<TView>)!;
public T CreateRenderStream<T>(ViewPort vp, (int x, int y, int z) unitCubeSize) where T : RenderStream, new()
{
T ret = new T();
ret.Initialize(vp, unitCubeSize, Binding.TimeProvider);
return ret;
}
public T CreateRenderStream<T>((int x, int y, int z) unitCubeSize) where T : RenderStream, new()
{
T ret = new T();
@@ -119,6 +107,13 @@ namespace StgSharp.MVVM.View
return ret;
}
public T CreateRenderStream<T>(ViewPort vp, (int x, int y, int z) unitCubeSize) where T : RenderStream, new()
{
T ret = new T();
ret.Initialize(vp, unitCubeSize, Binding.TimeProvider);
return ret;
}
public abstract void CustomizedInitialize();
public void Initialize()
@@ -128,6 +123,12 @@ namespace StgSharp.MVVM.View
public abstract bool ValidateInitializing();
#pragma warning disable CS8618
private Dictionary<string, RenderStream> _render;
private TView _binding;
#pragma warning restore CS8618
}
}
}
+15 -15
View File
@@ -47,12 +47,12 @@ namespace StgSharp.MVVM.View
void CustomizedInitialize(Func<ITrigger, string, Action> keyRegister);
void Initialize(Func<string, Action> keyGetter);
void ProcessUserInput();
bool ValidateInitializing();
void Initialize(Func<string, Action> keyGetter);
}
protected abstract class ViewResponder<TView> : IViewResponder<TView> where TView : ViewBase
@@ -90,19 +90,6 @@ namespace StgSharp.MVVM.View
public abstract void CustomizedInitialize(Func<ITrigger, string, Action> keyRegister);
public void ProcessUserInput()
{
foreach (KeyValuePair<ITrigger, Action> pair in keyCallbackIndex)
{
if (InternalIO.glfwGetKey(_binding.ViewHandle, pair.Key.TargetKeyOrButtonID) == pair.Key.TriggeredStatus)
{
pair.Value();
}
}
}
public abstract bool ValidateInitializing();
public void Initialize(Func<string, Action> keyGetter)
{
if (_isInitialized)
@@ -123,6 +110,19 @@ namespace StgSharp.MVVM.View
);
}
public void ProcessUserInput()
{
foreach (KeyValuePair<ITrigger, Action> pair in keyCallbackIndex)
{
if (InternalIO.glfwGetKey(_binding.ViewHandle, pair.Key.TargetKeyOrButtonID) == pair.Key.TriggeredStatus)
{
pair.Value();
}
}
}
public abstract bool ValidateInitializing();
}
}
@@ -47,6 +47,7 @@ namespace StgSharp.MVVM.ViewModel
public unsafe struct DataBindingEntry
{
private IntPtr getterPtr, setterPtr;
public DataBindingEntry(
@@ -63,24 +63,11 @@ namespace StgSharp.MVVM.ViewModel
}
}
private void ShowFrameOnce()
{
viewPortDisplay.FlushSize();
if (_nextView != _currentView)
{
Interlocked.Exchange(ref _currentView, _nextView);
}
CurrentView.Use();
RenderStream.PollEvents();
frameTimeProvider.WaitNextSpan();
Interlocked.Add(ref _frameCount, 1);
}
protected void UseViewInNextFrame(string name)
{
if (!allView.TryGetValue(name, out ViewBase v))
{
throw new KeyNotFoundException($"{($"Cannot find View named {name} ")}{($"in current View Model of {GetType().FullName}")}");
throw new KeyNotFoundException($"{$"Cannot find View named {name} "}{$"in current View Model of {GetType().FullName}"}");
}
CurrentView = v;
}
@@ -94,5 +81,18 @@ namespace StgSharp.MVVM.ViewModel
}
}
private void ShowFrameOnce()
{
viewPortDisplay.FlushSize();
if (_nextView != _currentView)
{
Interlocked.Exchange(ref _currentView, _nextView);
}
CurrentView.Use();
RenderStream.PollEvents();
frameTimeProvider.WaitNextSpan();
Interlocked.Add(ref _frameCount, 1);
}
}
}
@@ -41,6 +41,7 @@ namespace StgSharp.MVVM.ViewModel
{
public partial class ViewModelBase
{
private Dictionary<string, ViewBase> allView;
public T CreateAndBindView<T>(string name, (int x, int y, int z) unitCubeSize)
@@ -48,7 +49,7 @@ namespace StgSharp.MVVM.ViewModel
{
T ret = new T();
ret.SelfName = name;
ret.InternalInitialize(name,unitCubeSize,this);
ret.InternalInitialize(name, unitCubeSize, this);
allView.Add(name, ret);
return ret;
}
@@ -34,6 +34,7 @@ using StgSharp.Graphics.OpenGL;
using StgSharp.Math;
using StgSharp.MVVM.View;
using StgSharp.MVVM.ViewModel;
using StgSharp.Timing;
using System;
using System.Collections.Generic;
@@ -116,7 +117,7 @@ namespace StgSharp.MVVM.ViewModel
=>
{
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
GlFunction.CurrentGL.Viewport(0, 0, width, height);
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
PrivateShow();
};
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
@@ -147,7 +148,7 @@ namespace StgSharp.MVVM.ViewModel
=>
{
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
GlFunction.CurrentGL.Viewport(0, 0, width, height);
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
PrivateShow();
};
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)