gl.hh 11.4 KB
Newer Older
Jan Möbius's avatar
Jan Möbius committed
1
2
3
/*===========================================================================*\
 *                                                                           *
 *                              OpenFlipper                                  *
Jan Möbius's avatar
Jan Möbius committed
4
5
6
7
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
Jan Möbius's avatar
Jan Möbius committed
8
9
 *                                                                           *
 *---------------------------------------------------------------------------*
Jan Möbius's avatar
Jan Möbius committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
40
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
   
Jan Möbius committed
41

Jan Möbius's avatar
Jan Möbius committed
42
43
/*===========================================================================*\
 *                                                                           *
Jan Möbius's avatar
Jan Möbius committed
44
 *   $Revision$                                                       *
Jan Möbius's avatar
Jan Möbius committed
45
46
47
48
 *   $Author$                                                      *
 *   $Date$                   *
 *                                                                           *
\*===========================================================================*/
Jan Möbius's avatar
   
Jan Möbius committed
49
50
51
52
53
54
55
56
57
58
59
60
61


//=============================================================================
//  overload some GL functions
//=============================================================================


#ifndef ACG_GLTEXT_HH
#define ACG_GLTEXT_HH


//== INCLUDES =================================================================

Jan Möbius's avatar
Jan Möbius committed
62
63
64
#include <ACG/Config/ACGDefines.hh>


Jan Möbius's avatar
   
Jan Möbius committed
65
66
67
#if defined(ARCH_DARWIN)

  #include <glut.h>
Jan Möbius's avatar
Jan Möbius committed
68
  #include <OpenGL/gl.h>
Jan Möbius's avatar
   
Jan Möbius committed
69
70
71

#elif defined(WIN32)

schultz's avatar
schultz committed
72
  #include "acg_glew.hh"
Jan Möbius's avatar
   
Jan Möbius committed
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
  #include <windows.h>
  #include <gl/glut.h>

#else

  #include <GL/glut.h>
  #include <GL/gl.h>

#endif

#include "../Math/VectorT.hh"


