blob: f1d1d6fe3c6f1530008074183bb04e8f0f933128 [file] [log] [blame]
José Fonseca93f0e3f2011-10-09 16:16:18 +01001/**************************************************************************
2 *
3 * Copyright 2011 Jose Fonseca
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 *
24 **************************************************************************/
25
26
José Fonsecad1c301f2012-10-18 15:22:41 +010027#include <assert.h>
28
José Fonseca3e899d72013-10-29 14:40:57 +000029#include <iostream>
30
José Fonsecad1c301f2012-10-18 15:22:41 +010031#include "glproc.hpp"
José Fonseca93f0e3f2011-10-09 16:16:18 +010032#include "glws.hpp"
33
34
35namespace glws {
36
37
José Fonseca93f0e3f2011-10-09 16:16:18 +010038bool
39checkExtension(const char *extName, const char *extString)
40{
José Fonsecad1c301f2012-10-18 15:22:41 +010041 assert(extName);
42 assert(extString);
43
44 const char *p = extString;
45 const char *q = extName;
46 char c;
47 do {
48 c = *p++;
49 if (c == '\0' || c == ' ') {
50 if (q && *q == '\0') {
51 return true;
52 } else {
53 q = extName;
54 }
55 } else {
56 if (q && *q == c) {
57 ++q;
58 } else {
59 q = 0;
60 }
61 }
62 } while (c);
63 return false;
64}
65
66
José Fonseca3e899d72013-10-29 14:40:57 +000067void
68Drawable::copySubBuffer(int x, int y, int width, int height) {
69 std::cerr << "warning: copySubBuffer not yet implemented\n";
70}
71
72
José Fonsecad1c301f2012-10-18 15:22:41 +010073bool
74Context::hasExtension(const char *string) {
75 if (extensions.empty()) {
76 if (profile == PROFILE_CORE) {
77 // Use glGetStringi
78 GLint num_extensions = 0;
79 glGetIntegerv(GL_NUM_EXTENSIONS, &num_extensions);
80 for (int i = 0; i < num_extensions; ++i) {
81 const char *extension = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i));
82 if (extension) {
83 extensions.insert(extension);
84 }
85 }
86 } else {
87 // Use glGetString
88 const char *begin = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS));
89 do {
90 const char *end = begin;
91 char c = *end;
92 while (c != '\0' && c != ' ') {
93 ++end;
94 c = *end;
95 }
96 if (end != begin) {
97 extensions.insert(std::string(begin, end));
98 }
99
100 if (c == '\0') {
101 break;
102 }
103 begin = end + 1;
104 } while(1);
105 }
106 }
107
108 return extensions.find(string) != extensions.end();
José Fonseca93f0e3f2011-10-09 16:16:18 +0100109}
110
111
112} /* namespace glws */