daily uodate on 20240626 by nitload youmu

This commit is contained in:
Nitload
2024-06-26 07:33:12 +08:00
parent b2cb0cbddf
commit 8f9f1c4012
44 changed files with 722 additions and 383 deletions
@@ -48,13 +48,15 @@ namespace StgSharp.Graphics
public unsafe delegate void FrameBufferSizeHandler(IntPtr window, uint width, uint height);
public unsafe delegate void FramePositionHandler(IntPtr window, float width, float height);
#endregion
/// <summary>
/// Function handler to load an opengl function by searching its name.
/// </summary>
/// <param name="name">the name of the Opengl function</param>
/// <returns>An intptr value representing the pointer to the function</returns>
/// <returns>An Intptr value representing the pointer to the function</returns>
public delegate IntPtr glLoader(string name);
#region glDEBUG
@@ -103,7 +103,6 @@ namespace StgSharp.Graphics
internal unsafe delegate void GLFWkeyfun(glfwWindow* window, int key, int scancode, int action, int mods);
internal unsafe delegate void GLFWjoystickfun(int jid, int keyevent);
public unsafe delegate void GLFWglproc();
internal unsafe delegate void FramebuffersizeHandler(IntPtr window, int width, int height); //window is the pointer to a glfwWindow instance
internal unsafe delegate void GLFWerrorfun(int error_code, sbyte* description);
internal unsafe delegate void GLFWdropfun(glfwWindow* window, int path_count, sbyte*[] paths);
internal unsafe delegate void GLFWcursorposfun(glfwWindow* window, double xpos, double ypos);
@@ -120,15 +120,6 @@ namespace StgSharp.Graphics.GL
NativeCamera.SetViewDirection(position, direction, up);
}
protected static void PollEvents()
{
InternalIO.glfwPollEvents();
}
protected void SwapBuffers()
{
InternalIO.glfwSwapBuffers(CanvasHandle);
}
#region Key Control
+9 -9
View File
@@ -84,15 +84,6 @@ namespace StgSharp.Graphics
public string[] OutputInterfacesName => OutputPortsName;
public FrameBufferSizeHandler FrameSizeCallback
{
set
{
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(value);
InternalIO.glfwSetFramebufferSizeCallback(CanvasHandle, handlerPtr);
}
}
public int Height
{
get => primeArgs.Height;
@@ -186,6 +177,15 @@ namespace StgSharp.Graphics
InternalDraw(in input, in output);
}
internal protected static void PollEvents()
{
InternalIO.glfwPollEvents();
}
internal protected void SwapBuffers()
{
InternalIO.glfwSwapBuffers(CanvasHandle);
}
#region native camera operation
protected abstract void NativeCameraViewRange(Radius fieldOfRange, vec2d offset, (float frontDepth, float backDepth) viewDepth);
+23 -1
View File
@@ -34,6 +34,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
@@ -42,7 +43,9 @@ namespace StgSharp.Graphics
public class ViewPort
{
private int _width, _height;
private FrameBufferSizeHandler _sizeHandler;
private FramePositionHandler _positionHandler;
internal ViewPort()
{
_height = 800;
@@ -119,5 +122,24 @@ namespace StgSharp.Graphics
}
}
public FrameBufferSizeHandler FrameSizeCallback
{
set
{
_sizeHandler = value;
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(_sizeHandler);
InternalIO.glfwSetFramebufferSizeCallback(ViewPortID, handlerPtr);
}
}
public FramePositionHandler FramePostionCallback
{
set
{
_positionHandler = value;
IntPtr handlerPtr = Marshal.GetFunctionPointerForDelegate(_positionHandler);
InternalIO.glfwSetWindowPosCallback(ViewPortID,handlerPtr);
}
}
}
}
+2 -2
View File
@@ -157,7 +157,7 @@ namespace StgSharp
[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 = "glfwSetWindowPosCallback")] internal static extern unsafe GLFWwindowposfun glfwSetWindowPosCallback(IntPtr window, IntPtr callback);
[DllImport(SSC_libName, EntryPoint = "glfwSetWindowSizeCallback")] internal static extern unsafe GLFWwindowsizefun glfwSetWindowSizeCallback(IntPtr window, GLFWwindowsizefun callback);
@@ -171,7 +171,7 @@ namespace StgSharp
[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 = "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);