daily update on 20240901 by nitload youmu
This commit is contained in:
@@ -41,6 +41,12 @@ using StgSharp.Collections;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of a sets of OpenGL textures. The collection can automatically select one of the
|
||||
/// texture with minimum costs to upgrade pixels to buffer. Usually <see cref="AutoTextureGL"/> is used for
|
||||
/// <see cref="IImageProvider"/> loading, but not for target of
|
||||
/// <see cref="OpenGLFunction.FrameBufferTexture2d(FrameBufferTarget, uint, Texture2DTarget, GlHandle, int)"/>.
|
||||
/// </summary>
|
||||
public sealed class AutoTextureGL
|
||||
{
|
||||
private BidirectionalDictionary<Image, int> imageIndexMap = new BidirectionalDictionary<Image, int>();
|
||||
@@ -70,7 +76,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
propertyCache = new TextureProperty[_size];
|
||||
}
|
||||
|
||||
public AutoTextureGL(int textureObjectSize, [NotNull]glRenderStream binding)
|
||||
public AutoTextureGL(int textureObjectSize, [NotNull]glRender binding)
|
||||
{
|
||||
this._size = textureObjectSize;
|
||||
imageIndexMap = new BidirectionalDictionary<Image, int>();
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public sealed unsafe class ElementBuffer : GlBufferObjectBase
|
||||
{
|
||||
|
||||
internal ElementBuffer(int n, glRenderStream binding) : base(binding)
|
||||
internal ElementBuffer(int n, glRender binding) : base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public sealed class FrameBuffer : GlBufferObjectBase
|
||||
{
|
||||
|
||||
internal unsafe FrameBuffer(int count, glRenderStream binding) : base(binding)
|
||||
internal unsafe FrameBuffer(int count, glRender binding) : base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenFrameBuffers(count);
|
||||
}
|
||||
|
||||
@@ -39,9 +39,9 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public abstract class GlBufferObjectBase : BufferObjectBase
|
||||
{
|
||||
|
||||
private readonly glRenderStream _contextBinding;
|
||||
private readonly glRender _contextBinding;
|
||||
|
||||
protected GlBufferObjectBase(glRenderStream contextBinding)
|
||||
protected GlBufferObjectBase(glRender contextBinding)
|
||||
{
|
||||
binding = contextBinding;
|
||||
_contextBinding = contextBinding;
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public sealed class RenderBuffer : GlBufferObjectBase
|
||||
{
|
||||
|
||||
public RenderBuffer(int count, glRenderStream binding) : base(binding)
|
||||
public RenderBuffer(int count, glRender binding) : base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenRenderBuffer(count);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
private OpenGLFunction _gl;
|
||||
internal GlHandle[] _textureHandle;
|
||||
|
||||
internal TextureGL( int count, glRenderStream binding )
|
||||
internal TextureGL( int count, glRender binding )
|
||||
{
|
||||
//sourceList = new Image[count];
|
||||
this._gl = binding.GL;
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public sealed unsafe class VertexArray : GlBufferObjectBase
|
||||
{
|
||||
|
||||
internal VertexArray(int n, glRenderStream binding) : base(binding)
|
||||
internal VertexArray(int n, glRender binding) : base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenVertexArrays(n);
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public sealed unsafe class VertexBuffer : GlBufferObjectBase
|
||||
{
|
||||
|
||||
internal VertexBuffer(int n, glRenderStream binding) : base(binding)
|
||||
internal VertexBuffer(int n, glRender binding) : base(binding)
|
||||
{
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ using System.Xml.Linq;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public abstract partial class glRenderStream : RenderStream
|
||||
public abstract partial class glRender : RenderStream
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
@@ -69,7 +69,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal readonly GlHandle[] handle;
|
||||
public readonly ShaderType type;
|
||||
|
||||
internal unsafe Shader(GlHandle[] handle, ShaderType usage, glRenderStream stream)
|
||||
internal unsafe Shader(GlHandle[] handle, ShaderType usage, glRender stream)
|
||||
{
|
||||
this.handle = handle;
|
||||
GL = stream.GL;
|
||||
@@ -168,7 +168,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <summary>
|
||||
/// CustomizeInit a program with no shader attached.
|
||||
/// </summary>
|
||||
internal unsafe ShaderProgram(glRenderStream binding)
|
||||
internal unsafe ShaderProgram(glRender binding)
|
||||
{
|
||||
GL = binding.GL;
|
||||
handle = GL.CreateProgram();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glRenderStream.cs"
|
||||
// file="glRender.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -43,7 +43,7 @@ using System.Threading.Tasks;
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
|
||||
public abstract partial class glRenderStream : RenderStream
|
||||
public abstract partial class glRender : RenderStream
|
||||
{
|
||||
|
||||
private OpenGLFunction _context;
|
||||
|
||||
@@ -93,6 +93,11 @@ namespace StgSharp.Graphics
|
||||
get => primeArgs.Name;
|
||||
}
|
||||
|
||||
protected bool IsWaitingUserEvent
|
||||
{
|
||||
get => primeArgs.IsWaitingEvent;
|
||||
}
|
||||
|
||||
public vec2d GlobalCoordSize => ((Width * 1.0f) / _coordStretch.x, (Height * 1.0f) / _coordStretch.y);
|
||||
|
||||
public ViewPort Port
|
||||
@@ -155,6 +160,7 @@ namespace StgSharp.Graphics
|
||||
return target;
|
||||
}
|
||||
|
||||
/**/
|
||||
protected internal static void PollEvents()
|
||||
{
|
||||
InternalIO.glfwPollEvents();
|
||||
@@ -164,7 +170,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
InternalIO.glfwSwapBuffers(CanvasHandle);
|
||||
}
|
||||
|
||||
/**/
|
||||
#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);
|
||||
@@ -211,6 +217,8 @@ namespace StgSharp.Graphics
|
||||
protected abstract void CustomizeInit();
|
||||
protected abstract void Main();
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region public resource generator
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="OpenGLControllingItemRender.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 OpenGLControllingItemRender : glRender
|
||||
{
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace StgSharp.MVVM.View
|
||||
{
|
||||
@@ -61,7 +62,7 @@ namespace StgSharp.MVVM.View
|
||||
|
||||
private GetDataBindingEntryDelegate getDataBindingEntry;
|
||||
|
||||
private int usedFrame = 0;
|
||||
private int usedFrame;
|
||||
private IViewDesigner<ViewBase> _design;
|
||||
private IViewRender<ViewBase> _render;
|
||||
private IViewResponder<ViewBase> _responder;
|
||||
@@ -87,6 +88,11 @@ namespace StgSharp.MVVM.View
|
||||
}
|
||||
}
|
||||
|
||||
internal bool IsWaitingWindowEvent
|
||||
{
|
||||
get => context.IsWaitingEvent;
|
||||
}
|
||||
|
||||
public (int x, int y, int z) UnitCubeSize
|
||||
{
|
||||
get => unitCubeSize;
|
||||
@@ -142,7 +148,7 @@ namespace StgSharp.MVVM.View
|
||||
set => _responder = value;
|
||||
}
|
||||
|
||||
public abstract void CustomizedInitialize(ViewModelBase viewModelBinding);
|
||||
public abstract void CustomizedInitialize([NotNull]ViewModelBase viewModelBinding);
|
||||
|
||||
/// <summary>
|
||||
/// Get the status of a certain key on the keyboard.
|
||||
@@ -155,7 +161,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, [NotNull]ViewModelBase viewModelBinding)
|
||||
{
|
||||
SelfName = name;
|
||||
unitCubeSize = cubeSize;
|
||||
|
||||
@@ -28,13 +28,16 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
using StgSharp.Data;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -45,10 +48,40 @@ namespace StgSharp.MVVM.ViewModel
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate ref object BindingDataGetter();
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void BindingDataSetter(ref object value);
|
||||
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
public bool MethodLookup(string methodName, out Action callback)
|
||||
{
|
||||
MethodInfo method = GetType().GetMethod(methodName);
|
||||
try
|
||||
{
|
||||
callback = (Action)Delegate.CreateDelegate(typeof(Action), this, methodName);
|
||||
return true;
|
||||
}
|
||||
catch (MissingMethodException)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (MethodAccessException)
|
||||
{
|
||||
callback = null!;
|
||||
return false;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Explicit)]
|
||||
public unsafe struct DataBindingEntry
|
||||
{
|
||||
|
||||
private IntPtr getterPtr, setterPtr;
|
||||
[FieldOffset(0)] private M128 _mask;
|
||||
[FieldOffset(0)] private IntPtr getterPtr;
|
||||
[FieldOffset(8)] private IntPtr setterPtr;
|
||||
|
||||
public DataBindingEntry(
|
||||
[NotNull] BindingDataGetter gettingCallback,
|
||||
@@ -73,11 +106,39 @@ namespace StgSharp.MVVM.ViewModel
|
||||
return ref ((delegate* unmanaged[Cdecl]<ref object>)getterPtr)();
|
||||
}
|
||||
|
||||
public void SetData(ref object value)
|
||||
public void SetValue(ref object value)
|
||||
{
|
||||
((delegate* unmanaged[Cdecl]<ref object, void>)setterPtr)(ref value);
|
||||
}
|
||||
|
||||
public static bool operator ==(DataBindingEntry left, DataBindingEntry right)
|
||||
{
|
||||
return left._mask == right._mask;
|
||||
}
|
||||
|
||||
public static bool operator !=(DataBindingEntry left, DataBindingEntry right)
|
||||
{
|
||||
return left._mask != right._mask;
|
||||
}
|
||||
|
||||
public bool Equals(DataBindingEntry other)
|
||||
{
|
||||
return (_mask == other._mask);
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is not DataBindingEntry other)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return _mask.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
#nullable restore
|
||||
|
||||
@@ -40,7 +40,6 @@ namespace StgSharp.MVVM.ViewModel
|
||||
{
|
||||
public abstract partial class ViewModelBase
|
||||
{
|
||||
|
||||
private ViewBase _nextView, _currentView;
|
||||
|
||||
protected ViewBase CurrentView
|
||||
|
||||
@@ -77,6 +77,19 @@ namespace StgSharp.MVVM.ViewModel
|
||||
() =>
|
||||
{
|
||||
};
|
||||
|
||||
viewPortDisplay.FrameSizeCallback = (handle, width, height)
|
||||
=>
|
||||
{
|
||||
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
|
||||
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
|
||||
PrivateShow();
|
||||
};
|
||||
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
|
||||
=>
|
||||
{
|
||||
PrivateShow();
|
||||
};
|
||||
}
|
||||
|
||||
protected ViewModelBase(float frameLength)
|
||||
@@ -95,17 +108,30 @@ namespace StgSharp.MVVM.ViewModel
|
||||
() =>
|
||||
{
|
||||
};
|
||||
|
||||
viewPortDisplay.FrameSizeCallback = (handle, width, height)
|
||||
=>
|
||||
{
|
||||
InternalIO.glfwMakeContextCurrent(viewPortDisplay.ViewPortID);
|
||||
OpenGLFunction.CurrentGL.Viewport(0, 0, width, height);
|
||||
PrivateShow();
|
||||
};
|
||||
viewPortDisplay.FramePostionCallback = (handle, xpos, ypos)
|
||||
=>
|
||||
{
|
||||
PrivateShow();
|
||||
};
|
||||
}
|
||||
|
||||
public ViewModelBase(ViewPort vbinding, int framespeed)
|
||||
public ViewModelBase(ViewPort vBinding, int frameSpeed)
|
||||
{
|
||||
viewPortDisplay = vbinding;
|
||||
viewPortDisplay = vBinding;
|
||||
allView = new();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
_frameCount = 0;
|
||||
fpsCountProvider.SpanRefreshCallback = CountFps;
|
||||
long frameLength = (framespeed > 0) ? ((1000L * 1000L) / framespeed) : 0;
|
||||
long frameLength = (frameSpeed > 0) ? ((1000L * 1000L) / frameSpeed) : 0;
|
||||
frameTimeProvider = new TimeSpanProvider(
|
||||
frameLength, TimeSpanProvider.DefaultProvider
|
||||
);
|
||||
@@ -127,9 +153,9 @@ namespace StgSharp.MVVM.ViewModel
|
||||
};
|
||||
}
|
||||
|
||||
public ViewModelBase(ViewPort vbinding, float frameLength)
|
||||
public ViewModelBase(ViewPort vBinding, float frameLength)
|
||||
{
|
||||
viewPortDisplay = vbinding;
|
||||
viewPortDisplay = vBinding;
|
||||
allView = new();
|
||||
fpsCountProvider = new TimeSpanProvider(1.0, TimeSpanProvider.DefaultProvider);
|
||||
_frameSpeed = 0;
|
||||
@@ -251,12 +277,6 @@ namespace StgSharp.MVVM.ViewModel
|
||||
|
||||
public abstract void CustomizeInitialize();
|
||||
|
||||
public Action MethodLookup(string methodName)
|
||||
{
|
||||
MethodInfo method = GetType().GetMethod(methodName);
|
||||
return (method != null) ? ((Action)Delegate.CreateDelegate(typeof(Action), this, method)) : null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resize the current form
|
||||
/// </summary>
|
||||
|
||||
@@ -43,7 +43,6 @@ namespace StgSharp.MVVM
|
||||
{
|
||||
public class ViewPort
|
||||
{
|
||||
|
||||
private FrameBufferSizeHandler _sizeHandler;
|
||||
private FramePositionHandler _positionHandler;
|
||||
private int _width, _height;
|
||||
@@ -132,5 +131,19 @@ namespace StgSharp.MVVM
|
||||
}
|
||||
}
|
||||
|
||||
private int _eventWaitingMask;
|
||||
|
||||
internal bool IsWaitingEvent
|
||||
{
|
||||
get => _eventWaitingMask == 1;
|
||||
}
|
||||
|
||||
internal unsafe void InternalShowViewModelMain()
|
||||
{
|
||||
Interlocked.Exchange(ref _eventWaitingMask, 1);
|
||||
InternalIO.glfwWaitEvents();
|
||||
Interlocked.Exchange(ref _eventWaitingMask, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace StgSharp.Stg
|
||||
|
||||
}
|
||||
|
||||
public sealed class OneDimensionalCollisionTexture2D_GL : glRenderStream, IOneDimensionalCollisionTexture2D
|
||||
public sealed class OneDimensionalCollisionTexture2D_GL : glRender, IOneDimensionalCollisionTexture2D
|
||||
{
|
||||
|
||||
float[] textureOutput;
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+d082071f2d004b4566bd19a1a030cf06b112c3af")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+1ee4e4a42f2a6b8609a6fce1d36c8da7f4182da6")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("StgSharp")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
Reference in New Issue
Block a user