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