daily update on 20240407 by nitload youmu

This commit is contained in:
YoumuLiu
2024-04-07 15:08:52 +08:00
parent 127fcdbfd3
commit e1e416bb41
141 changed files with 2578 additions and 2576 deletions
@@ -28,6 +28,7 @@
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphic;
using StgSharp.Math;
using System;
@@ -39,12 +40,22 @@ using System.Text;
namespace StgSharp.Graphics
{
public class Uniform<T> where T : struct
public class Uniform
{
private IntPtr binding;
protected IntPtr binding;
internal glSHandle id;
public glSHandle Handle
{
get => id;
}
}
public sealed class Uniform<T> : Uniform
where T : struct
{
internal unsafe Uniform(glSHandle id)
{
this.id = id;
@@ -56,6 +67,7 @@ namespace StgSharp.Graphics
this.binding = binding.graphicContextID;
id = GL.GetUniformLocation(program.handle, name);
}
internal unsafe Uniform(
ShaderProgram program, string name, IntPtr binding)
{
@@ -63,16 +75,23 @@ namespace StgSharp.Graphics
id = GL.GetUniformLocation(program.handle, name);
}
internal Uniform()
{
}
internal static Uniform<T> FromHandle(glSHandle handle)
{
return new Uniform<T>() { id = handle };
}
}
public class Uniform<T, U>
public sealed class Uniform<T, U>: Uniform
where T : struct
where U : struct
{
private IntPtr binding;
internal glSHandle id;
internal unsafe Uniform(glSHandle id)
{
this.id = id;
@@ -92,17 +111,24 @@ namespace StgSharp.Graphics
id = GL.GetUniformLocation(program.handle, name);
}
internal Uniform()
{
}
internal static Uniform<T,U> FromHandle(glSHandle handle)
{
return new Uniform<T, U>() { id = handle };
}
}
public class Uniform<T, U, V>
public sealed class Uniform<T, U, V>:Uniform
where T : struct
where U : struct
where V : struct
{
private IntPtr binding;
internal glSHandle id;
internal unsafe Uniform(glSHandle id)
{
this.id = id;
@@ -121,17 +147,25 @@ namespace StgSharp.Graphics
id = GL.GetUniformLocation(program.handle, name);
}
internal Uniform()
{
}
internal static Uniform<T,U,V> FromHandle(glSHandle handle)
{
return new Uniform<T, U, V>() { id = handle };
}
}
public class Uniform<T, U, V, W>
public sealed class Uniform<T, U, V, W>:Uniform
where T : struct
where U : struct
where V : struct
where W : struct
{
private IntPtr binding;
internal glSHandle id;
internal unsafe Uniform(glSHandle id)
{
@@ -151,51 +185,69 @@ namespace StgSharp.Graphics
id = GL.GetUniformLocation(program.handle, name);
}
internal Uniform()
{
}
internal static Uniform<T, U, V, W> FromHandle(glSHandle handle)
{
return new Uniform<T, U, V, W>() { id = handle };
}
}
internal static partial class GL
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static void SetValue(Uniform<float, float, float, float> uniform, Vec4d vec)
public unsafe static void SetValue(Uniform<Matrix44> uniform, Matrix44 mat)
{
api->glUniform1fv(uniform.id.DirectValue , 4, &vec);
Matrix44 temp = mat;
api->glUniformMatrix4fv(uniform.Handle.Value, 16, false, (float*)&mat);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static void SetValue(Uniform<Vec4d> uniform, Vec4d vec)
public unsafe static void SetValue(Uniform<float, float, float, float> uniform, vec4d vec)
{
api->glUniform1fv(uniform.id.DirectValue , 4, &vec);
vec4d temp = vec;
api->glUniform1fv(uniform.id.Value , 4, &temp);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe static void SetValue(Uniform<vec4d> uniform, vec4d vec)
{
vec4d temp = vec;
api->glUniform1fv(uniform.id.Value , 4, &temp);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float> uniform, float v0)
{
api->glUniform1f(uniform.id.DirectValue , v0);
api->glUniform1f(uniform.id.Value , v0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<int> uniform, int i0)
{
api->glUniform1i(uniform.id.DirectValue , i0);
api->glUniform1i(uniform.id.Value , i0);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float, float> uniform, float v0, float v1)
{
api->glUniform2f(uniform.id.DirectValue , v0, v1);
api->glUniform2f(uniform.id.Value , v0, v1);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float, float, float> uniform, float v0, float v1, float v2)
{
api->glUniform3f(uniform.id.DirectValue , v0, v1, v2);
api->glUniform3f(uniform.id.Value , v0, v1, v2);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe void SetValue(Uniform<float, float, float, float> uniform, float v0, float v1, float v2, float v3)
{
api->glUniform4f(uniform.id.DirectValue , v0, v1, v2, v3);
api->glUniform4f(uniform.id.Value , v0, v1, v2, v3);
}
}