Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
gl.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41
42 #include "gl.hh"
43
44 #include <cstdlib>
45 #include <sstream>
46 #include <iostream>
47
48
49
50 //=============================================================================
51 namespace ACG {
52 //=============================================================================
53 namespace {
60 inline const char *_getExtensionString() {
61 const char *supported_cstr = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS));
62 if (supported_cstr == 0) {
63 std::cerr << "\x1b[1;31mACG::checkExtensionsSupported: "
64 "glGetString(GL_EXTENSIONS) call failed.\x1b[0m\n";
65 return "";
66 }
67 return supported_cstr;
68 }
69 }
70
73 bool checkExtensionSupported( const std::string& _extension ) {
78 static const std::string supported_str(_getExtensionString());
79
80 /*
81 * supported_str is a space delimited list. Tokenize it. Simply searching
82 * for _extension within supported_str yields false positives if the
83 * requested extension is a substring of a supported one.
84 */
85 for (std::istringstream supported(supported_str); !supported.eof(); ) {
86 std::string feature;
87 supported >> feature;
88 if (feature == _extension) return true;
89 }
90 return false;
91 }
92
95 bool openGLVersion( const int _major, const int _minor ) {
96
97 // Read OpenGL Version string
98 std::string glVersionString = (const char*)glGetString(GL_VERSION);
99
100 // Use string stream to parse
101 std::istringstream stream;
102 stream.str(glVersionString);
103
104 // Buffer for the dot between major and minor
105 char dot;
106
107 // Read Major version number
108 int major ;
109 stream >> major;
110 stream >> dot;
111
112 // Read minor version number
113 int minor;
114 stream >> minor;
115
116 if ( (_major > major) || ( (_major == major) && (_minor > minor)) ) {
117 std::cerr << "OpenGL Version check failed. Required : " << _major << "." << _minor << std::endl;
118 std::cerr << "OpenGL Version check failed. Available : " << major << "." << minor << std::endl;
119 return false;
120 }
121
122 return true;
123 }
124
125
126 //=============================================================================
127 } // namespace ACG
128 //=============================================================================
ACG
Namespace providing different geometric functions concerning angles.
Definition: DBSCANT.cc:51
ACG::openGLVersion
bool openGLVersion(const int _major, const int _minor)
Definition: gl.cc:95
ACG::checkExtensionSupported
bool checkExtensionSupported(const std::string &_extension)
Definition: gl.cc:73