Developer Documentation
gl.hh
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 //=============================================================================
43 // overload some GL functions
44 //=============================================================================
45 
46 
47 #ifndef ACG_GLTEXT_HH
48 #define ACG_GLTEXT_HH
49 
50 
51 //== INCLUDES =================================================================
52 
53 #include <ACG/Config/ACGDefines.hh>
54 
55 
56 #if defined(ARCH_DARWIN)
57 
58  #include <OpenGL/gl.h>
59 
60 #elif defined(WIN32)
61 
62  #include <windows.h>
63  // Dont do this anymore! Use dll version. No problems with plugins and dll
64  // but a lot with static linking
65  // # define GLEW_STATIC 1
66  #include <gl/glew.h>
67 
68 #else
69 
70  #include <GL/gl.h>
71 
72 #endif
73 
74 #include "../Math/VectorT.hh"
75 
76 
77 //=============================================================================
78 namespace ACG {
79 //=============================================================================
80 
81 
82 //-------------------------------------------------------------------- glVertex
83 
85 inline void glVertex(const Vec2i& _v) { glVertex2i(_v[0], _v[1]); }
87 inline void glVertex(const Vec2f& _v) { glVertex2fv(_v.data()); }
89 inline void glVertex(const Vec2d& _v) { glVertex2dv(_v.data()); }
90 
92 inline void glVertex(const Vec3f& _v) { glVertex3fv(_v.data()); }
94 inline void glVertex(const Vec3d& _v) { glVertex3dv(_v.data()); }
95 
97 inline void glVertex(const Vec4f& _v) { glVertex4fv(_v.data()); }
99 inline void glVertex(const Vec4d& _v) { glVertex4dv(_v.data()); }
100 
101 
102 
103 //------------------------------------------------------------------- glTexCoord
104 
106 inline void glTexCoord(const Vec2f& _t) { glTexCoord2fv(_t.data()); }
108 inline void glTexCoord(const Vec2d& _t) { glTexCoord2dv(_t.data()); }
109 
111 inline void glTexCoord(const Vec3f& _t) { glTexCoord3fv(_t.data()); }
113 inline void glTexCoord(const Vec3d& _t) { glTexCoord3dv(_t.data()); }
114 
116 inline void glTexCoord(const Vec4f& _t) { glTexCoord4fv(_t.data()); }
118 inline void glTexCoord(const Vec4d& _t) { glTexCoord4dv(_t.data()); }
119 
120 
121 
122 //--------------------------------------------------------------------- glNormal
123 
125 inline void glNormal(const Vec3f& _n) { glNormal3fv(_n.data()); }
127 inline void glNormal(const Vec3d& _n) { glNormal3dv(_n.data()); }
128 
129 
130 
131 //---------------------------------------------------------------------- glColor
132 
134 inline void glColor(const Vec3f& _v) { glColor3fv(_v.data()); }
136 inline void glColor(const Vec3uc& _v) { glColor3ubv(_v.data()); }
137 
139 inline void glColor(const Vec4f& _v) { glColor4fv(_v.data()); }
141 inline void glColor(const Vec4uc& _v) { glColor4ubv(_v.data()); }
142 
143 
144 
145 //-------------------------------------------------------------- ACG::GLState::vertexPointer
146 /*
148 inline void glVertexPointer(const Vec2f* _p)
149 { ::ACG::GLState::vertexPointer(2, GL_FLOAT, 0, _p); }
151 inline void ACG::GLState::vertexPointer(const Vec2d* _p)
152 { ::ACG::GLState::vertexPointer(2, GL_DOUBLE, 0, _p); }
153 
155 inline void ACG::GLState::vertexPointer(const Vec3f* _p)
156 { ::ACG::GLState::vertexPointer(3, GL_FLOAT, 0, _p); }
158 inline void ACG::GLState::vertexPointer(const Vec3d* _p)
159 { ::ACG::GLState::vertexPointer(3, GL_DOUBLE, 0, _p); }
160 
162 inline void ACG::GLState::vertexPointer(const Vec4f* _p)
163 { ::ACG::GLState::vertexPointer(4, GL_FLOAT, 0, _p); }
165 inline void ACG::GLState::vertexPointer(const Vec4d* _p)
166 { ::ACG::GLState::vertexPointer(4, GL_DOUBLE, 0, _p); }
167 
169 inline void ACG::GLState::vertexPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
170 { ::ACG::GLState::vertexPointer(n, t, s, p); }
171 
172 
173 
174 //-------------------------------------------------------------- ACG::GLState::normalPointer
175 
177 inline void ACG::GLState::normalPointer(const Vec3f* _p)
178 { ::ACG::GLState::normalPointer(GL_FLOAT, 0, _p); }
180 inline void ACG::GLState::normalPointer(const Vec3d* _p)
181 { ::ACG::GLState::normalPointer(GL_DOUBLE, 0, _p); }
182 
184 inline void ACG::GLState::normalPointer(GLenum t, GLsizei s, const GLvoid *p)
185 { ::ACG::GLState::normalPointer(t, s, p); }
186 
187 
188 
189 //--------------------------------------------------------------- ACG::GLState::colorPointer
190 
192 inline void ACG::GLState::colorPointer(const Vec3uc* _p)
193 { ::ACG::GLState::colorPointer(3, GL_UNSIGNED_BYTE, 0, _p); }
195 inline void ACG::GLState::colorPointer(const Vec3f* _p)
196 { ::ACG::GLState::colorPointer(3, GL_FLOAT, 0, _p); }
197 
199 inline void ACG::GLState::colorPointer(const Vec4uc* _p)
200 { ::ACG::GLState::colorPointer(4, GL_UNSIGNED_BYTE, 0, _p); }
202 inline void ACG::GLState::colorPointer(const Vec4f* _p)
203 { ::ACG::GLState::colorPointer(4, GL_FLOAT, 0, _p); }
204 
206 inline void ACG::GLState::colorPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
207 { ::ACG::GLState::colorPointer(n, t, s, p); }
208 
209 
210 
211 //------------------------------------------------------------ ACG::GLState::texcoordPointer
212 
214 inline void ACG::GLState::texcoordPointer(const float* _p)
215 { ::ACG::GLState::texcoordPointer(1, GL_FLOAT, 0, _p); }
217 inline void ACG::GLState::texcoordPointer(const double* _p)
218 { ::ACG::GLState::texcoordPointer(1, GL_DOUBLE, 0, _p); }
219 
221 inline void ACG::GLState::texcoordPointer(const Vec2f* _p)
222 { ::ACG::GLState::texcoordPointer(2, GL_FLOAT, 0, _p); }
224 inline void ACG::GLState::texcoordPointer(const Vec2d* _p)
225 { ::ACG::GLState::texcoordPointer(2, GL_DOUBLE, 0, _p); }
226 
228 inline void ACG::GLState::texcoordPointer(const Vec3f* _p)
229 { ::ACG::GLState::texcoordPointer(3, GL_FLOAT, 0, _p); }
231 inline void ACG::GLState::texcoordPointer(const Vec3d* _p)
232 { ::ACG::GLState::texcoordPointer(3, GL_DOUBLE, 0, _p); }
233 
235 inline void ACG::GLState::texcoordPointer(const Vec4f* _p)
236 { ::ACG::GLState::texcoordPointer(4, GL_FLOAT, 0, _p); }
238 inline void ACG::GLState::texcoordPointer(const Vec4d* _p)
239 { ::ACG::GLState::texcoordPointer(4, GL_DOUBLE, 0, _p); }
240 
242 inline void ACG::GLState::texcoordPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
243 { ::ACG::GLState::texcoordPointer(n, t, s, p); }
244 */
245 
252 std::string ACGDLLEXPORT getExtensionString( ) ;
253 
256 bool ACGDLLEXPORT checkExtensionSupported( const std::string& _extension ) ;
257 
260 bool ACGDLLEXPORT openGLVersion( const int _major, const int _minor, bool verbose = true );
261 
265 inline bool ACGDLLEXPORT openGLVersionTest( const int _major, const int _minor ){return openGLVersion(_major, _minor, false);}
266 
268 void ACGDLLEXPORT compatibilityProfile(bool _compatProfile);
269 
271 bool ACGDLLEXPORT compatibilityProfile( );
272 
273 //=============================================================================
274 } // namespace ACG
275 //=============================================================================
276 #endif // ACG_GLTEXT_HH defined
277 //=============================================================================
Namespace providing different geometric functions concerning angles.
Scalar * data()
access to Scalar array
Definition: Vector11T.hh:195
void compatibilityProfile(bool _enableCoreProfile)
Store opengl core profile setting.
Definition: gl.cc:166
void glNormal(const Vec3f &_n)
Wrapper: glNormal for Vec3f.
Definition: gl.hh:125
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
Definition: gl.hh:85
bool ACGDLLEXPORT openGLVersionTest(const int _major, const int _minor)
Definition: gl.hh:265
std::string getExtensionString()
getExtensionString returns a string containing all supported OpenGL extensions this function uses the...
Definition: gl.cc:100
bool checkExtensionSupported(const std::string &_extension)
Definition: gl.cc:107
void glTexCoord(const Vec2f &_t)
Wrapper: glTexCoord for Vec2f.
Definition: gl.hh:106
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
Definition: gl.hh:134
bool openGLVersion(const int _major, const int _minor, bool _verbose)
Definition: gl.cc:129