Files
stgsharp/源代码/StgSharp/Graphics/Graphic.cs
T

48 lines
1.3 KiB
C#

using StgSharp.Control;
using StgSharp.Graphics;
using StgSharp.Graphics.GL;
using StgSharp.Math;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
namespace StgSharp
{
public static unsafe class Graphic
{
/// <summary>
/// Init a form, attach its data to GLFW program,
/// and return the pointer of the GLFW package of the form.
/// </summary>
/// <param name="form">The C# instance of the form</param>
/// <returns>Pointer of the GLFW package of this form</returns>
/// <exception cref="Exception">The issue that form is not successfully initilized
/// or GLAD program fail to init</exception>
public static unsafe IntPtr InitWindow(Form form)
{
IntPtr a= internalIO.InternalInitWindow(form.info);
if ((long)a == -1)
{
throw new Exception("Failed to init form.");
}
else if ((long)a == -2)
{
throw new Exception("Failed to load GLAD program.");
}
else
{
return a;
}
}
public static unsafe void LoadForm(Form form)
{
ProgramTimeLine.allForm.Add(form);
}
}
}