daily update on 20240427 by nitload youmu

This commit is contained in:
YoumuLiu
2024-04-27 05:09:38 +08:00
parent dd6e8247bf
commit f83a130074
52 changed files with 1470 additions and 271 deletions
@@ -54,7 +54,7 @@ namespace StgSharp.Graphics
/// <summary>
/// Create a sets of <see cref="Texture"/>
/// </summary>
/// <param name="count">Amount of textures to be crated.</param>
/// <param name="count">Amount of textures to be created.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected Texture CreateTexture(int count)
@@ -65,7 +65,7 @@ namespace StgSharp.Graphics
/// <summary>
/// Create a set of <see cref="VertexArray"/>.
/// </summary>
/// <param name="count">Amount of VAO to be crated.</param>
/// <param name="count">Amount of VAO to be created.</param>
/// <returns></returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected VertexArray CreateVertexArray(int count)
@@ -74,7 +74,7 @@ namespace StgSharp.Graphics
}
/// <summary>
/// Create aset of <see cref="VertexBuffer"/>.
/// Create a set of <see cref="VertexBuffer"/>.
/// </summary>
/// <param name="count">Amount of Object to be created.</param>
/// <returns></returns>
@@ -84,5 +84,6 @@ namespace StgSharp.Graphics
return new VertexBuffer(count, this);
}
}
}
@@ -39,10 +39,14 @@ using System.Text;
namespace StgSharp.Graphics
{
public partial class Form
public partial class glRenderStream
{
protected glRenderStream(RenderStreamConstructArgs args) : base(args)
{
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected Shader CreateShader(ShaderType type, int count)
protected sealed override Shader CreateShaderSegment(ShaderType type, int count)
{
return new Shader( GL.CreateShaderSet(count, type), type);
}
@@ -51,7 +55,7 @@ namespace StgSharp.Graphics
/// </summary>
/// <returns>New instance of <see cref="Shader"/> instance. </returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected ShaderProgram CreateShaderProgram()
protected sealed override ShaderProgram CreateShaderProgram()
{
return new ShaderProgram(this);
}
@@ -126,9 +130,9 @@ namespace StgSharp.Graphics
/// <summary>
/// Init a program with no shader attached.
/// </summary>
internal unsafe ShaderProgram(Form binding)
internal unsafe ShaderProgram(glRenderStream binding)
{
this.binding = binding.graphicContextID;
this.binding = binding.ContextHandle;
handle = GL.CreateProgram();
}
@@ -62,9 +62,9 @@ namespace StgSharp.Graphics
}
internal unsafe Uniform(
ShaderProgram program, string name, Form binding)
ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.graphicContextID;
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
}
@@ -98,9 +98,9 @@ namespace StgSharp.Graphics
}
internal unsafe Uniform(
ShaderProgram program, string name, Form binding)
ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.graphicContextID;
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
}
@@ -141,9 +141,9 @@ namespace StgSharp.Graphics
id = GL.GetUniformLocation(program.handle, name);
}
public unsafe Uniform(ShaderProgram program, string name, Form binding)
public unsafe Uniform(ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.graphicContextID;
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
}
@@ -172,9 +172,9 @@ namespace StgSharp.Graphics
this.id = id;
}
internal unsafe Uniform(ShaderProgram program, string name, Form binding)
internal unsafe Uniform(ShaderProgram program, string name, glRenderStream binding)
{
this.binding = binding.graphicContextID;
this.binding = binding.ContextHandle;
id = GL.GetUniformLocation(program.handle, name);
}
+26 -26
View File
@@ -56,16 +56,16 @@ namespace StgSharp.Graphics
private static string glExtensionList;
/// <summary>
/// Load all aupportable OpenGL APIs and bind them to given <see cref="Form"/> context.
/// Load all supportted 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 to get address of OprnGL api</param>
public static unsafe void LoadGLapi(this Form form)
/// <param name="stream">The <see cref="Form"/> used as current OpenGL context</param>
/// <param name="loader">A delegate to get address of OpenGL api</param>
public static unsafe void LoadGLapi(this glRenderStream stream)
{
GLcontext* context = (GLcontext*)form.graphicContextID;
GLcontext* context = (GLcontext*)stream.ContextHandle;
GLfuncLoader loader = InternalIO.glfwGetProcAddress;
#pragma warning disable CS8909
if (((GLcontext*)form.graphicContextID)->glGetString != (delegate*<uint, IntPtr>)IntPtr.Zero)
if (((GLcontext*)stream.ContextHandle)->glGetString != (delegate*<uint, IntPtr>)IntPtr.Zero)
#pragma warning restore CS8909
{
return;
@@ -103,25 +103,25 @@ namespace StgSharp.Graphics
{
#region load_core_gl
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);
LoadGLcore10((GLcontext*)stream.ContextHandle, loader);
LoadGLcore11((GLcontext*)stream.ContextHandle, loader);
LoadGLcore12((GLcontext*)stream.ContextHandle, loader);
LoadGLcore13((GLcontext*)stream.ContextHandle, loader);
LoadGLcore14((GLcontext*)stream.ContextHandle, loader);
LoadGLcore15((GLcontext*)stream.ContextHandle, loader);
LoadGLcore20((GLcontext*)stream.ContextHandle, loader);
LoadGLcore21((GLcontext*)stream.ContextHandle, loader);
LoadGLcore30((GLcontext*)stream.ContextHandle, loader);
LoadGLcore31((GLcontext*)stream.ContextHandle, loader);
LoadGLcore32((GLcontext*)stream.ContextHandle, loader);
LoadGLcore33((GLcontext*)stream.ContextHandle, loader);
LoadGLcore40((GLcontext*)stream.ContextHandle, loader);
LoadGLcore41((GLcontext*)stream.ContextHandle, loader);
LoadGLcore42((GLcontext*)stream.ContextHandle, loader);
LoadGLcore43((GLcontext*)stream.ContextHandle, loader);
LoadGLcore44((GLcontext*)stream.ContextHandle, loader);
LoadGLcore45((GLcontext*)stream.ContextHandle, loader);
LoadGLcore46((GLcontext*)stream.ContextHandle, loader);
#endregion load_core_gl
}
@@ -779,7 +779,7 @@ namespace StgSharp.Graphics
/// Get the function pointer of given OpenGL api name
/// </summary>
/// <param name="name">Name of the OpenGL api</param>
/// <returns>The funtion pointer of the api in form of <see cref="IntPtr"/></returns>
/// <returns>The funtion pointer of the api in stream of <see cref="IntPtr"/></returns>
public static IntPtr LoadGLfunc(string name)
{
IntPtr ret = InternalIO.glfwGetProcAddress(name);
@@ -1,28 +1,47 @@
using System;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Graphics
{
public abstract partial class glRenderStream:RenderStream
public abstract partial class glRenderStream: RenderStream
{
protected sealed override void NativeCameraViewTarget(vec3d position, vec3d direction, vec3d up)
{
NativeCamera.SetViewDirection(position, direction, up);
}
protected sealed override Uniform<Matrix44> NativeCameraUniform(ShaderProgram source, string name)
{
NativeCamera.GainAllUniforms(source, name);
return NativeCamera.convertedUniform;
}
protected IntPtr glContextHandle
{
get { return ContextHandle; }
set { ContextHandle = value; }
}
internal sealed override void CreateCanvas((int width, int height, int depth) size, (int x_stretch, int y_stretch, int z_stretch) coordStrech, string name)
internal unsafe sealed override void CreateCanvas()
{
Width = size.width; Height = size.height;
Depth = size.depth;
_coordStretch = coordStrech;
Name = name;
byte[] nameCode = Encoding.UTF8.GetBytes(name);
CanvasHandle = InternalIO.glfwCreateWindow(
Width,Height,nameCode,Monitor,IntPtr.Zero
);
NativeCamera = new Camera();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected sealed override void NativeCameraViewRange(Radius fieldOfRange,vec2d offset, (float frontDepth, float backDepth) viewDepth)
{
NativeCamera.SetViewRange(fieldOfRange,this.Size, offset, viewDepth);
}
/// <summary>
@@ -40,11 +59,11 @@ namespace StgSharp.Graphics
byte[] tittleBytes = Encoding.UTF8.GetBytes(name);
if (SharedCanvas == IntPtr.Zero)
{
windowPtr = InternalIO.glfwCreateWindow(Width, Height, tittleBytes, monitor, IntPtr.Zero);
windowPtr = InternalIO.glfwCreateWindow(Width, Height, tittleBytes, Monitor, IntPtr.Zero);
}
else
{
windowPtr = InternalIO.glfwCreateWindow(Width, Height, tittleBytes, monitor, SharedCanvas.CanvasHandle);
windowPtr = InternalIO.glfwCreateWindow(Width, Height, tittleBytes, Monitor, SharedCanvas);
}
if (((long)windowPtr == -1) || ((long)windowPtr == -2))
{
@@ -64,8 +83,16 @@ namespace StgSharp.Graphics
InternalIO.glfwMakeContextCurrent(CanvasHandle);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public override void SetSizeLimit(int minWidth, int minHeight, int maxWidth, int maxHeight)
{
InternalIO.glfwSetWindowSizeLimits(this.CanvasHandle, minWidth, minHeight, maxWidth, maxHeight);
}
internal sealed override void InternalInit()
{
CreateCanvas();
MakeAsCurrentContext();
this.LoadGLapi();
Init();
}
@@ -80,5 +107,6 @@ namespace StgSharp.Graphics
{
Deinit();
}
}
}