diff options
Diffstat (limited to 'helpers')
-rw-r--r-- | helpers/glprofile.cpp | 48 | ||||
-rw-r--r-- | helpers/glprofile.hpp | 20 |
2 files changed, 65 insertions, 3 deletions
diff --git a/helpers/glprofile.cpp b/helpers/glprofile.cpp index 0cfcaa45..6207094e 100644 --- a/helpers/glprofile.cpp +++ b/helpers/glprofile.cpp @@ -208,4 +208,52 @@ getCurrentContextProfile(void) } +void +Extensions::getCurrentContextExtensions(const Profile & profile) +{ + assert(strings.empty()); + if (profile.major >= 3) { + // Use glGetStringi + GLint num_strings = 0; + _glGetIntegerv(GL_NUM_EXTENSIONS, &num_strings); + assert(num_strings); + for (int i = 0; i < num_strings; ++i) { + const char *extension = reinterpret_cast<const char *>(_glGetStringi(GL_EXTENSIONS, i)); + assert(extension); + if (extension) { + strings.insert(extension); + } + } + } else { + // Use glGetString + const char *begin = reinterpret_cast<const char *>(_glGetString(GL_EXTENSIONS)); + assert(begin); + if (begin) { + do { + const char *end = begin; + char c = *end; + while (c != '\0' && c != ' ') { + ++end; + c = *end; + } + if (end != begin) { + strings.insert(std::string(begin, end)); + } + if (c == '\0') { + break; + } + begin = end + 1; + } while(true); + } + } +} + + +bool +Extensions::has(const char *string) const +{ + return strings.find(string) != strings.end(); +} + + } /* namespace glprofile */ diff --git a/helpers/glprofile.hpp b/helpers/glprofile.hpp index 5915e897..25f0a2d4 100644 --- a/helpers/glprofile.hpp +++ b/helpers/glprofile.hpp @@ -29,13 +29,14 @@ */ -#include <ostream> - - #ifndef GLPROFILE_HPP #define GLPROFILE_HPP +#include <ostream> +#include <set> + + namespace glprofile { @@ -122,6 +123,19 @@ Profile getCurrentContextProfile(void); +struct Extensions +{ + std::set<std::string> strings; + + void + getCurrentContextExtensions(const Profile & profile); + + bool + has(const char *string) const; +}; + + + } /* namespace glprofile */ |