]> git.tdb.fi Git - libs/gl.git/blob - source/extension.h
Add a less-than operator to Version
[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 };
34
35
36 class Extension
37 {
38 public:
39         enum SupportLevel
40         {
41                 UNSUPPORTED,
42                 EXTENSION,
43                 CORE
44         };
45
46         typedef SupportLevel (*InitFunc)();
47
48 private:
49         const char *name;
50         InitFunc init_func;
51         mutable bool init_done;
52         mutable SupportLevel support;
53
54 public:
55         Extension(const char *, InitFunc);
56
57         const char *get_name() const { return name; }
58         operator bool() const;
59 };
60
61
62 struct Require
63 {
64         Require(const Extension &);
65 };
66
67
68 typedef void ExtFunc();
69
70 /** Indicates whether an extension is supported. */
71 bool is_supported(const std::string &);
72
73 /** Returns the API for which the library was compiled. */
74 GLApi get_gl_api();
75
76 /** Returns the OpenGL profile for the active context. */
77 GLProfile get_gl_profile();
78
79 /** Returns the OpenGL version number, as reported by the implementation. */
80 const Version &get_gl_version();
81
82 /** Returns the GLSL version number, as reported by the implementation. */
83 const Version &get_glsl_version();
84
85 /** Indicates whether the OpenGL version is at least a.b. */
86 bool is_version_at_least(unsigned a, unsigned b);
87
88 /** Returns the address of an extension function.  Only indended for internal
89 use. */
90 ExtFunc *get_proc_address(const std::string &);
91
92 } // namespace GL
93 } // namespace Msp
94
95 #endif