using System.Linq;
using OpenTK.Graphics.OpenGL4;
namespace SM.OGL
{
///
/// Contains data about the current OpenGL system.
///
public class GLSystem
{
private static bool _init = false;
///
/// Contains the device version of OpenGL.
///
public static Version DeviceVersion { get; private set; }
///
/// Get/Sets the forced version for OpenGL.
/// Needs to be set before init a window.
///
public static Version ForcedVersion { get; set; } = new Version();
///
/// Contains the shader version for GLSL.
///
public static Version ShadingVersion { get; private set; }
///
/// Contains the extensions for OpenGL.
///
public static string[] Extensions { get; private set; }
///
/// Checks if proper Debugging is for this system available.
/// Determent, if the system has the "KHR_debug"-extension.
///
public static bool Debugging { get; private set; }
///
/// Initialize the system data.
/// Does nothing after the data was already collected.
///
public static void INIT_SYSTEM()
{
if (_init) return;
DeviceVersion = Version.CreateGLVersion(GL.GetString(StringName.Version));
ShadingVersion = Version.CreateGLVersion(GL.GetString(StringName.ShadingLanguageVersion));
Extensions = GL.GetString(StringName.Extensions).Split(' ');
Debugging = Extensions.Contains("khr_debug");
if (Debugging) GLDebugging.EnableDebugging();
_init = true;
}
}
}