add a scanner, but this seems to be a wrong solution. Change open-source head
This commit is contained in:
@@ -1,30 +1,10 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="TextureGL"
|
||||
// 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.
|
||||
//
|
||||
// -----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using StgSharp.Graphics;
|
||||
using StgSharp.HighPerformance.ProcessorAbstraction;
|
||||
using StgSharp.Mathematics;
|
||||
@@ -45,38 +25,41 @@ namespace StgSharp.Graphics.OpenGL
|
||||
private OpenGLFunction _gl;
|
||||
internal GlHandle[] _textureHandle;
|
||||
|
||||
internal TextureGL(int count, glRender binding)
|
||||
internal TextureGL(
|
||||
int count,
|
||||
glRender binding
|
||||
)
|
||||
{
|
||||
// sourceList = new Image[count];
|
||||
this._gl = binding.GL;
|
||||
_textureHandle = _gl.GenTextures(count);
|
||||
}
|
||||
|
||||
public GlHandle this[int index]
|
||||
public GlHandle this[
|
||||
int index
|
||||
]
|
||||
{
|
||||
get => _textureHandle[index];
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get => _textureHandle.Length;
|
||||
}
|
||||
public int Count => _textureHandle.Length;
|
||||
|
||||
// internal Image[] sourceList;
|
||||
|
||||
public int IndexOfCurrentTexture
|
||||
{
|
||||
get => currentEditingTextureIndex;
|
||||
}
|
||||
public int IndexOfCurrentTexture => currentEditingTextureIndex;
|
||||
|
||||
internal OpenGLFunction GL => _gl;
|
||||
|
||||
public void ActivateAs(TextureUnit unit)
|
||||
public void ActivateAs(
|
||||
TextureUnit unit
|
||||
)
|
||||
{
|
||||
_gl.ActiveTextureUnit((uint)unit);
|
||||
}
|
||||
|
||||
public void Bind2D(int index)
|
||||
public void Bind2D(
|
||||
int index
|
||||
)
|
||||
{
|
||||
currentEditingTextureIndex = index;
|
||||
_gl.BindTexture(glConst.TEXTURE_2D, _textureHandle[index]);
|
||||
@@ -91,18 +74,25 @@ namespace StgSharp.Graphics.OpenGL
|
||||
/// <param _label="i">
|
||||
///
|
||||
/// </param>
|
||||
public unsafe void LoadTexture(int index, Image i)
|
||||
public unsafe void LoadTexture(
|
||||
int index,
|
||||
Image i
|
||||
)
|
||||
{
|
||||
byte[] handle = i.PixelBuffer;
|
||||
_gl.TextureImage2d(Texture2DTarget.Texture2D, 0, i.Channel, i.Width, i.Height, i.Channel, i.PixelLayout,
|
||||
pixels:handle);
|
||||
_gl.TextureImage2d(Texture2DTarget.Texture2D, 0, i.Channel, i.Width, i.Height,
|
||||
i.Channel, i.PixelLayout, pixels:handle);
|
||||
_gl.GenerateMipmap(Texture2DTarget.Texture2D);
|
||||
}
|
||||
|
||||
#region texture setting
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Set2dFilterProperty(int index, TextureFilter onMinify, TextureFilter onMagnify)
|
||||
public void Set2dFilterProperty(
|
||||
int index,
|
||||
TextureFilter onMinify,
|
||||
TextureFilter onMagnify
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
if (index != currentEditingTextureIndex)
|
||||
@@ -117,7 +107,11 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Set2dWrapProperty(int index, TextureWrap onHorizontial, TextureWrap onVertical)
|
||||
public void Set2dWrapProperty(
|
||||
int index,
|
||||
TextureWrap onHorizontial,
|
||||
TextureWrap onVertical
|
||||
)
|
||||
{
|
||||
#if DEBUG
|
||||
if (index != currentEditingTextureIndex)
|
||||
@@ -132,7 +126,10 @@ namespace StgSharp.Graphics.OpenGL
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Set2dProperty(int index, TextureProperty property)
|
||||
public void Set2dProperty(
|
||||
int index,
|
||||
TextureProperty property
|
||||
)
|
||||
{
|
||||
Set2dFilterProperty(index, property.FilterOnMinify, property.FilterOnMagnify);
|
||||
Set2dWrapProperty(index, property.WrapOnHorizontial, property.WrapOnVertical);
|
||||
@@ -156,7 +153,8 @@ namespace StgSharp.Graphics.OpenGL
|
||||
TextureFilter onMagnify,
|
||||
TextureFilter onMinify,
|
||||
TextureWrap onHorizontal,
|
||||
TextureWrap onVertical)
|
||||
TextureWrap onVertical
|
||||
)
|
||||
{
|
||||
FilterOnMagnify = onMagnify;
|
||||
FilterOnMinify = onMinify;
|
||||
@@ -188,14 +186,17 @@ namespace StgSharp.Graphics.OpenGL
|
||||
set => vert = value;
|
||||
}
|
||||
|
||||
public override bool Equals([NotNullWhen(true)] object obj)
|
||||
public override bool Equals(
|
||||
[NotNullWhen(true)] object obj
|
||||
)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(FilterOnMagnify, FilterOnMagnify, WrapOnHorizontial, WrapOnVertical);
|
||||
return HashCode.Combine(FilterOnMagnify, FilterOnMagnify, WrapOnHorizontial,
|
||||
WrapOnVertical);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@@ -203,12 +204,18 @@ 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;
|
||||
}
|
||||
@@ -217,10 +224,12 @@ namespace StgSharp.Graphics.OpenGL
|
||||
(
|
||||
TextureFilter onMagnify, TextureFilter onMinify,
|
||||
TextureWrap onHorizontial, TextureWrap onVertical
|
||||
) propertyValueTuple)
|
||||
) propertyValueTuple
|
||||
)
|
||||
{
|
||||
return new TextureProperty(propertyValueTuple.onMagnify, propertyValueTuple.onMinify,
|
||||
propertyValueTuple.onHorizontial, propertyValueTuple.onVertical);
|
||||
propertyValueTuple.onHorizontial,
|
||||
propertyValueTuple.onVertical);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user