]> git.tdb.fi Git - libs/gl.git/blob - source/extension.h
Add function to check GLSL 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 struct Version
10 {
11         unsigned short major;
12         unsigned short minor;
13
14         Version();
15         Version(unsigned short, unsigned short);
16         Version(const std::string &);
17
18         bool operator>=(const Version &) const;
19 };
20
21
22 class Extension
23 {
24 public:
25         enum SupportLevel
26         {
27                 UNSUPPORTED,
28                 EXTENSION,
29                 CORE
30         };
31
32         typedef SupportLevel (*InitFunc)();
33
34 private:
35         const char *name;
36         InitFunc init_func;
37         mutable bool init_done;
38         mutable SupportLevel support;
39
40 public:
41         Extension(const char *, InitFunc);
42
43         const char *get_name() const { return name; }
44         operator bool() const;
45 };
46
47
48 struct Require
49 {
50         Require(const Extension &);
51 };
52
53
54 typedef void ExtFunc();
55
56 /** Indicates whether an extension is supported. */
57 bool is_supported(const std::string &);
58
59 /** Returns the OpenGL version number, as reported by the implementation. */
60 const Version &get_gl_version();
61
62 /** Returns the GLSL version number, as reported by the implementation. */
63 const Version &get_glsl_version();
64
65 /** Indicates whether the OpenGL version is at least a.b. */
66 bool is_version_at_least(unsigned a, unsigned b);
67
68 /** Returns the address of an extension function.  Only indended for internal
69 use. */
70 ExtFunc *get_proc_address(const std::string &);
71
72 } // namespace GL
73 } // namespace Msp
74
75 #endif