]> git.tdb.fi Git - libs/gl.git/blob - source/extension.h
Remove some methods that have been deprecated for a long while
[libs/gl.git] / source / extension.h
1 #ifndef MSP_GL_EXTENSION_H_
2 #define MSP_GL_EXTENSION_H_
3
4 #include <string>
5
6 namespace Msp {
7 namespace GL {
8
9 enum GLApi
10 {
11         OPENGL,
12         OPENGL_ES2
13 };
14
15 enum GLProfile
16 {
17         CORE_PROFILE,
18         COMPATIBILITY_PROFILE
19 };
20
21
22 struct Version
23 {
24         unsigned short major;
25         unsigned short minor;
26
27         Version();
28         Version(unsigned short, unsigned short);
29         Version(const std::string &);
30
31         bool operator>=(const Version &) const;
32         bool operator<(const Version &o) const { return !(*this>=o); }
33         operator bool() const { return major || minor; }
34 };
35
36
37 class Extension
38 {
39 public:
40         enum SupportLevel
41         {
42                 UNSUPPORTED,
43                 EXTENSION,
44                 CORE
45         };
46
47         typedef SupportLevel (*InitFunc)();
48
49 private:
50         const char *name;
51         InitFunc init_func;
52         mutable bool init_done;
53         mutable SupportLevel support;
54
55 public:
56         Extension(const char *, InitFunc);
57
58         const char *get_name() const { return name; }
59         operator bool() const;
60 };
61
62
63 struct Require
64 {
65         Require(const Extension &);
66 };
67
68
69 typedef void ExtFunc();
70
71 /** Checks for extension support.  Only intended for internal use. */
72 bool is_supported(const std::string &);
73
74 /** Checks for OpenGL version support.  Only intended for internal use. */
75 bool is_supported(const Version &, const Version & = Version());
76
77 /** Indicates whether an extension has been disabled, either explicitly through
78 the MSPGL_DISABLE_EXTENSIONS environment variable or implicitly as a workaround
79 for a driver bug.  Only intended for internal use. */
80 bool is_disabled(const std::string &);
81
82 /** Returns the API for which the library was compiled. */
83 GLApi get_gl_api();
84
85 /** Returns the OpenGL profile for the active context. */
86 GLProfile get_gl_profile();
87
88 /** Returns the OpenGL version number, as reported by the implementation. */
89 const Version &get_gl_version();
90
91 /** Returns the GLSL version number, as reported by the implementation. */
92 const Version &get_glsl_version();
93
94 /** Returns the address of an extension function.  Only indended for internal
95 use. */
96 ExtFunc *get_proc_address(const std::string &);
97
98 } // namespace GL
99 } // namespace Msp
100
101 #endif