daily update on 20240501 by nitload youmu, tracking blueprint corupt[D[D[Dr
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using StgSharp.Math;
|
||||
using StgSharp.Logic;
|
||||
using StgSharp.Math;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,6 +13,20 @@ namespace StgSharp.Graphics
|
||||
{
|
||||
public abstract partial class glRenderStream: RenderStream
|
||||
{
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
protected sealed override void NativeCameraViewTarget(vec3d position, vec3d direction, vec3d up)
|
||||
{
|
||||
NativeCamera.SetViewDirection(position, direction, up);
|
||||
@@ -53,34 +68,18 @@ namespace StgSharp.Graphics
|
||||
/// </exception>
|
||||
public unsafe void MakeAsCurrentContext()
|
||||
{
|
||||
if (CanvasHandle == default)
|
||||
if (ContextHandle == default)
|
||||
{
|
||||
IntPtr windowPtr;
|
||||
byte[] tittleBytes = Encoding.UTF8.GetBytes(name);
|
||||
if (SharedCanvas == IntPtr.Zero)
|
||||
{
|
||||
windowPtr = InternalIO.glfwCreateWindow(Width, Height, tittleBytes, Monitor, IntPtr.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
windowPtr = InternalIO.glfwCreateWindow(Width, Height, tittleBytes, Monitor, SharedCanvas);
|
||||
}
|
||||
if (((long)windowPtr == -1) || ((long)windowPtr == -2))
|
||||
{
|
||||
throw new Exception("Cannot create window instance!");
|
||||
}
|
||||
else
|
||||
{
|
||||
CanvasHandle = windowPtr;
|
||||
}
|
||||
|
||||
ContextHandle = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(GLcontext)));
|
||||
GLcontext* contextID = (GLcontext*)ContextHandle;
|
||||
*contextID = new GLcontext();
|
||||
contextID->glGetString = (delegate*<uint, IntPtr>)IntPtr.Zero;
|
||||
}
|
||||
GL.api = (GLcontext*)ContextHandle;
|
||||
InternalIO.glfwMakeContextCurrent(CanvasHandle);
|
||||
if (GL.CurrentContextHandle != ContextHandle)
|
||||
{
|
||||
GL.CurrentContextHandle = ContextHandle;
|
||||
Console.WriteLine($"context set as {(ulong)GL.CurrentContextHandle}");
|
||||
InternalIO.glfwMakeContextCurrent(CanvasHandle);
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
@@ -96,10 +95,12 @@ namespace StgSharp.Graphics
|
||||
Init();
|
||||
}
|
||||
|
||||
internal sealed override void InternalDraw()
|
||||
internal sealed override void InternalDraw(
|
||||
in Dictionary<string, BlueprintPipeline> input,
|
||||
in Dictionary<string, BlueprintPipeline> output)
|
||||
{
|
||||
MakeAsCurrentContext();
|
||||
Main();
|
||||
Main(in input, in output);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user