daily update on 20240226 by nitload youmu
This commit is contained in:
@@ -19,13 +19,13 @@ using System.Threading;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
public abstract partial class Form
|
||||
{
|
||||
#region metadata
|
||||
|
||||
internal LinkedList<Control> allControl;
|
||||
internal Vector4 backgroundColor;
|
||||
internal unsafe GLcontext* contextID;
|
||||
@@ -38,20 +38,25 @@ namespace StgSharp.Graphics
|
||||
internal IntPtr windowID;
|
||||
private bool closed;
|
||||
internal IglFunc gl;
|
||||
#endregion
|
||||
|
||||
#endregion metadata
|
||||
|
||||
#region form thread setting
|
||||
|
||||
internal FrameUpdateTimer timer = new FrameUpdateTimer();
|
||||
private SemaphoreSlim _renderFinishSignal = new SemaphoreSlim(0, 1);
|
||||
private SemaphoreSlim _renderStartSignal = new SemaphoreSlim(1, 1);
|
||||
private bool isSingleThread = true;
|
||||
private Thread renderThread;
|
||||
#endregion
|
||||
|
||||
#endregion form thread setting
|
||||
|
||||
#region glapicount
|
||||
|
||||
private int missingAPIcount = 0;
|
||||
private int problemAPIcount = 0;
|
||||
#endregion
|
||||
|
||||
#endregion glapicount
|
||||
|
||||
protected Form()
|
||||
{
|
||||
@@ -76,7 +81,7 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Representing
|
||||
/// Representing
|
||||
/// </summary>
|
||||
public bool IsDoubleRendering
|
||||
{
|
||||
@@ -143,6 +148,7 @@ namespace StgSharp.Graphics
|
||||
InternalIO.glfwSetFramebufferSizeCallback(windowID, handlerPtr);
|
||||
}
|
||||
}
|
||||
|
||||
unsafe ~Form()
|
||||
{
|
||||
Marshal.FreeHGlobal((IntPtr)contextID);
|
||||
@@ -152,7 +158,7 @@ namespace StgSharp.Graphics
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <exception cref="Exception">Something goes wrong and
|
||||
/// <exception cref="Exception">Something goes wrong and
|
||||
/// StgSharp fails in creating a new OpenGL context. </exception>
|
||||
public unsafe void MakeAsCurrentContext()
|
||||
{
|
||||
@@ -179,6 +185,7 @@ namespace StgSharp.Graphics
|
||||
windowID = windowPtr;
|
||||
}
|
||||
}
|
||||
InternalIO.glfwMakeContextCurrent(windowID);
|
||||
gl.SwitchContext();
|
||||
}
|
||||
|
||||
@@ -210,14 +217,13 @@ namespace StgSharp.Graphics
|
||||
/// Resize the current form
|
||||
/// </summary>
|
||||
/// <param name="size">
|
||||
/// A <see cref="Vec2d"/> (width,height) representing the new size of current form
|
||||
/// A <see cref="Vec2d"/> (width,height) representing the new size of current form
|
||||
/// </param>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetSize(Vec2d size)
|
||||
{
|
||||
this.Size = size;
|
||||
InternalIO.glfwSetWindowSize(this.windowID, (int)size.X, (int)size.Y);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -293,12 +299,11 @@ namespace StgSharp.Graphics
|
||||
|
||||
/// <summary>
|
||||
/// Behaviour of current form when in a render cycle.
|
||||
/// When this form
|
||||
/// When this form
|
||||
/// </summary>
|
||||
/// <param name="args"></param>
|
||||
public abstract void Main(params object[] args);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Init this form and render it on screen, and respond with operation
|
||||
/// </summary>
|
||||
@@ -408,6 +413,7 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion form main
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
@@ -9,7 +10,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
public unsafe class Texture
|
||||
{
|
||||
internal static bool[] unitActivated = new bool[16];
|
||||
@@ -43,10 +43,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
Image.ImageInfo info = default;
|
||||
InternalIO.InternalLoadImage(name, &info, loader);
|
||||
Console.WriteLine(info);
|
||||
sourceList[index] = new Image(info);
|
||||
InternalIO.InternalUnloadImage(&info);
|
||||
Console.WriteLine(sourceList[index]);
|
||||
if (sourceList[index].info.pixelPtr != IntPtr.Zero)
|
||||
{
|
||||
uint channel;
|
||||
@@ -67,7 +64,8 @@ namespace StgSharp.Graphics
|
||||
GL.TextureImage2d<byte>(
|
||||
GLconst.TEXTURE_2D, 0, channel,
|
||||
(uint)sourceList[index].Width, (uint)sourceList[index].Height,
|
||||
channel, GLconst.UNSIGNED_BYTE, sourceList[index].pixelArray
|
||||
channel, GLconst.UNSIGNED_BYTE,
|
||||
sourceList[index].pixelArrayHandle
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -81,7 +79,7 @@ namespace StgSharp.Graphics
|
||||
GL = gl;
|
||||
}
|
||||
|
||||
#region texture set
|
||||
#region texture setting
|
||||
|
||||
public void Set2dFilterProperty(
|
||||
Filter onMinify, Filter onMagnify)
|
||||
@@ -97,7 +95,7 @@ namespace StgSharp.Graphics
|
||||
GL.TextureParameter(GLconst.TEXTURE_2D, GLconst.TEXTURE_WRAP_T, (int)onVertical);
|
||||
}
|
||||
|
||||
#endregion texture set
|
||||
#endregion texture setting
|
||||
}
|
||||
|
||||
public enum Filter
|
||||
@@ -137,4 +135,4 @@ namespace StgSharp.Graphics
|
||||
ClampToEdge = GLconst.CLAMP_TO_EDGE,
|
||||
ClampToBorder = GLconst.CLAMP_TO_BORDER,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,41 +9,8 @@ using System.Security.AccessControl;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
|
||||
namespace System
|
||||
{
|
||||
public unsafe struct glSHandle
|
||||
{
|
||||
internal int* valuePtr;
|
||||
internal glHandleSet source;
|
||||
|
||||
public static glSHandle Zero
|
||||
{
|
||||
get { return Alloc(1); }
|
||||
}
|
||||
|
||||
public static glSHandle Alloc(int value)
|
||||
{
|
||||
glSHandle ret = default;
|
||||
ret.source = new glHandleSet(1);
|
||||
ret.valuePtr = (int*)ret.source.handle;
|
||||
*ret.valuePtr = (int)value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal int DirectValue
|
||||
{
|
||||
get { return *valuePtr; }
|
||||
}
|
||||
|
||||
internal glSHandle(int* val, glHandleSet set)
|
||||
{
|
||||
source = set;
|
||||
valuePtr = val;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A handle to an OpenGL object,
|
||||
/// must be indexed from a <see cref="glHandleSet"/>.
|
||||
@@ -51,26 +18,12 @@ namespace System
|
||||
/// </summary>
|
||||
public unsafe struct glHandle
|
||||
{
|
||||
internal uint* valuePtr;
|
||||
internal glHandleSet source;
|
||||
internal uint* valuePtr;
|
||||
|
||||
public static glHandle Zero
|
||||
{
|
||||
get { return Alloc(0); }
|
||||
}
|
||||
|
||||
[Obsolete("Cannot init instance of this type", true)]
|
||||
public glHandle()
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
public static glHandle Alloc(uint value)
|
||||
{
|
||||
glHandle ret = default;
|
||||
ret.source = new glHandleSet(1);
|
||||
ret.valuePtr = ret.source.handle;
|
||||
*ret.valuePtr = value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
internal glHandle(uint* val, glHandleSet set)
|
||||
@@ -79,6 +32,17 @@ namespace System
|
||||
valuePtr = val;
|
||||
}
|
||||
|
||||
private glHandle(IntPtr handle)
|
||||
{
|
||||
this.valuePtr = (uint*)handle;
|
||||
source = null;
|
||||
}
|
||||
|
||||
public static glHandle Zero
|
||||
{
|
||||
get { return Alloc(0); }
|
||||
}
|
||||
|
||||
public IntPtr Handle
|
||||
{
|
||||
get
|
||||
@@ -91,14 +55,6 @@ namespace System
|
||||
}
|
||||
}
|
||||
|
||||
internal uint DirectValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return *valuePtr;
|
||||
}
|
||||
}
|
||||
|
||||
public uint Value
|
||||
{
|
||||
get
|
||||
@@ -118,6 +74,60 @@ namespace System
|
||||
*valuePtr = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal uint DirectValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return *valuePtr;
|
||||
}
|
||||
}
|
||||
|
||||
public static glHandle Alloc(uint value)
|
||||
{
|
||||
glHandle ret = default;
|
||||
ret.source = new glHandleSet(1);
|
||||
ret.valuePtr = ret.source.handle;
|
||||
*ret.valuePtr = value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static glHandle Alloc(IntPtr handle)
|
||||
{
|
||||
return new glHandle(handle);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe struct glSHandle
|
||||
{
|
||||
internal glHandleSet source;
|
||||
internal int* valuePtr;
|
||||
|
||||
internal glSHandle(int* val, glHandleSet set)
|
||||
{
|
||||
source = set;
|
||||
valuePtr = val;
|
||||
}
|
||||
|
||||
public static glSHandle Zero
|
||||
{
|
||||
get { return Alloc(1); }
|
||||
}
|
||||
|
||||
internal int DirectValue
|
||||
{
|
||||
get { return *valuePtr; }
|
||||
}
|
||||
|
||||
public static glSHandle Alloc(int value)
|
||||
{
|
||||
glSHandle ret = default;
|
||||
ret.source = new glHandleSet(1);
|
||||
ret.valuePtr = (int*)ret.source.handle;
|
||||
*ret.valuePtr = (int)value;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -125,24 +135,15 @@ namespace System
|
||||
/// </summary>
|
||||
public unsafe class glHandleSet
|
||||
{
|
||||
private readonly uint[] _value;
|
||||
internal int length;
|
||||
internal uint* handle;
|
||||
internal int length;
|
||||
private readonly uint[] _value;
|
||||
|
||||
public static void Copy(in glHandleSet source, glHandleSet target)
|
||||
public glHandleSet(int count)
|
||||
{
|
||||
if (source == null || target == null)
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
if (source.length != target.length)
|
||||
{
|
||||
throw new Exception($"Lengths of {nameof(source)} and {nameof(target)} are not equal.");
|
||||
}
|
||||
for (int i = 0; i < source.length; i++)
|
||||
{
|
||||
target._value[i] = source._value[i];
|
||||
}
|
||||
_value = new uint[count];
|
||||
length = count;
|
||||
handle = (uint*)GCHandle.Alloc(_value, GCHandleType.Pinned).AddrOfPinnedObject();
|
||||
}
|
||||
|
||||
public glHandle this[int index]
|
||||
@@ -169,17 +170,20 @@ namespace System
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetValue(int index, uint value)
|
||||
public static void Copy(in glHandleSet source, glHandleSet target)
|
||||
{
|
||||
_value[index] = value;
|
||||
}
|
||||
|
||||
public glHandleSet(int count)
|
||||
{
|
||||
_value = new uint[count];
|
||||
length = count;
|
||||
handle = (uint*)GCHandle.Alloc(_value, GCHandleType.Pinned).AddrOfPinnedObject();
|
||||
if (source == null || target == null)
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
if (source.length != target.length)
|
||||
{
|
||||
throw new Exception($"Lengths of {nameof(source)} and {nameof(target)} are not equal.");
|
||||
}
|
||||
for (int i = 0; i < source.length; i++)
|
||||
{
|
||||
target._value[i] = source._value[i];
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -207,7 +211,7 @@ namespace System
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Realse all resource in this handle.
|
||||
/// Realse all resource in this handle.
|
||||
/// This will release all resource in this <see cref="glHandle"/>.
|
||||
/// This <see langword="glHandle"/> will be not usable.
|
||||
/// </summary>
|
||||
@@ -224,5 +228,10 @@ namespace System
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void SetValue(int index, uint value)
|
||||
{
|
||||
_value[index] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -9,12 +10,10 @@ using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
internal unsafe partial class GLonRender : IglFunc
|
||||
{
|
||||
internal GLcontext* api;
|
||||
FrameTimeoutException refreshSIgnal = new FrameTimeoutException();
|
||||
|
||||
private FrameTimeoutException refreshSIgnal = new FrameTimeoutException();
|
||||
|
||||
internal GLonRender(GLcontext* context)
|
||||
{
|
||||
@@ -28,7 +27,6 @@ namespace StgSharp.Graphics
|
||||
|
||||
void IglFunc.SwitchContext()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -142,7 +140,6 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
|
||||
InternalIO.InternalWriteLog(log, LogType.Error);
|
||||
|
||||
}
|
||||
handleSet.SetValue(i, shaderID);
|
||||
}
|
||||
@@ -203,6 +200,7 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
api->glDeleteBuffers(1, (uint*)handle.Handle);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.DeleteBuffers(glHandleSet handle)
|
||||
{
|
||||
@@ -226,12 +224,15 @@ namespace StgSharp.Graphics
|
||||
case TypeCode.UInt32:
|
||||
a = GLconst.UNSIGNED_INT;
|
||||
break;
|
||||
|
||||
case TypeCode.UInt16:
|
||||
a = GLconst.UNSIGNED_SHORT;
|
||||
break;
|
||||
|
||||
case TypeCode.Byte:
|
||||
a = GLconst.UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
default:
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Parameter error in parameter {nameof(type)} method DrawElements. " +
|
||||
@@ -257,6 +258,7 @@ namespace StgSharp.Graphics
|
||||
api->glGenTextures((uint)count, h.handle);
|
||||
return h;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe glHandleSet IglFunc.GenVertexArrays(int count)
|
||||
{
|
||||
@@ -327,16 +329,12 @@ namespace StgSharp.Graphics
|
||||
api->glEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels)
|
||||
void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, glHandle pixels)
|
||||
{
|
||||
Console.WriteLine(pixels);
|
||||
IntPtr source = GCHandle.Alloc(pixels, GCHandleType.Pinned).AddrOfPinnedObject();
|
||||
api->glTexImage2D(
|
||||
(uint)target, level, internalformat, width, height, 0, format, type, (void*)source
|
||||
(uint)target, level, internalformat, width, height, 0, format, type, pixels.valuePtr
|
||||
);
|
||||
GCHandle.FromIntPtr(source).Free();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -356,8 +354,5 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
api->glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -14,12 +15,13 @@ namespace StgSharp.Graphics
|
||||
private static readonly GLonTimeout singleInstance
|
||||
= new GLonTimeout();
|
||||
|
||||
FrameTimeoutException refreshSIgnal = new FrameTimeoutException();
|
||||
FrameTimeoutException signal = new FrameTimeoutException("This frame is timeout");
|
||||
private FrameTimeoutException refreshSIgnal = new FrameTimeoutException();
|
||||
private FrameTimeoutException signal = new FrameTimeoutException("This frame is timeout");
|
||||
|
||||
unsafe GLcontext* IglFunc.Context => throw signal;
|
||||
|
||||
private GLonTimeout() { }
|
||||
private GLonTimeout()
|
||||
{ }
|
||||
|
||||
void IglFunc.ActiveTexture(uint type) => throw signal;
|
||||
|
||||
@@ -43,12 +45,10 @@ namespace StgSharp.Graphics
|
||||
|
||||
glHandleSet IglFunc.CompileShader(ShaderType shaderType, params string[] shaderCode) => throw signal;
|
||||
|
||||
|
||||
glHandle IglFunc.CreateProgram() => throw signal;
|
||||
|
||||
glHandleSet IglFunc.CreateProgram(int count) => throw signal;
|
||||
|
||||
|
||||
IntPtr IglFunc.CreateWindowHandle(int width, int height, string tittle, IntPtr monitor, Form share) => throw signal;
|
||||
|
||||
glHandle IglFunc.CreatGraphicProgram() => throw signal;
|
||||
@@ -57,18 +57,14 @@ namespace StgSharp.Graphics
|
||||
|
||||
void IglFunc.DeleteBuffers(glHandleSet handle) => throw signal;
|
||||
|
||||
|
||||
void IglFunc.DeleteVertexArrays(glHandleSet handle) => throw signal;
|
||||
|
||||
|
||||
void IglFunc.DrawElements(GepmetryType mode, uint count, TypeCode type, IntPtr ptr) => throw signal;
|
||||
|
||||
glHandleSet IglFunc.GenBuffers(int count) => throw signal;
|
||||
|
||||
|
||||
glHandleSet IglFunc.GenTextures(int count) => throw signal;
|
||||
|
||||
|
||||
glHandleSet IglFunc.GenVertexArrays(int count) => throw signal;
|
||||
|
||||
unsafe glSHandle IglFunc.GetUniformLocation(glHandle program, string name) => throw signal;
|
||||
@@ -97,7 +93,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
void IglFunc.SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer) => throw signal;
|
||||
|
||||
unsafe void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels) => throw signal;
|
||||
unsafe void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, glHandle pixels) => throw signal;
|
||||
|
||||
void IglFunc.TextureParameter(int target, uint pname, int param) => throw signal;
|
||||
|
||||
@@ -112,4 +108,4 @@ namespace StgSharp.Graphics
|
||||
throw signal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,8 +13,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
|
||||
|
||||
internal unsafe partial class GLonUpdate : IglFunc
|
||||
{
|
||||
private static ConcurrentQueue<IntPtr> glActionQueue;
|
||||
@@ -139,7 +138,7 @@ namespace StgSharp.Graphics
|
||||
for (int i = 0; i < l; i++)
|
||||
{
|
||||
GCHandle codePtr = GCHandle.Alloc(Encoding.UTF8.GetBytes(shaderCode[i] + '\0'), GCHandleType.Pinned);
|
||||
paramQueue.Enqueue((IntPtr)shaderHandle.handle + i, codePtr.AddrOfPinnedObject());
|
||||
paramQueue.Enqueue((IntPtr)(shaderHandle.handle + i), codePtr.AddrOfPinnedObject());
|
||||
}
|
||||
glActionQueue.Enqueue(CompileShaderPtr);
|
||||
return shaderHandle;
|
||||
@@ -235,12 +234,15 @@ namespace StgSharp.Graphics
|
||||
case TypeCode.UInt32:
|
||||
a = GLconst.UNSIGNED_INT;
|
||||
break;
|
||||
|
||||
case TypeCode.UInt16:
|
||||
a = GLconst.UNSIGNED_SHORT;
|
||||
break;
|
||||
|
||||
case TypeCode.Byte:
|
||||
a = GLconst.UNSIGNED_BYTE;
|
||||
break;
|
||||
|
||||
default:
|
||||
InternalIO.InternalWriteLog(
|
||||
$"Parameter error in parameter {type} method DrawElements. " +
|
||||
@@ -343,13 +345,12 @@ namespace StgSharp.Graphics
|
||||
//TODO:双线程,换运行环境
|
||||
void IglFunc.SwitchContext()
|
||||
{
|
||||
|
||||
paramQueue.context = api;
|
||||
}
|
||||
|
||||
unsafe void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels)
|
||||
unsafe void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, glHandle pixels)
|
||||
{
|
||||
IntPtr source = GCHandle.Alloc(pixels, GCHandleType.Pinned).AddrOfPinnedObject();
|
||||
paramQueue.Enqueue(source);
|
||||
paramQueue.Enqueue(pixels);
|
||||
paramQueue.Enqueue((uint)level, internalformat, width, height);
|
||||
paramQueue.Enqueue((uint)target, format, type);
|
||||
glActionQueue.Enqueue(textureImage2dPtr);
|
||||
@@ -388,4 +389,4 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
@@ -101,6 +102,9 @@ namespace StgSharp.Graphics
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
paramQueue.TryDequeue(out shaderHandle, out codeHandle);
|
||||
GCHandle code = GCHandle.FromIntPtr(codeHandle);
|
||||
byte[] c = (byte[])code.Target;
|
||||
Console.WriteLine(Encoding.UTF8.GetString(c));
|
||||
*(uint*)shaderHandle = InternalIO.InternalLoadShaderCode(paramQueue.context, (byte*)codeHandle, type);
|
||||
if (*(uint*)shaderHandle == 0)
|
||||
{
|
||||
@@ -275,4 +279,4 @@ namespace StgSharp.Graphics
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,141 +1,258 @@
|
||||
using StgSharp.Graphics;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
#if Windows
|
||||
using Windows.Win32;
|
||||
// using Windows.Win32;
|
||||
#endif
|
||||
|
||||
namespace StgSharp
|
||||
{
|
||||
internal partial class InternalIO
|
||||
{
|
||||
#region api call
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwInit")] internal extern unsafe static int glfwInit();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwTerminate")] internal extern unsafe static void glfwTerminate();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwInitHint")] internal extern unsafe static void glfwInitHint(int hint, int value);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVersion")] internal extern unsafe static void glfwGetVersion(int* major, int* minor, int* rev);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVersionString")] internal extern unsafe static byte* glfwGetVersionString();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetError")] internal extern unsafe static int glfwGetError(byte** description);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetErrorCallback")] internal extern unsafe static GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitors")] internal extern unsafe static IntPtr* glfwGetMonitors(int* count);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetPrimaryMonitor")] internal extern unsafe static IntPtr glfwGetPrimaryMonitor();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorPos")] internal extern unsafe static void glfwGetMonitorPos(IntPtr monitor, int* xpos, int* ypos);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorWorkarea")] internal extern unsafe static void glfwGetMonitorWorkarea(IntPtr monitor, int* xpos, int* ypos, int* width, int* height);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorPhysicalSize")] internal extern unsafe static void glfwGetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorContentScale")] internal extern unsafe static void glfwGetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorName")] internal extern unsafe static byte* glfwGetMonitorName(IntPtr monitor);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetMonitorUserPointer")] internal extern unsafe static void glfwSetMonitorUserPointer(IntPtr monitor, void* pointer);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorUserPointer")] internal extern unsafe static void* glfwGetMonitorUserPointer(IntPtr monitor);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetMonitorCallback")] internal extern unsafe static GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVideoModes")] internal extern unsafe static GLFWvidmode* glfwGetVideoModes(IntPtr monitor, int* count);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVideoMode")] internal extern unsafe static GLFWvidmode* glfwGetVideoMode(IntPtr monitor);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetGamma")] internal extern unsafe static void glfwSetGamma(IntPtr monitor, float gamma);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetGammaRamp")] internal extern unsafe static GLFWgammaramp* glfwGetGammaRamp(IntPtr monitor);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetGammaRamp")] internal extern unsafe static void glfwSetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwDefaultWindowHints")] internal extern unsafe static void glfwDefaultWindowHints();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWindowHint")] internal extern unsafe static void glfwWindowHint(int hint, int value);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWindowHintString")] internal extern unsafe static void glfwWindowHintString(int hint, byte* value);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwCreateWindow")] internal extern unsafe static IntPtr glfwCreateWindow(int width, int height, byte[] title, IntPtr monitor, IntPtr share);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwDestroyWindow")] internal extern unsafe static void glfwDestroyWindow(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWindowShouldClose")] internal extern unsafe static int glfwWindowShouldClose(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowShouldClose")] internal extern unsafe static void glfwSetWindowShouldClose(IntPtr window, int value);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowTitle")] internal extern unsafe static void glfwSetWindowTitle(IntPtr window, byte* title);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowIcon")] internal extern unsafe static void glfwSetWindowIcon(IntPtr window, int count, GLFWimage* images);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowPos")] internal extern unsafe static void glfwGetWindowPos(IntPtr window, int* xpos, int* ypos);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowPos")] internal extern unsafe static void glfwSetWindowPos(IntPtr window, int xpos, int ypos);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowSize")] internal extern unsafe static void glfwGetWindowSize(IntPtr window, int* width, int* height);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSizeLimits")] internal extern unsafe static void glfwSetWindowSizeLimits(IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowAspectRatio")] internal extern unsafe static void glfwSetWindowAspectRatio(IntPtr window, int numer, int denom);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSize")] internal extern unsafe static void glfwSetWindowSize(IntPtr window, int width, int height);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetFramebufferSize")] internal extern unsafe static void glfwGetFramebufferSize(IntPtr window, int* width, int* height);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowFrameSize")] internal extern unsafe static void glfwGetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowContentScale")] internal extern unsafe static void glfwGetWindowContentScale(IntPtr window, float* xscale, float* yscale);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowOpacity")] internal extern unsafe static float glfwGetWindowOpacity(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowOpacity")] internal extern unsafe static void glfwSetWindowOpacity(IntPtr window, float opacity);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwIconifyWindow")] internal extern unsafe static void glfwIconifyWindow(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwRestoreWindow")] internal extern unsafe static void glfwRestoreWindow(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwMaximizeWindow")] internal extern unsafe static void glfwMaximizeWindow(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwShowWindow")] internal extern unsafe static void glfwShowWindow(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwHideWindow")] internal extern unsafe static void glfwHideWindow(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwFocusWindow")] internal extern unsafe static void glfwFocusWindow(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwRequestWindowAttention")] internal extern unsafe static void glfwRequestWindowAttention(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowMonitor")] internal extern unsafe static IntPtr glfwGetWindowMonitor(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowMonitor")] internal extern unsafe static void glfwSetWindowMonitor(IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowAttrib")] internal extern unsafe static int glfwGetWindowAttrib(IntPtr window, int attrib);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowAttrib")] internal extern unsafe static void glfwSetWindowAttrib(IntPtr window, int attrib, int value);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowUserPointer")] internal extern unsafe static void glfwSetWindowUserPointer(IntPtr window, void* pointer);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowUserPointer")] internal extern unsafe static void* glfwGetWindowUserPointer(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowPosCallback")] internal extern unsafe static GLFWwindowposfun glfwSetWindowPosCallback(IntPtr window, GLFWwindowposfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSizeCallback")] internal extern unsafe static GLFWwindowsizefun glfwSetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowCloseCallback")] internal extern unsafe static GLFWwindowclosefun glfwSetWindowCloseCallback(IntPtr window, GLFWwindowclosefun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowRefreshCallback")] internal extern unsafe static GLFWwindowrefreshfun glfwSetWindowRefreshCallback(IntPtr window, GLFWwindowrefreshfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowFocusCallback")] internal extern unsafe static GLFWwindowfocusfun glfwSetWindowFocusCallback(IntPtr window, GLFWwindowfocusfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowIconifyCallback")] internal extern unsafe static GLFWwindowiconifyfun glfwSetWindowIconifyCallback(IntPtr window, GLFWwindowiconifyfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowMaximizeCallback")] internal extern unsafe static GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetFramebufferSizeCallback")] internal extern unsafe static FramebuffersizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowContentScaleCallback")] internal extern unsafe static GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwPollEvents")] internal extern unsafe static void glfwPollEvents();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWaitEvents")] internal extern unsafe static void glfwWaitEvents();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWaitEventsTimeout")] internal extern unsafe static void glfwWaitEventsTimeout(double timeout);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwPostEmptyEvent")] internal extern unsafe static void glfwPostEmptyEvent();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetInputMode")] internal extern unsafe static int glfwGetInputMode(IntPtr window, int mode);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetInputMode")] internal extern unsafe static void glfwSetInputMode(IntPtr window, int mode, int value);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwRawMouseMotionSupported")] internal extern unsafe static int glfwRawMouseMotionSupported();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetKeyName")] internal extern unsafe static byte* glfwGetKeyName(int key, int scancode);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetKeyScancode")] internal extern unsafe static int glfwGetKeyScancode(int key);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetKey")] internal extern unsafe static KeyStatus glfwGetKey(IntPtr window, int key);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMouseButton")] internal extern unsafe static int glfwGetMouseButton(IntPtr window, int button);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetCursorPos")] internal extern unsafe static void glfwGetCursorPos(IntPtr window, double* xpos, double* ypos);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorPos")] internal extern unsafe static void glfwSetCursorPos(IntPtr window, double xpos, double ypos);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwCreateCursor")] internal extern unsafe static GLFWcursor* glfwCreateCursor(GLFWimage* image, int xhot, int yhot);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwCreateStandardCursor")] internal extern unsafe static GLFWcursor* glfwCreateStandardCursor(int shape);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwDestroyCursor")] internal extern unsafe static void glfwDestroyCursor(GLFWcursor* cursor);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursor")] internal extern unsafe static void glfwSetCursor(IntPtr window, GLFWcursor* cursor);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetKeyCallback")] internal extern unsafe static GLFWkeyfun glfwSetKeyCallback(IntPtr window, GLFWkeyfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCharCallback")] internal extern unsafe static GLFWcharfun glfwSetCharCallback(IntPtr window, GLFWcharfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCharModsCallback")] internal extern unsafe static GLFWcharmodsfun glfwSetCharModsCallback(IntPtr window, GLFWcharmodsfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetMouseButtonCallback")] internal extern unsafe static GLFWmousebuttonfun glfwSetMouseButtonCallback(IntPtr window, GLFWmousebuttonfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorPosCallback")] internal extern unsafe static GLFWcursorposfun glfwSetCursorPosCallback(IntPtr window, GLFWcursorposfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorEnterCallback")] internal extern unsafe static GLFWcursorenterfun glfwSetCursorEnterCallback(IntPtr window, GLFWcursorenterfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetScrollCallback")] internal extern unsafe static GLFWscrollfun glfwSetScrollCallback(IntPtr window, GLFWscrollfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetDropCallback")] internal extern unsafe static GLFWdropfun glfwSetDropCallback(IntPtr window, GLFWdropfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwJoystickPresent")] internal extern unsafe static int glfwJoystickPresent(int jid);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickAxes")] internal extern unsafe static float* glfwGetJoystickAxes(int jid, int* count);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickButtons")] internal extern unsafe static byte* glfwGetJoystickButtons(int jid, int* count);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickHats")] internal extern unsafe static byte* glfwGetJoystickHats(int jid, int* count);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickName")] internal extern unsafe static byte* glfwGetJoystickName(int jid);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickGUID")] internal extern unsafe static byte* glfwGetJoystickGUID(int jid);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetJoystickUserPointer")] internal extern unsafe static void glfwSetJoystickUserPointer(int jid, void* pointer);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickUserPointer")] internal extern unsafe static void* glfwGetJoystickUserPointer(int jid);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwJoystickIsGamepad")] internal extern unsafe static int glfwJoystickIsGamepad(int jid);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetJoystickCallback")] internal extern unsafe static GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwUpdateGamepadMappings")] internal extern unsafe static int glfwUpdateGamepadMappings(byte* str);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetGamepadName")] internal extern unsafe static byte* glfwGetGamepadName(int jid);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetGamepadState")] internal extern unsafe static int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetClipboardString")] internal extern unsafe static void glfwSetClipboardString(IntPtr window, byte* str);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetClipboardString")] internal extern unsafe static byte* glfwGetClipboardString(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetTime")] internal extern unsafe static double glfwGetTime();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetTime")] internal extern unsafe static void glfwSetTime(double time);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetTimerValue")] internal extern unsafe static ulong* glfwGetTimerValue();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetTimerFrequency")] internal extern unsafe static ulong* glfwGetTimerFrequency();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwMakeContextCurrent")] internal extern unsafe static void glfwMakeContextCurrent(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetCurrentContext")] internal extern unsafe static IntPtr glfwGetCurrentContext();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSwapBuffers")] internal extern unsafe static void glfwSwapBuffers(IntPtr window);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSwapInterval")] internal extern unsafe static void glfwSwapInterval(int interval);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwExtensionSupported")] internal extern unsafe static int glfwExtensionSupported(byte* extension);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetProcAddress", CharSet = CharSet.Ansi)] internal extern unsafe static IntPtr glfwGetProcAddress(string procname);
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwVulkanSupported")] internal extern unsafe static int glfwVulkanSupported();
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetRequiredInstanceExtensions")] internal extern unsafe static byte** glfwGetRequiredInstanceExtensions(uint* count);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwInit")] internal static extern unsafe int glfwInit();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwTerminate")] internal static extern unsafe void glfwTerminate();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwInitHint")] internal static extern unsafe void glfwInitHint(int hint, int value);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVersion")] internal static extern unsafe void glfwGetVersion(int* major, int* minor, int* rev);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVersionString")] internal static extern unsafe byte* glfwGetVersionString();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetError")] internal static extern unsafe int glfwGetError(byte** description);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetErrorCallback")] internal static extern unsafe GLFWerrorfun glfwSetErrorCallback(GLFWerrorfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitors")] internal static extern unsafe IntPtr* glfwGetMonitors(int* count);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetPrimaryMonitor")] internal static extern unsafe IntPtr glfwGetPrimaryMonitor();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorPos")] internal static extern unsafe void glfwGetMonitorPos(IntPtr monitor, int* xpos, int* ypos);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorWorkarea")] internal static extern unsafe void glfwGetMonitorWorkarea(IntPtr monitor, int* xpos, int* ypos, int* width, int* height);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorPhysicalSize")] internal static extern unsafe void glfwGetMonitorPhysicalSize(IntPtr monitor, int* widthMM, int* heightMM);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorContentScale")] internal static extern unsafe void glfwGetMonitorContentScale(IntPtr monitor, float* xscale, float* yscale);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorName")] internal static extern unsafe byte* glfwGetMonitorName(IntPtr monitor);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetMonitorUserPointer")] internal static extern unsafe void glfwSetMonitorUserPointer(IntPtr monitor, void* pointer);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMonitorUserPointer")] internal static extern unsafe void* glfwGetMonitorUserPointer(IntPtr monitor);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetMonitorCallback")] internal static extern unsafe GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVideoModes")] internal static extern unsafe GLFWvidmode* glfwGetVideoModes(IntPtr monitor, int* count);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetVideoMode")] internal static extern unsafe GLFWvidmode* glfwGetVideoMode(IntPtr monitor);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetGamma")] internal static extern unsafe void glfwSetGamma(IntPtr monitor, float gamma);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetGammaRamp")] internal static extern unsafe GLFWgammaramp* glfwGetGammaRamp(IntPtr monitor);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetGammaRamp")] internal static extern unsafe void glfwSetGammaRamp(IntPtr monitor, GLFWgammaramp* ramp);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwDefaultWindowHints")] internal static extern unsafe void glfwDefaultWindowHints();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWindowHint")] internal static extern unsafe void glfwWindowHint(int hint, int value);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWindowHintString")] internal static extern unsafe void glfwWindowHintString(int hint, byte* value);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwCreateWindow")] internal static extern unsafe IntPtr glfwCreateWindow(int width, int height, byte[] title, IntPtr monitor, IntPtr share);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwDestroyWindow")] internal static extern unsafe void glfwDestroyWindow(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWindowShouldClose")] internal static extern unsafe int glfwWindowShouldClose(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowShouldClose")] internal static extern unsafe void glfwSetWindowShouldClose(IntPtr window, int value);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowTitle")] internal static extern unsafe void glfwSetWindowTitle(IntPtr window, byte* title);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowIcon")] internal static extern unsafe void glfwSetWindowIcon(IntPtr window, int count, GLFWimage* images);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowPos")] internal static extern unsafe void glfwGetWindowPos(IntPtr window, int* xpos, int* ypos);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowPos")] internal static extern unsafe void glfwSetWindowPos(IntPtr window, int xpos, int ypos);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowSize")] internal static extern unsafe void glfwGetWindowSize(IntPtr window, int* width, int* height);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSizeLimits")] internal static extern unsafe void glfwSetWindowSizeLimits(IntPtr window, int minwidth, int minheight, int maxwidth, int maxheight);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowAspectRatio")] internal static extern unsafe void glfwSetWindowAspectRatio(IntPtr window, int numer, int denom);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSize")] internal static extern unsafe void glfwSetWindowSize(IntPtr window, int width, int height);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetFramebufferSize")] internal static extern unsafe void glfwGetFramebufferSize(IntPtr window, int* width, int* height);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowFrameSize")] internal static extern unsafe void glfwGetWindowFrameSize(IntPtr window, int* left, int* top, int* right, int* bottom);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowContentScale")] internal static extern unsafe void glfwGetWindowContentScale(IntPtr window, float* xscale, float* yscale);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowOpacity")] internal static extern unsafe float glfwGetWindowOpacity(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowOpacity")] internal static extern unsafe void glfwSetWindowOpacity(IntPtr window, float opacity);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwIconifyWindow")] internal static extern unsafe void glfwIconifyWindow(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwRestoreWindow")] internal static extern unsafe void glfwRestoreWindow(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwMaximizeWindow")] internal static extern unsafe void glfwMaximizeWindow(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwShowWindow")] internal static extern unsafe void glfwShowWindow(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwHideWindow")] internal static extern unsafe void glfwHideWindow(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwFocusWindow")] internal static extern unsafe void glfwFocusWindow(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwRequestWindowAttention")] internal static extern unsafe void glfwRequestWindowAttention(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowMonitor")] internal static extern unsafe IntPtr glfwGetWindowMonitor(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowMonitor")] internal static extern unsafe void glfwSetWindowMonitor(IntPtr window, IntPtr monitor, int xpos, int ypos, int width, int height, int refreshRate);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowAttrib")] internal static extern unsafe int glfwGetWindowAttrib(IntPtr window, int attrib);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowAttrib")] internal static extern unsafe void glfwSetWindowAttrib(IntPtr window, int attrib, int value);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowUserPointer")] internal static extern unsafe void glfwSetWindowUserPointer(IntPtr window, void* pointer);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetWindowUserPointer")] internal static extern unsafe void* glfwGetWindowUserPointer(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowPosCallback")] internal static extern unsafe GLFWwindowposfun glfwSetWindowPosCallback(IntPtr window, GLFWwindowposfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowSizeCallback")] internal static extern unsafe GLFWwindowsizefun glfwSetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowCloseCallback")] internal static extern unsafe GLFWwindowclosefun glfwSetWindowCloseCallback(IntPtr window, GLFWwindowclosefun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowRefreshCallback")] internal static extern unsafe GLFWwindowrefreshfun glfwSetWindowRefreshCallback(IntPtr window, GLFWwindowrefreshfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowFocusCallback")] internal static extern unsafe GLFWwindowfocusfun glfwSetWindowFocusCallback(IntPtr window, GLFWwindowfocusfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowIconifyCallback")] internal static extern unsafe GLFWwindowiconifyfun glfwSetWindowIconifyCallback(IntPtr window, GLFWwindowiconifyfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowMaximizeCallback")] internal static extern unsafe GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(IntPtr window, GLFWwindowmaximizefun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetFramebufferSizeCallback")] internal static extern unsafe FramebuffersizeHandler glfwSetFramebufferSizeCallback(IntPtr window, IntPtr callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetWindowContentScaleCallback")] internal static extern unsafe GLFWwindowcontentscalefun glfwSetWindowContentScaleCallback(IntPtr window, GLFWwindowcontentscalefun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwPollEvents")] internal static extern unsafe void glfwPollEvents();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWaitEvents")] internal static extern unsafe void glfwWaitEvents();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwWaitEventsTimeout")] internal static extern unsafe void glfwWaitEventsTimeout(double timeout);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwPostEmptyEvent")] internal static extern unsafe void glfwPostEmptyEvent();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetInputMode")] internal static extern unsafe int glfwGetInputMode(IntPtr window, int mode);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetInputMode")] internal static extern unsafe void glfwSetInputMode(IntPtr window, int mode, int value);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwRawMouseMotionSupported")] internal static extern unsafe int glfwRawMouseMotionSupported();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetKeyName")] internal static extern unsafe byte* glfwGetKeyName(int key, int scancode);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetKeyScancode")] internal static extern unsafe int glfwGetKeyScancode(int key);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetKey")] internal static extern unsafe KeyStatus glfwGetKey(IntPtr window, int key);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetMouseButton")] internal static extern unsafe int glfwGetMouseButton(IntPtr window, int button);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetCursorPos")] internal static extern unsafe void glfwGetCursorPos(IntPtr window, double* xpos, double* ypos);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorPos")] internal static extern unsafe void glfwSetCursorPos(IntPtr window, double xpos, double ypos);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwCreateCursor")] internal static extern unsafe GLFWcursor* glfwCreateCursor(GLFWimage* image, int xhot, int yhot);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwCreateStandardCursor")] internal static extern unsafe GLFWcursor* glfwCreateStandardCursor(int shape);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwDestroyCursor")] internal static extern unsafe void glfwDestroyCursor(GLFWcursor* cursor);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursor")] internal static extern unsafe void glfwSetCursor(IntPtr window, GLFWcursor* cursor);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetKeyCallback")] internal static extern unsafe GLFWkeyfun glfwSetKeyCallback(IntPtr window, GLFWkeyfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCharCallback")] internal static extern unsafe GLFWcharfun glfwSetCharCallback(IntPtr window, GLFWcharfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCharModsCallback")] internal static extern unsafe GLFWcharmodsfun glfwSetCharModsCallback(IntPtr window, GLFWcharmodsfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetMouseButtonCallback")] internal static extern unsafe GLFWmousebuttonfun glfwSetMouseButtonCallback(IntPtr window, GLFWmousebuttonfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorPosCallback")] internal static extern unsafe GLFWcursorposfun glfwSetCursorPosCallback(IntPtr window, GLFWcursorposfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetCursorEnterCallback")] internal static extern unsafe GLFWcursorenterfun glfwSetCursorEnterCallback(IntPtr window, GLFWcursorenterfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetScrollCallback")] internal static extern unsafe GLFWscrollfun glfwSetScrollCallback(IntPtr window, GLFWscrollfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetDropCallback")] internal static extern unsafe GLFWdropfun glfwSetDropCallback(IntPtr window, GLFWdropfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwJoystickPresent")] internal static extern unsafe int glfwJoystickPresent(int jid);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickAxes")] internal static extern unsafe float* glfwGetJoystickAxes(int jid, int* count);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickButtons")] internal static extern unsafe byte* glfwGetJoystickButtons(int jid, int* count);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickHats")] internal static extern unsafe byte* glfwGetJoystickHats(int jid, int* count);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickName")] internal static extern unsafe byte* glfwGetJoystickName(int jid);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickGUID")] internal static extern unsafe byte* glfwGetJoystickGUID(int jid);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetJoystickUserPointer")] internal static extern unsafe void glfwSetJoystickUserPointer(int jid, void* pointer);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetJoystickUserPointer")] internal static extern unsafe void* glfwGetJoystickUserPointer(int jid);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwJoystickIsGamepad")] internal static extern unsafe int glfwJoystickIsGamepad(int jid);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetJoystickCallback")] internal static extern unsafe GLFWjoystickfun glfwSetJoystickCallback(GLFWjoystickfun callback);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwUpdateGamepadMappings")] internal static extern unsafe int glfwUpdateGamepadMappings(byte* str);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetGamepadName")] internal static extern unsafe byte* glfwGetGamepadName(int jid);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetGamepadState")] internal static extern unsafe int glfwGetGamepadState(int jid, GLFWgamepadstate* state);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetClipboardString")] internal static extern unsafe void glfwSetClipboardString(IntPtr window, byte* str);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetClipboardString")] internal static extern unsafe byte* glfwGetClipboardString(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetTime")] internal static extern unsafe double glfwGetTime();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSetTime")] internal static extern unsafe void glfwSetTime(double time);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetTimerValue")] internal static extern unsafe ulong* glfwGetTimerValue();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetTimerFrequency")] internal static extern unsafe ulong* glfwGetTimerFrequency();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwMakeContextCurrent")] internal static extern unsafe void glfwMakeContextCurrent(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetCurrentContext")] internal static extern unsafe IntPtr glfwGetCurrentContext();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSwapBuffers")] internal static extern unsafe void glfwSwapBuffers(IntPtr window);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwSwapInterval")] internal static extern unsafe void glfwSwapInterval(int interval);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwExtensionSupported")] internal static extern unsafe int glfwExtensionSupported(byte* extension);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetProcAddress", CharSet = CharSet.Ansi)] internal static extern unsafe IntPtr glfwGetProcAddress(string procname);
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwVulkanSupported")] internal static extern unsafe int glfwVulkanSupported();
|
||||
|
||||
[DllImport(SSC_libname, EntryPoint = "glfwGetRequiredInstanceExtensions")] internal static extern unsafe byte** glfwGetRequiredInstanceExtensions(uint* count);
|
||||
|
||||
//[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetInstanceProcAddress")] internal extern unsafe static GLFWvkproc glfwGetInstanceProcAddress(VkInstance instance, byte* procname);
|
||||
//[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwGetPhysicalDevicePresentationSupport")] internal extern unsafe static int glfwGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint* queuefamily);
|
||||
//[DllImport(InternalIO.SSC_libname, EntryPoint = "glfwCreateWindowSurface")] internal extern unsafe static VkResult glfwCreateWindowSurface(VkInstance instance, IntPtr window, VkAllocationCallbacks* allocator, VkSurfaceKHR* surface);
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#endregion api call
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,9 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public static partial class glManager
|
||||
{
|
||||
const int glExtension = 0x1f03;
|
||||
const int glVersion = 0x1f02;
|
||||
private const int glExtension = 0x1f03;
|
||||
private const int glVersion = 0x1f02;
|
||||
|
||||
private static readonly string[] glBranch =
|
||||
new string[] {
|
||||
"OpenGL ES-CM ",
|
||||
@@ -22,19 +23,17 @@ namespace StgSharp.Graphics
|
||||
|
||||
private static string glExtensionList;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Load all aupportable OpenGL APIs and bind them to given <see cref="Form"/> context.
|
||||
/// </summary>
|
||||
/// <param name="form">The <see cref="Form"/> used as current OpenGL context</param>
|
||||
/// <param name="loader">A delegate that can get o</param>
|
||||
/// <param name="loader">A delegate to get address of OprnGL api</param>
|
||||
public static unsafe void LoadGLapi(this Form form, GLfuncLoader loader)
|
||||
{
|
||||
GLcontext* context = form.contextID;
|
||||
if (loader == null)
|
||||
{
|
||||
loader = LoadGLfunc;
|
||||
loader = InternalIO.glfwGetProcAddress;
|
||||
}
|
||||
#pragma warning disable CS8909
|
||||
if ((form.contextID->glGetString) != (delegate*<uint, IntPtr>)IntPtr.Zero)
|
||||
@@ -43,15 +42,14 @@ namespace StgSharp.Graphics
|
||||
return;
|
||||
}
|
||||
IntPtr proc = loader("glGetString");
|
||||
context->glGetString = (delegate*<uint, IntPtr>)proc;
|
||||
|
||||
if ((IntPtr)context->glGetString == IntPtr.Zero)
|
||||
if (proc == IntPtr.Zero)
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine("Cannot load GL.");
|
||||
throw new Exception("Cannot load gl");
|
||||
#endif
|
||||
throw new Exception("Cannot load gl");
|
||||
}
|
||||
context->glGetString = (delegate*<uint, IntPtr>)proc;
|
||||
|
||||
string coreVersion;
|
||||
if (context->glGetString(glVersion) == IntPtr.Zero)
|
||||
@@ -60,7 +58,6 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
coreVersion = Marshal.PtrToStringAnsi(context->glGetString(glVersion));
|
||||
|
||||
|
||||
foreach (string branch in glBranch)
|
||||
{
|
||||
if (coreVersion.Contains(branch))
|
||||
@@ -97,7 +94,7 @@ namespace StgSharp.Graphics
|
||||
LoadGLcore45(form.contextID, loader);
|
||||
LoadGLcore46(form.contextID, loader);
|
||||
|
||||
#endregion
|
||||
#endregion load_core_gl
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -120,6 +117,7 @@ namespace StgSharp.Graphics
|
||||
extension.Split(" ").ToList();
|
||||
|
||||
#region checkGLextensions
|
||||
|
||||
if (extensions.Contains("gl_4DFX_multisample")) { _4DFX_multisample = true; extensions.Remove("gl_4DFX_multisample"); }
|
||||
if (extensions.Contains("gl_3DFX_tbuffer")) { _3DFX_tbuffer = true; extensions.Remove("gl_3DFX_tbuffer"); }
|
||||
if (extensions.Contains("gl_3DFX_texture_compression_FXT1")) { _3DFX_texture_compression_FXT1 = true; extensions.Remove("gl_3DFX_texture_compression_FXT1"); }
|
||||
@@ -739,7 +737,8 @@ namespace StgSharp.Graphics
|
||||
if (extensions.Contains("gl_SUN_vertex")) { SUN_vertex = true; extensions.Remove("glSUN_vertex"); }
|
||||
if (extensions.Contains("gl_WIN_phong_shading")) { WIN_phong_shading = true; extensions.Remove("glWIN_phong_shading"); }
|
||||
if (extensions.Contains("gl_WIN_specular_fog")) { WIN_specular_fog = true; extensions.Remove("glWIN_specular_fog"); }
|
||||
#endregion
|
||||
|
||||
#endregion checkGLextensions
|
||||
|
||||
InternalIO.InternalWriteLog("Find OpenGL extensions.", LogType.Info);
|
||||
|
||||
@@ -770,7 +769,6 @@ namespace StgSharp.Graphics
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
internal static void CheckCoreVersion(int majorVersion, int minorVersion)
|
||||
{
|
||||
if ((majorVersion >= 1) || (majorVersion == 1 && minorVersion == 0)) core10 = true; else goto log;
|
||||
@@ -798,10 +796,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalWriteLog("Find core OpenGL version.", LogType.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal unsafe static string GetExtensions(this GLcontext context)
|
||||
internal static unsafe string GetExtensions(this GLcontext context)
|
||||
{
|
||||
if (context.glGetString == null)
|
||||
{
|
||||
@@ -835,7 +832,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 1.0 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBlendFunc = (delegate*<uint, uint, void>)load("glBlendFunc");
|
||||
contextPtr->glClear = (delegate*<uint, void>)load("glClear");
|
||||
contextPtr->glClearColor = (delegate*<float, float, float, float, void>)load("glClearColor");
|
||||
@@ -885,7 +884,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glTexParameteriv = (delegate*<uint, uint, int*, void>)load("glTexParameteriv");
|
||||
contextPtr->glViewport = (delegate*<int, int, uint, uint, void>)load("glViewport");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.0 APIs");
|
||||
}
|
||||
|
||||
@@ -896,7 +896,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 1.1 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBindTexture = (delegate*<uint, uint, void>)load("glBindTexture");
|
||||
contextPtr->glCopyTexImage1D = (delegate*<uint, int, uint, int, int, uint, int, void>)load("glCopyTexImage1D");
|
||||
contextPtr->glCopyTexImage2D = (delegate*<uint, int, uint, int, int, uint, uint, int, void>)load("glCopyTexImage2D");
|
||||
@@ -912,9 +914,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glTexSubImage1D = (delegate*<uint, int, int, uint, uint, uint, void*, void>)load("glTexSubImage1D");
|
||||
contextPtr->glTexSubImage2D = (delegate*<uint, int, int, int, uint, uint, uint, uint, void*, void>)load("glTexSubImage2D");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.1 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.1 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore12(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -924,25 +926,29 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 1.2 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glCopyTexSubImage3D = (delegate*<uint, int, int, int, int, int, int, uint, uint, void>)load("glCopyTexSubImage3D");
|
||||
contextPtr->glDrawRangeElements = (delegate*<uint, uint, uint, uint, uint, void*, void>)load("glDrawRangeElements");
|
||||
contextPtr->glTexImage3D = (delegate*<uint, int, int, uint, uint, uint, int, uint, uint, void*, void>)load("glTexImage3D");
|
||||
contextPtr->glTexSubImage3D = (delegate*<uint, int, int, int, int, uint, uint, uint, uint, uint, void*, void>)load("glTexSubImage3D");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.2 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore13(GLcontext* contextPtr, GLfuncLoader load)
|
||||
{
|
||||
|
||||
if (!core13)
|
||||
{
|
||||
InternalIO.InternalAppendLog("The core version 1.3 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glActiveTexture = (delegate*<uint, void>)load("glActiveTexture");
|
||||
contextPtr->glCompressedTexImage1D = (delegate*<uint, int, uint, uint, int, uint, void*, void>)load("glCompressedTexImage1D");
|
||||
contextPtr->glCompressedTexImage2D = (delegate*<uint, int, uint, uint, uint, int, uint, void*, void>)load("glCompressedTexImage2D");
|
||||
@@ -953,9 +959,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glGetCompressedTexImage = (delegate*<uint, int, void*, void>)load("glGetCompressedTexImage");
|
||||
contextPtr->glSampleCoverage = (delegate*<float, bool, void>)load("glSampleCoverage");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.3 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.3 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore14(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -965,7 +971,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 1.4 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBlendColor = (delegate*<float, float, float, float, void>)load("glBlendColor");
|
||||
contextPtr->glBlendEquation = (delegate*<uint, void>)load("glBlendEquation");
|
||||
contextPtr->glBlendFuncSeparate = (delegate*<uint, uint, uint, uint, void>)load("glBlendFuncSeparate");
|
||||
@@ -976,20 +984,21 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glPointParameteri = (delegate*<uint, int, void>)load("glPointParameteri");
|
||||
contextPtr->glPointParameteriv = (delegate*<uint, int*, void>)load("glPointParameteriv");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.4 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.4 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore15(GLcontext* contextPtr, GLfuncLoader load)
|
||||
{
|
||||
|
||||
if (!core15)
|
||||
{
|
||||
InternalIO.InternalAppendLog("The core version 1.5 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBeginQuery = (delegate*<uint, uint, void>)load("glBeginQuery");
|
||||
contextPtr->glBindBuffer = (delegate*<uint, uint, void>)load("glBindBuffer");
|
||||
contextPtr->glBufferData = (delegate*<uint, IntPtr, void*, uint, void>)load("glBufferData");
|
||||
@@ -1010,9 +1019,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glMapBuffer = (delegate*<uint, uint, void*>)load("glMapBuffer");
|
||||
contextPtr->glUnmapBuffer = (delegate*<uint, bool>)load("glUnmapBuffer");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.5 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 1.5 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore20(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -1022,7 +1031,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 2.0 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glAttachShader = (delegate*<uint, uint, void>)load("glAttachShader");
|
||||
contextPtr->glBindAttribLocation = (delegate*<uint, uint, byte*, void>)load("glBindAttribLocation");
|
||||
contextPtr->glBlendEquationSeparate = (delegate*<uint, uint, void>)load("glBlendEquationSeparate");
|
||||
@@ -1117,9 +1128,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glVertexAttrib4usv = (delegate*<uint, ushort*, void>)load("glVertexAttrib4usv");
|
||||
contextPtr->glVertexAttribPointer = (delegate*<uint, int, uint, int, uint, void*, void>)load("glVertexAttribPointer");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 2.0 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 2.0 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore21(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -1129,7 +1140,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 2.1 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glUniformMatrix2x3fv = (delegate*<int, uint, bool, float*, void>)load("glUniformMatrix2x3fv");
|
||||
contextPtr->glUniformMatrix2x4fv = (delegate*<int, uint, bool, float*, void>)load("glUniformMatrix2x4fv");
|
||||
contextPtr->glUniformMatrix3x2fv = (delegate*<int, uint, bool, float*, void>)load("glUniformMatrix3x2fv");
|
||||
@@ -1137,9 +1150,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glUniformMatrix4x2fv = (delegate*<int, uint, bool, float*, void>)load("glUniformMatrix4x2fv");
|
||||
contextPtr->glUniformMatrix4x3fv = (delegate*<int, uint, bool, float*, void>)load("glUniformMatrix4x3fv");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 2.1 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 2.1 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore30(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -1149,7 +1162,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 3.0 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBeginConditionalRender = (delegate*<uint, uint, void>)load("glBeginConditionalRender");
|
||||
contextPtr->glBeginTransformFeedback = (delegate*<uint, void>)load("glBeginTransformFeedback");
|
||||
contextPtr->glBindBufferBase = (delegate*<uint, uint, uint, void>)load("glBindBufferBase");
|
||||
@@ -1235,9 +1250,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glVertexAttribI4usv = (delegate*<uint, ushort*, void>)load("glVertexAttribI4usv");
|
||||
contextPtr->glVertexAttribIPointer = (delegate*<uint, int, uint, uint, void*, void>)load("glVertexAttribIPointer");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.0 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.0 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore31(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -1247,7 +1262,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 3.1 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBindBufferBase = (delegate*<uint, uint, uint, void>)load("glBindBufferBase");
|
||||
contextPtr->glBindBufferRange = (delegate*<uint, uint, uint, IntPtr, UIntPtr, void>)load("glBindBufferRange");
|
||||
contextPtr->glCopyBufferSubData = (delegate*<uint, uint, IntPtr, IntPtr, UIntPtr, void>)load("glCopyBufferSubData");
|
||||
@@ -1264,7 +1281,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glTexBuffer = (delegate*<uint, uint, uint, void>)load("glTexBuffer");
|
||||
contextPtr->glUniformBlockBinding = (delegate*<uint, uint, uint, void>)load("glUniformBlockBinding");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.1 APIs");
|
||||
}
|
||||
|
||||
@@ -1275,7 +1293,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 3.2 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glClientWaitSync = (delegate*<GLsync, uint, ulong, uint>)load("glClientWaitSync");
|
||||
contextPtr->glDeleteSync = (delegate*<GLsync, void>)load("glDeleteSync");
|
||||
contextPtr->glDrawElementsBaseVertex = (delegate*<uint, uint, uint, void*, int, void>)load("glDrawElementsBaseVertex");
|
||||
@@ -1296,9 +1316,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glTexImage3DMultisample = (delegate*<uint, uint, uint, uint, uint, uint, bool, void>)load("glTexImage3DMultisample");
|
||||
contextPtr->glWaitSync = (delegate*<GLsync, uint, ulong, void>)load("glWaitSync");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.2 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.2 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore33(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -1308,7 +1328,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 3.3 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBindFragDataLocationIndexed = (delegate*<uint, uint, uint, byte*, void>)load("glBindFragDataLocationIndexed");
|
||||
contextPtr->glBindSampler = (delegate*<uint, uint, void>)load("glBindSampler");
|
||||
contextPtr->glDeleteSamplers = (delegate*<uint, uint*, void>)load("glDeleteSamplers");
|
||||
@@ -1338,9 +1360,9 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glVertexAttribP4ui = (delegate*<uint, uint, bool, uint, void>)load("glVertexAttribP4ui");
|
||||
contextPtr->glVertexAttribP4uiv = (delegate*<uint, uint, bool, uint*, void>)load("glVertexAttribP4uiv");
|
||||
|
||||
#endregion
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.3 APIs");
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 3.3 APIs");
|
||||
}
|
||||
|
||||
internal static unsafe void LoadGLcore40(GLcontext* contextPtr, GLfuncLoader load)
|
||||
@@ -1350,7 +1372,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 4.0 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBeginQueryIndexed = (delegate*<uint, uint, uint, void>)load("glBeginQueryIndexed");
|
||||
contextPtr->glBindTransformFeedback = (delegate*<uint, uint, void>)load("glBindTransformFeedback");
|
||||
contextPtr->glBlendEquationSeparatei = (delegate*<uint, uint, uint, void>)load("glBlendEquationSeparatei");
|
||||
@@ -1398,7 +1422,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glUniformMatrix4x3dv = (delegate*<int, uint, bool, double*, void>)load("glUniformMatrix4x3dv");
|
||||
contextPtr->glUniformSubroutinesuiv = (delegate*<uint, uint, uint*, void>)load("glUniformSubroutinesuiv");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.0 APIs");
|
||||
}
|
||||
|
||||
@@ -1409,7 +1434,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 4.1 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glActiveShaderProgram = (delegate*<uint, uint, void>)load("glActiveShaderProgram");
|
||||
contextPtr->glBindProgramPipeline = (delegate*<uint, void>)load("glBindProgramPipeline");
|
||||
contextPtr->glClearDepthf = (delegate*<float, void>)load("glClearDepthf");
|
||||
@@ -1499,7 +1526,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glViewportIndexedf = (delegate*<uint, float, float, float, float, void>)load("glViewportIndexedf");
|
||||
contextPtr->glViewportIndexedfv = (delegate*<uint, float*, void>)load("glViewportIndexedfv");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.1 APIs");
|
||||
}
|
||||
|
||||
@@ -1510,7 +1538,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 4.2 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBindImageTexture = (delegate*<uint, uint, int, bool, int, uint, uint, void>)load("glBindImageTexture");
|
||||
contextPtr->glDrawArraysInstancedBaseInstance = (delegate*<uint, int, uint, uint, uint, void>)load("glDrawArraysInstancedBaseInstance");
|
||||
contextPtr->glDrawElementsInstancedBaseInstance = (delegate*<uint, uint, uint, void*, uint, uint, void>)load("glDrawElementsInstancedBaseInstance");
|
||||
@@ -1524,7 +1554,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glTexStorage2D = (delegate*<uint, uint, uint, uint, uint, void>)load("glTexStorage2D");
|
||||
contextPtr->glTexStorage3D = (delegate*<uint, uint, uint, uint, uint, uint, void>)load("glTexStorage3D");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.2 APIs");
|
||||
}
|
||||
|
||||
@@ -1535,7 +1566,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 4.3 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBindVertexBuffer = (delegate*<uint, uint, IntPtr, uint, void>)load("glBindVertexBuffer");
|
||||
contextPtr->glClearBufferData = (delegate*<uint, uint, uint, uint, void*, void>)load("glClearBufferData");
|
||||
contextPtr->glClearBufferSubData = (delegate*<uint, uint, IntPtr, UIntPtr, uint, uint, void*, void>)load("glClearBufferSubData");
|
||||
@@ -1581,7 +1614,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glClearBufferData = (delegate*<uint, uint, uint, uint, void*, void>)load("glClearBufferData");
|
||||
contextPtr->glVertexBindingDivisor = (delegate*<uint, uint, void>)load("glVertexBindingDivisor");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.3 APIs");
|
||||
}
|
||||
|
||||
@@ -1592,7 +1626,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 4.4 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBindBuffersBase = (delegate*<uint, uint, uint, uint*, void>)load("glBindBuffersBase");
|
||||
contextPtr->glBindBuffersRange = (delegate*<uint, uint, uint, uint*, IntPtr*, UIntPtr*, void>)load("glBindBuffersRange");
|
||||
contextPtr->glBindImageTextures = (delegate*<uint, uint, uint*, void>)load("glBindImageTextures");
|
||||
@@ -1603,7 +1639,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glClearTexImage = (delegate*<uint, int, uint, uint, void*, void>)load("glClearTexImage");
|
||||
contextPtr->glClearTexSubImage = (delegate*<uint, int, int, int, int, uint, uint, uint, uint, uint, void*, void>)load("glClearTexSubImage");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.4 APIs");
|
||||
}
|
||||
|
||||
@@ -1614,7 +1651,9 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 4.5 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glBindTextureUnit = (delegate*<uint, uint, void>)load("glBindTextureUnit");
|
||||
contextPtr->glBlitNamedFramebuffer = (delegate*<uint, uint, int, int, int, int, int, int, int, int, uint, uint, void>)load("glBlitNamedFramebuffer");
|
||||
contextPtr->glCheckNamedFramebufferStatus = (delegate*<uint, uint, uint>)load("glCheckNamedFramebufferStatus");
|
||||
@@ -1726,7 +1765,8 @@ namespace StgSharp.Graphics
|
||||
contextPtr->glVertexArrayVertexBuffer = (delegate*<uint, uint, uint, IntPtr, uint, void>)load("glVertexArrayVertexBuffer");
|
||||
contextPtr->glVertexArrayVertexBuffers = (delegate*<uint, uint, uint, uint*, IntPtr*, uint*, void>)load("glVertexArrayVertexBuffers");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.5 APIs");
|
||||
}
|
||||
|
||||
@@ -1737,15 +1777,17 @@ namespace StgSharp.Graphics
|
||||
InternalIO.InternalAppendLog("The core version 4.6 is not supported.");
|
||||
throw new Exception("Final Version");
|
||||
}
|
||||
|
||||
#region load
|
||||
|
||||
contextPtr->glMultiDrawArraysIndirectCount = (delegate*<uint, void*, IntPtr, uint, uint, void>)load("glMultiDrawArraysIndirectCount");
|
||||
contextPtr->glMultiDrawElementsIndirectCount = (delegate*<uint, uint, void*, IntPtr, uint, uint, void>)load("glMultiDrawElementsIndirectCount");
|
||||
contextPtr->glPolygonOffsetClamp = (delegate*<float, float, float, void>)load("glPolygonOffsetClamp");
|
||||
contextPtr->glSpecializeShader = (delegate*<uint, byte*, uint, uint*, uint*, void>)load("glSpecializeShader");
|
||||
|
||||
#endregion
|
||||
#endregion load
|
||||
|
||||
InternalIO.InternalAppendLog("Successfully load all OpenGL 4.6 APIs");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public interface IglFunc
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Same function as OpenGL api glActiveTexture
|
||||
/// </summary>
|
||||
@@ -15,7 +14,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
/// <summary>
|
||||
/// Operation after alignment by calling <see cref="AlignFrame(Form)"/>.
|
||||
/// No calling of this method is acceptable, but it will bring the risk
|
||||
/// No calling of this method is acceptable, but it will bring the risk
|
||||
/// of that relevant code will not run if it is interrupted by frame overtime.
|
||||
/// Please call this method immediately after calling <see cref="AlignFrame(Form)"/>,
|
||||
/// too early or sonner may cause <see cref="InvalidOperationException"/>.
|
||||
@@ -74,7 +73,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
/// <summary>
|
||||
/// Call apiClearColor in OpenGL
|
||||
/// specifies the red, green, blue, and alpha values used by apiClear to clear the color buffers.
|
||||
/// specifies the red, green, blue, and alpha values used by apiClear to clear the color buffers.
|
||||
/// Values specified by apiClearColor are clamped to the range [0,1]
|
||||
/// </summary>
|
||||
/// <param name="R">Specify the red values used when the color buffers are cleared.</param>
|
||||
@@ -108,7 +107,7 @@ namespace StgSharp.Graphics
|
||||
glHandleSet CreateProgram(int count);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a form and its associated
|
||||
/// Creates a form and its associated
|
||||
/// </summary>
|
||||
/// <param name="width">Required width</param>
|
||||
/// <param name="height">Required width</param>
|
||||
@@ -139,7 +138,7 @@ namespace StgSharp.Graphics
|
||||
unsafe void DeleteVertexArrays(glHandleSet handleSet);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
/// <param name="count"></param>
|
||||
@@ -166,7 +165,6 @@ namespace StgSharp.Graphics
|
||||
/// <param name="count">Amount of vao to be generated</param>
|
||||
unsafe glHandleSet GenVertexArrays(int count);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Same fucntion as OpenGL api, glGetUniformLocation
|
||||
/// </summary>
|
||||
@@ -175,7 +173,6 @@ namespace StgSharp.Graphics
|
||||
/// <returns></returns>
|
||||
unsafe glSHandle GetUniformLocation(glHandle program, string name);
|
||||
|
||||
|
||||
bool GetWindowShouldClose(Form form);
|
||||
|
||||
/// <summary>
|
||||
@@ -272,7 +269,7 @@ namespace StgSharp.Graphics
|
||||
/// <param name="format">color channels of this image</param>
|
||||
/// <param name="type">how this image express each pixel</param>
|
||||
/// <param name="pixels">data array of pixels</param>
|
||||
unsafe void TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, T[] pixels) where T : struct;
|
||||
unsafe void TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, glHandle pixels) where T : struct;
|
||||
|
||||
/// <summary>
|
||||
/// Same fucntion as OpenGL api glTexParameteri
|
||||
@@ -289,7 +286,7 @@ namespace StgSharp.Graphics
|
||||
void UseProgram(glHandle program);
|
||||
|
||||
/// <summary>
|
||||
/// Same function as the OpenGL api, glViewPort
|
||||
/// Same function as the OpenGL api, glViewPort
|
||||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -20,46 +21,23 @@ namespace StgSharp.Graphics
|
||||
internal IntPtr pixelPtr;
|
||||
}
|
||||
|
||||
internal byte[] pixelArray;
|
||||
internal glHandle pixelArrayHandle;
|
||||
internal ImageInfo info;
|
||||
|
||||
public int Width { get => info.width; }
|
||||
public int Height { get => info.height; }
|
||||
public int Channel { get => info.channel; }
|
||||
|
||||
//TODO fix the bug
|
||||
internal Image(ImageInfo information)
|
||||
{
|
||||
info = information;
|
||||
int length = info.width * info.height * info.channel;
|
||||
pixelArray = new byte[length];
|
||||
Marshal.Copy(
|
||||
source: info.pixelPtr,
|
||||
destination: pixelArray,
|
||||
startIndex: 0,
|
||||
length: length
|
||||
);
|
||||
}
|
||||
|
||||
internal byte[] PixelArray
|
||||
{
|
||||
get
|
||||
{
|
||||
if (pixelArray == null)
|
||||
{
|
||||
pixelArray = new byte[info.width * info.height * info.channel];
|
||||
Marshal.Copy(source: info.pixelPtr, destination: pixelArray,
|
||||
startIndex: 0, length: info.width * info.height * info.channel);
|
||||
Marshal.FreeHGlobal(info.pixelPtr);
|
||||
}
|
||||
return pixelArray;
|
||||
}
|
||||
pixelArrayHandle = glHandle.Alloc(information.pixelPtr);
|
||||
}
|
||||
|
||||
public unsafe Image()
|
||||
{
|
||||
#if NET5_0_OR_GREATER
|
||||
Unsafe.SkipInit(out pixelArray);
|
||||
#endif
|
||||
info = new ImageInfo();
|
||||
}
|
||||
|
||||
@@ -67,8 +45,5 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
Marshal.FreeHGlobal(info.pixelPtr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user