]> git.tdb.fi Git - libs/gl.git/blob - source/extension.h
ed2530a922fdf5c7ae3de64a29d4de3e693d0d62
[libs/gl.git] / source / extension.h
1 /* $Id$
2
3 This file is part of libmspgl
4 Copyright © 2007-2008, 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
6 */
7
8 #ifndef MSP_GL_EXTENSION_H_
9 #define MSP_GL_EXTENSION_H_
10
11 #include <msp/core/except.h>
12
13 namespace Msp {
14 namespace GL {
15
16 struct Version
17 {
18         unsigned short major;
19         unsigned short minor;
20 };
21
22 typedef void ExtFunc();
23
24 /**
25 Indicates whether an extension is supported.  If this returns true, the
26 functions of that extension are safe to use.
27 */
28 bool is_supported(const std::string &);
29
30 /**
31 Checks that an extension is supported and throws if it isn't.
32 */
33 void require_extension(const std::string &);
34
35 /**
36 RAII version of require_extension.  Useful as a static local variable.
37 */
38 struct RequireExtension
39 {
40         RequireExtension(const std::string &e) { require_extension(e); }
41 };
42
43 /**
44 Returns the OpenGL version number, as reported by the implementation.
45 Functions up to the returned version are safe to use.
46 */
47 const Version &get_gl_version();
48
49 /**
50 Indicates whether the OpenGL version is at least a.b.
51 */
52 bool is_version_at_least(unsigned a, unsigned b);
53
54 /**
55 Checks that the OpenGL version is at least a.b and throws if it isn't.
56 */
57 void require_version(unsigned a, unsigned b);
58
59 /**
60 RAII version of require_version.  Useful as a static local variable.
61 */
62 struct RequireVersion
63 {
64         RequireVersion(unsigned a, unsigned b) { require_version(a, b); }
65 };
66
67 /**
68 Returns the address of an extension function.  Only indended for internal use.
69 */
70 ExtFunc *get_proc_address(const std::string &);
71
72 } // namespace GL
73 } // namespace Msp
74
75 #endif