//=============================================================================
namespace ACG {
//=============================================================================


//-------------------------------------------------------------------- glVertex

/// Wrapper: glVertex for Vec2i
inline void glVertex(const Vec2i& _v)  { glVertex2i(_v[0], _v[1]); }
/// Wrapper: glVertex for Vec2f
inline void glVertex(const Vec2f& _v)  { glVertex2fv(_v.data()); }
/// Wrapper: glVertex for Vec2d
inline void glVertex(const Vec2d& _v)  { glVertex2dv(_v.data()); }

/// Wrapper: glVertex for Vec3f
inline void glVertex(const Vec3f& _v)  { glVertex3fv(_v.data()); }
/// Wrapper: glVertex for Vec3d
inline void glVertex(const Vec3d& _v)  { glVertex3dv(_v.data()); }

/// Wrapper: glVertex for Vec4f
inline void glVertex(const Vec4f& _v)  { glVertex4fv(_v.data()); }
/// Wrapper: glVertex for Vec4d
inline void glVertex(const Vec4d& _v)  { glVertex4dv(_v.data()); }



//------------------------------------------------------------------- glTexCoord

/// Wrapper: glTexCoord for Vec2f
inline void glTexCoord(const Vec2f& _t) { glTexCoord2fv(_t.data()); }
/// Wrapper: glTexCoord for Vec2d
inline void glTexCoord(const Vec2d& _t) { glTexCoord2dv(_t.data()); }

/// Wrapper: glTexCoord for Vec3f
inline void glTexCoord(const Vec3f& _t) { glTexCoord3fv(_t.data()); }
/// Wrapper: glTexCoord for Vec3d
inline void glTexCoord(const Vec3d& _t) { glTexCoord3dv(_t.data()); }

/// Wrapper: glTexCoord for Vec4f
inline void glTexCoord(const Vec4f& _t) { glTexCoord4fv(_t.data()); }
/// Wrapper: glTexCoord for Vec4d
inline void glTexCoord(const Vec4d& _t) { glTexCoord4dv(_t.data()); }



//--------------------------------------------------------------------- glNormal

/// Wrapper: glNormal for Vec3f
inline void glNormal(const Vec3f& _n)  { glNormal3fv(_n.data()); }
/// Wrapper: glNormal for Vec3d
inline void glNormal(const Vec3d& _n)  { glNormal3dv(_n.data()); }



//---------------------------------------------------------------------- glColor

/// Wrapper: glColor for Vec3f
inline void glColor(const Vec3f&  _v)  { glColor3fv(_v.data()); }
/// Wrapper: glColor for Vec3uc
inline void glColor(const Vec3uc& _v)  { glColor3ubv(_v.data()); }

/// Wrapper: glColor for Vec4f
inline void glColor(const Vec4f&  _v)  { glColor4fv(_v.data()); }
/// Wrapper: glColor for Vec4uc
inline void glColor(const Vec4uc&  _v) { glColor4ubv(_v.data()); }



154
155
156
//-------------------------------------------------------------- ACG::GLState::vertexPointer
/*
/// Wrapper: ACG::GLState::vertexPointer for Vec2f
Jan Möbius's avatar
   
Jan Möbius committed
157
inline void glVertexPointer(const Vec2f* _p)
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{ ::ACG::GLState::vertexPointer(2, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec2d
inline void ACG::GLState::vertexPointer(const Vec2d* _p)
{ ::ACG::GLState::vertexPointer(2, GL_DOUBLE, 0, _p); }

/// Wrapper: ACG::GLState::vertexPointer for Vec3f
inline void ACG::GLState::vertexPointer(const Vec3f* _p)
{ ::ACG::GLState::vertexPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec3d
inline void ACG::GLState::vertexPointer(const Vec3d* _p)
{ ::ACG::GLState::vertexPointer(3, GL_DOUBLE, 0, _p); }

/// Wrapper: ACG::GLState::vertexPointer for Vec4f
inline void ACG::GLState::vertexPointer(const Vec4f* _p)
{ ::ACG::GLState::vertexPointer(4, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::vertexPointer for Vec4d
inline void ACG::GLState::vertexPointer(const Vec4d* _p)
{ ::ACG::GLState::vertexPointer(4, GL_DOUBLE, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
176
177

/// original method
178
179
inline void ACG::GLState::vertexPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::vertexPointer(n, t, s, p); }
Jan Möbius's avatar
   
Jan Möbius committed
180
181
182



183
//-------------------------------------------------------------- ACG::GLState::normalPointer
Jan Möbius's avatar
   
Jan Möbius committed
184

185
186
187
188
189
190
/// Wrapper: ACG::GLState::normalPointer for Vec3f
inline void ACG::GLState::normalPointer(const Vec3f* _p)
{ ::ACG::GLState::normalPointer(GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::normalPointer for Vec3d
inline void ACG::GLState::normalPointer(const Vec3d* _p)
{ ::ACG::GLState::normalPointer(GL_DOUBLE, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
191
192

/// original method
193
194
inline void ACG::GLState::normalPointer(GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::normalPointer(t, s, p); }
Jan Möbius's avatar
   
Jan Möbius committed
195
196
197



198
//--------------------------------------------------------------- ACG::GLState::colorPointer
Jan Möbius's avatar
   
Jan Möbius committed
199

200
201
202
203
204
205
/// Wrapper: ACG::GLState::colorPointer for Vec3uc
inline void ACG::GLState::colorPointer(const Vec3uc* _p)
{ ::ACG::GLState::colorPointer(3, GL_UNSIGNED_BYTE, 0, _p); }
/// Wrapper: ACG::GLState::colorPointer for Vec3f
inline void ACG::GLState::colorPointer(const Vec3f* _p)
{ ::ACG::GLState::colorPointer(3, GL_FLOAT, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
206

207
208
209
210
211
212
/// Wrapper: ACG::GLState::colorPointer for Vec4uc
inline void ACG::GLState::colorPointer(const Vec4uc* _p)
{ ::ACG::GLState::colorPointer(4, GL_UNSIGNED_BYTE, 0, _p); }
/// Wrapper: ACG::GLState::colorPointer for Vec4f
inline void ACG::GLState::colorPointer(const Vec4f* _p)
{ ::ACG::GLState::colorPointer(4, GL_FLOAT, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
213
214

/// original method
215
216
inline void ACG::GLState::colorPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::colorPointer(n, t, s, p); }
Jan Möbius's avatar
   
Jan Möbius committed
217
218
219



220
//------------------------------------------------------------ ACG::GLState::texcoordPointer
Jan Möbius's avatar
   
Jan Möbius committed
221

222
223
224
225
226
227
/// Wrapper: ACG::GLState::texcoordPointer for float
inline void ACG::GLState::texcoordPointer(const float* _p)
{ ::ACG::GLState::texcoordPointer(1, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec2d
inline void ACG::GLState::texcoordPointer(const double* _p)
{ ::ACG::GLState::texcoordPointer(1, GL_DOUBLE, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
228

229
230
231
232
233
234
/// Wrapper: ACG::GLState::texcoordPointer for Vec2f
inline void ACG::GLState::texcoordPointer(const Vec2f* _p)
{ ::ACG::GLState::texcoordPointer(2, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec2d
inline void ACG::GLState::texcoordPointer(const Vec2d* _p)
{ ::ACG::GLState::texcoordPointer(2, GL_DOUBLE, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
235

236
237
238
239
240
241
/// Wrapper: ACG::GLState::texcoordPointer for Vec3f
inline void ACG::GLState::texcoordPointer(const Vec3f* _p)
{ ::ACG::GLState::texcoordPointer(3, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec3d
inline void ACG::GLState::texcoordPointer(const Vec3d* _p)
{ ::ACG::GLState::texcoordPointer(3, GL_DOUBLE, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
242

243
244
245
246
247
248
/// Wrapper: ACG::GLState::texcoordPointer for Vec4f
inline void ACG::GLState::texcoordPointer(const Vec4f* _p)
{ ::ACG::GLState::texcoordPointer(4, GL_FLOAT, 0, _p); }
/// Wrapper: ACG::GLState::texcoordPointer for Vec4d
inline void ACG::GLState::texcoordPointer(const Vec4d* _p)
{ ::ACG::GLState::texcoordPointer(4, GL_DOUBLE, 0, _p); }
Jan Möbius's avatar
   
Jan Möbius committed
249
250

/// original method
251
252
253
inline void ACG::GLState::texcoordPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
{ ::ACG::GLState::texcoordPointer(n, t, s, p); }
*/
Jan Möbius's avatar
   
Jan Möbius committed
254
255


256
257
/** Check if the extension given by a std::string is supported by the current OpenGL extension
*/
Jan Möbius's avatar
Jan Möbius committed
258
bool ACGDLLEXPORT checkExtensionSupported( const std::string& _extension ) ;
259

260
261
/** Check if OpenGL Version is greater or equal than the given values
*/
Jan Möbius's avatar
Jan Möbius committed
262
bool ACGDLLEXPORT openGLVersion( const int _major, const int _minor  );
263

Jan Möbius's avatar
   
Jan Möbius committed
264
265
266
267
268
269

//=============================================================================
}  // namespace ACG
//=============================================================================
#endif // ACG_GLTEXT_HH defined
//=============================================================================