]> git.mxchange.org Git - simgear.git/blob - simgear/screen/extensions.cxx
canvas::Map: Property to keep children aligned to given hdg.
[simgear.git] / simgear / screen / extensions.cxx
1 /*
2  *
3  * Copyright (c) 2001 César Blecua Udías    All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included
13  * in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18  * CESAR BLECUA UDIAS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
20  * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  *
23  */
24
25
26 #include "extensions.hxx"
27
28 #include <cstring>
29 #include <osg/GL> // for glGetString
30
31 bool SGSearchExtensionsString(const char *extString, const char *extName) {
32     // Returns GL_TRUE if the *extName string appears in the *extString string,
33     // surrounded by white spaces, or GL_FALSE otherwise.
34
35     const char *p, *end;
36     int n, extNameLen;
37
38     if ((extString == NULL) || (extName == NULL))
39         return false;
40
41     extNameLen = strlen(extName);
42
43     p=extString;
44     end = p + strlen(p);
45
46     while (p < end) {
47         n = strcspn(p, " ");
48         if ((extNameLen == n) && (strncmp(extName, p, n) == 0))
49             return GL_TRUE;
50
51         p += (n + 1);
52     }
53
54     return GL_FALSE;
55 }
56
57 bool SGIsOpenGLExtensionSupported(const char *extName) {
58    // Returns GL_TRUE if the OpenGL Extension whose name is *extName
59    // is supported by the system, or GL_FALSE otherwise.
60    //
61    // The *extName string must follow the OpenGL extensions naming scheme
62    // (ie: "GL_type_extension", like GL_EXT_convolution)
63
64     return SGSearchExtensionsString((const char *)glGetString(GL_EXTENSIONS),extName);
65 }