daily update on 20240528 by nitload youmu
This commit is contained in:
@@ -39,14 +39,18 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
namespace StgSharp.Graphics.GL
|
||||
{
|
||||
|
||||
public abstract partial class glRenderStream : RenderStream
|
||||
{
|
||||
|
||||
protected glRenderStream(RenderStreamConstructArgs args) : base(args)
|
||||
{
|
||||
}
|
||||
protected glRenderStream(RenderStreamConstructArgs args,bool isSharing) : base(args,isSharing)
|
||||
{
|
||||
}
|
||||
|
||||
protected IntPtr glContextHandle
|
||||
{
|
||||
@@ -54,19 +58,6 @@ namespace StgSharp.Graphics
|
||||
set { ContextHandle = value; }
|
||||
}
|
||||
|
||||
public static T AsMainStreamOf<T>(Form f, (int x, int y, int z) unitCubeSize) where T : glRenderStream
|
||||
{
|
||||
RenderStreamConstructArgs args = new RenderStreamConstructArgs();
|
||||
args.UnitCubeSize = unitCubeSize;
|
||||
args.Name = f.name;
|
||||
args.Height = f.Height;
|
||||
args.Width = f.Width;
|
||||
T ret = Activator.CreateInstance(typeof(T), args) as T;
|
||||
ret!.InternalInit();
|
||||
f.WindowID = ret.CanvasHandle;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
@@ -82,10 +73,10 @@ namespace StgSharp.Graphics
|
||||
GLcontext* contextID = (GLcontext*)ContextHandle;
|
||||
contextID->glGetString = (delegate*<uint, IntPtr>)IntPtr.Zero;
|
||||
}
|
||||
if (GL.CurrentContextHandle != ContextHandle)
|
||||
if (glFunc.CurrentContextHandle != ContextHandle)
|
||||
{
|
||||
GL.CurrentContextHandle = ContextHandle;
|
||||
//Console.WriteLine($"context set as {(ulong)GL.CurrentContextHandle}");
|
||||
glFunc.CurrentContextHandle = ContextHandle;
|
||||
//Console.WriteLine($"context set as {(ulong)glFunc.CurrentContextHandle}");
|
||||
InternalIO.glfwMakeContextCurrent(CanvasHandle);
|
||||
}
|
||||
}
|
||||
@@ -98,11 +89,10 @@ namespace StgSharp.Graphics
|
||||
|
||||
internal override sealed unsafe void CreateCanvas()
|
||||
{
|
||||
byte[] nameCode = Encoding.UTF8.GetBytes(name);
|
||||
byte[] nameCode = Encoding.UTF8.GetBytes(Name);
|
||||
CanvasHandle = InternalIO.glfwCreateWindow(
|
||||
Width, Height, nameCode, Monitor, IntPtr.Zero
|
||||
);
|
||||
NativeCamera = new Camera();
|
||||
}
|
||||
|
||||
internal override sealed void InternalDraw(
|
||||
@@ -113,6 +103,7 @@ namespace StgSharp.Graphics
|
||||
ProcessInput();
|
||||
Main(in input, in output);
|
||||
}
|
||||
|
||||
internal override sealed void InternalInit()
|
||||
{
|
||||
CreateCanvas();
|
||||
|
||||
Reference in New Issue
Block a user