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 
75 // qt refers to outdated include guard of glext.h, set the old guard if the
76 // new one is defined:
77 #ifdef __gl_glext_h_
78 # ifndef __glext_h_
79 # define __glext_h_ 1
80 # endif
81 #endif
82 
83 
84 #include "../Math/VectorT.hh"
85 
86 
87 //=============================================================================
88 namespace ACG {
89 //=============================================================================
90 
91 
92 //-------------------------------------------------------------------- glVertex
93 
95 inline void glVertex(const Vec2i& _v) { glVertex2i(_v[0], _v[1]); }
97 inline void glVertex(const Vec2f& _v) { glVertex2fv(_v.data()); }
99 inline void glVertex(const Vec2d& _v) { glVertex2dv(_v.data()); }
100 
102 inline void glVertex(const Vec3f& _v) { glVertex3fv(_v.data()); }
104 inline void glVertex(const Vec3d& _v) { glVertex3dv(_v.data()); }
105 
107 inline void glVertex(const Vec4f& _v) { glVertex4fv(_v.data()); }
109 inline void glVertex(const Vec4d& _v) { glVertex4dv(_v.data()); }
110 
111 
112 
113 //------------------------------------------------------------------- glTexCoord
114 
116 inline void glTexCoord(const Vec2f& _t) { glTexCoord2fv(_t.data()); }
118 inline void glTexCoord(const Vec2d& _t) { glTexCoord2dv(_t.data()); }
119 
121 inline void glTexCoord(const Vec3f& _t) { glTexCoord3fv(_t.data()); }
123 inline void glTexCoord(const Vec3d& _t) { glTexCoord3dv(_t.data()); }
124 
126 inline void glTexCoord(const Vec4f& _t) { glTexCoord4fv(_t.data()); }
128 inline void glTexCoord(const Vec4d& _t) { glTexCoord4dv(_t.data()); }
129 
130 
131 
132 //--------------------------------------------------------------------- glNormal
133 
135 inline void glNormal(const Vec3f& _n) { glNormal3fv(_n.data()); }
137 inline void glNormal(const Vec3d& _n) { glNormal3dv(_n.data()); }
138 
139 
140 
141 //---------------------------------------------------------------------- glColor
142 
144 inline void glColor(const Vec3f& _v) { glColor3fv(_v.data()); }
146 inline void glColor(const Vec3uc& _v) { glColor3ubv(_v.data()); }
147 
149 inline void glColor(const Vec4f& _v) { glColor4fv(_v.data()); }
151 inline void glColor(const Vec4uc& _v) { glColor4ubv(_v.data()); }
152 
153 
154 
155 //-------------------------------------------------------------- ACG::GLState::vertexPointer
156 /*
158 inline void glVertexPointer(const Vec2f* _p)
159 { ::ACG::GLState::vertexPointer(2, GL_FLOAT, 0, _p); }
161 inline void ACG::GLState::vertexPointer(const Vec2d* _p)
162 { ::ACG::GLState::vertexPointer(2, GL_DOUBLE, 0, _p); }
163 
165 inline void ACG::GLState::vertexPointer(const Vec3f* _p)
166 { ::ACG::GLState::vertexPointer(3, GL_FLOAT, 0, _p); }
168 inline void ACG::GLState::vertexPointer(const Vec3d* _p)
169 { ::ACG::GLState::vertexPointer(3, GL_DOUBLE, 0, _p); }
170 
172 inline void ACG::GLState::vertexPointer(const Vec4f* _p)
173 { ::ACG::GLState::vertexPointer(4, GL_FLOAT, 0, _p); }
175 inline void ACG::GLState::vertexPointer(const Vec4d* _p)
176 { ::ACG::GLState::vertexPointer(4, GL_DOUBLE, 0, _p); }
177 
179 inline void ACG::GLState::vertexPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
180 { ::ACG::GLState::vertexPointer(n, t, s, p); }
181 
182 
183 
184 //-------------------------------------------------------------- ACG::GLState::normalPointer
185 
187 inline void ACG::GLState::normalPointer(const Vec3f* _p)
188 { ::ACG::GLState::normalPointer(GL_FLOAT, 0, _p); }
190 inline void ACG::GLState::normalPointer(const Vec3d* _p)
191 { ::ACG::GLState::normalPointer(GL_DOUBLE, 0, _p); }
192 
194 inline void ACG::GLState::normalPointer(GLenum t, GLsizei s, const GLvoid *p)
195 { ::ACG::GLState::normalPointer(t, s, p); }
196 
197 
198 
199 //--------------------------------------------------------------- ACG::GLState::colorPointer
200 
202 inline void ACG::GLState::colorPointer(const Vec3uc* _p)
203 { ::ACG::GLState::colorPointer(3, GL_UNSIGNED_BYTE, 0, _p); }
205 inline void ACG::GLState::colorPointer(const Vec3f* _p)
206 { ::ACG::GLState::colorPointer(3, GL_FLOAT, 0, _p); }
207 
209 inline void ACG::GLState::colorPointer(const Vec4uc* _p)
210 { ::ACG::GLState::colorPointer(4, GL_UNSIGNED_BYTE, 0, _p); }
212 inline void ACG::GLState::colorPointer(const Vec4f* _p)
213 { ::ACG::GLState::colorPointer(4, GL_FLOAT, 0, _p); }
214 
216 inline void ACG::GLState::colorPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
217 { ::ACG::GLState::colorPointer(n, t, s, p); }
218 
219 
220 
221 //------------------------------------------------------------ ACG::GLState::texcoordPointer
222 
224 inline void ACG::GLState::texcoordPointer(const float* _p)
225 { ::ACG::GLState::texcoordPointer(1, GL_FLOAT, 0, _p); }
227 inline void ACG::GLState::texcoordPointer(const double* _p)
228 { ::ACG::GLState::texcoordPointer(1, GL_DOUBLE, 0, _p); }
229 
231 inline void ACG::GLState::texcoordPointer(const Vec2f* _p)
232 { ::ACG::GLState::texcoordPointer(2, GL_FLOAT, 0, _p); }
234 inline void ACG::GLState::texcoordPointer(const Vec2d* _p)
235 { ::ACG::GLState::texcoordPointer(2, GL_DOUBLE, 0, _p); }
236 
238 inline void ACG::GLState::texcoordPointer(const Vec3f* _p)
239 { ::ACG::GLState::texcoordPointer(3, GL_FLOAT, 0, _p); }
241 inline void ACG::GLState::texcoordPointer(const Vec3d* _p)
242 { ::ACG::GLState::texcoordPointer(3, GL_DOUBLE, 0, _p); }
243 
245 inline void ACG::GLState::texcoordPointer(const Vec4f* _p)
246 { ::ACG::GLState::texcoordPointer(4, GL_FLOAT, 0, _p); }
248 inline void ACG::GLState::texcoordPointer(const Vec4d* _p)
249 { ::ACG::GLState::texcoordPointer(4, GL_DOUBLE, 0, _p); }
250 
252 inline void ACG::GLState::texcoordPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
253 { ::ACG::GLState::texcoordPointer(n, t, s, p); }
254 */
255 
262 std::string ACGDLLEXPORT getExtensionString( ) ;
263 
266 bool ACGDLLEXPORT checkExtensionSupported( const std::string& _extension ) ;
267 
270 bool ACGDLLEXPORT openGLVersion( const int _major, const int _minor, bool verbose = true );
271 
275 inline bool ACGDLLEXPORT openGLVersionTest( const int _major, const int _minor ){return openGLVersion(_major, _minor, false);}
276 
278 void ACGDLLEXPORT compatibilityProfile(bool _compatProfile);
279 
281 bool ACGDLLEXPORT compatibilityProfile( );
282 
283 //=============================================================================
284 } // namespace ACG
285 //=============================================================================
286 #endif // ACG_GLTEXT_HH defined
287 //=============================================================================
void glTexCoord(const Vec2f &_t)
Wrapper: glTexCoord for Vec2f.
Definition: gl.hh:116
void glColor(const Vec3f &_v)
Wrapper: glColor for Vec3f.
Definition: gl.hh:144
void glNormal(const Vec3f &_n)
Wrapper: glNormal for Vec3f.
Definition: gl.hh:135
Namespace providing different geometric functions concerning angles.
Scalar * data()
access to Scalar array
Definition: Vector11T.hh:200
bool ACGDLLEXPORT openGLVersionTest(const int _major, const int _minor)
Definition: gl.hh:275
bool openGLVersion(const int _major, const int _minor, bool _verbose)
Definition: gl.cc:129
void glVertex(const Vec2i &_v)
Wrapper: glVertex for Vec2i.
Definition: gl.hh:95
bool checkExtensionSupported(const std::string &_extension)
Definition: gl.cc:107
void compatibilityProfile(bool _enableCoreProfile)
Store opengl core profile setting.
Definition: gl.cc:166
std::string getExtensionString()
getExtensionString returns a string containing all supported OpenGL extensions this function uses the...
Definition: gl.cc:100