daily update on 20240423 by nitload youmu, mvvm confirm
This commit is contained in:
@@ -46,9 +46,9 @@ namespace StgSharp.Graphics
|
||||
public unsafe class ElementBuffer : BufferObjectBase
|
||||
{
|
||||
|
||||
internal ElementBuffer(int n, Form binding)
|
||||
internal ElementBuffer(int n, glRenderStream binding)
|
||||
{
|
||||
this.binding = binding.graphicContextID;
|
||||
this.binding = binding.ContextHandle;
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@ namespace StgSharp.Graphics
|
||||
|
||||
public class FrameBuffer : BufferObjectBase
|
||||
{
|
||||
internal unsafe FrameBuffer(int count, IntPtr contextBinding)
|
||||
internal unsafe FrameBuffer(int count, glRenderStream contextBinding)
|
||||
{
|
||||
binding = contextBinding;
|
||||
binding = contextBinding.ContextHandle;
|
||||
_bufferHandle = new glHandleSet(count);
|
||||
((GLcontext*)binding)->glGenFramebuffers((uint)count,_bufferHandle.handle);
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ namespace StgSharp.Graphics
|
||||
public unsafe class VertexArray : BufferObjectBase
|
||||
{
|
||||
|
||||
internal VertexArray(int n, Form binding)
|
||||
internal VertexArray(int n, glRenderStream binding)
|
||||
{
|
||||
this.binding = binding.graphicContextID;
|
||||
this.binding = binding.ContextHandle;
|
||||
_bufferHandle = GL.GenVertexArrays(n);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ namespace StgSharp.Graphics
|
||||
public unsafe class VertexBuffer : BufferObjectBase
|
||||
{
|
||||
|
||||
internal VertexBuffer(int n, Form binding)
|
||||
internal VertexBuffer(int n, glRenderStream binding)
|
||||
{
|
||||
this.binding = binding.graphicContextID;
|
||||
this.binding = binding.ContextHandle;
|
||||
_bufferHandle = GL.GenBuffers(n);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,10 @@ namespace StgSharp.Graphics
|
||||
internal glHandleSet _textureHandle;
|
||||
internal Image[] sourceList;
|
||||
|
||||
internal Texture(int n, Form binding)
|
||||
internal Texture(int n, glRenderStream binding)
|
||||
{
|
||||
sourceList = new Image[n];
|
||||
this.binding = binding.graphicContextID;
|
||||
this.binding = binding.ContextHandle;
|
||||
_textureHandle = GL.GenTextures(n);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public partial class Form
|
||||
public partial class glRenderStream
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Graphics
|
||||
{
|
||||
public abstract partial class glRenderStream:RenderStream
|
||||
{
|
||||
protected IntPtr glContextHandle
|
||||
{
|
||||
get { return ContextHandle; }
|
||||
set { ContextHandle = value; }
|
||||
}
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
/// <exception cref="Exception">
|
||||
/// Something goes wrong and StgSharp fails in creating a new OpenGL context.
|
||||
/// </exception>
|
||||
public unsafe void MakeAsCurrentContext()
|
||||
{
|
||||
if (CanvasHandle == 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.CanvasHandle);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
internal sealed override void InternalInit()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
internal sealed override void InternalDraw()
|
||||
{
|
||||
MakeAsCurrentContext();
|
||||
Main();
|
||||
}
|
||||
|
||||
|
||||
internal sealed override void InternalTerminate()
|
||||
{
|
||||
Deinit();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user