]> git.tdb.fi Git - libs/gl.git/blob - source/extension.h
Rework exceptions
[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 typedef void ExtFunc();
16
17 /**
18 Indicates whether an extension is supported.  If this returns true, the
19 functions of that extension are safe to use.
20 */
21 bool is_supported(const std::string &);
22
23 /**
24 Checks that an extension is supported and throws if it isn't.
25 */
26 void require_extension(const std::string &);
27
28 /**
29 RAII version of require_extension.  Useful as a static local variable.
30 */
31 struct RequireExtension
32 {
33         RequireExtension(const std::string &e) { require_extension(e); }
34 };
35
36 /**
37 Returns the OpenGL version number, as reported by the implementation.
38 Functions up to the returned version are safe to use.
39 */
40 const Version &get_gl_version();
41
42 /**
43 Indicates whether the OpenGL version is at least a.b.
44 */
45 bool is_version_at_least(unsigned a, unsigned b);
46
47 /**
48 Checks that the OpenGL version is at least a.b and throws if it isn't.
49 */
50 void require_version(unsigned a, unsigned b);
51
52 /**
53 RAII version of require_version.  Useful as a static local variable.
54 */
55 struct RequireVersion
56 {
57         RequireVersion(unsigned a, unsigned b) { require_version(a, b); }
58 };
59
60 /**
61 Returns the address of an extension function.  Only indended for internal use.
62 */
63 ExtFunc *get_proc_address(const std::string &);
64
65 } // namespace GL
66 } // namespace Msp
67
68 #endif