daily update on 20240423 by nitload youmu, mvvm confirm
This commit is contained in:
@@ -59,7 +59,7 @@ namespace StgSharp.Graphics
|
||||
internal Vector4 backgroundColor;
|
||||
internal TimeSpanProvider fpsCountProvider;
|
||||
internal TimeSpanProvider frameTimeProvider;
|
||||
internal IntPtr graphicContextID;
|
||||
internal RenderStream mainRenderStream;
|
||||
internal int height;
|
||||
internal IntPtr monitor;
|
||||
internal string name;
|
||||
@@ -126,7 +126,7 @@ namespace StgSharp.Graphics
|
||||
|
||||
internal unsafe IntPtr id => windowID;
|
||||
|
||||
protected FrameBufferSizeHandler FrameBufferSizeCallback
|
||||
protected FrameBufferSizeHandler FrameSizeCallback
|
||||
{
|
||||
set
|
||||
{
|
||||
@@ -135,57 +135,6 @@ namespace StgSharp.Graphics
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void DeInit();
|
||||
|
||||
/// <summary>
|
||||
/// Necessary operation to init graphic elements this form.
|
||||
/// </summary>
|
||||
/// <param name="gl">OpenGL library binded to current form.</param>
|
||||
protected abstract void Init();
|
||||
|
||||
/// <summary>
|
||||
/// Behaviour of current form when in a frame cycle.
|
||||
/// </summary>
|
||||
protected abstract void Main();
|
||||
|
||||
/// <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 (windowID == default)
|
||||
{
|
||||
IntPtr windowPtr;
|
||||
byte[] tittleBytes = Encoding.UTF8.GetBytes(name);
|
||||
if (sharedForm == null)
|
||||
{
|
||||
windowPtr = InternalIO.glfwCreateWindow(width, height, tittleBytes, monitor, IntPtr.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
windowPtr = InternalIO.glfwCreateWindow(width, height, tittleBytes, monitor, sharedForm.windowID);
|
||||
}
|
||||
if (((long)windowPtr == -1) || ((long)windowPtr == -2))
|
||||
{
|
||||
throw new Exception("Cannot create window instance!");
|
||||
}
|
||||
else
|
||||
{
|
||||
windowID = windowPtr;
|
||||
}
|
||||
|
||||
graphicContextID = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(GLcontext)));
|
||||
GLcontext* contextID = (GLcontext*)graphicContextID;
|
||||
*contextID = new GLcontext();
|
||||
contextID->glGetString = (delegate*<uint, IntPtr>)IntPtr.Zero;
|
||||
}
|
||||
GL.api = (GLcontext*)graphicContextID;
|
||||
InternalIO.glfwMakeContextCurrent(windowID);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -213,7 +162,6 @@ namespace StgSharp.Graphics
|
||||
InternalIO.glfwSetWindowSize(this.windowID, (int)size.X, (int)size.Y);
|
||||
}
|
||||
|
||||
protected abstract void ProcessInput();
|
||||
|
||||
/// <summary>
|
||||
/// Resize the current form
|
||||
|
||||
Reference in New Issue
Block a user