daily update on 20240315 by nitload youmu
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public unsafe partial class Form
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -42,13 +42,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
void IglFunc.AlignFrame(Form form)
|
||||
{
|
||||
if (form.timer.alignSign.byte0 > 0)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
form.timer.alignSign.byte0++;
|
||||
form.timer.WaitNextFrame();
|
||||
throw refreshSIgnal;
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -337,11 +331,9 @@ namespace StgSharp.Graphics
|
||||
api->glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
void IglFunc.frameworkHandleEnqueue(System.IntPtr handle, params StgSharp.Math.M128[] param)
|
||||
void IglFunc.frameworkHandleEnqueue(System.IntPtr handle, params M128[] param)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
bool IglFunc.FrameCanUpdate => true;
|
||||
}
|
||||
}
|
||||
@@ -15,10 +15,10 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
internal unsafe partial class GLonUpdate : IglFunc
|
||||
{
|
||||
private static FrameOperationBuffer frameOpBuffer;
|
||||
private GLcontext* api;
|
||||
private IntPtr SwapBufferPtr = (IntPtr)(delegate*<IntPtr, void>)&InternalIO.glfwSwapBuffers;
|
||||
private glSHandle unupdatedFrame = glSHandle.Alloc(0);
|
||||
private FrameOperationBuffer frameOpBuffer;
|
||||
|
||||
internal GLonUpdate(GLcontext* context)
|
||||
{
|
||||
@@ -42,8 +42,8 @@ namespace StgSharp.Graphics
|
||||
|
||||
void IglFunc.ActiveTexture(uint type)
|
||||
{
|
||||
frameOpBuffer.Enqueue(type);
|
||||
frameOpBuffer.Enqueue(ActiveTexturePtr);
|
||||
frameOpBuffer.ParamEnqueue(type);
|
||||
frameOpBuffer.MethodEnqueue(ActiveTexturePtr);
|
||||
}
|
||||
|
||||
void IglFunc.AfterAlign(Form form, Action action)
|
||||
@@ -59,8 +59,8 @@ namespace StgSharp.Graphics
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
unsafe void IglFunc.AttachShader(glHandle program, glHandle shader)
|
||||
{
|
||||
frameOpBuffer.Enqueue(program, shader);
|
||||
frameOpBuffer.Enqueue(AttachShaderPtr);
|
||||
frameOpBuffer.ParamEnqueue(program, shader);
|
||||
frameOpBuffer.MethodEnqueue(AttachShaderPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -69,8 +69,8 @@ namespace StgSharp.Graphics
|
||||
M128 m = default;
|
||||
m.Write<uint>(0, (uint)bufferType);
|
||||
m.Write<ulong>(1, (ulong)handle.valuePtr);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(BindBufferPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(BindBufferPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -79,49 +79,49 @@ namespace StgSharp.Graphics
|
||||
M128 m = default;
|
||||
m.Write<uint>(0, (uint)type);
|
||||
m.Write<ulong>(1, (ulong)texture.valuePtr);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(BindTexturePtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(BindTexturePtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.BindVertexArray(glHandle index)
|
||||
{
|
||||
frameOpBuffer.Enqueue(index);
|
||||
frameOpBuffer.Enqueue(BindVertexArrayPtr);
|
||||
frameOpBuffer.ParamEnqueue(index);
|
||||
frameOpBuffer.MethodEnqueue(BindVertexArrayPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.Clear(MaskBufferBit mask)
|
||||
{
|
||||
frameOpBuffer.Enqueue((int)mask);
|
||||
frameOpBuffer.Enqueue(ClearPtr);
|
||||
frameOpBuffer.ParamEnqueue((int)mask);
|
||||
frameOpBuffer.MethodEnqueue(ClearPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.ClearColor(float R, float G, float B, float A)
|
||||
{
|
||||
frameOpBuffer.Enqueue(R, G, B, A);
|
||||
frameOpBuffer.Enqueue(ClearColorPtr);
|
||||
frameOpBuffer.ParamEnqueue(R, G, B, A);
|
||||
frameOpBuffer.MethodEnqueue(ClearColorPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
void IglFunc.ClearGraphicError()
|
||||
{
|
||||
frameOpBuffer.Enqueue(ClearGraphicErrorPtr);
|
||||
frameOpBuffer.MethodEnqueue(ClearGraphicErrorPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.CompileShader(glHandle shaderhandle)
|
||||
{
|
||||
frameOpBuffer.Enqueue((IntPtr)shaderhandle.valuePtr);
|
||||
frameOpBuffer.Enqueue(CompileShaderPtr);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)shaderhandle.valuePtr);
|
||||
frameOpBuffer.MethodEnqueue(CompileShaderPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
glHandle IglFunc.CreateProgram()
|
||||
{
|
||||
glHandle h = glHandle.Alloc(1);
|
||||
frameOpBuffer.Enqueue(h);
|
||||
frameOpBuffer.Enqueue(CreateProgramPtr);
|
||||
frameOpBuffer.ParamEnqueue(h);
|
||||
frameOpBuffer.MethodEnqueue(CreateProgramPtr);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -132,8 +132,8 @@ namespace StgSharp.Graphics
|
||||
glHandleSet h = new glHandleSet(count);
|
||||
m.Write<ulong>(0, (ulong)h.handle);
|
||||
m.Write<int>(2, count);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(CreateProgramSetPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(CreateProgramSetPtr);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ namespace StgSharp.Graphics
|
||||
m.Write<int>(0, count);
|
||||
m.Write<uint>(1, (uint)type);
|
||||
m.Write<ulong>(1, (ulong)ret.handle);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(CreateShaderPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(CreateShaderPtr);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -178,8 +178,8 @@ namespace StgSharp.Graphics
|
||||
glHandle IglFunc.CreatGraphicProgram()
|
||||
{
|
||||
glHandle h = glHandle.Alloc(1);
|
||||
frameOpBuffer.Enqueue(h);
|
||||
frameOpBuffer.Enqueue(CreateProgramPtr);
|
||||
frameOpBuffer.ParamEnqueue(h);
|
||||
frameOpBuffer.MethodEnqueue(CreateProgramPtr);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -189,8 +189,8 @@ namespace StgSharp.Graphics
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)handle.valuePtr);
|
||||
m.Write(2, 1);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(DeleBufferPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(DeleBufferPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.DeleteBuffers(glHandleSet handle)
|
||||
@@ -198,16 +198,16 @@ namespace StgSharp.Graphics
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)handle.handle);
|
||||
m.Write<uint>(2, (uint)handle.length);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(DeleBufferPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(DeleBufferPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.DeleteVertexArrays(glHandleSet arrays)
|
||||
{
|
||||
M128 m = default; m.Write<ulong>(1, (ulong)arrays.handle);
|
||||
m.Write<int>(0, arrays.length);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(DeleteVertexArrayPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(DeleteVertexArrayPtr);
|
||||
}
|
||||
|
||||
void IglFunc.DrawElements(GepmetryType mode, uint count, TypeCode type, IntPtr ptr)
|
||||
@@ -234,17 +234,17 @@ namespace StgSharp.Graphics
|
||||
LogType.Error);
|
||||
return;
|
||||
}
|
||||
frameOpBuffer.Enqueue((uint)mode, count, a);
|
||||
frameOpBuffer.Enqueue(ptr);
|
||||
frameOpBuffer.Enqueue(DrawElementsPtr);
|
||||
frameOpBuffer.ParamEnqueue((uint)mode, count, a);
|
||||
frameOpBuffer.ParamEnqueue(ptr);
|
||||
frameOpBuffer.MethodEnqueue(DrawElementsPtr);
|
||||
}
|
||||
|
||||
unsafe glHandleSet IglFunc.GenBuffers(int count)
|
||||
{
|
||||
glHandleSet h = new glHandleSet(count);
|
||||
M128 m = default; m.Write<uint>(2, (uint)count); m.Write<ulong>(0, (ulong)h.handle);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(GenBufferPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(GenBufferPtr);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -252,8 +252,8 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
glHandleSet h = new glHandleSet(count);
|
||||
M128 m = default; m.Write<uint>(2, (uint)count); m.Write<ulong>(0, (ulong)h.handle);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(GenTexturesPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(GenTexturesPtr);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -261,8 +261,8 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
glHandleSet h = new glHandleSet(count);
|
||||
M128 m = default; m.Write<uint>(2, (uint)count); m.Write<ulong>(0, (ulong)h.handle);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(GenTexturesPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(GenTexturesPtr);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -273,9 +273,9 @@ namespace StgSharp.Graphics
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)program.Handle);
|
||||
m.Write<ulong>(1, (ulong)GCHandle.Alloc(Encoding.UTF8.GetBytes(ptr), GCHandleType.Pinned).AddrOfPinnedObject());
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue((IntPtr)h.valuePtr);
|
||||
frameOpBuffer.Enqueue(GetUniformLocationPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)h.valuePtr);
|
||||
frameOpBuffer.MethodEnqueue(GetUniformLocationPtr);
|
||||
return h;
|
||||
}
|
||||
|
||||
@@ -296,9 +296,9 @@ namespace StgSharp.Graphics
|
||||
|
||||
void IglFunc.LoadShaderSource(glHandle shaderHandle, string codeStream)
|
||||
{
|
||||
frameOpBuffer.Enqueue(shaderHandle);
|
||||
frameOpBuffer.Enqueue(codeStream);
|
||||
frameOpBuffer.Enqueue(ShaderSourcePtr);
|
||||
frameOpBuffer.ParamEnqueue(shaderHandle);
|
||||
frameOpBuffer.ParamEnqueue(codeStream);
|
||||
frameOpBuffer.MethodEnqueue(ShaderSourcePtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -313,40 +313,38 @@ namespace StgSharp.Graphics
|
||||
|
||||
void IglFunc.SetBufferData<T>(BufferType bufferType, T bufferData, BufferUsage usage)
|
||||
{
|
||||
frameOpBuffer.Enqueue((uint)bufferType, (uint)usage);
|
||||
frameOpBuffer.Enqueue((IntPtr)sizeof(T));
|
||||
frameOpBuffer.Enqueue<T>(new T[] { bufferData });
|
||||
frameOpBuffer.Enqueue(BufferDataPtr);
|
||||
frameOpBuffer.ParamEnqueue((uint)bufferType, (uint)usage);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)sizeof(T));
|
||||
frameOpBuffer.ParamEnqueue<T>(new T[] { bufferData });
|
||||
frameOpBuffer.MethodEnqueue(BufferDataPtr);
|
||||
}
|
||||
|
||||
void IglFunc.SetBufferData<T>(BufferType bufferType, T[] bufferArray, BufferUsage usage)
|
||||
{
|
||||
frameOpBuffer.Enqueue((uint)bufferType, (uint)usage);
|
||||
frameOpBuffer.Enqueue((IntPtr)(Marshal.SizeOf<T>() * bufferArray.Length));
|
||||
frameOpBuffer.Enqueue<T>(bufferArray);
|
||||
frameOpBuffer.Enqueue(BufferDataPtr);
|
||||
frameOpBuffer.ParamEnqueue((uint)bufferType, (uint)usage);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)(Marshal.SizeOf<T>() * bufferArray.Length));
|
||||
frameOpBuffer.ParamEnqueue<T>(bufferArray);
|
||||
frameOpBuffer.MethodEnqueue(BufferDataPtr);
|
||||
}
|
||||
|
||||
void IglFunc.SetVertexAttribute(uint index, int size, TypeCode t, bool normalized, uint stride, int pointer)
|
||||
{
|
||||
uint type = InternalIO.GLtype[t];
|
||||
frameOpBuffer.Enqueue(index, type, stride);
|
||||
frameOpBuffer.Enqueue(size, normalized ? 1 : 0, pointer);
|
||||
frameOpBuffer.Enqueue(SetVertexArrayPtr);
|
||||
frameOpBuffer.ParamEnqueue(index, type, stride);
|
||||
frameOpBuffer.ParamEnqueue(size, normalized ? 1 : 0, pointer);
|
||||
frameOpBuffer.MethodEnqueue(SetVertexArrayPtr);
|
||||
}
|
||||
|
||||
//TODO:双线程,换运行环境
|
||||
void IglFunc.SwitchContext()
|
||||
{
|
||||
frameOpBuffer.context = api;
|
||||
}
|
||||
|
||||
unsafe void IglFunc.TextureImage2d<T>(int target, int level, uint internalformat, uint width, uint height, uint format, uint type, glHandle pixels)
|
||||
{
|
||||
frameOpBuffer.Enqueue(pixels);
|
||||
frameOpBuffer.Enqueue((uint)level, internalformat, width, height);
|
||||
frameOpBuffer.Enqueue((uint)target, format, type);
|
||||
frameOpBuffer.Enqueue(textureImage2dPtr);
|
||||
frameOpBuffer.ParamEnqueue(pixels);
|
||||
frameOpBuffer.ParamEnqueue((uint)level, internalformat, width, height);
|
||||
frameOpBuffer.ParamEnqueue((uint)target, format, type);
|
||||
frameOpBuffer.MethodEnqueue(textureImage2dPtr);
|
||||
}
|
||||
|
||||
void IglFunc.TextureParameter(int target, uint pname, int param)
|
||||
@@ -355,21 +353,21 @@ namespace StgSharp.Graphics
|
||||
m.Write<int>(0, target);
|
||||
m.Write<uint>(2, pname);
|
||||
m.Write<int>(3, param);
|
||||
frameOpBuffer.Enqueue(m);
|
||||
frameOpBuffer.Enqueue(TextureParameterPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(TextureParameterPtr);
|
||||
}
|
||||
|
||||
void IglFunc.UseProgram(glHandle program)
|
||||
{
|
||||
frameOpBuffer.Enqueue((IntPtr)program.valuePtr);
|
||||
frameOpBuffer.Enqueue(UseProgramPtr);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)program.valuePtr);
|
||||
frameOpBuffer.MethodEnqueue(UseProgramPtr);
|
||||
}
|
||||
|
||||
void IglFunc.Viewport(int x, int y, uint width, uint height)
|
||||
{
|
||||
Vec4d v = new Vec4d(x, y, (int)width, (int)height);
|
||||
frameOpBuffer.Enqueue(v);
|
||||
frameOpBuffer.Enqueue(ViewPortPtr);
|
||||
frameOpBuffer.ParamEnqueue(v);
|
||||
frameOpBuffer.MethodEnqueue(ViewPortPtr);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -377,27 +375,9 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
foreach (M128 item in param)
|
||||
{
|
||||
frameOpBuffer.Enqueue(item);
|
||||
}
|
||||
frameOpBuffer.Enqueue(methodHandle);
|
||||
}
|
||||
|
||||
bool IglFunc.FrameCanUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (unupdatedFrame.DirectValue > 5)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
*unupdatedFrame.valuePtr += 1;
|
||||
frameOpBuffer.Enqueue((IntPtr)unupdatedFrame.valuePtr);
|
||||
frameOpBuffer.Enqueue(CanUpdatePtr);
|
||||
return true;
|
||||
}
|
||||
frameOpBuffer.ParamEnqueue(item);
|
||||
}
|
||||
frameOpBuffer.ParamEnqueue(methodHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,253 +16,253 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
internal unsafe partial class GLonUpdate : IglFunc
|
||||
{
|
||||
private IntPtr ActiveTexturePtr = (IntPtr)(delegate*<void>)&InternalActiveTexture;
|
||||
private IntPtr AttachShaderPtr = (IntPtr)(delegate*<void>)&InternalAttachShader;
|
||||
private IntPtr BindBufferPtr = (IntPtr)(delegate*<void>)&InternalBindBuffer;
|
||||
private IntPtr BindTexturePtr = (IntPtr)(delegate*<void>)&InternalBindTexture;
|
||||
private IntPtr BindVertexArrayPtr = (IntPtr)(delegate*<void>)&InternalBindVertexArray;
|
||||
private IntPtr BufferDataPtr = (IntPtr)(delegate*<void>)&InternalSetBufferData;
|
||||
private IntPtr CanUpdatePtr = (IntPtr)(delegate*<void>)&InternalFrameCanUpdate;
|
||||
private IntPtr ClearColorPtr = (IntPtr)(delegate*<void>)&InternalClearColor;
|
||||
private IntPtr ClearGraphicErrorPtr = (IntPtr)(delegate*<void>)&InternalClearGraphicError;
|
||||
private IntPtr ClearPtr = (IntPtr)(delegate*<void>)&InternalClear;
|
||||
private IntPtr CompileShaderPtr = (IntPtr)(delegate*<void>)&InternalCompileShader;
|
||||
private IntPtr CreateProgramPtr = (IntPtr)(delegate*<void>)&InternalCreateProgram;
|
||||
private IntPtr CreateProgramSetPtr = (IntPtr)(delegate*<void>)&InternalCreateProgramSet;
|
||||
private IntPtr CreateShaderPtr = (IntPtr)(delegate*<void>)&InternalCreateShader;
|
||||
private IntPtr DeleBufferPtr = (IntPtr)(delegate*<void>)&InternalDeleteBuffer;
|
||||
private IntPtr DeleteVertexArrayPtr = (IntPtr)(delegate*<void>)&InternalDeleteVertexArrays;
|
||||
private IntPtr DrawElementsPtr = (IntPtr)(delegate*<void>)&InternalDrawElements;
|
||||
private IntPtr GenBufferPtr = (IntPtr)(delegate*<void>)&InternalGenBuffers;
|
||||
private IntPtr GenTexturesPtr = (IntPtr)(delegate*<void>)&InternalGenTextures;
|
||||
private IntPtr GenVertexArraysPtr = (IntPtr)(delegate*<void>)&InternalGenVertexArrays;
|
||||
private IntPtr GetUniformLocationPtr = (IntPtr)(delegate*<void>)&InternalGetUniformLocation;
|
||||
private IntPtr SetVertexArrayPtr = (IntPtr)(delegate*<void>)&InternalSetVertexAttribute;
|
||||
private IntPtr ShaderSourcePtr = (IntPtr)(delegate*<void>)&InternalShaderSource;
|
||||
private IntPtr textureImage2dPtr = (IntPtr)(delegate*<void>)&InternalTextureImage2d;
|
||||
private IntPtr TextureParameterPtr = (IntPtr)(delegate*<void>)&InternalTextureParameter;
|
||||
private IntPtr UseProgramPtr = (IntPtr)(delegate*<void>)&InternalUseProgram;
|
||||
private IntPtr ViewPortPtr = (IntPtr)(delegate*<void>)&InternalViewport;
|
||||
private IntPtr ActiveTexturePtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalActiveTexture;
|
||||
private IntPtr AttachShaderPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalAttachShader;
|
||||
private IntPtr BindBufferPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalBindBuffer;
|
||||
private IntPtr BindTexturePtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalBindTexture;
|
||||
private IntPtr BindVertexArrayPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalBindVertexArray;
|
||||
private IntPtr BufferDataPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalSetBufferData;
|
||||
private IntPtr CanUpdatePtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalFrameCanUpdate;
|
||||
private IntPtr ClearColorPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalClearColor;
|
||||
private IntPtr ClearGraphicErrorPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalClearGraphicError;
|
||||
private IntPtr ClearPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalClear;
|
||||
private IntPtr CompileShaderPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalCompileShader;
|
||||
private IntPtr CreateProgramPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalCreateProgram;
|
||||
private IntPtr CreateProgramSetPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalCreateProgramSet;
|
||||
private IntPtr CreateShaderPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalCreateShader;
|
||||
private IntPtr DeleBufferPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalDeleteBuffer;
|
||||
private IntPtr DeleteVertexArrayPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalDeleteVertexArrays;
|
||||
private IntPtr DrawElementsPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalDrawElements;
|
||||
private IntPtr GenBufferPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalGenBuffers;
|
||||
private IntPtr GenTexturesPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalGenTextures;
|
||||
private IntPtr GenVertexArraysPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalGenVertexArrays;
|
||||
private IntPtr GetUniformLocationPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalGetUniformLocation;
|
||||
private IntPtr SetVertexArrayPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalSetVertexAttribute;
|
||||
private IntPtr ShaderSourcePtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalShaderSource;
|
||||
private IntPtr textureImage2dPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalTextureImage2d;
|
||||
private IntPtr TextureParameterPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalTextureParameter;
|
||||
private IntPtr UseProgramPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalUseProgram;
|
||||
private IntPtr ViewPortPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&InternalViewport;
|
||||
|
||||
private static void InternalActiveTexture()
|
||||
private static void InternalActiveTexture(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
uint t;
|
||||
paramQueue.TryDequeue(out t);
|
||||
paramQueue.context->glActiveTexture(t);
|
||||
frameBuffer.TryDequeue(out t);
|
||||
activatedContext->glActiveTexture(t);
|
||||
}
|
||||
|
||||
private static void InternalAttachShader()
|
||||
private static void InternalAttachShader(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
uint p, s;
|
||||
paramQueue.TryDequeue(out p, out s);
|
||||
paramQueue.context->glAttachShader(p, s);
|
||||
frameBuffer.TryDequeue(out p, out s);
|
||||
activatedContext->glAttachShader(p, s);
|
||||
}
|
||||
|
||||
private static void InternalBindBuffer()
|
||||
private static void InternalBindBuffer(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = new M128();
|
||||
paramQueue.TryDequeue(out m);
|
||||
frameBuffer.TryDequeue(out m);
|
||||
uint usage = m.Read<uint>(0);
|
||||
uint handle = *(uint*)m.Read<ulong>(1);
|
||||
paramQueue.context->glBindBuffer(usage, handle);
|
||||
activatedContext->glBindBuffer(usage, handle);
|
||||
}
|
||||
|
||||
private static void InternalBindTexture()
|
||||
private static void InternalBindTexture(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glBindTexture(
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glBindTexture(
|
||||
m.Read<uint>(0),
|
||||
*(uint*)m.Read<ulong>(1)
|
||||
);
|
||||
}
|
||||
|
||||
private static void InternalBindVertexArray()
|
||||
private static void InternalBindVertexArray(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr i;
|
||||
paramQueue.TryDequeue(out i);
|
||||
paramQueue.context->glBindVertexArray(*(uint*)i);
|
||||
frameBuffer.TryDequeue(out i);
|
||||
activatedContext->glBindVertexArray(*(uint*)i);
|
||||
}
|
||||
|
||||
private static void InternalClear()
|
||||
private static void InternalClear(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
uint mt;
|
||||
paramQueue.TryDequeue(out mt);
|
||||
paramQueue.context->glClear(mt);
|
||||
frameBuffer.TryDequeue(out mt);
|
||||
activatedContext->glClear(mt);
|
||||
}
|
||||
|
||||
private static void InternalClearColor()
|
||||
private static void InternalClearColor(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
float r, g, b, a;
|
||||
paramQueue.TryDequeue(out r, out g, out b, out a);
|
||||
paramQueue.context->glClearColor(r, g, b, a);
|
||||
frameBuffer.TryDequeue(out r, out g, out b, out a);
|
||||
activatedContext->glClearColor(r, g, b, a);
|
||||
}
|
||||
|
||||
private static void InternalClearGraphicError()
|
||||
private static void InternalClearGraphicError(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
while (paramQueue.context->glGetError() != 0) { }
|
||||
while (activatedContext->glGetError() != 0) { }
|
||||
}
|
||||
|
||||
private static unsafe void InternalCompileShader()
|
||||
private static unsafe void InternalCompileShader(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = default;
|
||||
paramQueue.TryDequeue(out handle);
|
||||
paramQueue.context->glCompileShader(*(uint*)handle);
|
||||
frameBuffer.TryDequeue(out handle);
|
||||
activatedContext->glCompileShader(*(uint*)handle);
|
||||
}
|
||||
|
||||
private static void InternalCreateProgram()
|
||||
private static void InternalCreateProgram(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr programHandle = default;
|
||||
paramQueue.TryDequeue(out programHandle);
|
||||
*(uint*)programHandle = paramQueue.context->glCreateProgram();
|
||||
frameBuffer.TryDequeue(out programHandle);
|
||||
*(uint*)programHandle = activatedContext->glCreateProgram();
|
||||
}
|
||||
|
||||
private static void InternalCreateProgramSet()
|
||||
private static void InternalCreateProgramSet(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
uint* programHandle;
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
frameBuffer.TryDequeue(out m);
|
||||
programHandle = (uint*)m.Read<ulong>(0);
|
||||
for (int i = 0; i < m.Read<int>(2); i++)
|
||||
{
|
||||
*(programHandle + i) = paramQueue.context->glCreateProgram();
|
||||
*(programHandle + i) = activatedContext->glCreateProgram();
|
||||
}
|
||||
}
|
||||
|
||||
private static unsafe void InternalCreateShader()
|
||||
private static unsafe void InternalCreateShader(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
frameBuffer.TryDequeue(out m);
|
||||
int count = m.Read<int>(0); uint type = m.Read<uint>(1); uint* handle = (uint*)m.Read<ulong>(1);
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
*(handle + i) = paramQueue.context->glCreateShader(type);
|
||||
*(handle + i) = activatedContext->glCreateShader(type);
|
||||
}
|
||||
}
|
||||
|
||||
private static void InternalDeleteBuffer()
|
||||
private static void InternalDeleteBuffer(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glDeleteBuffers(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glDeleteBuffers(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
for (int i = 0; i < m.Read<uint>(2); i++)
|
||||
{
|
||||
*((uint*)m.Read<ulong>(0) + i) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static void InternalDeleteVertexArrays()
|
||||
private static void InternalDeleteVertexArrays(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glDeleteVertexArrays((uint)m.Read<int>(0), (uint*)m.Read<ulong>(0));
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glDeleteVertexArrays((uint)m.Read<int>(0), (uint*)m.Read<ulong>(0));
|
||||
}
|
||||
|
||||
private static void InternalDrawElements()
|
||||
private static void InternalDrawElements(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
uint mode, count, type;
|
||||
IntPtr ptr;
|
||||
paramQueue.TryDequeue(out mode, out count, out type);
|
||||
paramQueue.TryDequeue(out ptr);
|
||||
paramQueue.context->glDrawElements(mode, count, type, (void*)ptr);
|
||||
frameBuffer.TryDequeue(out mode, out count, out type);
|
||||
frameBuffer.TryDequeue(out ptr);
|
||||
activatedContext->glDrawElements(mode, count, type, (void*)ptr);
|
||||
}
|
||||
|
||||
private static void InternalFrameCanUpdate()
|
||||
private static void InternalFrameCanUpdate(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr ptr;
|
||||
paramQueue.TryDequeue(out ptr);
|
||||
frameBuffer.TryDequeue(out ptr);
|
||||
Interlocked.Add(ref *(int*)ptr, -1);
|
||||
}
|
||||
|
||||
private static void InternalGenBuffers()
|
||||
private static void InternalGenBuffers(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glGenBuffers(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glGenBuffers(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
}
|
||||
|
||||
private static void InternalGenTextures()
|
||||
private static void InternalGenTextures(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glGenTextures(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glGenTextures(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
}
|
||||
|
||||
private static void InternalGenVertexArrays()
|
||||
private static void InternalGenVertexArrays(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glGenVertexArrays(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glGenVertexArrays(m.Read<uint>(2), (uint*)m.Read<ulong>(0));
|
||||
}
|
||||
|
||||
private static void InternalGetUniformLocation()
|
||||
private static void InternalGetUniformLocation(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr programHandle = default, nameHandle = default, targetHandle = default;
|
||||
paramQueue.TryDequeue(out programHandle, out nameHandle);
|
||||
paramQueue.TryDequeue(out targetHandle);
|
||||
*(int*)targetHandle = paramQueue.context->glGetUniformLocation(*(uint*)programHandle, (byte*)nameHandle);
|
||||
frameBuffer.TryDequeue(out programHandle, out nameHandle);
|
||||
frameBuffer.TryDequeue(out targetHandle);
|
||||
*(int*)targetHandle = activatedContext->glGetUniformLocation(*(uint*)programHandle, (byte*)nameHandle);
|
||||
}
|
||||
|
||||
private static void InternalSetBufferData()
|
||||
private static void InternalSetBufferData(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
uint type = 0, use = 0;
|
||||
IntPtr size = default;
|
||||
glArrayHandle array = default;
|
||||
paramQueue.TryDequeue(out type, out use);
|
||||
paramQueue.TryDequeue(out size);
|
||||
paramQueue.TryDequeue(out array);
|
||||
paramQueue.context->glBufferData(type, size, array.AddressOfArray(), use);
|
||||
frameBuffer.TryDequeue(out type, out use);
|
||||
frameBuffer.TryDequeue(out size);
|
||||
frameBuffer.TryDequeue(out array);
|
||||
activatedContext->glBufferData(type, size, array.AddressOfArray(), use);
|
||||
}
|
||||
|
||||
private static void InternalSetVertexAttribute()
|
||||
private static void InternalSetVertexAttribute(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
uint index, type, stride;
|
||||
int size, normalized, pointer;
|
||||
paramQueue.TryDequeue(out index, out type, out stride);
|
||||
paramQueue.TryDequeue(out size, out normalized, out pointer);
|
||||
paramQueue.context->glVertexAttribPointer(index, size, type, normalized, stride, (void*)pointer);
|
||||
paramQueue.context->glEnableVertexAttribArray(index);
|
||||
frameBuffer.TryDequeue(out index, out type, out stride);
|
||||
frameBuffer.TryDequeue(out size, out normalized, out pointer);
|
||||
activatedContext->glVertexAttribPointer(index, size, type, normalized, stride, (void*)pointer);
|
||||
activatedContext->glEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
private static unsafe void InternalShaderSource()
|
||||
private static unsafe void InternalShaderSource(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = default;
|
||||
glArrayHandle stream = default;
|
||||
paramQueue.TryDequeue(out handle);
|
||||
paramQueue.TryDequeue(out stream);
|
||||
frameBuffer.TryDequeue(out handle);
|
||||
frameBuffer.TryDequeue(out stream);
|
||||
IntPtr buffer = stream.AddressOfArray();
|
||||
paramQueue.context->glShaderSource(*(uint*)handle, 1, (byte**)&buffer, (void*)0);
|
||||
activatedContext->glShaderSource(*(uint*)handle, 1, (byte**)&buffer, (void*)0);
|
||||
}
|
||||
|
||||
private static void InternalTextureImage2d()
|
||||
private static void InternalTextureImage2d(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr pix = IntPtr.Zero;
|
||||
uint target, level, internalFormat, width, height, format, type;
|
||||
paramQueue.TryDequeue(out pix);
|
||||
paramQueue.TryDequeue(out level, out internalFormat, out width, out height);
|
||||
paramQueue.TryDequeue(out target, out format, out type);
|
||||
paramQueue.context->glTexImage2D(target, (int)level, internalFormat, width, height, 0, format, type, (void*)pix);
|
||||
frameBuffer.TryDequeue(out pix);
|
||||
frameBuffer.TryDequeue(out level, out internalFormat, out width, out height);
|
||||
frameBuffer.TryDequeue(out target, out format, out type);
|
||||
activatedContext->glTexImage2D(target, (int)level, internalFormat, width, height, 0, format, type, (void*)pix);
|
||||
}
|
||||
|
||||
private static void InternalTextureParameter()
|
||||
private static void InternalTextureParameter(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glTextureParameteri(m.Read<uint>(0), m.Read<uint>(2), m.Read<int>(3));
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glTextureParameteri(m.Read<uint>(0), m.Read<uint>(2), m.Read<int>(3));
|
||||
}
|
||||
|
||||
private static void InternalUseProgram()
|
||||
private static void InternalUseProgram(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
paramQueue.TryDequeue(out handle);
|
||||
paramQueue.context->glUseProgram(*(uint*)handle);
|
||||
frameBuffer.TryDequeue(out handle);
|
||||
activatedContext->glUseProgram(*(uint*)handle);
|
||||
}
|
||||
|
||||
private static void InternalViewport()
|
||||
private static void InternalViewport(FrameOperationBuffer frameBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glViewport(m.Read<int>(0), m.Read<int>(1), m.Read<uint>(2), m.Read<uint>(3));
|
||||
frameBuffer.TryDequeue(out m);
|
||||
activatedContext->glViewport(m.Read<int>(0), m.Read<int>(1), m.Read<uint>(2), m.Read<uint>(3));
|
||||
}
|
||||
|
||||
private void InternalMakeContexCurrent(Form form)
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace StgSharp.Graphics
|
||||
return new ElementBuffer(count, this.gl);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create a set of <see cref="VertexArray"/>.
|
||||
/// </summary>
|
||||
@@ -53,6 +52,5 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
return new VertexBuffer(count, gl);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,20 +36,23 @@ namespace StgSharp.Graphics.GL.ShaderEdit
|
||||
{
|
||||
if (inputParams.Length != function.ParameterCount)
|
||||
{
|
||||
// Param list length not equal
|
||||
throw new ArgumentException("Provided parameters does not match function's parameter list.");
|
||||
}
|
||||
if (!ShaderParameter.IsSameType(outPut, function.outPut))
|
||||
{
|
||||
// Type of returning value not qual
|
||||
throw new Exception("Provided parameters does not match function's parameter list.");
|
||||
}
|
||||
for (int i = 0; i < inputParams.Length; i++)
|
||||
{
|
||||
if (!ShaderParameter.IsSameType(function.inputList[i], inputParams[i]))
|
||||
{
|
||||
// Input type not match
|
||||
throw new Exception("Provided parameters does not match function's parameter list.");
|
||||
}
|
||||
}
|
||||
string codeLine = "";
|
||||
string codeLine = ""; // adding a line like " outvalue = Func(input1, input2,...); "
|
||||
if (outPut != ShaderParameter.Void)
|
||||
{
|
||||
codeLine += $"{outPut.name} = ";
|
||||
|
||||
@@ -135,18 +135,18 @@ namespace StgSharp.Graphics
|
||||
|
||||
internal unsafe partial class GLonUpdate
|
||||
{
|
||||
private IntPtr UniformVal1fPtr = (IntPtr)(delegate*<void>)&UniformVal1f;
|
||||
private IntPtr UniformVal1fvPtr = (IntPtr)(delegate*<void>)&UniformVal1fv;
|
||||
private IntPtr UniformVal1iPtr = (IntPtr)(delegate*<void>)&UniformVal1i;
|
||||
private IntPtr UniformVal2fPtr = (IntPtr)(delegate*<void>)&UniformVal2f;
|
||||
private IntPtr UniformVal3fPtr = (IntPtr)(delegate*<void>)&UniformVal3f;
|
||||
private IntPtr UniformVal4fPtr = (IntPtr)(delegate*<void>)&UniformVal4f;
|
||||
private IntPtr UniformVal1fPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal1f;
|
||||
private IntPtr UniformVal1fvPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal1fv;
|
||||
private IntPtr UniformVal1iPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal1i;
|
||||
private IntPtr UniformVal2fPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal2f;
|
||||
private IntPtr UniformVal3fPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal3f;
|
||||
private IntPtr UniformVal4fPtr = (IntPtr)(delegate*<FrameOperationBuffer, GLcontext*, void>)&UniformVal4f;
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<float, float, float> uniform, float f0, float f1, float f2)
|
||||
{
|
||||
paramQueue.Enqueue((IntPtr)uniform.id.valuePtr);
|
||||
paramQueue.Enqueue(f0, f1, f2);
|
||||
glActionQueue.Enqueue(UniformVal3fPtr);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)uniform.id.valuePtr);
|
||||
frameOpBuffer.ParamEnqueue(f0, f1, f2);
|
||||
frameOpBuffer.MethodEnqueue(UniformVal3fPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<float, float> uniform, float f0, float f1)
|
||||
@@ -155,22 +155,22 @@ namespace StgSharp.Graphics
|
||||
m.Write<ulong>(0, (ulong)uniform.id.valuePtr);
|
||||
m.Write<float>(2, f0);
|
||||
m.Write<float>(3, f1);
|
||||
paramQueue.Enqueue(m);
|
||||
glActionQueue.Enqueue(UniformVal2fPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(UniformVal2fPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<float, float, float, float> uniform, float f0, float f1, float f2, float f3)
|
||||
{
|
||||
paramQueue.Enqueue((IntPtr)uniform.id.valuePtr);
|
||||
paramQueue.Enqueue(f0, f1, f2, f3);
|
||||
glActionQueue.Enqueue(UniformVal4fPtr);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)uniform.id.valuePtr);
|
||||
frameOpBuffer.ParamEnqueue(f0, f1, f2, f3);
|
||||
frameOpBuffer.MethodEnqueue(UniformVal4fPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<float, float, float, float> uniform, Vec4d vec)
|
||||
{
|
||||
Vec4d m = vec;
|
||||
paramQueue.Enqueue((IntPtr)uniform.id.valuePtr, (IntPtr)(Vec4d*)&m);
|
||||
glActionQueue.Enqueue(UniformVal1fvPtr);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)uniform.id.valuePtr);
|
||||
frameOpBuffer.ParamEnqueue(vec);
|
||||
frameOpBuffer.MethodEnqueue(UniformVal1fvPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<float> uniform, float f0)
|
||||
@@ -178,8 +178,8 @@ namespace StgSharp.Graphics
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)uniform.id.valuePtr);
|
||||
m.Write<float>(2, f0);
|
||||
paramQueue.Enqueue(m);
|
||||
glActionQueue.Enqueue(UniformVal1fPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(UniformVal1fPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<int> uniform, int i0)
|
||||
@@ -187,61 +187,62 @@ namespace StgSharp.Graphics
|
||||
M128 m = default;
|
||||
m.Write<ulong>(0, (ulong)uniform.id.valuePtr);
|
||||
m.Write<int>(2, i0);
|
||||
paramQueue.Enqueue(m);
|
||||
glActionQueue.Enqueue(UniformVal1fPtr);
|
||||
frameOpBuffer.ParamEnqueue(m);
|
||||
frameOpBuffer.MethodEnqueue(UniformVal1fPtr);
|
||||
}
|
||||
|
||||
unsafe void IglFunc.SetValue(Uniform<Vec4d> uniform, Vec4d vec)
|
||||
{
|
||||
Vec4d m = vec;
|
||||
paramQueue.Enqueue((IntPtr)uniform.id.valuePtr, (IntPtr)(Vec4d*)&m);
|
||||
glActionQueue.Enqueue(UniformVal1fvPtr);
|
||||
frameOpBuffer.ParamEnqueue((IntPtr)uniform.id.valuePtr, (IntPtr)(Vec4d*)&m);
|
||||
frameOpBuffer.MethodEnqueue(UniformVal1fvPtr);
|
||||
}
|
||||
|
||||
private static void UniformVal1f()
|
||||
private static void UniformVal1f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glUniform1f(*(int*)m.Read<ulong>(0), m.Read<uint>(2));
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform1f(*(int*)m.Read<ulong>(0), m.Read<uint>(2));
|
||||
}
|
||||
|
||||
private static unsafe void UniformVal1fv()
|
||||
private static unsafe void UniformVal1fv(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default, v = default;
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
frameOpBuffer.TryDequeue(out v);
|
||||
activatedContext->glUniform1fv(*(int*)m.Read<ulong>(0), 4, (Vec4d*)&v);
|
||||
}
|
||||
|
||||
private static void UniformVal1i(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glUniform1fv(*(int*)m.Read<ulong>(0), 4, (Vec4d*)&m.vec);
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform1i(*(int*)m.Read<ulong>(0), m.Read<int>(2));
|
||||
}
|
||||
|
||||
private static void UniformVal1i()
|
||||
private static void UniformVal2f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glUniform1i(*(int*)m.Read<ulong>(0), m.Read<int>(2));
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform2f(*(int*)m.Read<ulong>(0), m.Read<float>(2), m.Read<float>(3));
|
||||
}
|
||||
|
||||
private static void UniformVal2f()
|
||||
{
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glUniform2f(*(int*)m.Read<ulong>(0), m.Read<float>(2), m.Read<float>(3));
|
||||
}
|
||||
|
||||
private static void UniformVal3f()
|
||||
private static void UniformVal3f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out handle);
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glUniform3f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2));
|
||||
frameOpBuffer.TryDequeue(out handle);
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform3f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2));
|
||||
}
|
||||
|
||||
private static void UniformVal4f()
|
||||
private static void UniformVal4f(FrameOperationBuffer frameOpBuffer, GLcontext* activatedContext)
|
||||
{
|
||||
IntPtr handle = IntPtr.Zero;
|
||||
M128 m = default;
|
||||
paramQueue.TryDequeue(out handle);
|
||||
paramQueue.TryDequeue(out m);
|
||||
paramQueue.context->glUniform4f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2), m.Read<float>(3));
|
||||
frameOpBuffer.TryDequeue(out handle);
|
||||
frameOpBuffer.TryDequeue(out m);
|
||||
activatedContext->glUniform4f(*(int*)handle, m.Read<float>(0), m.Read<float>(1), m.Read<float>(2), m.Read<float>(3));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,13 +31,13 @@ namespace StgSharp.Graphics
|
||||
/// <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;
|
||||
GLcontext* context = (GLcontext*)form.graphicContextID;
|
||||
if (loader == null)
|
||||
{
|
||||
loader = InternalIO.glfwGetProcAddress;
|
||||
}
|
||||
#pragma warning disable CS8909
|
||||
if ((form.contextID->glGetString) != (delegate*<uint, IntPtr>)IntPtr.Zero)
|
||||
if (((GLcontext*)form.graphicContextID)->glGetString != (delegate*<uint, IntPtr>)IntPtr.Zero)
|
||||
#pragma warning restore CS8909
|
||||
{
|
||||
return;
|
||||
@@ -75,25 +75,25 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
#region load_core_gl
|
||||
|
||||
LoadGLcore10(form.contextID, loader);
|
||||
LoadGLcore11(form.contextID, loader);
|
||||
LoadGLcore12(form.contextID, loader);
|
||||
LoadGLcore13(form.contextID, loader);
|
||||
LoadGLcore14(form.contextID, loader);
|
||||
LoadGLcore15(form.contextID, loader);
|
||||
LoadGLcore20(form.contextID, loader);
|
||||
LoadGLcore21(form.contextID, loader);
|
||||
LoadGLcore30(form.contextID, loader);
|
||||
LoadGLcore31(form.contextID, loader);
|
||||
LoadGLcore32(form.contextID, loader);
|
||||
LoadGLcore33(form.contextID, loader);
|
||||
LoadGLcore40(form.contextID, loader);
|
||||
LoadGLcore41(form.contextID, loader);
|
||||
LoadGLcore42(form.contextID, loader);
|
||||
LoadGLcore43(form.contextID, loader);
|
||||
LoadGLcore44(form.contextID, loader);
|
||||
LoadGLcore45(form.contextID, loader);
|
||||
LoadGLcore46(form.contextID, loader);
|
||||
LoadGLcore10((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore11((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore12((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore13((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore14((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore15((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore20((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore21((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore30((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore31((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore32((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore33((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore40((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore41((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore42((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore43((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore44((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore45((GLcontext*)form.graphicContextID, loader);
|
||||
LoadGLcore46((GLcontext*)form.graphicContextID, loader);
|
||||
|
||||
#endregion load_core_gl
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user