-
Notifications
You must be signed in to change notification settings - Fork 1
/
GLConfig.cs
58 lines (51 loc) · 1.95 KB
/
GLConfig.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#region --- License ---
/* Copyright (c) Nikita Tereshin
* https://github.com/rumkex/Calcifer/blob/master/Utilities/GLConfig.cs
*/
#endregion
using System;
using System.Collections.Generic;
using OpenTK.Graphics.OpenGL;
namespace glomp
{
public static class GLConfig
{
private static readonly HashSet<string> exts;
static GLConfig()
{
var v = GL.GetString(StringName.Version).Split(new[]{' '}, 2)[0].Split('.');
Version = new Version(v.Length < 1 ? 0 : int.Parse(v[0]), v.Length < 2 ? 0 : int.Parse(v[1]), v.Length < 3 ? 0 : int.Parse(v[2]));
if (Version.Major > 2)
{
v = GL.GetString(StringName.ShadingLanguageVersion).Split(new[] { ' ' }, 2)[0].Split('.');
GLSLVersion = new Version(v.Length < 1 ? 0 : int.Parse(v[0]), v.Length < 2 ? 0 : int.Parse(v[1]));
}
else GLSLVersion = new Version();
if (Version.Major < 3)
// pre-3.0 extension enumeration
exts = new HashSet<string>(GL.GetString(StringName.Extensions).Split(' '));
else
{
int num;
GL.GetInteger(GetPName.NumExtensions, out num);
exts = new HashSet<string>();
for (var i = 0; i < num; i++)
{
exts.Add(GL.GetString(StringNameIndexed.Extensions, i));
}
}
}
public static Version Version { get; private set; }
public static Version GLSLVersion { get; private set; }
public static bool HasExtension (string ext)
{
return exts.Contains(ext);
}
}
public static class Extensions
{
public const string Framebuffer = "GL_EXT_framebuffer_object";
public const string TransformFeedback = "GL_EXT_transform_feedback";
public const string TextureFilterAnisotropic = "GL_EXT_texture_filter_anisotropic";
}
}