aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics/Gal/OpenGL/OGLExtension.cs
blob: 5ad422980c196a922e994855ea3399fea9e99efa (plain)
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
using OpenTK.Graphics.OpenGL;

namespace Ryujinx.Graphics.Gal.OpenGL
{
    static class OGLExtension
    {
        private static bool Initialized = false;

        private static bool EnhancedLayouts;

        private static bool TextureMirrorClamp;

        public static bool HasEnhancedLayouts()
        {
            EnsureInitialized();

            return EnhancedLayouts;
        }

        public static bool HasTextureMirrorClamp()
        {
            EnsureInitialized();

            return TextureMirrorClamp;
        }

        private static void EnsureInitialized()
        {
            if (Initialized)
            {
                return;
            }

            EnhancedLayouts = HasExtension("GL_ARB_enhanced_layouts");

            TextureMirrorClamp = HasExtension("GL_EXT_texture_mirror_clamp");
        }

        private static bool HasExtension(string Name)
        {
            int NumExtensions = GL.GetInteger(GetPName.NumExtensions);

            for (int Extension = 0; Extension < NumExtensions; Extension++)
            {
                if (GL.GetString(StringNameIndexed.Extensions, Extension) == Name)
                {
                    return true;
                }
            }

            return false;
        }
    }
}