Daily update on 20251015-002614 by Nitload Youmu. Additional Message : Organize files of numerial math.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -1,34 +1,32 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="VBO.cs"
|
||||
// file="VBO"
|
||||
// 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.
|
||||
// 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.Mathematics;
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -79,11 +77,11 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteMatrixData<T>(int index, T bufferData, BufferUsage usage)
|
||||
where T: unmanaged, IMatrix<T>
|
||||
public void WriteMatrixData<T>(int index, ref IMatrix<T> bufferData, BufferUsage usage)
|
||||
where T: unmanaged, INumber<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, bufferData, usage);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, bufferData.AsSpan(), usage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -101,8 +99,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteScalerData<T>(int index, T[] bufferArray, BufferUsage usage)
|
||||
where T: unmanaged, INumber<T>
|
||||
public void WriteScalerData<T>(int index, T[] bufferArray, BufferUsage usage) where T: unmanaged, INumber<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferData(BufferType.ArrayBuffer, bufferArray, usage);
|
||||
@@ -146,7 +143,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// How OpenGL use these data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteVectorData<T>(int index, ReadOnlySpan<T> vectorSpan, BufferUsage usage)
|
||||
where T: unmanaged, IFixedVector<T>
|
||||
where T: unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorSpan, usage);
|
||||
@@ -168,7 +165,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteVectorData<T>(int index, T[] vectorArray, BufferUsage usage)
|
||||
where T: unmanaged, IFixedVector<T>
|
||||
where T: unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
GL.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
|
||||
GL.SetBufferVectorData(BufferType.ArrayBuffer, vectorArray, usage);
|
||||
|
||||
@@ -1,36 +1,34 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="glFunction.cs"
|
||||
// file="glFunction"
|
||||
// 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.
|
||||
// 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;
|
||||
using StgSharp.Internal;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Numeric;
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
@@ -62,9 +60,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
unusedTextureImageUintInitilizing = new Lazy<ConcurrentQueue<TextureUnit>>(
|
||||
InitializeUnusedTextureImageUint);
|
||||
_attachmentColorRange = new Lazy<int>(
|
||||
() => {
|
||||
return GetMaskInteger((uint)glConst.MAX_COLOR_ATTACHMENTS);
|
||||
});
|
||||
() => { return GetMaskInteger((uint)glConst.MAX_COLOR_ATTACHMENTS); });
|
||||
}
|
||||
|
||||
public int AttachmentColorRange
|
||||
@@ -126,7 +122,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
/// <summary>
|
||||
/// Bind a frame BufferHandle to a frame BufferHandle target Same function as <see
|
||||
/// href="https://docs._gl/gl3/glBindFramebuffer"> glBindFramebuffer </see>.
|
||||
/// href="https://docs._gl/gl3/glBindFramebuffer">glBindFramebuffer</see>.
|
||||
/// </summary>
|
||||
/// <param _label="target">
|
||||
/// The frame BufferHandle target of the binding operation.
|
||||
@@ -202,9 +198,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void CombineFrameBufferRenderBuffer(
|
||||
FrameBufferAttachment attachment,
|
||||
GlHandle rboHandle)
|
||||
public void CombineFrameBufferRenderBuffer(FrameBufferAttachment attachment, GlHandle rboHandle)
|
||||
{
|
||||
Context.glFramebufferRenderbuffer(
|
||||
glConst.FRAMEBUFFER, (uint)attachment, glConst.RENDERBUFFER, rboHandle.Value);
|
||||
@@ -279,9 +273,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
/// <summary>
|
||||
/// Delete a render BufferHandle object Very simlilar function as <see
|
||||
/// href="https://docs.gl/gl3/glDeleteRenderbuffers"> glDeleteRenderbuffers </see>. The
|
||||
/// only deifference is that this mehtod can only delete one renderbuffer at the same
|
||||
/// time.
|
||||
/// href="https://docs.gl/gl3/glDeleteRenderbuffers">glDeleteRenderbuffers</see>. The only
|
||||
/// deifference is that this mehtod can only delete one renderbuffer at the same time.
|
||||
/// </summary>
|
||||
/// <param _label="bufferHandle">
|
||||
/// Handle to BufferHandle to delete.
|
||||
@@ -336,12 +329,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void DrawElementsInstanced(
|
||||
GeometryType mode,
|
||||
uint count,
|
||||
TypeCode type,
|
||||
IntPtr ptr,
|
||||
uint amount)
|
||||
public void DrawElementsInstanced(GeometryType mode, uint count, TypeCode type, IntPtr ptr, uint amount)
|
||||
{
|
||||
uint a;
|
||||
switch (type)
|
||||
@@ -458,8 +446,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
IntPtr sptr = IntPtr.Zero;
|
||||
if (InternalIO.glCheckShaderStatus(ref Context, s.handle[index].Value, key,
|
||||
ref sptr) ==
|
||||
0) {
|
||||
ref sptr) == 0) {
|
||||
return Marshal.PtrToStringAnsi(sptr);
|
||||
}
|
||||
return string.Empty;
|
||||
@@ -484,11 +471,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void GetTextureLevelProperty(
|
||||
uint textureTypeMask,
|
||||
int level,
|
||||
uint propertyMask,
|
||||
out int propertyValue)
|
||||
public void GetTextureLevelProperty(uint textureTypeMask, int level, uint propertyMask, out int propertyValue)
|
||||
{
|
||||
fixed (int* iptr = &propertyValue) {
|
||||
Context.glGetTexLevelParameteriv(textureTypeMask, level, propertyMask, iptr);
|
||||
@@ -563,8 +546,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
fixed (byte* bptr = stream) {
|
||||
Context.glReadPixels(
|
||||
beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format,
|
||||
(uint)dataType, bptr);
|
||||
beginPosition.X, beginPosition.Y, size.width, size.height, (uint)format, (uint)dataType, bptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -580,15 +562,14 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
fixed (byte* bptr = pixels) {
|
||||
Context.glReadPixels(
|
||||
beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format,
|
||||
(uint)dataType, bptr);
|
||||
beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, (uint)dataType, bptr);
|
||||
}
|
||||
i.PixelUpdateCount++;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
|
||||
where T: unmanaged
|
||||
where T: unmanaged,INumber<T>
|
||||
{
|
||||
int size = Marshal.SizeOf<T>();
|
||||
#pragma warning disable CS8500
|
||||
@@ -598,10 +579,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
T[] bufferArray,
|
||||
BufferUsage usage)
|
||||
public unsafe void SetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
|
||||
where T: unmanaged,INumber<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
|
||||
@@ -618,10 +596,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage)
|
||||
public unsafe void SetBufferData<T>(BufferType bufferType, ReadOnlySpan<T> bufferSpan, BufferUsage usage)
|
||||
where T: unmanaged,INumber<T>
|
||||
{
|
||||
int size = bufferSpan.Length * Marshal.SizeOf(typeof(T));
|
||||
@@ -638,10 +613,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
Span<T> bufferArray,
|
||||
BufferUsage usage)
|
||||
public unsafe void SetBufferData<T>(BufferType bufferType, Span<T> bufferArray, BufferUsage usage)
|
||||
where T: unmanaged, INumber<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
|
||||
@@ -659,11 +631,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferVectorData<T>(
|
||||
BufferType bufferType,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage)
|
||||
where T: unmanaged, IFixedVector<T>
|
||||
public unsafe void SetBufferVectorData<T>(BufferType bufferType, ReadOnlySpan<T> bufferSpan, BufferUsage usage)
|
||||
where T: unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
int size = bufferSpan.Length * Marshal.SizeOf(typeof(T));
|
||||
#pragma warning disable CS8500
|
||||
@@ -676,11 +645,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public unsafe void SetBufferVectorData<T>(
|
||||
BufferType bufferType,
|
||||
T[] bufferArray,
|
||||
BufferUsage usage)
|
||||
where T: unmanaged, IFixedVector<T>
|
||||
public unsafe void SetBufferVectorData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
|
||||
where T: unmanaged, IUnmanagedVector<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
|
||||
if (bufferArray == null) {
|
||||
@@ -714,17 +680,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetVertexAttribute(
|
||||
uint index,
|
||||
int size,
|
||||
TypeCode t,
|
||||
bool normalized,
|
||||
uint stride,
|
||||
int pointer)
|
||||
public void SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer)
|
||||
{
|
||||
uint type = InternalIO.GLtype[t];
|
||||
Context.glVertexAttribPointer(
|
||||
index, size, type, normalized ? 1 : 0, stride, (void*)pointer);
|
||||
Context.glVertexAttribPointer(index, size, type, normalized ? 1 : 0, stride, (void*)pointer);
|
||||
Context.glEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
@@ -745,8 +704,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
T* ptr = ((pixels == null) || (pixels.Length == 0)) ? (T*)IntPtr.Zero : tptr;
|
||||
Context.glTexImage2D(
|
||||
(uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel,
|
||||
(uint)type, tptr);
|
||||
(uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr);
|
||||
}
|
||||
#pragma warning restore CS8500
|
||||
}
|
||||
@@ -767,8 +725,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
fixed (T* tptr = pixelSpan)
|
||||
{
|
||||
Context.glTexImage2D(
|
||||
(uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel,
|
||||
(uint)type, tptr);
|
||||
(uint)target, level, (uint)sourceChannel, width, height, 0, (uint)targetChannel, (uint)type, tptr);
|
||||
}
|
||||
#pragma warning restore CS8500
|
||||
}
|
||||
|
||||
@@ -1,34 +1,32 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="glRenderStream.cs"
|
||||
// file="glRenderStream"
|
||||
// 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.
|
||||
// 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.Mathematics;
|
||||
using StgSharp.Mathematics.Graphic;
|
||||
using StgSharp.Threading;
|
||||
|
||||
using System;
|
||||
@@ -137,9 +135,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
CustomizeDeinit();
|
||||
}
|
||||
|
||||
protected sealed override Uniform<Matrix44> NativeCameraUniform(
|
||||
ShaderProgram source,
|
||||
string name)
|
||||
protected sealed override Uniform<Matrix44> NativeCameraUniform(ShaderProgram source, string name)
|
||||
{
|
||||
NativeCamera.GainAllUniforms(source, name);
|
||||
return NativeCamera.convertedUniform;
|
||||
@@ -155,10 +151,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
protected sealed override void NativeCameraViewTarget(
|
||||
Vec3 position,
|
||||
Vec3 direction,
|
||||
Vec3 up)
|
||||
protected sealed override void NativeCameraViewTarget(Vec3 position, Vec3 direction, Vec3 up)
|
||||
{
|
||||
NativeCamera.SetViewDirection(position, direction, up);
|
||||
}
|
||||
|
||||
@@ -1,35 +1,33 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="PlainGeometryMesh.cs"
|
||||
// file="PlainGeometryMesh"
|
||||
// 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.
|
||||
// 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.Geometries;
|
||||
using StgSharp.Mathematics;
|
||||
using StgSharp.Mathematics.Graphic;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -1,36 +1,33 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="RenderStream.cs"
|
||||
// file="RenderStream"
|
||||
// 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.
|
||||
// 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 StgSharp.Mathematics;
|
||||
|
||||
using StgSharp.Mathematics.Graphic;
|
||||
using StgSharp.MVVM;
|
||||
using StgSharp.Timing;
|
||||
|
||||
@@ -56,6 +53,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
public (int width, int height) Size
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => (Width, Height);
|
||||
}
|
||||
|
||||
@@ -63,6 +61,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
public int Height
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => primeArgs.Height;
|
||||
}
|
||||
|
||||
@@ -90,6 +89,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
internal IntPtr CanvasHandle
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => primeArgs.ViewPortHandle;
|
||||
}
|
||||
|
||||
@@ -107,21 +107,25 @@ namespace StgSharp.Graphics
|
||||
|
||||
protected float FramePassed
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timeProvider.CurrentSpan;
|
||||
}
|
||||
|
||||
protected int PassedFrames
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timeProvider.CurrentSpan;
|
||||
}
|
||||
|
||||
protected float TimePassed
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timeProvider.CurrentSecond;
|
||||
}
|
||||
|
||||
protected TimeSpanProvider TimeProvider
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
get => _timeProvider;
|
||||
}
|
||||
|
||||
@@ -143,8 +147,7 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public abstract void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight);
|
||||
|
||||
public static TTarget ShareContextFrom<TSource, TTarget>([NotNull]TSource source)
|
||||
where TSource: RenderStream
|
||||
public static TTarget ShareContextFrom<TSource, TTarget>([NotNull]TSource source) where TSource: RenderStream
|
||||
where TTarget: RenderStream, new()
|
||||
{
|
||||
TTarget target = new TTarget();
|
||||
|
||||
@@ -1,40 +1,37 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="TextureProvider.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
// -----------------------------------------------------------------------
|
||||
// file="TextureProvider.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:
|
||||
// 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 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.
|
||||
// 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.Mathematics;
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Mathematics.Graphic;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
@@ -44,20 +41,20 @@ namespace StgSharp.Graphics
|
||||
private Vec2[] _texCoord;
|
||||
private Image _tex;
|
||||
|
||||
public TextureProvider( Image image, Vec2[] coord )
|
||||
public TextureProvider(Image image, Vec2[] coord)
|
||||
{
|
||||
_tex = image;
|
||||
_texCoord = coord;
|
||||
}
|
||||
|
||||
public ref Vec2 this[ int index ]
|
||||
public ref Vec2 this[int index]
|
||||
{
|
||||
get => ref _texCoord[ index ];
|
||||
get => ref _texCoord[index];
|
||||
}
|
||||
|
||||
public Span<Vec2> TextureCoordinate
|
||||
{
|
||||
get => new Span<Vec2>( _texCoord );
|
||||
get => new Span<Vec2>(_texCoord);
|
||||
}
|
||||
|
||||
public Image ProvideImage()
|
||||
@@ -65,23 +62,23 @@ namespace StgSharp.Graphics
|
||||
return _tex;
|
||||
}
|
||||
|
||||
public void ReadImage( IImageProvider provider )
|
||||
public void ReadImage(IImageProvider provider)
|
||||
{
|
||||
_tex = provider.ProvideImage();
|
||||
}
|
||||
|
||||
public void UpdateFromImage( [NotNull]Image i )
|
||||
public void UpdateFromImage([NotNull]Image i)
|
||||
{
|
||||
if( i == _tex ) {
|
||||
if (i == _tex) {
|
||||
return;
|
||||
}
|
||||
if( i.Size == _tex.Size )
|
||||
if (i.Size == _tex.Size)
|
||||
{
|
||||
_tex = i;
|
||||
} else
|
||||
{
|
||||
throw new ArgumentException(
|
||||
$"Size of {nameof(i)} does not equals to current image." );
|
||||
$"Size of {nameof(i)} does not equals to current image.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user