TYPE3
[iec.git] / src / type3_AndroidCloud / anbox-master / src / anbox / graphics / gl_extensions.h
1 /*
2  * Copyright (C) 2017 Simon Fels <morphis@gravedo.de>
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License version 3, as published
6  * by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranties of
10  * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11  * PURPOSE.  See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program.  If not, see <http://www.gnu.org/licenses/>.
15  *
16  */
17
18 #ifndef ANBOX_GRAPHICS_GL_EXTENSIONS_H_
19 #define ANBOX_GRAPHICS_GL_EXTENSIONS_H_
20
21 #include <stdexcept>
22 #include <string.h>
23
24 namespace anbox {
25 namespace graphics {
26 class GLExtensions {
27  public:
28   GLExtensions(char const* extensions) : extensions{extensions} {
29     if (!extensions)
30       throw std::runtime_error("Couldn't get list of GL extensions");
31   }
32
33   bool support(char const* ext) const {
34     if (!ext)
35       throw std::invalid_argument("Invalid extension name");
36
37     char const* ext_ptr = extensions;
38     size_t const len = strlen(ext);
39     while ((ext_ptr = strstr(ext_ptr, ext)) != nullptr) {
40       if (ext_ptr[len] == ' ' || ext_ptr[len] == '\0')
41         break;
42       ext_ptr += len;
43     }
44
45     return ext_ptr != nullptr;
46   }
47
48   char const* raw() { return extensions; }
49
50  private:
51   char const* extensions;
52 };
53 }  // namespace graphics
54 }  // namespace anbox
55
56 #endif