Daily update on 20250618-051714 by Nitload Youmu. Additional Message : Brief support to collection operation in EXPRESS. A collection type added in core lib and compilestack.
Signed-off-by: Nitload <YoumuLiu_NSI@whv0t.onmicrosoft.com>
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Commom.Collections;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -42,11 +41,11 @@ using System.Threading.Tasks;
|
||||
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)" />.
|
||||
/// 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
|
||||
{
|
||||
@@ -54,8 +53,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
private TextureProperty[] propertyCache;
|
||||
private BidirectionalDictionary<Image, int> imageIndexMap = new BidirectionalDictionary<Image, int>(
|
||||
);
|
||||
private Dictionary<Image, int> imageUpdateIndex = new Dictionary<Image, int>(
|
||||
);
|
||||
private Dictionary<Image, int> imageUpdateIndex = new Dictionary<Image, int>();
|
||||
|
||||
private int _size, _currentIndex;
|
||||
private LinkedList<int> usedTextureIndex;
|
||||
@@ -69,8 +67,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
texturePackage = texture;
|
||||
_size = texture.Count;
|
||||
imageIndexMap = new BidirectionalDictionary<Image, int>();
|
||||
unusedTextureUnitIndex = new Queue<int>(
|
||||
Enumerable.Range( 0, _size ) );
|
||||
unusedTextureUnitIndex = new Queue<int>( Enumerable.Range( 0, _size ) );
|
||||
usedTextureIndex = new LinkedList<int>();
|
||||
propertyCache = new TextureProperty[_size];
|
||||
}
|
||||
@@ -80,8 +77,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
this._size = textureObjectSize;
|
||||
imageIndexMap = new BidirectionalDictionary<Image, int>();
|
||||
texturePackage = new TextureGL( textureObjectSize, binding );
|
||||
unusedTextureUnitIndex = new Queue<int>(
|
||||
Enumerable.Range( 0, _size ) );
|
||||
unusedTextureUnitIndex = new Queue<int>( Enumerable.Range( 0, _size ) );
|
||||
usedTextureIndex = new LinkedList<int>();
|
||||
propertyCache = new TextureProperty[_size];
|
||||
}
|
||||
@@ -105,29 +101,34 @@ namespace StgSharp.Graphics.OpenGL
|
||||
SelectTextureAndBind( i, property );
|
||||
}
|
||||
|
||||
public void SelectTextureAndBind(
|
||||
[NotNull]Image i,
|
||||
TextureProperty property )
|
||||
public void SelectTextureAndBind( [NotNull]Image i, TextureProperty property )
|
||||
{
|
||||
//usable texture with image match
|
||||
if( imageIndexMap.TryGetValue( i, out int index ) ) {
|
||||
if( imageIndexMap.TryGetValue( i, out int index ) )
|
||||
{
|
||||
//prop setting match
|
||||
if( propertyCache[ index ] == property ) {
|
||||
if( propertyCache[ index ] == property )
|
||||
{
|
||||
_currentIndex = index; //GL.Assert(true);
|
||||
texturePackage.Bind2D( index ); //GL.Assert(true);
|
||||
if( i.PixelUpdateCount != imageUpdateIndex[ i ] ) {
|
||||
if( i.PixelUpdateCount != imageUpdateIndex[ i ] )
|
||||
{
|
||||
texturePackage.LoadTexture( index, i ); //GL.Assert(true);
|
||||
}
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
_currentIndex = index; //GL.Assert(true);
|
||||
texturePackage.Bind2D( index ); //GL.Assert(true);
|
||||
texturePackage.Set2dProperty( index, property ); //GL.Assert(true);
|
||||
if( i.PixelUpdateCount != imageUpdateIndex[ i ] ) {
|
||||
if( i.PixelUpdateCount != imageUpdateIndex[ i ] )
|
||||
{
|
||||
texturePackage.LoadTexture( index, i ); //GL.Assert(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if( unusedTextureUnitIndex.TryDequeue( out int newIndex ) ) {
|
||||
} else
|
||||
{
|
||||
if( unusedTextureUnitIndex.TryDequeue( out int newIndex ) )
|
||||
{
|
||||
//has extra unused texture object
|
||||
imageIndexMap.Add( i, index );
|
||||
texturePackage.Bind2D( index );
|
||||
@@ -136,7 +137,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
usedTextureIndex.AddLast( newIndex );
|
||||
propertyCache[ newIndex ] = property;
|
||||
imageUpdateIndex[ i ] = i.PixelUpdateCount;
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
//recycle from current
|
||||
int reusedIndex = usedTextureIndex.First!.Value;
|
||||
usedTextureIndex.RemoveFirst();
|
||||
@@ -151,8 +153,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public static AutoTextureGL ToAuto( [NotNull]TextureGL texture )
|
||||
{
|
||||
if( texture.IndexOfCurrentTexture != -1 ) {
|
||||
throw new InvalidOperationException(
|
||||
"Texture to be converted has been editted." );
|
||||
throw new InvalidOperationException( "Texture to be converted has been editted." );
|
||||
}
|
||||
return new AutoTextureGL( texture );
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ using System.Text;
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of handle to Element Buffer Object in OpenglFunc. Each <see langword="uint" />
|
||||
/// value indexed from instance of this class this is the only handle to one Element Buffer
|
||||
/// Object.
|
||||
/// A collection of handle to Element Buffer Object in OpenglFunc. Each <see langword="uint"
|
||||
/// /> value indexed from instance of this class this is the only handle to one Element Buffer
|
||||
/// Object.
|
||||
/// </summary>
|
||||
public sealed unsafe class ElementBuffer : GlBufferObjectBase
|
||||
{
|
||||
@@ -58,29 +58,21 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
public override sealed void Bind( int index )
|
||||
{
|
||||
GL.BindBuffer(
|
||||
BufferType.ElementArrayBuffer, _bufferHandle[ index ] );
|
||||
GL.BindBuffer( BufferType.ElementArrayBuffer, _bufferHandle[ index ] );
|
||||
}
|
||||
|
||||
public void SetValue<T>( int index, T[] bufferArray, BufferUsage usage )
|
||||
where T: struct, INumber<T>
|
||||
{
|
||||
GL.BindBuffer(
|
||||
BufferType.ElementArrayBuffer, _bufferHandle[ index ] );
|
||||
GL.SetBufferData<T>(
|
||||
BufferType.ElementArrayBuffer, bufferArray, usage );
|
||||
GL.BindBuffer( BufferType.ElementArrayBuffer, _bufferHandle[ index ] );
|
||||
GL.SetBufferData<T>( BufferType.ElementArrayBuffer, bufferArray, usage );
|
||||
}
|
||||
|
||||
public void SetValue<T>(
|
||||
int index,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage )
|
||||
public void SetValue<T>( int index, ReadOnlySpan<T> bufferSpan, BufferUsage usage )
|
||||
where T: struct, INumber<T>
|
||||
{
|
||||
GL.BindBuffer(
|
||||
BufferType.ElementArrayBuffer, _bufferHandle[ index ] );
|
||||
GL.SetBufferData<T>( BufferType.ElementArrayBuffer, bufferSpan,
|
||||
usage );
|
||||
GL.BindBuffer( BufferType.ElementArrayBuffer, _bufferHandle[ index ] );
|
||||
GL.SetBufferData<T>( BufferType.ElementArrayBuffer, bufferSpan, usage );
|
||||
}
|
||||
|
||||
protected override sealed void Dispose( bool disposing )
|
||||
|
||||
@@ -63,10 +63,13 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bind the frame Buffer object with _name frame Buffer to the frame Buffer target specified
|
||||
/// by target. <see langword="FrameBufferTarget.All" /> will be set as default target.
|
||||
/// Bind the frame Buffer object with _label frame Buffer to the frame Buffer target
|
||||
/// specified by target. <see langword="FrameBufferTarget.All" /> will be set as default
|
||||
/// target.
|
||||
/// </summary>
|
||||
/// <param _name="index"> Index of object to be binded in handle set </param>
|
||||
/// <param _label="index">
|
||||
/// Index of object to be binded in handle set
|
||||
/// </param>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public override unsafe void Bind( int index )
|
||||
{
|
||||
@@ -74,11 +77,15 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Bind the frame Buffer object with _name frame Buffer to the frame Buffer target specified
|
||||
/// by target. Target of this frame Buffer should be set manually.
|
||||
/// Bind the frame Buffer object with _label frame Buffer to the frame Buffer target
|
||||
/// specified by target. Target of this frame Buffer should be set manually.
|
||||
/// </summary>
|
||||
/// <param _name="target"> The frame Buffer target of the binding operation. </param>
|
||||
/// <param _name="index"> Index of object to be binded in handle set </param>
|
||||
/// <param _label="target">
|
||||
/// The frame Buffer target of the binding operation.
|
||||
/// </param>
|
||||
/// <param _label="index">
|
||||
/// Index of object to be binded in handle set
|
||||
/// </param>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public unsafe void Bind( FrameBufferTarget target, int index )
|
||||
{
|
||||
@@ -88,8 +95,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static void BindNull()
|
||||
{
|
||||
OpenGLFunction.CurrentGL
|
||||
.BindFrameBuffer( FrameBufferTarget.All, GlHandle.Zero );
|
||||
OpenGLFunction.CurrentGL.BindFrameBuffer( FrameBufferTarget.All, GlHandle.Zero );
|
||||
}
|
||||
|
||||
protected override void Dispose( bool disposing )
|
||||
|
||||
@@ -51,19 +51,17 @@ namespace StgSharp.Graphics.OpenGL
|
||||
GL.BindRenderBuffer( this[ index ] );
|
||||
}
|
||||
|
||||
public void Store(
|
||||
RenderBufferInternalFormat format,
|
||||
(int width, int height) size )
|
||||
public void Store( RenderBufferInternalFormat format, (int width, int height) size )
|
||||
{
|
||||
if( ( size.width > binding.Width ) || ( size.height > binding.Height ) ) {
|
||||
StgSharp.LogWarning(
|
||||
"FrameBuffer is larger than current canvas binding" );
|
||||
World.LogWarning( "FrameBuffer is larger than current canvas binding" );
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose( bool disposing )
|
||||
{
|
||||
foreach( GlHandle item in _bufferHandle ) {
|
||||
foreach( GlHandle item in _bufferHandle )
|
||||
{
|
||||
Console.WriteLine( "removing a render buffer" );
|
||||
GL.DeleteRenderBuffer( item );
|
||||
}
|
||||
|
||||
@@ -84,16 +84,20 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load an <see cref="Image" /> to certain texture.
|
||||
/// Load an <see cref="Image" /> to certain texture.
|
||||
/// </summary>
|
||||
/// <param _name="index"> </param>
|
||||
/// <param _name="i"> </param>
|
||||
/// <param _label="index">
|
||||
///
|
||||
/// </param>
|
||||
/// <param _label="i">
|
||||
///
|
||||
/// </param>
|
||||
public unsafe void LoadTexture( int index, Image i )
|
||||
{
|
||||
byte[] handle = i.PixelBuffer;
|
||||
_gl.TextureImage2d(
|
||||
Texture2DTarget.Texture2D, 0, i.Channel, ( uint )i.Width,
|
||||
( uint )i.Height, i.Channel, i.PixelLayout, pixels: handle );
|
||||
Texture2DTarget.Texture2D, 0, i.Channel, ( uint )i.Width, ( uint )i.Height,
|
||||
i.Channel, i.PixelLayout, pixels: handle );
|
||||
_gl.GenerateMipmap( Texture2DTarget.Texture2D );
|
||||
}
|
||||
|
||||
@@ -101,50 +105,45 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void Set2dFilterProperty(
|
||||
int index,
|
||||
TextureFilter onMinify,
|
||||
TextureFilter onMagnify )
|
||||
int index,
|
||||
TextureFilter onMinify,
|
||||
TextureFilter onMagnify )
|
||||
{
|
||||
#if DEBUG
|
||||
if( index != currentEditingTextureIndex ) {
|
||||
if( index != currentEditingTextureIndex )
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Texture to be editted is not the one being activated." );
|
||||
}
|
||||
#endif
|
||||
_gl.TextureParameter(
|
||||
glConst.TEXTURE_2D, glConst.TEXTURE_MIN_FILTER,
|
||||
( int )onMinify );
|
||||
_gl.TextureParameter(
|
||||
glConst.TEXTURE_2D, glConst.TEXTURE_MAG_FILTER,
|
||||
( int )onMagnify );
|
||||
_gl.TextureParameter( glConst.TEXTURE_2D, glConst.TEXTURE_MIN_FILTER, ( int )onMinify );
|
||||
_gl.TextureParameter( glConst.TEXTURE_2D, glConst.TEXTURE_MAG_FILTER,
|
||||
( int )onMagnify );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void Set2dWrapProperty(
|
||||
int index,
|
||||
TextureWrap onHorizontial,
|
||||
TextureWrap onVertical )
|
||||
int index,
|
||||
TextureWrap onHorizontial,
|
||||
TextureWrap onVertical )
|
||||
{
|
||||
#if DEBUG
|
||||
if( index != currentEditingTextureIndex ) {
|
||||
if( index != currentEditingTextureIndex )
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
"Texture to be editted is not the one being activated." );
|
||||
}
|
||||
#endif
|
||||
_gl.TextureParameter(
|
||||
glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_S,
|
||||
( int )onHorizontial );
|
||||
_gl.TextureParameter(
|
||||
glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_T, ( int )onVertical );
|
||||
_gl.TextureParameter( glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_S,
|
||||
( int )onHorizontial );
|
||||
_gl.TextureParameter( glConst.TEXTURE_2D, glConst.TEXTURE_WRAP_T, ( int )onVertical );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void Set2dProperty( int index, TextureProperty property )
|
||||
{
|
||||
Set2dFilterProperty(
|
||||
index, property.FilterOnMinify, property.FilterOnMagnify );
|
||||
Set2dWrapProperty(
|
||||
index, property.WrapOnHorizontial, property.WrapOnVertical );
|
||||
Set2dFilterProperty( index, property.FilterOnMinify, property.FilterOnMagnify );
|
||||
Set2dWrapProperty( index, property.WrapOnHorizontial, property.WrapOnVertical );
|
||||
}
|
||||
|
||||
#endregion texture setting
|
||||
@@ -162,10 +161,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
[FieldOffset( 12 )] private TextureWrap vert;
|
||||
|
||||
public TextureProperty(
|
||||
TextureFilter onMagnify,
|
||||
TextureFilter onMinify,
|
||||
TextureWrap onHorizontial,
|
||||
TextureWrap onVertical )
|
||||
TextureFilter onMagnify,
|
||||
TextureFilter onMinify,
|
||||
TextureWrap onHorizontial,
|
||||
TextureWrap onVertical )
|
||||
{
|
||||
FilterOnMagnify = onMagnify;
|
||||
FilterOnMinify = onMinify;
|
||||
@@ -205,8 +204,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(
|
||||
FilterOnMagnify, FilterOnMagnify, WrapOnHorizontial,
|
||||
WrapOnVertical );
|
||||
FilterOnMagnify, FilterOnMagnify, WrapOnHorizontial, WrapOnVertical );
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -214,30 +212,25 @@ namespace StgSharp.Graphics.OpenGL
|
||||
return $"FilterOnMagnify:{FilterOnMagnify}, " + $"FilterOnMagnify:{FilterOnMagnify}, " + $"WrapOnHorizontial:{WrapOnHorizontial}, " + $"WrapOnVertical:{WrapOnVertical}";
|
||||
}
|
||||
|
||||
public static bool operator !=(
|
||||
TextureProperty left,
|
||||
TextureProperty right )
|
||||
public static bool operator !=( TextureProperty left, TextureProperty right )
|
||||
{
|
||||
return left.mask != right.mask;
|
||||
}
|
||||
|
||||
public static bool operator ==(
|
||||
TextureProperty left,
|
||||
TextureProperty right )
|
||||
public static bool operator ==( TextureProperty left, TextureProperty right )
|
||||
{
|
||||
return left.mask == right.mask;
|
||||
}
|
||||
|
||||
public static implicit operator TextureProperty(
|
||||
(
|
||||
(
|
||||
TextureFilter onMagnify, TextureFilter onMinify,
|
||||
TextureWrap onHorizontial, TextureWrap onVertical
|
||||
) propertyValueTuple )
|
||||
{
|
||||
return new TextureProperty(
|
||||
propertyValueTuple.onMagnify, propertyValueTuple.onMinify,
|
||||
propertyValueTuple.onHorizontial,
|
||||
propertyValueTuple.onVertical );
|
||||
propertyValueTuple.onHorizontial, propertyValueTuple.onVertical );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="VAO.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -59,15 +58,15 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void SetVertexAttribute(
|
||||
uint index,
|
||||
int vertexLength,
|
||||
TypeCode dataType,
|
||||
bool isNomalized,
|
||||
uint stride,
|
||||
int pointer )
|
||||
uint attributeIndex,
|
||||
int vertexLength,
|
||||
TypeCode dataType,
|
||||
bool isNomalized,
|
||||
uint stride,
|
||||
int pointer )
|
||||
{
|
||||
GL.SetVertexAttribute(
|
||||
index, vertexLength, dataType, isNomalized, stride, pointer );
|
||||
attributeIndex, vertexLength, dataType, isNomalized, stride, pointer );
|
||||
}
|
||||
|
||||
protected override sealed void Dispose( bool disposing )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="VBO.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -65,16 +65,21 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// </summary>
|
||||
/// <typeparam _name="TItem"> Type of bufferData </typeparam>
|
||||
/// <param _name="index"> Index to find certain VBO in this instance </param>
|
||||
/// <param _name="bufferData"> Data to write in </param>
|
||||
/// <param _name="usage"> How OpenGL use these _data, defined by <see cref="BufferUsage" /></param>
|
||||
public void WriteMatrixData<T>(
|
||||
int index,
|
||||
T bufferData,
|
||||
BufferUsage usage )
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="bufferData">
|
||||
/// Data to write in
|
||||
/// </param>
|
||||
/// <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: struct, IMatrix<T>
|
||||
{
|
||||
GL.BindBuffer( BufferType.ArrayBuffer, _bufferHandle[ index ] );
|
||||
@@ -82,16 +87,21 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// </summary>
|
||||
/// <typeparam _name="TItem"> Type of bufferData </typeparam>
|
||||
/// <param _name="index"> Index to find certain VBO in this instance </param>
|
||||
/// <param _name="bufferArray"> Data to write in </param>
|
||||
/// <param _name="usage"> How OpenGL use these _data, defined by <see cref="BufferUsage" /></param>
|
||||
public void WriteScalerData<T>(
|
||||
int index,
|
||||
T[] bufferArray,
|
||||
BufferUsage usage )
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="bufferArray">
|
||||
/// Data to write in
|
||||
/// </param>
|
||||
/// <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: struct, INumber<T>
|
||||
{
|
||||
GL.BindBuffer( BufferType.ArrayBuffer, _bufferHandle[ index ] );
|
||||
@@ -99,16 +109,21 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// </summary>
|
||||
/// <typeparam _name="TItem"> Type of bufferData </typeparam>
|
||||
/// <param _name="index"> Index to find certain VBO in this instance </param>
|
||||
/// <param _name="scalerSpan"> A <see cref="Span{T}" /> of _data to write in </param>
|
||||
/// <param _name="usage"> How OpenGL use these _data, defined by <see cref="BufferUsage" /></param>
|
||||
public void WriteScalerData<T>(
|
||||
int index,
|
||||
ReadOnlySpan<T> scalerSpan,
|
||||
BufferUsage usage )
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="scalerSpan">
|
||||
/// A <see cref="Span{T}" /> of _data to write in
|
||||
/// </param>
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteScalerData<T>( int index, ReadOnlySpan<T> scalerSpan, BufferUsage usage )
|
||||
where T: struct,INumber<T>
|
||||
{
|
||||
GL.BindBuffer( BufferType.ArrayBuffer, _bufferHandle[ index ] );
|
||||
@@ -116,16 +131,21 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// Set data to current vertex Buffer object
|
||||
/// </summary>
|
||||
/// <typeparam _name="TItem"> Type of bufferData </typeparam>
|
||||
/// <param _name="index"> Index to find certain VBO in this instance </param>
|
||||
/// <param _name="vectorSpan"> A <see cref="Span{T}" /> of _data to write in </param>
|
||||
/// <param _name="usage"> How OpenGL use these _data, defined by <see cref="BufferUsage" /></param>
|
||||
public void WriteVectorData<T>(
|
||||
int index,
|
||||
ReadOnlySpan<T> vectorSpan,
|
||||
BufferUsage usage )
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="vectorSpan">
|
||||
/// A <see cref="Span{T}" /> of data to write in
|
||||
/// </param>
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteVectorData<T>( int index, ReadOnlySpan<T> vectorSpan, BufferUsage usage )
|
||||
where T: struct, IVector<T>
|
||||
{
|
||||
GL.BindBuffer( BufferType.ArrayBuffer, _bufferHandle[ index ] );
|
||||
@@ -133,21 +153,25 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// Set _data to current vertex Buffer object
|
||||
/// </summary>
|
||||
/// <typeparam _name="TItem"> Type of bufferData </typeparam>
|
||||
/// <param _name="index"> Index to find certain VBO in this instance </param>
|
||||
/// <param _name="vectorArray"> A array of _data to write in </param>
|
||||
/// <param _name="usage"> How OpenGL use these _data, defined by <see cref="BufferUsage" /></param>
|
||||
public void WriteVectorData<T>(
|
||||
int index,
|
||||
T[] vectorArray,
|
||||
BufferUsage usage )
|
||||
/// <typeparam _label="TItem">
|
||||
/// Type of bufferData
|
||||
/// </typeparam>
|
||||
/// <param _label="index">
|
||||
/// Index to find certain VBO in this instance
|
||||
/// </param>
|
||||
/// <param _label="vectorArray">
|
||||
/// A array of _data to write in
|
||||
/// </param>
|
||||
/// <param _label="usage">
|
||||
/// How OpenGL use these _data, defined by <see cref="BufferUsage" />
|
||||
/// </param>
|
||||
public void WriteVectorData<T>( int index, T[] vectorArray, BufferUsage usage )
|
||||
where T: struct, IVector<T>
|
||||
{
|
||||
GL.BindBuffer( BufferType.ArrayBuffer, _bufferHandle[ index ] );
|
||||
GL.SetBufferVectorData( BufferType.ArrayBuffer, vectorArray,
|
||||
usage );
|
||||
GL.SetBufferVectorData( BufferType.ArrayBuffer, vectorArray, usage );
|
||||
}
|
||||
|
||||
protected override sealed void Dispose( bool disposing )
|
||||
|
||||
@@ -49,14 +49,14 @@ namespace StgSharp.Graphics.ShaderEdit
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public void GainAllUniforms(
|
||||
ShaderProgram source,
|
||||
params string[] uniformName );
|
||||
public void GainAllUniforms( ShaderProgram source, params string[] uniformName );
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
public ShaderStruct GetConvertedGLtype();
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Shader.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -33,6 +33,7 @@ using StgSharp.Internal;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -83,14 +84,14 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <summary>
|
||||
/// Attach one shader code to a shader program.
|
||||
/// </summary>
|
||||
/// <param _name="target">
|
||||
/// <param _label="target">
|
||||
/// Shader program to attach
|
||||
/// </param>
|
||||
/// <param _name="index">
|
||||
/// <param _label="index">
|
||||
/// Index of shader code in current shader code set.
|
||||
/// </param>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void AttachTo( int index, ShaderProgram target )
|
||||
public void AttachTo( int index, [NotNull]ShaderProgram target )
|
||||
{
|
||||
GL.AttachShader( target.handle, handle[ index ] );
|
||||
}
|
||||
@@ -187,7 +188,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _name="name">
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
@@ -202,7 +203,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _name="name">
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
@@ -216,7 +217,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _name="name">
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
@@ -232,7 +233,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <summary>
|
||||
/// Get a uniform form current shader, the value type of the uniform should be provided.
|
||||
/// </summary>
|
||||
/// <param _name="name">
|
||||
/// <param _label="name">
|
||||
/// ContextName of the Uniform in shader code
|
||||
/// </param>
|
||||
/// <returns>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="Uniform.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -35,6 +35,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
@@ -65,7 +66,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
internal static Uniform<T> FromHandle( GlHandle handle )
|
||||
{
|
||||
return new Uniform<T> { id = handle };
|
||||
return new Uniform<T>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,14 +86,15 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
internal static Uniform<T, U> FromHandle( GlHandle handle )
|
||||
{
|
||||
return new Uniform<T, U> { id = handle };
|
||||
return new Uniform<T, U>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public sealed class Uniform<T, U, V> : Uniform where T: struct
|
||||
where U: struct
|
||||
where V: struct
|
||||
public sealed class Uniform<T, U, V> : Uniform where T: struct where U: struct where V: struct
|
||||
{
|
||||
|
||||
internal Uniform() { }
|
||||
@@ -101,13 +106,15 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
internal static Uniform<T, U, V> FromHandle( GlHandle handle )
|
||||
{
|
||||
return new Uniform<T, U, V> { id = handle };
|
||||
return new Uniform<T, U, V>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public sealed class Uniform<T, U, V, W> : Uniform where T: struct
|
||||
where U: struct
|
||||
public sealed class Uniform<T, U, V, W> : Uniform where T: struct where U: struct
|
||||
where V: struct
|
||||
where W: struct
|
||||
{
|
||||
@@ -121,7 +128,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
internal static Uniform<T, U, V, W> FromHandle( GlHandle handle )
|
||||
{
|
||||
return new Uniform<T, U, V, W> { id = handle };
|
||||
return new Uniform<T, U, V, W>
|
||||
{
|
||||
id = handle
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -133,14 +143,13 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public void SetUniformValue( [NotNull] Uniform<Matrix44> uniform, Matrix44 mat )
|
||||
{
|
||||
Matrix44 temp = mat;
|
||||
Context.glUniformMatrix4fv(
|
||||
uniform.id.SignedValue, 1, false, ( float* )&temp );
|
||||
Context.glUniformMatrix4fv( uniform.id.SignedValue, 1, false, ( float* )&temp );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void SetUniformValue(
|
||||
[NotNull]Uniform<float, float, float, float> uniform,
|
||||
Vec4 vec )
|
||||
[NotNull]Uniform<float, float, float, float> uniform,
|
||||
Vec4 vec )
|
||||
{
|
||||
Vec4 temp = vec;
|
||||
Context.glUniform1fv( uniform.id.SignedValue, 4, &temp.reg );
|
||||
@@ -166,31 +175,28 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void SetUniformValue(
|
||||
[NotNull] Uniform<float, float> uniform,
|
||||
float v0,
|
||||
float v1 )
|
||||
public void SetUniformValue( [NotNull] Uniform<float, float> uniform, float v0, float v1 )
|
||||
{
|
||||
Context.glUniform2f( uniform.id.SignedValue, v0, v1 );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void SetUniformValue(
|
||||
[NotNull] Uniform<float, float, float> uniform,
|
||||
float v0,
|
||||
float v1,
|
||||
float v2 )
|
||||
[NotNull] Uniform<float, float, float> uniform,
|
||||
float v0,
|
||||
float v1,
|
||||
float v2 )
|
||||
{
|
||||
Context.glUniform3f( uniform.id.SignedValue, v0, v1, v2 );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void SetUniformValue(
|
||||
[NotNull] Uniform<float, float, float, float> uniform,
|
||||
float v0,
|
||||
float v1,
|
||||
float v2,
|
||||
float v3 )
|
||||
[NotNull] Uniform<float, float, float, float> uniform,
|
||||
float v0,
|
||||
float v1,
|
||||
float v2,
|
||||
float v3 )
|
||||
{
|
||||
Context.glUniform4f( uniform.id.SignedValue, v0, v1, v2, v3 );
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,7 +38,7 @@ using System.Threading.Tasks;
|
||||
namespace StgSharp.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// OpenGL numeric type. An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
/// OpenGL numeric type. An IEEE-754 floating-point value, clamped to the range [0,1].
|
||||
/// </summary>
|
||||
[StructLayout( LayoutKind.Sequential )]
|
||||
public struct GLclampf
|
||||
@@ -64,8 +64,8 @@ namespace StgSharp.Internal
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OpenGL numeric type. An IEEE-754 double precision floating-point value, clamped to the range
|
||||
/// [0,1].
|
||||
/// OpenGL numeric type. An IEEE-754 double precision floating-point value, clamped to the
|
||||
/// range [0,1].
|
||||
/// </summary>
|
||||
[StructLayout( LayoutKind.Sequential )]
|
||||
public struct GLclampd
|
||||
|
||||
@@ -4851,7 +4851,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public static uint Color( int i )
|
||||
{
|
||||
#if DEBUG
|
||||
if( ( i > OpenGLFunction.CurrentGL.AttachmentColorRange ) || ( i < 0 ) ) {
|
||||
if( ( i > OpenGLFunction.CurrentGL.AttachmentColorRange ) || ( i < 0 ) )
|
||||
{
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glContext.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using StgSharp.HighPerformance;
|
||||
using StgSharp.Internal;
|
||||
using StgSharp.Internal.Intrinsic;
|
||||
@@ -57,16 +56,12 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
public static bool operator !=(
|
||||
OpenglContext left,
|
||||
OpenglContext right )
|
||||
public static bool operator !=( OpenglContext left, OpenglContext right )
|
||||
{
|
||||
return !( left == right );
|
||||
}
|
||||
|
||||
public static bool operator ==(
|
||||
OpenglContext left,
|
||||
OpenglContext right )
|
||||
public static bool operator ==( OpenglContext left, OpenglContext right )
|
||||
{
|
||||
return left.Equals( right );
|
||||
}
|
||||
@@ -95,7 +90,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint*, ulong*, uint, uint, uint, uint, IntPtr, IntPtr, UIntPtr, uint, uint*, ulong*, uint> glAsyncCopyBufferSubDataNVX;
|
||||
internal unsafe delegate*<uint, uint*, ulong*, uint, uint, uint, uint, int, int, int, int, uint, uint, int, int, int, int, uint, uint, uint, uint, uint*, ulong*, uint> glAsyncCopyImageSubDataNVX;
|
||||
internal unsafe delegate*<uint, void> glAsyncMarkerSGIX;
|
||||
internal unsafe delegate*<GLhandleARB, GLhandleARB, void> glAttachObjectARB;
|
||||
internal unsafe delegate*<glHandleARB, glHandleARB, void> glAttachObjectARB;
|
||||
internal unsafe delegate*<uint, uint, void> glAttachShader;
|
||||
internal unsafe delegate*<uint, uint, void> glBeginConditionalRender;
|
||||
internal unsafe delegate*<uint, uint, void> glBeginConditionalRenderNV;
|
||||
@@ -113,7 +108,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<void> glBeginVertexShaderEXT;
|
||||
internal unsafe delegate*<uint, void> glBeginVideoCaptureNV;
|
||||
internal unsafe delegate*<uint, uint, byte*, void> glBindAttribLocation;
|
||||
internal unsafe delegate*<GLhandleARB, uint, byte*, void> glBindAttribLocationARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, byte*, void> glBindAttribLocationARB;
|
||||
internal unsafe delegate*<uint, uint, void> glBindBuffer;
|
||||
internal unsafe delegate*<uint, uint, void> glBindBufferARB;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glBindBufferBase;
|
||||
@@ -301,7 +296,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, void> glCommandListSegmentsNV;
|
||||
internal unsafe delegate*<uint, void> glCompileCommandListNV;
|
||||
internal unsafe delegate*<uint, void> glCompileShader;
|
||||
internal unsafe delegate*<GLhandleARB, void> glCompileShaderARB;
|
||||
internal unsafe delegate*<glHandleARB, void> glCompileShaderARB;
|
||||
internal unsafe delegate*<uint, uint, byte*, int*, void> glCompileShaderIncludeARB;
|
||||
internal unsafe delegate*<uint, uint, int, uint, uint, int, uint, void*, void> glCompressedMultiTexImage1DEXT;
|
||||
internal unsafe delegate*<uint, uint, int, uint, uint, uint, int, uint, void*, void> glCompressedMultiTexImage2DEXT;
|
||||
@@ -384,7 +379,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint*, void> glCreateMemoryObjectsEXT;
|
||||
internal unsafe delegate*<uint, uint*, void> glCreatePerfQueryINTEL;
|
||||
internal unsafe delegate*<uint> glCreateProgram;
|
||||
internal unsafe delegate*<GLhandleARB> glCreateProgramObjectARB;
|
||||
internal unsafe delegate*<glHandleARB> glCreateProgramObjectARB;
|
||||
internal unsafe delegate*<uint, uint*, void> glCreateProgramPipelines;
|
||||
internal unsafe delegate*<uint> glCreateProgressFenceNVX;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glCreateQueries;
|
||||
@@ -392,7 +387,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint*, void> glCreateSamplers;
|
||||
internal unsafe delegate*<uint, uint*, void> glCreateSemaphoresNV;
|
||||
internal unsafe delegate*<uint, uint> glCreateShader;
|
||||
internal unsafe delegate*<uint, GLhandleARB> glCreateShaderObjectARB;
|
||||
internal unsafe delegate*<uint, glHandleARB> glCreateShaderObjectARB;
|
||||
internal unsafe delegate*<uint, byte*, uint> glCreateShaderProgramEXT;
|
||||
internal unsafe delegate*<uint, uint, byte*, uint> glCreateShaderProgramv;
|
||||
internal unsafe delegate*<uint, uint*, void> glCreateStatesNV;
|
||||
@@ -428,7 +423,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteMemoryObjectsEXT;
|
||||
internal unsafe delegate*<int, byte*, void> glDeleteNamedStringARB;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glDeleteNamesAMD;
|
||||
internal unsafe delegate*<GLhandleARB, void> glDeleteObjectARB;
|
||||
internal unsafe delegate*<glHandleARB, void> glDeleteObjectARB;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeleteOcclusionQueriesNV;
|
||||
internal unsafe delegate*<uint, uint, void> glDeletePathsNV;
|
||||
internal unsafe delegate*<uint, uint*, void> glDeletePerfMonitorsAMD;
|
||||
@@ -467,7 +462,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<float, float, void> glDepthRangef;
|
||||
internal unsafe delegate*<GLclampf, GLclampf, void> glDepthRangefOES;
|
||||
internal unsafe delegate*<GLfixed, GLfixed, void> glDepthRangexOES;
|
||||
internal unsafe delegate*<GLhandleARB, GLhandleARB, void> glDetachObjectARB;
|
||||
internal unsafe delegate*<glHandleARB, glHandleARB, void> glDetachObjectARB;
|
||||
internal unsafe delegate*<uint, uint, void> glDetachShader;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glDetailTexFuncSGIS;
|
||||
internal unsafe delegate*<uint, void> glDisable;
|
||||
@@ -682,12 +677,12 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, void> glGenerateTextureMipmapEXT;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetActiveAtomicCounterBufferiv;
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, int*, uint*, byte*, void> glGetActiveAttrib;
|
||||
internal unsafe delegate*<GLhandleARB, uint, uint, uint*, int*, uint*, byte*, void> glGetActiveAttribARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, uint, uint*, int*, uint*, byte*, void> glGetActiveAttribARB;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint*, byte*, void> glGetActiveSubroutineName;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint*, byte*, void> glGetActiveSubroutineUniformName;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, int*, void> glGetActiveSubroutineUniformiv;
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, int*, uint*, byte*, void> glGetActiveUniform;
|
||||
internal unsafe delegate*<GLhandleARB, uint, uint, uint*, int*, uint*, byte*, void> glGetActiveUniformARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, uint, uint*, int*, uint*, byte*, void> glGetActiveUniformARB;
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, byte*, void> glGetActiveUniformBlockName;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetActiveUniformBlockiv;
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, byte*, void> glGetActiveUniformName;
|
||||
@@ -695,10 +690,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, uint*, uint*, byte*, void> glGetActiveVaryingNV;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetArrayObjectfvATI;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetArrayObjectivATI;
|
||||
internal unsafe delegate*<GLhandleARB, uint, uint*, GLhandleARB*, void> glGetAttachedObjectsARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, uint*, glHandleARB*, void> glGetAttachedObjectsARB;
|
||||
internal unsafe delegate*<uint, uint, uint*, uint*, void> glGetAttachedShaders;
|
||||
internal unsafe delegate*<uint, byte*, int> glGetAttribLocation;
|
||||
internal unsafe delegate*<GLhandleARB, byte*, int> glGetAttribLocationARB;
|
||||
internal unsafe delegate*<glHandleARB, byte*, int> glGetAttribLocationARB;
|
||||
internal unsafe delegate*<uint, uint, bool*, void> glGetBooleanIndexedvEXT;
|
||||
internal unsafe delegate*<uint, uint, bool*, void> glGetBooleani_v;
|
||||
internal unsafe delegate*<uint, bool*, void> glGetBooleanv;
|
||||
@@ -769,7 +764,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetFramebufferParameterivMESA;
|
||||
internal unsafe delegate*<uint> glGetGraphicsResetStatus;
|
||||
internal unsafe delegate*<uint> glGetGraphicsResetStatusARB;
|
||||
internal unsafe delegate*<uint, GLhandleARB> glGetHandleARB;
|
||||
internal unsafe delegate*<uint, glHandleARB> glGetHandleARB;
|
||||
internal unsafe delegate*<uint, bool, uint, uint, void*, void> glGetHistogramEXT;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetHistogramParameterfvEXT;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetHistogramParameterivEXT;
|
||||
@@ -778,7 +773,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, int, bool, int, uint, ulong> glGetImageHandleNV;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glGetImageTransformParameterfvHP;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetImageTransformParameterivHP;
|
||||
internal unsafe delegate*<GLhandleARB, uint, uint*, byte*, void> glGetInfoLogARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, uint*, byte*, void> glGetInfoLogARB;
|
||||
internal unsafe delegate*<int> glGetInstrumentsSGIX;
|
||||
internal unsafe delegate*<uint, uint, long*, void> glGetInteger64i_v;
|
||||
internal unsafe delegate*<uint, long*, void> glGetInteger64v;
|
||||
@@ -853,9 +848,9 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetObjectBufferivATI;
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, byte*, void> glGetObjectLabel;
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, byte*, void> glGetObjectLabelEXT;
|
||||
internal unsafe delegate*<GLhandleARB, uint, float*, void> glGetObjectParameterfvARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, float*, void> glGetObjectParameterfvARB;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetObjectParameterivAPPLE;
|
||||
internal unsafe delegate*<GLhandleARB, uint, int*, void> glGetObjectParameterivARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, int*, void> glGetObjectParameterivARB;
|
||||
internal unsafe delegate*<void*, uint, uint*, byte*, void> glGetObjectPtrLabel;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetOcclusionQueryivNV;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glGetOcclusionQueryuivNV;
|
||||
@@ -944,7 +939,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, uint*, byte*, void> glGetShaderInfoLog;
|
||||
internal unsafe delegate*<uint, uint, int*, int*, void> glGetShaderPrecisionFormat;
|
||||
internal unsafe delegate*<uint, uint, uint*, byte*, void> glGetShaderSource;
|
||||
internal unsafe delegate*<GLhandleARB, uint, uint*, byte*, void> glGetShaderSourceARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, uint*, byte*, void> glGetShaderSourceARB;
|
||||
internal unsafe delegate*<uint, uint, int*, void> glGetShaderiv;
|
||||
internal unsafe delegate*<uint, uint, uint*, void> glGetShadingRateImagePaletteNV;
|
||||
internal unsafe delegate*<uint, uint, uint, int*, void> glGetShadingRateSampleLocationivNV;
|
||||
@@ -1002,16 +997,16 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, int, int> glGetUniformBufferSizeEXT;
|
||||
internal unsafe delegate*<uint, uint, byte*, char**, uint*, void> glGetUniformIndices;
|
||||
internal unsafe delegate*<uint, byte*, int> glGetUniformLocation;
|
||||
internal unsafe delegate*<GLhandleARB, byte*, int> glGetUniformLocationARB;
|
||||
internal unsafe delegate*<glHandleARB, byte*, int> glGetUniformLocationARB;
|
||||
internal unsafe delegate*<uint, int, IntPtr> glGetUniformOffsetEXT;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glGetUniformSubroutineuiv;
|
||||
internal unsafe delegate*<uint, int, double*, void> glGetUniformdv;
|
||||
internal unsafe delegate*<uint, int, float*, void> glGetUniformfv;
|
||||
internal unsafe delegate*<GLhandleARB, int, float*, void> glGetUniformfvARB;
|
||||
internal unsafe delegate*<glHandleARB, int, float*, void> glGetUniformfvARB;
|
||||
internal unsafe delegate*<uint, int, long*, void> glGetUniformi64vARB;
|
||||
internal unsafe delegate*<uint, int, long*, void> glGetUniformi64vNV;
|
||||
internal unsafe delegate*<uint, int, int*, void> glGetUniformiv;
|
||||
internal unsafe delegate*<GLhandleARB, int, int*, void> glGetUniformivARB;
|
||||
internal unsafe delegate*<glHandleARB, int, int*, void> glGetUniformivARB;
|
||||
internal unsafe delegate*<uint, int, ulong*, void> glGetUniformui64vARB;
|
||||
internal unsafe delegate*<uint, int, ulong*, void> glGetUniformui64vNV;
|
||||
internal unsafe delegate*<uint, int, uint*, void> glGetUniformuiv;
|
||||
@@ -1178,7 +1173,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<float, void> glLineWidth;
|
||||
internal unsafe delegate*<GLfixed, void> glLineWidthxOES;
|
||||
internal unsafe delegate*<uint, void> glLinkProgram;
|
||||
internal unsafe delegate*<GLhandleARB, void> glLinkProgramARB;
|
||||
internal unsafe delegate*<glHandleARB, void> glLinkProgramARB;
|
||||
internal unsafe delegate*<uint, uint, void**, uint*, uint*, uint*, uint, void> glListDrawCommandsStatesClientNV;
|
||||
internal unsafe delegate*<uint, uint, float, void> glListParameterfSGIX;
|
||||
internal unsafe delegate*<uint, uint, float*, void> glListParameterfvSGIX;
|
||||
@@ -1844,7 +1839,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, uint, uint, void> glShaderOp2EXT;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint, void> glShaderOp3EXT;
|
||||
internal unsafe delegate* unmanaged[Stdcall]<uint, uint, byte**, void*, void> glShaderSource;
|
||||
internal unsafe delegate*<GLhandleARB, uint, byte**, int*, void> glShaderSourceARB;
|
||||
internal unsafe delegate*<glHandleARB, uint, byte**, int*, void> glShaderSourceARB;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glShaderStorageBlockBinding;
|
||||
internal unsafe delegate*<bool, void> glShadingRateImageBarrierNV;
|
||||
internal unsafe delegate*<uint, uint, uint, uint*, void> glShadingRateImagePaletteNV;
|
||||
@@ -2196,7 +2191,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint, uint, void*, uint, void> glUpdateObjectBufferATI;
|
||||
internal unsafe delegate*<uint, void> glUploadGpuMaskNVX;
|
||||
internal unsafe delegate*<uint, void> glUseProgram;
|
||||
internal unsafe delegate*<GLhandleARB, void> glUseProgramObjectARB;
|
||||
internal unsafe delegate*<glHandleARB, void> glUseProgramObjectARB;
|
||||
internal unsafe delegate*<uint, uint, uint, void> glUseProgramStages;
|
||||
internal unsafe delegate*<uint, uint, void> glUseShaderProgramEXT;
|
||||
internal unsafe delegate*<void> glVDPAUFiniNV;
|
||||
@@ -2211,7 +2206,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal unsafe delegate*<uint, uint*, void> glVDPAUUnmapSurfacesNV;
|
||||
internal unsafe delegate*<uint, void> glVDPAUUnregisterSurfaceNV;
|
||||
internal unsafe delegate*<uint, void> glValidateProgram;
|
||||
internal unsafe delegate*<GLhandleARB, void> glValidateProgramARB;
|
||||
internal unsafe delegate*<glHandleARB, void> glValidateProgramARB;
|
||||
internal unsafe delegate*<uint, void> glValidateProgramPipeline;
|
||||
internal unsafe delegate*<uint, uint, uint, uint, uint, void> glVariantArrayObjectATI;
|
||||
internal unsafe delegate*<uint, uint, uint, void*, void> glVariantPointerEXT;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glEnum.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -28,13 +28,13 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
public enum PixelChannelLayout
|
||||
{
|
||||
|
||||
UByte = glConst.UNSIGNED_BYTE,
|
||||
Byte = glConst.BYTE,
|
||||
UShort = glConst.UNSIGNED_SHORT,
|
||||
@@ -54,6 +54,16 @@ namespace StgSharp.Graphics.OpenGL
|
||||
UInt8888Rev = glConst.UNSIGNED_INT_8_8_8_8_REV,
|
||||
UInt1010102 = glConst.UNSIGNED_INT_10_10_10_2,
|
||||
UInt2101010Rev = glConst.UNSIGNED_INT_2_10_10_10_REV
|
||||
|
||||
}
|
||||
|
||||
public enum FaceMode
|
||||
{
|
||||
|
||||
Point = glConst.POINT,
|
||||
Line = glConst.LINE,
|
||||
Fill = glConst.FILL
|
||||
|
||||
}
|
||||
|
||||
public enum FrameBufferStatus
|
||||
@@ -125,12 +135,18 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
public enum glOperation : uint
|
||||
{
|
||||
|
||||
StencilTest = glConst.STENCIL_TEST,
|
||||
DepthTest = glConst.DEPTH_TEST,
|
||||
PolygonOffsetFill = glConst.POLYGON_OFFSET_FILL,
|
||||
PolygonOffsetLine = glConst.POLYGON_OFFSET_LINE,
|
||||
PolygonOffsetPoint = glConst.POLYGON_OFFSET_POINT,
|
||||
|
||||
}
|
||||
|
||||
#pragma warning disable CA1008
|
||||
#pragma warning disable CA1008
|
||||
public enum ShaderType : int
|
||||
#pragma warning restore CA1008
|
||||
#pragma warning restore CA1008
|
||||
{
|
||||
|
||||
Fragment = glConst.FRAGMENT_SHADER,
|
||||
@@ -140,9 +156,9 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
}
|
||||
|
||||
#pragma warning disable CA1008
|
||||
#pragma warning disable CA1008
|
||||
public enum BufferType : int
|
||||
#pragma warning restore CA1008
|
||||
#pragma warning restore CA1008
|
||||
{
|
||||
|
||||
ArrayBuffer = glConst.ARRAY_BUFFER,
|
||||
@@ -162,9 +178,9 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
}
|
||||
|
||||
#pragma warning disable CA1008
|
||||
#pragma warning disable CA1008
|
||||
public enum BufferUsage : int
|
||||
#pragma warning restore CA1008
|
||||
#pragma warning restore CA1008
|
||||
{
|
||||
|
||||
StreamDraw = 0x88E0,
|
||||
|
||||
@@ -60,19 +60,13 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
internal GlArrayFormatException( string message ) : base( message ) { }
|
||||
|
||||
internal GlArrayFormatException(
|
||||
SerializationInfo info,
|
||||
StreamingContext context )
|
||||
internal GlArrayFormatException( SerializationInfo info, StreamingContext context )
|
||||
: base( info, context ) { }
|
||||
|
||||
internal GlArrayFormatException(
|
||||
string message,
|
||||
Exception innerException )
|
||||
internal GlArrayFormatException( string message, Exception innerException )
|
||||
: base( message, innerException ) { }
|
||||
|
||||
public GlArrayFormatException(
|
||||
PixelChannelLayout layout,
|
||||
string arrayname )
|
||||
public GlArrayFormatException( PixelChannelLayout layout, string arrayname )
|
||||
: base( $"{arrayname} cannot be used as layout of {layout}" ) { }
|
||||
|
||||
}
|
||||
@@ -80,13 +74,12 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public static partial class GlHelper
|
||||
{
|
||||
|
||||
public static bool CheckArrayFormat(
|
||||
this Array array,
|
||||
PixelChannelLayout layout )
|
||||
public static bool CheckArrayFormat( this Array array, PixelChannelLayout layout )
|
||||
{
|
||||
return layout switch
|
||||
{
|
||||
PixelChannelLayout.Byte or PixelChannelLayout.UByte332 or PixelChannelLayout.UByte233Rev => ( array is byte[] ) || ( array is sbyte[] ),
|
||||
PixelChannelLayout.Byte or PixelChannelLayout.UByte332 or PixelChannelLayout.UByte233Rev => ( array is byte[] ) ||
|
||||
( array is sbyte[] ),
|
||||
PixelChannelLayout.Short => array is short[],
|
||||
PixelChannelLayout.UShort => array is ushort[],
|
||||
PixelChannelLayout.Int => array is int[],
|
||||
|
||||
@@ -55,7 +55,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
internal void ReturnAvailableUnit( IEnumerable<TextureUnit> source )
|
||||
{
|
||||
int v = glConst.TEXTURE0 + TextureUnitCount;
|
||||
foreach( TextureUnit unit in source ) {
|
||||
foreach( TextureUnit unit in source )
|
||||
{
|
||||
if( ( int )unit > v ) {
|
||||
throw new InvalidOperationException(
|
||||
"Source contains texture unit beyond context support." );
|
||||
@@ -63,15 +64,16 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
internal int TryGetAvailableTextureUnit(
|
||||
int count,
|
||||
out IEnumerable<TextureUnit> result )
|
||||
internal int TryGetAvailableTextureUnit( int count, out IEnumerable<TextureUnit> result )
|
||||
{
|
||||
result = new Queue<TextureUnit>();
|
||||
for( int i = 0; i < count; i++ ) {
|
||||
if( UnusedTextureImageUint.TryDequeue( out TextureUnit unit ) ) {
|
||||
for( int i = 0; i < count; i++ )
|
||||
{
|
||||
if( UnusedTextureImageUint.TryDequeue( out TextureUnit unit ) )
|
||||
{
|
||||
( result as Queue<TextureUnit> )!.Enqueue( unit );
|
||||
} else {
|
||||
} else
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -80,8 +82,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
private ConcurrentQueue<TextureUnit> InitializeUnusedTextureImageUint()
|
||||
{
|
||||
ConcurrentQueue<TextureUnit> result = new ConcurrentQueue<TextureUnit>(
|
||||
);
|
||||
ConcurrentQueue<TextureUnit> result = new ConcurrentQueue<TextureUnit>();
|
||||
for( int index = 0; index < TextureUnitCount; index++ ) {
|
||||
result.Enqueue( ( TextureUnit )( glConst.TEXTURE0 + index ) );
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glFunction.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -128,10 +128,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// Bind a frame Buffer to a frame Buffer target Same function as <see
|
||||
/// href="https://docs._gl/gl3/glBindFramebuffer"> glBindFramebuffer </see>.
|
||||
/// </summary>
|
||||
/// <param _name="target">
|
||||
/// <param _label="target">
|
||||
/// The frame Buffer target of the binding operation.
|
||||
/// </param>
|
||||
/// <param _name="handle">
|
||||
/// <param _label="handle">
|
||||
/// The handle of the frame Buffer object to bind.
|
||||
/// </param>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
@@ -283,7 +283,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// only deifference is that this mehtod can only delete one renderbuffer at the same
|
||||
/// time.
|
||||
/// </summary>
|
||||
/// <param _name="bufferHandle">
|
||||
/// <param _label="bufferHandle">
|
||||
/// Handle to Buffer to delete.
|
||||
/// </param>
|
||||
public unsafe void DeleteRenderBuffer( GlHandle bufferHandle )
|
||||
@@ -303,6 +303,23 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
public void DepthMaskAccess( bool isWrite )
|
||||
{
|
||||
Context.glDepthMask( isWrite );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void Disable( glOperation operation )
|
||||
{
|
||||
Context.glDisable( ( uint )operation );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public unsafe void DrawArrays( GeometryType mode, int first, uint count )
|
||||
{
|
||||
Context.glDrawArrays( ( uint )mode, first, count );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public unsafe void DrawElements( GeometryType mode, uint count, TypeCode type, IntPtr ptr )
|
||||
{
|
||||
@@ -340,7 +357,6 @@ namespace StgSharp.Graphics.OpenGL
|
||||
case TypeCode.Byte:
|
||||
a = glConst.UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
default:
|
||||
InternalIO.InternalWriteLog(
|
||||
$"{$"Parameter error in parameter {nameof(type)} method DrawElements. "}{$"Only {typeof(uint).Name},{typeof(ushort).Name},{typeof(byte).Name} types are supported."}",
|
||||
@@ -525,6 +541,18 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void PolygonMode( FaceMode mode )
|
||||
{
|
||||
Context.glPolygonMode( glConst.FRONT_AND_BACK, ( uint )mode );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void PolygonOffset( float factor, float unit )
|
||||
{
|
||||
Context.glPolygonOffset( factor, unit );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void ReadPixels(
|
||||
(int X, int Y) beginPosition,
|
||||
@@ -595,16 +623,16 @@ namespace StgSharp.Graphics.OpenGL
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public unsafe void SetBufferData<T>(
|
||||
BufferType bufferType,
|
||||
ReadOnlySpan<T> bufferArray,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage )
|
||||
where T: struct,INumber<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf( typeof( T ) );
|
||||
if( bufferArray == null ) {
|
||||
int size = bufferSpan.Length * Marshal.SizeOf( typeof( T ) );
|
||||
if( bufferSpan == null ) {
|
||||
return;
|
||||
}
|
||||
#pragma warning disable CS8500
|
||||
fixed( void* bufferPtr = bufferArray )
|
||||
fixed( void* bufferPtr = bufferSpan )
|
||||
#pragma warning restore CS8500
|
||||
{
|
||||
Context.glBufferData(
|
||||
@@ -625,7 +653,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
#pragma warning disable CS8500
|
||||
fixed( void* bufferPtr = &bufferArray.GetPinnableReference() )
|
||||
fixed( void* bufferPtr = bufferArray )
|
||||
#pragma warning restore CS8500
|
||||
{
|
||||
Context.glBufferData(
|
||||
@@ -636,16 +664,13 @@ namespace StgSharp.Graphics.OpenGL
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public unsafe void SetBufferVectorData<T>(
|
||||
BufferType bufferType,
|
||||
ReadOnlySpan<T> bufferArray,
|
||||
ReadOnlySpan<T> bufferSpan,
|
||||
BufferUsage usage )
|
||||
where T: struct, IVector<T>
|
||||
{
|
||||
int size = bufferArray.Length * Marshal.SizeOf( typeof( T ) );
|
||||
if( bufferArray == null ) {
|
||||
return;
|
||||
}
|
||||
int size = bufferSpan.Length * Marshal.SizeOf( typeof( T ) );
|
||||
#pragma warning disable CS8500
|
||||
fixed( void* bufferPtr = &bufferArray.GetPinnableReference() )
|
||||
fixed( void* bufferPtr = bufferSpan )
|
||||
#pragma warning restore CS8500
|
||||
{
|
||||
Context.glBufferData(
|
||||
@@ -783,6 +808,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
Context.glViewport( x, y, width, height );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public void WaitAccomplishment()
|
||||
{
|
||||
Context.glFinish();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glHalfNV.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -35,7 +35,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Internal.OpenGL
|
||||
namespace StgSharp.Graphics.OpenGL
|
||||
{
|
||||
[StructLayout( LayoutKind.Explicit, Size = 16 )]
|
||||
public struct glHalfNV
|
||||
@@ -48,9 +48,14 @@ namespace StgSharp.Internal.OpenGL
|
||||
binary = bin;
|
||||
}
|
||||
|
||||
public static glHalfNV FromInt16(short x)
|
||||
public static glHalfNV FromInt16( short x )
|
||||
{
|
||||
return new glHalfNV(x);
|
||||
return new glHalfNV( x );
|
||||
}
|
||||
|
||||
public static short ToInt16( glHalfNV half )
|
||||
{
|
||||
return half.binary;
|
||||
}
|
||||
|
||||
public static explicit operator glHalfNV( short x )
|
||||
@@ -58,11 +63,6 @@ namespace StgSharp.Internal.OpenGL
|
||||
return new glHalfNV( x );
|
||||
}
|
||||
|
||||
public static short ToInt16(glHalfNV half)
|
||||
{
|
||||
return half.binary;
|
||||
}
|
||||
|
||||
public static explicit operator short( glHalfNV x )
|
||||
{
|
||||
return x.binary;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glHandle.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -46,24 +46,33 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public struct GlHandle
|
||||
{
|
||||
|
||||
[FieldOffset( 0 )] public int SignedValue;
|
||||
[FieldOffset( 0 )] public uint Value;
|
||||
[FieldOffset( 0 )] internal int SignedValue;
|
||||
[FieldOffset( 0 )] internal uint Value;
|
||||
|
||||
public static GlHandle Zero
|
||||
{
|
||||
get => new GlHandle { Value = 0 };
|
||||
get => new GlHandle
|
||||
{
|
||||
Value = 0
|
||||
};
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static GlHandle Alloc( uint value )
|
||||
{
|
||||
return new GlHandle { Value = value };
|
||||
return new GlHandle
|
||||
{
|
||||
Value = value
|
||||
};
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public static GlHandle SignedAlloc( int value )
|
||||
{
|
||||
return new GlHandle { SignedValue = value };
|
||||
return new GlHandle
|
||||
{
|
||||
SignedValue = value
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glRenderSourceGenrator.cs"
|
||||
// file="glRenderObjectGenrator.cs"
|
||||
// Project: StgSharp
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
@@ -48,10 +48,14 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a set of <see cref="ElementBuffer" />.
|
||||
/// Create a set of <see cref="ElementBuffer" />.
|
||||
/// </summary>
|
||||
/// <param _name="count"> Amount of EBO to be created. </param>
|
||||
/// <returns></returns>
|
||||
/// <param _label="count">
|
||||
/// Amount of EBO to be created.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
protected ElementBuffer CreateElementBuffer( int count )
|
||||
{
|
||||
@@ -71,10 +75,14 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a sets of <see cref="TextureGL" />
|
||||
/// Create a sets of <see cref="TextureGL" />
|
||||
/// </summary>
|
||||
/// <param _name="count"> Amount of textures to be created. </param>
|
||||
/// <returns></returns>
|
||||
/// <param _label="count">
|
||||
/// Amount of textures to be created.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
protected TextureGL CreateTexture( int count )
|
||||
{
|
||||
@@ -82,10 +90,14 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a set of <see cref="VertexArray" />.
|
||||
/// Create a set of <see cref="VertexArray" />.
|
||||
/// </summary>
|
||||
/// <param _name="count"> Amount of VAO to be created. </param>
|
||||
/// <returns></returns>
|
||||
/// <param _label="count">
|
||||
/// Amount of VAO to be created.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
protected VertexArray CreateVertexArray( int count )
|
||||
{
|
||||
@@ -93,10 +105,14 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a set of <see cref="VertexBuffer" />.
|
||||
/// Create a set of <see cref="VertexBuffer" />.
|
||||
/// </summary>
|
||||
/// <param _name="count"> Amount of Object to be created. </param>
|
||||
/// <returns></returns>
|
||||
/// <param _label="count">
|
||||
/// Amount of Object to be created.
|
||||
/// </param>
|
||||
/// <returns>
|
||||
///
|
||||
/// </returns>
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
protected VertexBuffer CreateVertexBuffer( int count )
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glRenderStream.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -58,29 +58,28 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an opengl context and load all opengl functions.
|
||||
/// Initialize an opengl context and load all opengl functions.
|
||||
/// </summary>
|
||||
public unsafe void InitializeContext()
|
||||
{
|
||||
if( ContextHandle == default ) {
|
||||
ContextHandle = Marshal.AllocHGlobal(
|
||||
Marshal.SizeOf( typeof( OpenglContext ) ) );
|
||||
if( ContextHandle == default )
|
||||
{
|
||||
ContextHandle = Marshal.AllocHGlobal( Marshal.SizeOf( typeof( OpenglContext ) ) );
|
||||
OpenglContext* contextID = ( OpenglContext* )ContextHandle;
|
||||
contextID->glGetString = ( delegate*<uint, IntPtr> )IntPtr.Zero;
|
||||
}
|
||||
if( GL == null ) {
|
||||
_context = OpenGLFunction.BuildGlFunctionPackage(
|
||||
ContextHandle );
|
||||
_context = OpenGLFunction.BuildGlFunctionPackage( ContextHandle );
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize an OpenGl viewPortDisplay if current form has not been binded to any
|
||||
/// viewPortDisplay. and set the viewPortDisplay binded to current form as current OpenGL
|
||||
/// viewPortDisplay.
|
||||
/// Initialize an OpenGl viewPortDisplay if current form has not been binded to any
|
||||
/// viewPortDisplay. and set the viewPortDisplay binded to current form as current OpenGL
|
||||
/// viewPortDisplay.
|
||||
/// </summary>
|
||||
/// <exception cref="Exception">
|
||||
/// Something goes wrong and StgSharp fails in creating a new OpenGL viewPortDisplay.
|
||||
/// Something goes wrong and World fails in creating a new OpenGL viewPortDisplay.
|
||||
/// </exception>
|
||||
public unsafe void MakeAsCurrentContext()
|
||||
{
|
||||
@@ -91,8 +90,7 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <inheritdoc />
|
||||
public override void RenderEnd()
|
||||
{
|
||||
if( !renderToThread.TryGetValue( this,
|
||||
out Thread t ) || t != Thread.CurrentThread ) {
|
||||
if( !renderToThread.TryGetValue( this, out Thread t ) || t != Thread.CurrentThread ) {
|
||||
throw new InvalidOperationException(
|
||||
$"Current render has had been binded to thread {t!.ManagedThreadId}" );
|
||||
}
|
||||
@@ -106,8 +104,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
public override void RenderStart()
|
||||
{
|
||||
Thread current = Thread.CurrentThread;
|
||||
if( !renderToThread.TryGetValue( this,
|
||||
out Thread t ) || t == ThreadHelper.EmptyThread ) {
|
||||
if( !renderToThread.TryGetValue( this, out Thread t ) || t == ThreadHelper.EmptyThread )
|
||||
{
|
||||
renderToThread[ this ] = current;
|
||||
MakeAsCurrentContext();
|
||||
return;
|
||||
@@ -120,10 +118,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
public override void SetSizeLimit(
|
||||
int minWidth,
|
||||
int minHeight,
|
||||
int maxWidth,
|
||||
int maxHeight )
|
||||
int minWidth,
|
||||
int minHeight,
|
||||
int maxWidth,
|
||||
int maxHeight )
|
||||
{
|
||||
InternalIO.glfwSetWindowSizeLimits(
|
||||
this.CanvasHandle, minWidth, minHeight, maxWidth, maxHeight );
|
||||
@@ -144,8 +142,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
protected override sealed Uniform<Matrix44> NativeCameraUniform(
|
||||
ShaderProgram source,
|
||||
string name )
|
||||
ShaderProgram source,
|
||||
string name )
|
||||
{
|
||||
NativeCamera.GainAllUniforms( source, name );
|
||||
return NativeCamera.convertedUniform;
|
||||
@@ -153,18 +151,18 @@ namespace StgSharp.Graphics.OpenGL
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
protected override sealed void NativeCameraViewRange(
|
||||
Radius fieldOfRange,
|
||||
Vec2 offset,
|
||||
(float frontDepth, float backDepth) viewDepth )
|
||||
Radius fieldOfRange,
|
||||
Vec2 offset,
|
||||
(float frontDepth, float backDepth) viewDepth )
|
||||
{
|
||||
NativeCamera.SetViewRange(
|
||||
fieldOfRange, this.Size, offset, viewDepth );
|
||||
NativeCamera.SetViewRange( fieldOfRange, this.Size, offset, viewDepth );
|
||||
}
|
||||
|
||||
[MethodImpl( MethodImplOptions.AggressiveInlining )]
|
||||
protected override sealed void NativeCameraViewTarget(
|
||||
Vec3 position,
|
||||
Vec3 direction,
|
||||
Vec3 up )
|
||||
Vec3 position,
|
||||
Vec3 direction,
|
||||
Vec3 up )
|
||||
{
|
||||
NativeCamera.SetViewDirection( position, direction, up );
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// file="glType.cs"
|
||||
// Project: StgSharp
|
||||
// Project: StepVisualizer
|
||||
// AuthorGroup: Nitload Space
|
||||
// Copyright (c) Nitload Space. All rights reserved.
|
||||
//
|
||||
@@ -28,7 +28,6 @@
|
||||
//
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
@@ -37,24 +36,26 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Internal.OpenGL
|
||||
{
|
||||
public delegate IntPtr GLfuncLoader( string name );
|
||||
|
||||
internal delegate void GLVULKANPROCNV();
|
||||
|
||||
public unsafe struct GLhandleARB
|
||||
public unsafe struct glHandleARB
|
||||
{
|
||||
|
||||
private dynamic value;
|
||||
|
||||
public unsafe GLhandleARB( dynamic value )
|
||||
public unsafe glHandleARB( dynamic value )
|
||||
{
|
||||
if( !RuntimeInformation.IsOSPlatform( OSPlatform.OSX ) ) {
|
||||
if( value.GetType().Name != "Uint32" ) {
|
||||
if( !RuntimeInformation.IsOSPlatform( OSPlatform.OSX ) )
|
||||
{
|
||||
if( value.GetType().Name != "Uint32" )
|
||||
{
|
||||
goto errorlog;
|
||||
}
|
||||
this.value = value;
|
||||
} else {
|
||||
if( value.GetType().Name != "IntPtr" ) {
|
||||
} else
|
||||
{
|
||||
if( value.GetType().Name != "IntPtr" )
|
||||
{
|
||||
goto errorlog;
|
||||
}
|
||||
this.value = value;
|
||||
@@ -68,81 +69,10 @@ namespace StgSharp.Internal.OpenGL
|
||||
}
|
||||
}
|
||||
|
||||
public static implicit operator uint( GLhandleARB value )
|
||||
public static implicit operator uint( glHandleARB value )
|
||||
{
|
||||
return ( uint )value;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region GLFW_dele
|
||||
|
||||
internal unsafe delegate void GLFWwindowsizefun(
|
||||
glfwWindow* window,
|
||||
int width,
|
||||
int height );
|
||||
internal unsafe delegate void GLFWwindowrefreshfun( glfwWindow* window );
|
||||
internal unsafe delegate void GLFWwindowposfun(
|
||||
glfwWindow* window,
|
||||
int xpos,
|
||||
int ypos );
|
||||
internal unsafe delegate void GLFWwindowmaximizefun(
|
||||
glfwWindow* window,
|
||||
int maximized );
|
||||
internal unsafe delegate void GLFWwindowiconifyfun(
|
||||
glfwWindow* window,
|
||||
int iconified );
|
||||
internal unsafe delegate void GLFWwindowfocusfun(
|
||||
glfwWindow* window,
|
||||
int focused );
|
||||
internal unsafe delegate void GLFWwindowcontentscalefun(
|
||||
glfwWindow* window,
|
||||
float xscale,
|
||||
float yscale );
|
||||
internal unsafe delegate void GLFWwindowclosefun( glfwWindow* window );
|
||||
internal unsafe delegate void GLFWvkproc();
|
||||
internal unsafe delegate void GLFWscrollfun(
|
||||
glfwWindow* window,
|
||||
double xoffset,
|
||||
double yoffset );
|
||||
internal unsafe delegate void GLFWmousebuttonfun(
|
||||
glfwWindow* window,
|
||||
int button,
|
||||
int action,
|
||||
int mods );
|
||||
internal unsafe delegate void GLFWmonitorfun(
|
||||
glfwMonitor* monitor,
|
||||
int monitorevent );
|
||||
internal unsafe delegate void GLFWkeyfun(
|
||||
glfwWindow* window,
|
||||
int key,
|
||||
int scancode,
|
||||
int action,
|
||||
int mods );
|
||||
internal unsafe delegate void GLFWjoystickfun( int jid, int keyevent );
|
||||
public unsafe delegate void GLFWglproc();
|
||||
internal unsafe delegate void GLFWerrorfun(
|
||||
int error_code,
|
||||
sbyte* description );
|
||||
internal unsafe delegate void GLFWdropfun(
|
||||
glfwWindow* window,
|
||||
int path_count,
|
||||
sbyte*[] paths );
|
||||
internal unsafe delegate void GLFWcursorposfun(
|
||||
glfwWindow* window,
|
||||
double xpos,
|
||||
double ypos );
|
||||
internal unsafe delegate void GLFWcursorenterfun(
|
||||
glfwWindow* window,
|
||||
int entered );
|
||||
internal unsafe delegate void GLFWcharmodsfun(
|
||||
glfwWindow* window,
|
||||
uint codepoint,
|
||||
int mods );
|
||||
internal unsafe delegate void GLFWcharfun(
|
||||
glfwWindow* window,
|
||||
uint codepoint );
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user