daily update on 20240528 by nitload youmu

This commit is contained in:
Nitload
2024-05-28 17:45:54 +08:00
parent de399e22c2
commit 70890e3e33
88 changed files with 10678 additions and 5761 deletions
@@ -34,14 +34,14 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
/// <summary>
/// Interface of all kinds OpenGL buffer objects
/// </summary>
public abstract class BufferObjectBase : IDisposable
{
protected IntPtr binding;
protected RenderStream binding;
protected glHandleSet _bufferHandle;
/// <summary>
+14 -7
View File
@@ -36,7 +36,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
/// <summary>
/// A collection of handle to Element Buffer Object in OpenGL.
@@ -48,27 +48,34 @@ namespace StgSharp.Graphics
internal ElementBuffer(int n, glRenderStream binding)
{
this.binding = binding.ContextHandle;
_bufferHandle = GL.GenBuffers(n);
this.binding = binding;
_bufferHandle = glFunc.GenBuffers(n);
}
public override sealed void Bind(int index)
{
GL.BindBuffer(BufferType.ELEMENT_ARRAY_BUFFER, _bufferHandle[index]);
glFunc.BindBuffer(BufferType.ElementArrayBuffer, _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);
glFunc.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
glFunc.SetBufferData(BufferType.ElementArrayBuffer, bufferArray, usage);
}
public void SetValue<T>(int index, ReadOnlySpan<T> bufferSpan, BufferUsage usage)
where T : struct, IConvertible
{
glFunc.BindBuffer(BufferType.ElementArrayBuffer, _bufferHandle[index]);
glFunc.SetBufferData(BufferType.ElementArrayBuffer, bufferSpan, usage);
}
protected override sealed void Dispose(bool disposing)
{
if (disposing)
{
GL.DeleteBuffers(_bufferHandle);
glFunc.DeleteBuffers(_bufferHandle);
_bufferHandle.Release();
}
}
+14 -5
View File
@@ -4,9 +4,13 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
#pragma warning disable CA1008
#pragma warning disable CA1028
public enum FrameBufferTarget:uint
#pragma warning restore CA1028
#pragma warning restore CA1008
{
Read = GLconst.READ_FRAMEBUFFER,
All = GLconst.FRAMEBUFFER,
@@ -17,9 +21,9 @@ namespace StgSharp.Graphics
{
internal unsafe FrameBuffer(int count, glRenderStream contextBinding)
{
binding = contextBinding.ContextHandle;
binding = contextBinding;
_bufferHandle = new glHandleSet(count);
((GLcontext*)binding)->glGenFramebuffers((uint)count,_bufferHandle.handle);
((GLcontext*)binding.ContextHandle)->glGenFramebuffers((uint)count,_bufferHandle.handle);
}
/// <summary>
@@ -29,7 +33,12 @@ namespace StgSharp.Graphics
/// <param name="index">Index of object to be binded in handle set</param>
public unsafe override void Bind(int index)
{
((GLcontext*)binding)->glBindFramebuffer(GLconst.FRAMEBUFFER, _bufferHandle[index].Value);
glFunc.BindFrameBuffer(FrameBufferTarget.All,_bufferHandle[index]);
}
public static void BindNull()
{
glFunc.BindFrameBuffer(FrameBufferTarget.All,glHandle.Zero);
}
/// <summary>
@@ -40,7 +49,7 @@ namespace StgSharp.Graphics
/// <param name="index">Index of object to be binded in handle set</param>
public unsafe void Bind(FrameBufferTarget target, int index)
{
((GLcontext*)binding)->glBindFramebuffer((uint)target, _bufferHandle[index].Value);
((GLcontext*)binding.ContextHandle)->glBindFramebuffer((uint)target, _bufferHandle[index].Value);
}
protected override void Dispose(bool disposing)
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.Security.Principal;
using System.Text;
namespace StgSharp.Graphics.GL
{
public class RenderBuffer : BufferObjectBase
{
public RenderBuffer(int count, glRenderStream binding)
{
this.binding = binding;
_bufferHandle = glFunc.GenRenderBuffer(count);
}
public override void Bind(int index)
{
glFunc.BindRenderBuffer(this[index]);
}
protected override void Dispose(bool disposing)
{
throw new NotImplementedException();
}
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");
}
}
}
}
@@ -0,0 +1,155 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="texture.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics.GL
{
public unsafe class TextureGL
{
internal static bool[] unitActivated = new bool[16];
private IntPtr binding;
internal glHandleSet _textureHandle;
internal Image[] sourceList;
public glHandle this[int index]
{
get => _textureHandle[index];
}
internal TextureGL(int n, glRenderStream binding)
{
sourceList = new Image[n];
this.binding = binding.ContextHandle;
_textureHandle = glFunc.GenTextures(n);
}
public static void Activate(TextureUnit unit)
{
glFunc.ActiveTexture((uint)unit);
}
public void Bind2D(int index)
{
glFunc.BindTexture(GLconst.TEXTURE_2D, _textureHandle[index]);
}
/// <summary>
/// </summary>
/// <param name="index"> </param>
/// <param name="i"> </param>
public unsafe void LoadTexture(int index, Image i)
{
sourceList[index] = i;
glArrayHandle handle = sourceList[index].GetArrayHandle();
glFunc.TextureImage2d(
Texture2DTarget.Texture2D, 0, (uint)i.Channel,
(uint)sourceList[index].Width, (uint)sourceList[index].Height,
(uint)i.Channel, ImageChannelLayout.Byte,
pixelArrayHandle: handle
);
handle.Release();
}
#region texture setting
public void Set2dFilterProperty(
Filter onMinify, Filter onMagnify)
{
glFunc.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_MIN_FILTER, (int)onMinify);
glFunc.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_MAG_FILTER, (int)onMagnify);
}
public void Set2dWrapProperty(
Wrap onHorizontial, Wrap onVertical)
{
glFunc.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_WRAP_S, (int)onHorizontial);
glFunc.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_WRAP_T, (int)onVertical);
}
#endregion texture setting
}
#pragma warning disable CA1008
public enum Filter
#pragma warning restore CA1008
{
Nearest = GLconst.NEAREST,
Linear = GLconst.LINEAR,
NearestLinearMipmap = GLconst.NEAREST_MIPMAP_LINEAR,
LinearLinearMipmap = GLconst.LINEAR_MIPMAP_LINEAR,
NearestNearestMipmap = GLconst.NEAREST_MIPMAP_NEAREST,
LinearNearestMipmap = GLconst.LINEAR_MIPMAP_NEAREST,
}
#pragma warning disable CA1008
public enum TextureUnit
#pragma warning restore CA1008
{
Unit0 = GLconst.TEXTURE0,
Unit1 = GLconst.TEXTURE1,
Unit2 = GLconst.TEXTURE2,
Unit3 = GLconst.TEXTURE3,
Unit4 = GLconst.TEXTURE4,
Unit5 = GLconst.TEXTURE5,
Unit6 = GLconst.TEXTURE6,
Unit7 = GLconst.TEXTURE7,
Unit8 = GLconst.TEXTURE8,
Unit9 = GLconst.TEXTURE9,
Unit10 = GLconst.TEXTURE10,
Unit11 = GLconst.TEXTURE11,
Unit12 = GLconst.TEXTURE12,
Unit13 = GLconst.TEXTURE13,
Unit14 = GLconst.TEXTURE14,
Unit15 = GLconst.TEXTURE15,
}
#pragma warning disable CA1008
public enum Wrap
#pragma warning restore CA1008
{
Repeat = GLconst.REPEAT,
MirroredRepeat = GLconst.MIRRORED_REPEAT,
ClampToEdge = GLconst.CLAMP_TO_EDGE,
ClampToBorder = GLconst.CLAMP_TO_BORDER,
}
}
+11 -9
View File
@@ -28,38 +28,40 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public unsafe class VertexArray : BufferObjectBase
{
internal VertexArray(int n, glRenderStream binding)
{
this.binding = binding.ContextHandle;
_bufferHandle = GL.GenVertexArrays(n);
this.binding = binding;
_bufferHandle = glFunc.GenVertexArrays(n);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override sealed void Bind(int index)
{
GL.BindVertexArray(_bufferHandle[index]);
glFunc.BindVertexArray(_bufferHandle[index]);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void BindNull()
public static void BindNull()
{
GL.BindVertexArray(glHandle.Zero);
glFunc.BindVertexArray(glHandle.Zero);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SetVertexAttribute(uint index, int vertexLength, TypeCode dataType, bool isNomalized, uint stride, int pointer)
public static void SetVertexAttribute(uint index, int vertexLength, TypeCode dataType, bool isNomalized, uint stride, int pointer)
{
GL.SetVertexAttribute(
glFunc.SetVertexAttribute(
index, vertexLength, dataType,
isNomalized,
stride, pointer);
@@ -69,7 +71,7 @@ namespace StgSharp.Graphics
{
if (disposing)
{
GL.DeleteVertexArrays(_bufferHandle);
glFunc.DeleteVertexArrays(_bufferHandle);
_bufferHandle.Release();
}
}
+19 -18
View File
@@ -28,6 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics.GL;
using StgSharp.Math;
using System;
@@ -38,20 +39,20 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public unsafe class VertexBuffer : BufferObjectBase
{
internal VertexBuffer(int n, glRenderStream binding)
{
this.binding = binding.ContextHandle;
_bufferHandle = GL.GenBuffers(n);
this.binding = binding;
_bufferHandle = glFunc.GenBuffers(n);
}
public override sealed void Bind(int index)
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
glFunc.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
}
/// <summary>
@@ -64,8 +65,8 @@ namespace StgSharp.Graphics
public void WriteMatrixData<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);
glFunc.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
glFunc.SetBufferData(BufferType.ArrayBuffer, bufferData, usage);
}
/// <summary>
@@ -83,8 +84,8 @@ namespace StgSharp.Graphics
IConvertible
#endif
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
GL.SetBufferData(BufferType.ARRAY_BUFFER, bufferArray, usage);
glFunc.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
glFunc.SetBufferData(BufferType.ArrayBuffer, bufferArray, usage);
}
/// <summary>
@@ -94,7 +95,7 @@ namespace StgSharp.Graphics
/// <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, Span<T> scalerSpan, BufferUsage usage)
public void WriteScalerData<T>(int index, ReadOnlySpan<T> scalerSpan, BufferUsage usage)
where T : struct,
#if NET8_0_OR_GREATER
INumber
@@ -102,8 +103,8 @@ namespace StgSharp.Graphics
IConvertible
#endif
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
GL.SetBufferData(BufferType.ARRAY_BUFFER, scalerSpan, usage);
glFunc.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
glFunc.SetBufferData(BufferType.ArrayBuffer, scalerSpan, usage);
}
/// <summary>
@@ -113,10 +114,10 @@ namespace StgSharp.Graphics
/// <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, Span<T> vectorSpan, BufferUsage usage) where T : struct, IVector
public void WriteVectorData<T>(int index, ReadOnlySpan<T> vectorSpan, BufferUsage usage) where T : struct, IVector
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
GL.SetBufferVectorData(BufferType.ARRAY_BUFFER, vectorSpan, usage);
glFunc.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
glFunc.SetBufferVectorData(BufferType.ArrayBuffer, vectorSpan, usage);
}
/// <summary>
@@ -128,8 +129,8 @@ namespace StgSharp.Graphics
/// <param name="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
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, _bufferHandle[index]);
GL.SetBufferVectorData(BufferType.ARRAY_BUFFER, vectorArray, usage);
glFunc.BindBuffer(BufferType.ArrayBuffer, _bufferHandle[index]);
glFunc.SetBufferVectorData(BufferType.ArrayBuffer, vectorArray, usage);
}
/// <summary>
@@ -138,14 +139,14 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Unbind()
{
GL.BindBuffer(BufferType.ARRAY_BUFFER, glHandle.Zero);
glFunc.BindBuffer(BufferType.ArrayBuffer, glHandle.Zero);
}
protected override sealed void Dispose(bool disposing)
{
if (disposing)
{
GL.DeleteBuffers(_bufferHandle);
glFunc.DeleteBuffers(_bufferHandle);
_bufferHandle.Release();
}
}
+29 -3
View File
@@ -36,6 +36,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.AccessControl;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
@@ -46,7 +47,7 @@ namespace StgSharp.Graphics
/// must be indexed from a <see cref="glHandleSet"/>.
/// Direct call will cause <see langword="InvalidOperationException"/>
/// </summary>
public unsafe class glHandle
public unsafe class glHandle: IDisposable
{
private static uint* zeroHandle = (uint*)Marshal.AllocHGlobal(Marshal.SizeOf<uint>());
@@ -93,6 +94,8 @@ namespace StgSharp.Graphics
set => *valuePtr = value;
}
public static glHandle ZeroHandle => FromPtr(IntPtr.Zero);
public static glHandle Zero => Alloc(0);
public static glHandle Alloc(uint value)
@@ -113,6 +116,30 @@ namespace StgSharp.Graphics
Marshal.FreeHGlobal((IntPtr)valuePtr);
}
}
protected virtual void Dispose(bool disposing)
{
if (IsIsolated)
{
GCHandle.FromIntPtr((IntPtr)valuePtr).Free();
if (disposing)
{
}
}
}
//
// ~glHandle()
// {
// Dispose(disposing: false);
// }
public void Dispose()
{
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
public unsafe class glSHandle
@@ -188,9 +215,9 @@ namespace StgSharp.Graphics
public unsafe class glArrayHandle
{
internal readonly Array a;
internal GCHandle handle;
private bool disposedValue;
internal glArrayHandle(Array array)
{
@@ -230,7 +257,6 @@ namespace StgSharp.Graphics
handle.Free();
handle = default;
}
}
/// <summary>
+154 -50
View File
@@ -43,14 +43,19 @@ namespace StgSharp
{
internal static unsafe partial class InternalIO
{
[DllImport(SSC_libName, EntryPoint = "glCheckShaderStat",
CallingConvention = CallingConvention.Cdecl)]
internal static extern int glCheckShaderStatus(ref GLcontext context, uint shaderHandle,int key, ref IntPtr logPtr);
#pragma warning disable CA5392
internal static extern int glCheckShaderStatus(ref GLcontext context, uint shaderHandle, int key, ref IntPtr logPtr);
#pragma warning restore CA5392
}
}
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
internal static unsafe partial class GL
internal static unsafe partial class glFunc
{
private static GLcontext* context;
@@ -58,15 +63,12 @@ namespace StgSharp.Graphics
public static IntPtr CurrentContextHandle
{
get { return (IntPtr)context; }
set
{
context = (GLcontext*)value;
}
set { context = (GLcontext*)value; }
}
private static ref GLcontext Context
{
get
get
{
#if DEBUG
if ((IntPtr)context==IntPtr.Zero)
@@ -74,7 +76,7 @@ namespace StgSharp.Graphics
throw new NullReferenceException();
}
#endif
return ref *context;
return ref (*context);
}
}
@@ -96,14 +98,21 @@ namespace StgSharp.Graphics
Context.glBindBuffer((uint)bufferType, handle.Value);
}
public static string GetShaderStatus(Shader s, int index, int key)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void GetTextureImage<T>(Texture2DTarget target, int level, ImageChannel channel, ImageChannelLayout channelLayout, ref T[] dataStream)where T: struct,
#if NET8_0_OR_GREATER
INumber
#else
IConvertible
#endif
{
IntPtr sptr = IntPtr.Zero;
if (InternalIO.glCheckShaderStatus(ref Context, s.handle[index].Value, key,ref sptr) == 0)
#pragma warning disable CS8500
fixed (T* tptr = dataStream)
{
return Marshal.PtrToStringAnsi(sptr);
Context.glGetTexImage((uint)target, level, (uint)channel, (uint)channelLayout, tptr);
}
return "";
#pragma warning restore CS8500
}
/// <summary>
@@ -118,12 +127,30 @@ namespace StgSharp.Graphics
Context.glBindFramebuffer((uint)target, handle.Value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void BindRenderBuffer(glHandle handle)
{
Context.glBindRenderbuffer(GLconst.RENDERBUFFER, handle.Value);
}
public static void WaitAccomplishment()
{
Context.glFinish();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void BindTexture(uint type, glHandle texture)
{
Context.glBindTexture(type, texture.Value);
}
public static unsafe int GetMaskInteger(uint statusCode)
{
int ret = 0;
Context.glGetIntegerv(statusCode,&ret);
return ret;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void BindVertexArray(glHandle handle)
@@ -131,10 +158,35 @@ namespace StgSharp.Graphics
Context.glBindVertexArray(handle.Value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void VertexAttributeDivisor(uint layoutIndex, uint divisor)
public static void RereadImage(
this Image i, (int X, int Y) beginPosition, FrameBufferChannel format, ImageChannelLayout dataType)
{
Context.glVertexAttribDivisor(layoutIndex, divisor);
glArrayHandle handle = i.GetArrayHandle();
Context.glReadPixels(
beginPosition.X, beginPosition.Y, i.Width, i.Height, (uint)format, (uint)dataType, (byte*)handle.AddressOfArray()
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void FrameBufferTexture2d(FrameBufferTarget target, uint attachment, Texture2DTarget texTarget,glHandle textureHandle ,int level)
{
Context.glFramebufferTexture2D(
(uint)target, attachment, (uint)texTarget,textureHandle.Value, level
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ReadPixels(
(int X, int Y) beginPosition, (int width, int height) size, FrameBufferChannel format, ImageChannelLayout dataType, ref byte[] stream
)
{
fixed (byte* bptr = stream)
{
Context.glReadPixels(
beginPosition.X, beginPosition.Y,
size.width, size.height, (uint)format, (uint)dataType, bptr);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -143,6 +195,11 @@ namespace StgSharp.Graphics
Context.glClear((uint)mask);
}
public static void CombineFrameBufferRenderBuffer(glHandle fboHandle, glHandle rboHandle)
{
Context.glFramebufferRenderbuffer(GLconst.FRAMEBUFFER,fboHandle.Value,GLconst.RENDERBUFFER, rboHandle.Value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void ClearColor(float R, float G, float B, float A)
{
@@ -203,31 +260,8 @@ namespace StgSharp.Graphics
return ret;
}
public static unsafe IntPtr CreateWindowHandle(
int width, int height, string tittle, IntPtr monitor, Form share)
{
byte[] tittleBytes = Encoding.UTF8.GetBytes(tittle);
IntPtr windowPtr;
if (share == null)
{
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, IntPtr.Zero);
}
else
{
windowPtr = InternalIO.glfwCreateWindow(
width, height, tittleBytes, monitor, share.id);
}
if (((long)windowPtr == -1) || ((long)windowPtr == -2))
{
throw new Exception("Cannot create window instance!");
}
else
{
return windowPtr;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void DeleteBuffer(glHandle handle)
@@ -278,7 +312,7 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void DrawElementsInstanced(
GeometryType mode , uint count, TypeCode type, IntPtr ptr, uint amount
GeometryType mode, uint count, TypeCode type, IntPtr ptr, uint amount
)
{
uint a;
@@ -302,7 +336,7 @@ namespace StgSharp.Graphics
LogType.Error);
return;
}
Context.glDrawElementsInstanced((uint)mode, count, a, (void*)ptr,amount);
Context.glDrawElementsInstanced((uint)mode, count, a, (void*)ptr, amount);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -319,6 +353,15 @@ namespace StgSharp.Graphics
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe glHandleSet GenRenderBuffer(int count)
{
glHandleSet h = new glHandleSet(count);
Context.glGenRenderbuffers(count, (uint*)h.Handle);
return h;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe glHandleSet GenTextures(int count)
{
@@ -328,6 +371,14 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetRenderBufferStorage(RenderBufferInternalFormat internalFormat ,(int width, int height) size)
{
Context.glRenderbufferStorage(
GLconst.RENDERBUFFER, (uint)internalFormat,size.width,size.height
);
}
public static unsafe glHandleSet GenVertexArrays(int count)
{
glHandleSet h = new glHandleSet(count);
@@ -335,6 +386,16 @@ namespace StgSharp.Graphics
return h;
}
public static string GetShaderStatus(Shader s, int index, int key)
{
IntPtr sptr = IntPtr.Zero;
if (InternalIO.glCheckShaderStatus(ref Context, s.handle[index].Value, key, ref sptr) == 0)
{
return Marshal.PtrToStringAnsi(sptr);
}
return string.Empty;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe glSHandle GetUniformLocation(glHandle program, string name)
@@ -359,17 +420,16 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void LoadShaderSource(glHandle shaderHandle, string codeStream)
public static unsafe void LoadShaderSource(glHandle shaderHandle, byte[] codeStream)
{
byte[] stream = Encoding.UTF8.GetBytes(codeStream);
fixed (byte* streamPtr = stream)
fixed (byte* streamPtr = codeStream)
{
Context.glShaderSource(shaderHandle.Value, 1, &streamPtr, (void*)0);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void MakeContextCurrent(Form form)
public static unsafe void MakeContextCurrent(ViewModel form)
{
if (form.WindowID == IntPtr.Zero)
{
@@ -420,6 +480,34 @@ namespace StgSharp.Graphics
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetBufferData<T>(BufferType bufferType, ReadOnlySpan<T> bufferArray, BufferUsage usage)
where T : struct,
#if NET8_0_OR_GREATER
INumber
#else
IConvertible
#endif
{
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
if (bufferArray == null)
{
return;
}
#pragma warning disable CS8500
fixed (void* bufferPtr = bufferArray)
#pragma warning restore CS8500
{
Context.glBufferData(
(uint)bufferType,
(IntPtr)size,
(IntPtr)bufferPtr,
(uint)usage);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetBufferData<T>(BufferType bufferType, Span<T> bufferArray, BufferUsage usage)
where T : struct,
@@ -449,7 +537,7 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetBufferVectorData<T>(BufferType bufferType, Span<T> bufferArray, BufferUsage usage)
public static unsafe void SetBufferVectorData<T>(BufferType bufferType, ReadOnlySpan<T> bufferArray, BufferUsage usage)
where T : struct, IVector
{
int size = bufferArray.Length * Marshal.SizeOf(typeof(T));
@@ -499,10 +587,20 @@ namespace StgSharp.Graphics
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, glHandle pixels)
public static void TextureImage2d(Texture2DTarget target, int level, uint internalformat, uint width, uint height,
uint format, ImageChannelLayout type, glHandle pixels)
{
Context.glTexImage2D(
(uint)target, level, internalformat, width, height, 0, format, type, pixels.valuePtr
(uint)target, level, internalformat, width, height, 0, format, (uint)type, pixels.valuePtr
);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void TextureImage2d(Texture2DTarget target, int level, uint internalformat, uint width, uint height,
uint format, ImageChannelLayout type, glArrayHandle pixelArrayHandle)
{
Context.glTexImage2D(
(uint)target, level, internalformat, width, height, 0, format, (uint)type, (void*)pixelArrayHandle.handle.AddrOfPinnedObject()
);
}
@@ -518,6 +616,12 @@ namespace StgSharp.Graphics
Context.glUseProgram(program.Value);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void VertexAttributeDivisor(uint layoutIndex, uint divisor)
{
Context.glVertexAttribDivisor(layoutIndex, divisor);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Viewport(int x, int y, uint width, uint height)
{
@@ -35,7 +35,7 @@ using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public partial class glRenderStream
{
@@ -51,15 +51,28 @@ namespace StgSharp.Graphics
return new ElementBuffer(count, this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected RenderBuffer CreateRenderBuffer(int count)
{
return new RenderBuffer(count, this);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected FrameBuffer CreateFrameBuffer(int count)
{
return new FrameBuffer(count, this);
}
/// <summary>
/// Create a sets of <see cref="Texture"/>
/// Create a sets of <see cref="TextureGL"/>
/// </summary>
/// <param name="count">Amount of textures to be created.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected Texture CreateTexture(int count)
protected TextureGL CreateTexture(int count)
{
return new Texture(count, this);
return new TextureGL(count, this);
}
/// <summary>
@@ -1,4 +1,6 @@
using System;
using StgSharp.Graphics.GL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -39,15 +39,15 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Xml.Linq;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public partial class glRenderStream
public abstract partial class glRenderStream : RenderStream
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected sealed override Shader CreateShaderSegment(ShaderType type, int count)
{
return new Shader( GL.CreateShaderSet(count, type), type);
return new Shader( glFunc.CreateShaderSet(count, type), type);
}
/// <summary>
/// Create an instance of <see cref="Shader"/> program
@@ -72,7 +72,7 @@ namespace StgSharp.Graphics
internal unsafe Shader(glHandleSet handle, ShaderType usage)
{
this.handle = handle;
context = GL.CurrentContextHandle;
context = glFunc.CurrentContextHandle;
type = usage;
}
@@ -84,31 +84,43 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AttachTo(int index, ShaderProgram target)
{
GL.AttachShader(target.handle, handle[index]);
glFunc.AttachShader(target.handle, handle[index]);
}
public static string FromCodeFile(string fileRoute)
public static byte[] FromCodeFile(string fileRoute)
{
string str = File.ReadAllText(fileRoute);
if (str == "")
if (string.IsNullOrEmpty(str))
{
throw new Exception($"Cannot load and GLSL code from {fileRoute}");
throw new InvalidOperationException($"Cannot load and GLSL code from {fileRoute}");
}
return str;
return Encoding.UTF8.GetBytes(str);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void Compile(int index, string code)
public unsafe void Compile(int index, byte[] codeStream)
{
if (code == null)
if (codeStream == null)
{
throw new ArgumentNullException("Must provide enough code");
throw new ArgumentNullException(nameof(codeStream));
}
GL.LoadShaderSource(handle[index], $"{code}\0");
GL.CompileShader(handle[index]);
glFunc.LoadShaderSource(handle[index], codeStream);
glFunc.CompileShader(handle[index]);
CheckStatus(index,ShaderStatus.CompileStatus);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void Compile(int index, string codeStream)
{
if (codeStream == null)
{
throw new ArgumentNullException(nameof(codeStream));
}
glFunc.LoadShaderSource(handle[index],Encoding.ASCII.GetBytes( codeStream));
glFunc.CompileShader(handle[index]);
CheckStatus(index, ShaderStatus.CompileStatus);
}
public override string ToString()
{
return $"This is a {type} shader, its shader handles are {handle.ToString()}.";
@@ -122,7 +134,7 @@ namespace StgSharp.Graphics
public void CheckStatus(int index, ShaderStatus status)
{
string log = GL.GetShaderStatus(this,index, (int)status);
string log = glFunc.GetShaderStatus(this,index, (int)status);
if (log != "")
{
throw new Exception($"Shader Error\n{status}\n" + log);
@@ -147,7 +159,6 @@ namespace StgSharp.Graphics
public class ShaderProgram
{
private readonly IntPtr binding;
internal readonly glHandle handle;
@@ -157,7 +168,7 @@ namespace StgSharp.Graphics
internal unsafe ShaderProgram(glRenderStream binding)
{
this.binding = binding.ContextHandle;
handle = GL.CreateProgram();
handle = glFunc.CreateProgram();
}
/// <summary>
@@ -242,7 +253,7 @@ namespace StgSharp.Graphics
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe void Use()
{
GL.UseProgram(handle);
glFunc.UseProgram(handle);
}
~ShaderProgram()
@@ -38,7 +38,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public class Uniform
{
@@ -65,14 +65,14 @@ namespace StgSharp.Graphics
ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
id = glFunc.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(
ShaderProgram program, string name, IntPtr binding)
{
this.binding = binding;
id = GL.GetUniformLocation(program.handle, name);
id = glFunc.GetUniformLocation(program.handle, name);
}
internal Uniform()
@@ -101,14 +101,14 @@ namespace StgSharp.Graphics
ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
id = glFunc.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(
ShaderProgram program, string name, IntPtr binding)
{
this.binding = binding;
id = GL.GetUniformLocation(program.handle, name);
id = glFunc.GetUniformLocation(program.handle, name);
}
internal Uniform()
@@ -137,14 +137,14 @@ namespace StgSharp.Graphics
internal unsafe Uniform(
ShaderProgram program, string name)
{
this.binding = GL.CurrentContextHandle;
id = GL.GetUniformLocation(program.handle, name);
this.binding = glFunc.CurrentContextHandle;
id = glFunc.GetUniformLocation(program.handle, name);
}
public unsafe Uniform(ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
id = glFunc.GetUniformLocation(program.handle, name);
}
internal Uniform()
@@ -175,14 +175,14 @@ namespace StgSharp.Graphics
internal unsafe Uniform(ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
id = glFunc.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(
ShaderProgram program, string name)
{
this.binding = GL.CurrentContextHandle;
id = GL.GetUniformLocation(program.handle, name);
this.binding = glFunc.CurrentContextHandle;
id = glFunc.GetUniformLocation(program.handle, name);
}
internal Uniform()
@@ -197,55 +197,57 @@ namespace StgSharp.Graphics
}
internal static partial class GL
internal static partial class glFunc
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static void SetValue(Uniform<Matrix44> uniform, Matrix44 mat)
public unsafe static void SetUniformValue
(Uniform<Matrix44> uniform, Matrix44 mat)
{
Matrix44 temp = mat;
Context.glUniformMatrix4fv(uniform.id.Value, 1, false, (float*)&temp);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static void SetValue(Uniform<float, float, float, float> uniform, vec4d vec)
public unsafe static void SetUniformValue(Uniform<float, float, float, float> uniform, vec4d vec)
{
vec4d temp = vec;
Context.glUniform1fv(uniform.id.Value , 4, &temp);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static void SetUniformValue(Uniform<vec4d> uniform, vec4d vec)
{
vec4d temp = vec;
Context.glUniform1fv(uniform.id.Value , 4, &temp);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static void SetValue(Uniform<vec4d> uniform, vec4d vec)
{
vec4d temp = vec;
Context.glUniform1fv(uniform.id.Value , 4, &temp);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float> uniform, float v0)
public static unsafe void SetUniformValue(Uniform<float> uniform, float v0)
{
Context.glUniform1f(uniform.id.Value , v0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<int> uniform, int i0)
public static unsafe void SetUniformValue(Uniform<int> uniform, int i0)
{
Context.glUniform1i(uniform.id.Value , i0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float, float> uniform, float v0, float v1)
public static unsafe void SetUniformValue(Uniform<float, float> uniform, float v0, float v1)
{
Context.glUniform2f(uniform.id.Value , v0, v1);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
public static unsafe void SetUniformValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
{
Context.glUniform3f(uniform.id.Value , v0, v1, v2);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
public static unsafe void SetUniformValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
{
Context.glUniform4f(uniform.id.Value , v0, v1, v2, v3);
}
@@ -37,7 +37,7 @@ using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public static partial class glManager
{
@@ -56,9 +56,9 @@ namespace StgSharp.Graphics
private static string glExtensionList;
/// <summary>
/// Load all supported OpenGL APIs and bind them to given <see cref="Form"/> context.
/// Load all supported OpenGL APIs and bind them to given <see cref="ViewModel"/> context.
/// </summary>
/// <param name="stream">The <see cref="Form"/> used as current OpenGL context</param>
/// <param name="stream">The <see cref="ViewModel"/> used as current OpenGL context</param>
public static unsafe void LoadGLapi(this glRenderStream stream)
{
GLcontext* context = (GLcontext*)stream.ContextHandle;
@@ -1044,7 +1044,7 @@ namespace StgSharp.Graphics
contextPtr->glPointSize = (delegate*<float, void>)load("glPointSize");
contextPtr->glPolygonMode = (delegate*<uint, uint, void>)load("glPolygonMode");
contextPtr->glReadBuffer = (delegate*<uint, void>)load("glReadBuffer");
contextPtr->glReadPixels = (delegate*<int, int, uint, uint, uint, uint, void*, void>)load("glReadPixels");
contextPtr->glReadPixels = (delegate*<int, int, int, int, uint, uint, void*, void>)load("glReadPixels");
contextPtr->glScissor = (delegate*<int, int, uint, uint, void>)load("glScissor");
contextPtr->glStencilFunc = (delegate*<uint, int, uint, void>)load("glStencilFunc");
contextPtr->glStencilMask = (delegate*<uint, void>)load("glStencilMask");
@@ -1368,7 +1368,7 @@ namespace StgSharp.Graphics
contextPtr->glFramebufferTexture3D = (delegate*<uint, uint, uint, uint, int, int, void>)load("glFramebufferTexture3D");
contextPtr->glFramebufferTextureLayer = (delegate*<uint, uint, uint, int, int, void>)load("glFramebufferTextureLayer");
contextPtr->glGenFramebuffers = (delegate*<uint, uint*, void>)load("glGenFramebuffers");
contextPtr->glGenRenderbuffers = (delegate*<uint, uint*, void>)load("glGenRenderbuffers");
contextPtr->glGenRenderbuffers = (delegate*<int, uint*, void>)load("glGenRenderbuffers");
contextPtr->glGenVertexArrays = (delegate*<int, uint*, void>)load("glGenVertexArrays");
contextPtr->glGenerateMipmap = (delegate*<uint, void>)load("glGenerateMipmap");
contextPtr->glGetBooleani_v = (delegate*<uint, uint, bool*, void>)load("glGetBooleani_v");
@@ -1388,7 +1388,7 @@ namespace StgSharp.Graphics
contextPtr->glIsRenderbuffer = (delegate*<uint, bool>)load("glIsRenderbuffer");
contextPtr->glIsVertexArray = (delegate*<uint, bool>)load("glIsVertexArray");
contextPtr->glMapBufferRange = (delegate*<uint, IntPtr, UIntPtr, uint, void*>)load("glMapBufferRange");
contextPtr->glRenderbufferStorage = (delegate*<uint, uint, uint, uint, void>)load("glRenderbufferStorage");
contextPtr->glRenderbufferStorage = (delegate*<uint, uint, int, int, void>)load("glRenderbufferStorage");
contextPtr->glRenderbufferStorageMultisample = (delegate*<uint, uint, uint, uint, uint, void>)load("glRenderbufferStorageMultisample");
contextPtr->glTexParameterIiv = (delegate*<uint, uint, int*, void>)load("glTexParameterIiv");
contextPtr->glTexParameterIuiv = (delegate*<uint, uint, uint*, void>)load("glTexParameterIuiv");
@@ -1908,7 +1908,7 @@ namespace StgSharp.Graphics
contextPtr->glNamedFramebufferTextureLayer = (delegate*<uint, uint, uint, int, int, void>)load("glNamedFramebufferTextureLayer");
contextPtr->glNamedRenderbufferStorage = (delegate*<uint, uint, uint, uint, void>)load("glNamedRenderbufferStorage");
contextPtr->glNamedRenderbufferStorageMultisample = (delegate*<uint, uint, uint, uint, uint, void>)load("glNamedRenderbufferStorageMultisample");
contextPtr->glReadnPixels = (delegate*<int, int, uint, uint, uint, uint, uint, void*, void>)load("glReadnPixels");
contextPtr->glReadnPixels = (delegate*<int, int, int, int, uint, uint, uint, void*, void>)load("glReadnPixels");
contextPtr->glTextureBarrier = (delegate*<void>)load("glTextureBarrier");
contextPtr->glTextureBuffer = (delegate*<uint, uint, uint, void>)load("glTextureBuffer");
contextPtr->glTextureBufferRange = (delegate*<uint, uint, uint, IntPtr, UIntPtr, void>)load("glTextureBufferRange");
@@ -32,7 +32,7 @@ using System;
using System.Collections.Generic;
using System.Text;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public static partial class glManager
{
@@ -39,14 +39,18 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
namespace StgSharp.Graphics.GL
{
public abstract partial class glRenderStream : RenderStream
{
protected glRenderStream(RenderStreamConstructArgs args) : base(args)
{
}
protected glRenderStream(RenderStreamConstructArgs args,bool isSharing) : base(args,isSharing)
{
}
protected IntPtr glContextHandle
{
@@ -54,19 +58,6 @@ namespace StgSharp.Graphics
set { ContextHandle = value; }
}
public static T AsMainStreamOf<T>(Form f, (int x, int y, int z) unitCubeSize) where T : glRenderStream
{
RenderStreamConstructArgs args = new RenderStreamConstructArgs();
args.UnitCubeSize = unitCubeSize;
args.Name = f.name;
args.Height = f.Height;
args.Width = f.Width;
T ret = Activator.CreateInstance(typeof(T), args) as T;
ret!.InternalInit();
f.WindowID = ret.CanvasHandle;
return ret;
}
/// <summary>
/// Init an OpenGl context if current form has not been binded to any context. and set the context binded to
/// current form as current OpenGL context.
@@ -82,10 +73,10 @@ namespace StgSharp.Graphics
GLcontext* contextID = (GLcontext*)ContextHandle;
contextID->glGetString = (delegate*<uint, IntPtr>)IntPtr.Zero;
}
if (GL.CurrentContextHandle != ContextHandle)
if (glFunc.CurrentContextHandle != ContextHandle)
{
GL.CurrentContextHandle = ContextHandle;
//Console.WriteLine($"context set as {(ulong)GL.CurrentContextHandle}");
glFunc.CurrentContextHandle = ContextHandle;
//Console.WriteLine($"context set as {(ulong)glFunc.CurrentContextHandle}");
InternalIO.glfwMakeContextCurrent(CanvasHandle);
}
}
@@ -98,11 +89,10 @@ namespace StgSharp.Graphics
internal override sealed unsafe void CreateCanvas()
{
byte[] nameCode = Encoding.UTF8.GetBytes(name);
byte[] nameCode = Encoding.UTF8.GetBytes(Name);
CanvasHandle = InternalIO.glfwCreateWindow(
Width, Height, nameCode, Monitor, IntPtr.Zero
);
NativeCamera = new Camera();
}
internal override sealed void InternalDraw(
@@ -113,6 +103,7 @@ namespace StgSharp.Graphics
ProcessInput();
Main(in input, in output);
}
internal override sealed void InternalInit()
{
CreateCanvas();