68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
using StgSharp.Controlling;
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace StgSharp.Graphics
|
|
{
|
|
public static unsafe partial class Graphic
|
|
{
|
|
private static bool isGLSet = false;
|
|
private static bool isGLADset = false;
|
|
private static bool isGLready = false;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Init an instance of OpenGL program,
|
|
/// This method should be called before other
|
|
/// graphic methods, after LoadGL method.
|
|
/// </summary>
|
|
public static void InitGL(int majorVersion, int minorVersion)
|
|
{
|
|
if (!isGLSet)
|
|
{
|
|
internalIO.InternalInitGL(majorVersion, minorVersion);
|
|
isGLready = isGLSet && isGLADset;
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Do not init GL twice");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Attach GLFW API to GLAD,
|
|
/// this method should be called after LoadGL
|
|
/// and before other graphic method.
|
|
/// </summary>
|
|
/// <exception cref="Exception">The accident that program cannot attach GLFW to GLAD</exception>
|
|
public static unsafe void InitGLManager(glLoader loader)
|
|
{
|
|
|
|
if (!isGLADset)
|
|
{
|
|
int a = internalIO.InternalInitGLAD();
|
|
if (a == 0)
|
|
{
|
|
throw new Exception("Cannot attach GLFW to GLAD!");
|
|
}
|
|
else
|
|
{
|
|
isGLready = isGLSet && isGLADset;
|
|
|
|
LoadGLLoader(loader);
|
|
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("Do not init GLAD twice.");
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|