daily update on 20240325 by nitload youmu
This commit is contained in:
@@ -43,7 +43,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
protected glHandleSet _bufferHandle;
|
||||
protected IglFunc GL;
|
||||
protected Form binding;
|
||||
|
||||
/// <summary>
|
||||
/// Get the only handle to one of the Object instance
|
||||
|
||||
@@ -46,29 +46,29 @@ namespace StgSharp.Graphics
|
||||
public unsafe class ElementBuffer : BufferObjectBase
|
||||
{
|
||||
|
||||
internal ElementBuffer(int n, IglFunc gl)
|
||||
internal ElementBuffer(int n, Form binding)
|
||||
{
|
||||
GL = gl;
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
this.binding = binding;
|
||||
_bufferHandle = binding.GL.GenBuffers(n);
|
||||
}
|
||||
|
||||
public override sealed void Bind(int index)
|
||||
{
|
||||
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferHandle[index]);
|
||||
binding.GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferHandle[index]);
|
||||
}
|
||||
|
||||
public void SetValue<T>(int index, T[] bufferArray, BufferUsage usage)
|
||||
where T : struct, IConvertible
|
||||
{
|
||||
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferHandle[index]);
|
||||
GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage);
|
||||
binding.GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferHandle[index]);
|
||||
binding.GL.SetBufferData(BufferType.ELEMENT_ARRAY_BUFFER, bufferArray, usage);
|
||||
}
|
||||
|
||||
protected override sealed void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
GL.DeleteBuffers(_bufferHandle);
|
||||
binding.GL.DeleteBuffers(_bufferHandle);
|
||||
_bufferHandle.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,28 +38,28 @@ namespace StgSharp.Graphics
|
||||
public unsafe class VertexArray : BufferObjectBase
|
||||
{
|
||||
|
||||
internal VertexArray(int n, IglFunc gl)
|
||||
internal VertexArray(int n, Form binding)
|
||||
{
|
||||
GL = gl;
|
||||
_bufferHandle = GL.GenVertexArrays(n);
|
||||
this.binding = binding;
|
||||
_bufferHandle = binding.GL.GenVertexArrays(n);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override sealed void Bind(int index)
|
||||
{
|
||||
GL.BindVertexArray(_bufferHandle[index]);
|
||||
binding.GL.BindVertexArray(_bufferHandle[index]);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void BindNull()
|
||||
{
|
||||
GL.BindVertexArray(glHandle.Zero);
|
||||
binding.GL.BindVertexArray(glHandle.Zero);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetVertexAttribute(uint index, int vertexLength, TypeCode dataType, bool isNomalized, uint stride, int pointer)
|
||||
{
|
||||
GL.SetVertexAttribute(
|
||||
binding.GL.SetVertexAttribute(
|
||||
index, vertexLength, dataType,
|
||||
isNomalized,
|
||||
stride, pointer);
|
||||
@@ -69,7 +69,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
GL.DeleteVertexArrays(_bufferHandle);
|
||||
binding.GL.DeleteVertexArrays(_bufferHandle);
|
||||
_bufferHandle.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,15 +43,15 @@ namespace StgSharp.Graphics
|
||||
public unsafe class VertexBuffer : BufferObjectBase
|
||||
{
|
||||
|
||||
internal VertexBuffer(int n, IglFunc glFunc)
|
||||
internal VertexBuffer(int n, Form binding)
|
||||
{
|
||||
GL = glFunc;
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
this.binding = binding;
|
||||
_bufferHandle = binding.GL.GenBuffers(n);
|
||||
}
|
||||
|
||||
public override sealed void Bind(int index)
|
||||
{
|
||||
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
|
||||
binding.GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -63,8 +63,8 @@ namespace StgSharp.Graphics
|
||||
/// <param name="usage">How OpenGL use these data, defined by <see cref="BufferUsage"/></param>
|
||||
public void SetValue<T>(int index, T bufferData, BufferUsage usage) where T : struct, IMat
|
||||
{
|
||||
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
|
||||
GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferData, usage);
|
||||
binding.GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
|
||||
binding.GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferData, usage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -76,8 +76,8 @@ namespace StgSharp.Graphics
|
||||
/// <param name="usage">How OpenGL use these data, defined by <see cref="BufferUsage"/></param>
|
||||
public void SetValueArray<T>(int index, T[] bufferArray, BufferUsage usage) where T : struct, IConvertible
|
||||
{
|
||||
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
|
||||
GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferArray, usage);
|
||||
binding.GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
|
||||
binding.GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferArray, usage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -86,20 +86,16 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void Unbind()
|
||||
{
|
||||
GL.BindBuffer(BufferType.ARRAY_BUFFER, glHandle.Zero);
|
||||
binding.GL.BindBuffer(BufferType.ARRAY_BUFFER, glHandle.Zero);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal void ChangeEnvironment(IglFunc gl)
|
||||
{
|
||||
GL = gl;
|
||||
}
|
||||
|
||||
|
||||
protected override sealed void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
GL.DeleteBuffers(_bufferHandle);
|
||||
binding.GL.DeleteBuffers(_bufferHandle);
|
||||
_bufferHandle.Release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,25 +44,25 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
internal static bool[] unitActivated = new bool[16];
|
||||
private IglFunc GL;
|
||||
private Form binding;
|
||||
internal glHandleSet _textureHandle;
|
||||
internal Image[] sourceList;
|
||||
|
||||
internal Texture(int n, IglFunc gl)
|
||||
internal Texture(int n, Form binding)
|
||||
{
|
||||
sourceList = new Image[n];
|
||||
GL = gl;
|
||||
_textureHandle = GL.GenTextures(n);
|
||||
this.binding = binding;
|
||||
_textureHandle = binding.GL.GenTextures(n);
|
||||
}
|
||||
|
||||
public void Activate(TextureUnit unit)
|
||||
{
|
||||
GL.ActiveTexture((uint)unit);
|
||||
binding.GL.ActiveTexture((uint)unit);
|
||||
}
|
||||
|
||||
public void Bind2D(int index)
|
||||
{
|
||||
GL.BindTexture(GLconst.TEXTURE_2D, _textureHandle[index]);
|
||||
binding.GL.BindTexture(GLconst.TEXTURE_2D, _textureHandle[index]);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,7 +92,7 @@ namespace StgSharp.Graphics
|
||||
channel = 0;
|
||||
break;
|
||||
}
|
||||
GL.TextureImage2d<byte>(
|
||||
binding.GL.TextureImage2d<byte>(
|
||||
GLconst.TEXTURE_2D, 0, channel,
|
||||
(uint)sourceList[index].Width, (uint)sourceList[index].Height,
|
||||
channel, GLconst.UNSIGNED_BYTE,
|
||||
@@ -105,25 +105,21 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
internal void ChangeEnvironment(IglFunc gl)
|
||||
{
|
||||
GL = gl;
|
||||
}
|
||||
|
||||
#region texture setting
|
||||
|
||||
public void Set2dFilterProperty(
|
||||
Filter onMinify, Filter onMagnify)
|
||||
{
|
||||
GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_MIN_FILTER, (int)onMinify);
|
||||
GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_MAG_FILTER, (int)onMagnify);
|
||||
binding.GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_MIN_FILTER, (int)onMinify);
|
||||
binding.GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_MAG_FILTER, (int)onMagnify);
|
||||
}
|
||||
|
||||
public void Set2dWrapProperty(
|
||||
Wrap onHorizontial, Wrap onVertical)
|
||||
{
|
||||
GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_WRAP_S, (int)onHorizontial);
|
||||
GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_WRAP_T, (int)onVertical);
|
||||
binding.GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_WRAP_S, (int)onHorizontial);
|
||||
binding.GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_WRAP_T, (int)onVertical);
|
||||
}
|
||||
|
||||
#endregion texture setting
|
||||
|
||||
Reference in New Issue
Block a user