gl.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8521 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2010-02-10 15:57:35 +0100 (Mi, 10. Feb 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 //=============================================================================
00045 //  overload some GL functions
00046 //=============================================================================
00047 
00048 
00049 #ifndef ACG_GLTEXT_HH
00050 #define ACG_GLTEXT_HH
00051 
00052 
00053 //== INCLUDES =================================================================
00054 
00055 #include <stdlib.h>
00056 
00057 
00058 #if defined(ARCH_DARWIN)
00059 
00060   #include <GL/glew.h>
00061   #include <glut.h>
00062   #include <OpenGL/gl.h>
00063   #include <OpenGL/glu.h>
00064 
00065 #elif defined(WIN32)
00066 
00067   #include <windows.h>
00068   // Dont do this anymore! Use dll version. No problems with plugins and dll
00069   // but a lot with static linking
00070   // #  define GLEW_STATIC 1
00071   #include <gl/glew.h>
00072   #include <gl/glut.h>
00073 
00074 #else
00075 
00076   #include <GL/glew.h>
00077   #include <GL/glut.h>
00078   #include <GL/gl.h>
00079   #include <GL/glu.h>
00080 
00081 #endif
00082 
00083 #include "../Math/VectorT.hh"
00084 
00085 
00086 //=============================================================================
00087 namespace ACG {
00088 //=============================================================================
00089 
00090 
00091 //-------------------------------------------------------------------- glVertex
00092 
00094 inline void glVertex(const Vec2i& _v)  { glVertex2i(_v[0], _v[1]); }
00096 inline void glVertex(const Vec2f& _v)  { glVertex2fv(_v.data()); }
00098 inline void glVertex(const Vec2d& _v)  { glVertex2dv(_v.data()); }
00099 
00101 inline void glVertex(const Vec3f& _v)  { glVertex3fv(_v.data()); }
00103 inline void glVertex(const Vec3d& _v)  { glVertex3dv(_v.data()); }
00104 
00106 inline void glVertex(const Vec4f& _v)  { glVertex4fv(_v.data()); }
00108 inline void glVertex(const Vec4d& _v)  { glVertex4dv(_v.data()); }
00109 
00110 
00111 
00112 //------------------------------------------------------------------- glTexCoord
00113 
00115 inline void glTexCoord(const Vec2f& _t) { glTexCoord2fv(_t.data()); }
00117 inline void glTexCoord(const Vec2d& _t) { glTexCoord2dv(_t.data()); }
00118 
00120 inline void glTexCoord(const Vec3f& _t) { glTexCoord3fv(_t.data()); }
00122 inline void glTexCoord(const Vec3d& _t) { glTexCoord3dv(_t.data()); }
00123 
00125 inline void glTexCoord(const Vec4f& _t) { glTexCoord4fv(_t.data()); }
00127 inline void glTexCoord(const Vec4d& _t) { glTexCoord4dv(_t.data()); }
00128 
00129 
00130 
00131 //--------------------------------------------------------------------- glNormal
00132 
00134 inline void glNormal(const Vec3f& _n)  { glNormal3fv(_n.data()); }
00136 inline void glNormal(const Vec3d& _n)  { glNormal3dv(_n.data()); }
00137 
00138 
00139 
00140 //---------------------------------------------------------------------- glColor
00141 
00143 inline void glColor(const Vec3f&  _v)  { glColor3fv(_v.data()); }
00145 inline void glColor(const Vec3uc& _v)  { glColor3ubv(_v.data()); }
00146 
00148 inline void glColor(const Vec4f&  _v)  { glColor4fv(_v.data()); }
00150 inline void glColor(const Vec4uc&  _v) { glColor4ubv(_v.data()); }
00151 
00152 
00153 
00154 //-------------------------------------------------------------- glVertexPointer
00155 
00157 inline void glVertexPointer(const Vec2f* _p)
00158 { ::glVertexPointer(2, GL_FLOAT, 0, _p); }
00160 inline void glVertexPointer(const Vec2d* _p)
00161 { ::glVertexPointer(2, GL_DOUBLE, 0, _p); }
00162 
00164 inline void glVertexPointer(const Vec3f* _p)
00165 { ::glVertexPointer(3, GL_FLOAT, 0, _p); }
00167 inline void glVertexPointer(const Vec3d* _p)
00168 { ::glVertexPointer(3, GL_DOUBLE, 0, _p); }
00169 
00171 inline void glVertexPointer(const Vec4f* _p)
00172 { ::glVertexPointer(4, GL_FLOAT, 0, _p); }
00174 inline void glVertexPointer(const Vec4d* _p)
00175 { ::glVertexPointer(4, GL_DOUBLE, 0, _p); }
00176 
00178 inline void glVertexPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
00179 { ::glVertexPointer(n, t, s, p); }
00180 
00181 
00182 
00183 //-------------------------------------------------------------- glNormalPointer
00184 
00186 inline void glNormalPointer(const Vec3f* _p)
00187 { ::glNormalPointer(GL_FLOAT, 0, _p); }
00189 inline void glNormalPointer(const Vec3d* _p)
00190 { ::glNormalPointer(GL_DOUBLE, 0, _p); }
00191 
00193 inline void glNormalPointer(GLenum t, GLsizei s, const GLvoid *p)
00194 { ::glNormalPointer(t, s, p); }
00195 
00196 
00197 
00198 //--------------------------------------------------------------- glColorPointer
00199 
00201 inline void glColorPointer(const Vec3uc* _p)
00202 { ::glColorPointer(3, GL_UNSIGNED_BYTE, 0, _p); }
00204 inline void glColorPointer(const Vec3f* _p)
00205 { ::glColorPointer(3, GL_FLOAT, 0, _p); }
00206 
00208 inline void glColorPointer(const Vec4uc* _p)
00209 { ::glColorPointer(4, GL_UNSIGNED_BYTE, 0, _p); }
00211 inline void glColorPointer(const Vec4f* _p)
00212 { ::glColorPointer(4, GL_FLOAT, 0, _p); }
00213 
00215 inline void glColorPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
00216 { ::glColorPointer(n, t, s, p); }
00217 
00218 
00219 
00220 //------------------------------------------------------------ glTexCoordPointer
00221 
00223 inline void glTexCoordPointer(const float* _p)
00224 { ::glTexCoordPointer(1, GL_FLOAT, 0, _p); }
00226 inline void glTexCoordPointer(const double* _p)
00227 { ::glTexCoordPointer(1, GL_DOUBLE, 0, _p); }
00228 
00230 inline void glTexCoordPointer(const Vec2f* _p)
00231 { ::glTexCoordPointer(2, GL_FLOAT, 0, _p); }
00233 inline void glTexCoordPointer(const Vec2d* _p)
00234 { ::glTexCoordPointer(2, GL_DOUBLE, 0, _p); }
00235 
00237 inline void glTexCoordPointer(const Vec3f* _p)
00238 { ::glTexCoordPointer(3, GL_FLOAT, 0, _p); }
00240 inline void glTexCoordPointer(const Vec3d* _p)
00241 { ::glTexCoordPointer(3, GL_DOUBLE, 0, _p); }
00242 
00244 inline void glTexCoordPointer(const Vec4f* _p)
00245 { ::glTexCoordPointer(4, GL_FLOAT, 0, _p); }
00247 inline void glTexCoordPointer(const Vec4d* _p)
00248 { ::glTexCoordPointer(4, GL_DOUBLE, 0, _p); }
00249 
00251 inline void glTexCoordPointer(GLint n, GLenum t, GLsizei s, const GLvoid *p)
00252 { ::glTexCoordPointer(n, t, s, p); }
00253 
00254 
00255 
00256 //-----------------------------------------------------------------------------
00257 
00258 
00262 inline void glCheckErrors()
00263 {
00264   GLenum error;
00265   while ((error = glGetError()) != GL_NO_ERROR)
00266   {
00267     std::cerr << "GL error: " << gluErrorString(error) << std::endl;
00268   }
00269 }
00270 
00271 
00272 //=============================================================================
00273 }  // namespace ACG
00274 //=============================================================================
00275 #endif // ACG_GLTEXT_HH defined
00276 //=============================================================================

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .