]> git.tdb.fi Git - libs/gl.git/blob - source/backends/opengl/extension.h
Add support for padding in vertex formats
[libs/gl.git] / source / backends / opengl / extension.h
1 #ifndef MSP_GL_EXTENSION_H_
2 #define MSP_GL_EXTENSION_H_
3
4 #include <string>
5 #include "backend.h"
6
7 namespace Msp {
8 namespace GL {
9
10 enum GLProfile
11 {
12         CORE_PROFILE,
13         COMPATIBILITY_PROFILE
14 };
15
16
17 /**
18 Holds metadata about an extension.  Evaluates to true if the extension is
19 supported.
20 */
21 class Extension
22 {
23 public:
24         enum SupportLevel
25         {
26                 UNSUPPORTED,
27                 EXTENSION,
28                 CORE
29         };
30
31         typedef SupportLevel (*InitFunc)();
32
33 private:
34         const char *name;
35         InitFunc init_func;
36         mutable bool init_done;
37         mutable SupportLevel support;
38
39 public:
40         Extension(const char *, InitFunc);
41
42         const char *get_name() const { return name; }
43         operator bool() const;
44 };
45
46
47 struct Require
48 {
49         Require(const Extension &);
50 };
51
52
53 typedef void ExtFunc();
54
55 /** Checks for extension support.  Only intended for internal use. */
56 bool is_supported(const std::string &);
57
58 /** Checks for OpenGL version support.  Only intended for internal use. */
59 bool is_supported(const Version &, const Version & = Version());
60
61 /** Indicates whether an extension has been disabled, either explicitly through
62 the MSPGL_DISABLE_EXTENSIONS environment variable or implicitly as a workaround
63 for a driver bug.  Only intended for internal use. */
64 bool is_disabled(const std::string &);
65
66 /** Returns the OpenGL profile for the active context. */
67 GLProfile get_gl_profile();
68
69 /** Returns the GLSL version number, as reported by the implementation. */
70 const Version &get_glsl_version();
71
72 /** Returns the address of an extension function.  Only indended for internal
73 use. */
74 ExtFunc *get_proc_address(const std::string &);
75
76 } // namespace GL
77 } // namespace Msp
78
79 #endif