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