00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef SOFA_HELPER_GL_TEMPLATE_H
00028 #define SOFA_HELPER_GL_TEMPLATE_H
00029
00030 #include <sofa/helper/system/gl.h>
00031
00032 namespace sofa
00033 {
00034
00035 namespace helper
00036 {
00037
00038 namespace gl
00039 {
00040
00041 template<int N>
00042 inline void glVertexNv(const float* p)
00043 {
00044 glVertex3f(p[0],p[1],p[2]);
00045 }
00046
00047 template<>
00048 inline void glVertexNv<2>(const float* p)
00049 {
00050 glVertex2f(p[0],p[1]);
00051 }
00052
00053 template<>
00054 inline void glVertexNv<1>(const float* p)
00055 {
00056 glVertex2f(p[0],0.0f);
00057 }
00058
00059 template<int N>
00060 inline void glVertexNv(const double* p)
00061 {
00062 glVertex3d(p[0],p[1],p[2]);
00063 }
00064
00065 template<>
00066 inline void glVertexNv<2>(const double* p)
00067 {
00068 glVertex2d(p[0],p[1]);
00069 }
00070
00071 template<>
00072 inline void glVertexNv<1>(const double* p)
00073 {
00074 glVertex2d(p[0],0.0);
00075 }
00076
00077 template<class Coord>
00078 inline void glVertexT(const Coord& c)
00079 {
00080 glVertexNv<Coord::static_size>(c.ptr());
00081 }
00082
00083 template<>
00084 inline void glVertexT<double>(const double& c)
00085 {
00086 glVertex3d(c,0.0,0.0);
00087 }
00088
00089 template<>
00090 inline void glVertexT<float>(const float& c)
00091 {
00092 glVertex3f(c,0.0f,0.0f);
00093 }
00094
00095
00096
00097
00098 template<int N>
00099 inline void glNormalNv(const float* p)
00100 {
00101 glNormal3f(p[0],p[1],p[2]);
00102 }
00103
00104 template<>
00105 inline void glNormalNv<2>(const float* p)
00106 {
00107 glNormal3f(p[0],p[1],0.0f);
00108 }
00109
00110 template<>
00111 inline void glNormalNv<1>(const float* p)
00112 {
00113 glNormal3f(p[0],0.0f,0.0f);
00114 }
00115
00116 template<int N>
00117 inline void glNormalNv(const double* p)
00118 {
00119 glNormal3d(p[0],p[1],p[2]);
00120 }
00121
00122 template<>
00123 inline void glNormalNv<2>(const double* p)
00124 {
00125 glNormal3d(p[0],p[1],0.0);
00126 }
00127
00128 template<>
00129 inline void glNormalNv<1>(const double* p)
00130 {
00131 glNormal3d(p[0],0.0,0.0);
00132 }
00133
00134 template<class Coord>
00135 inline void glNormalT(const Coord& c)
00136 {
00137 glNormalNv<Coord::static_size>(c.ptr());
00138 }
00139
00140 template<>
00141 inline void glNormalT<double>(const double& c)
00142 {
00143 glNormal3d(c,0.0,0.0);
00144 }
00145
00146 template<>
00147 inline void glNormalT<float>(const float& c)
00148 {
00149 glNormal3f(c,0.0f,0.0f);
00150 }
00152 inline void glTranslate(const float& c1, const float& c2, const float& c3)
00153 {
00154 glTranslatef(c1, c2, c3);
00155 }
00156
00157 inline void glTranslate(const double& c1, const double& c2, const double& c3)
00158 {
00159 glTranslated(c1, c2, c3);
00160 }
00161
00162 inline void glScale(const float& c1, const float& c2, const float& c3)
00163 {
00164 glScalef(c1, c2, c3);
00165 }
00166
00167 inline void glScale(const double& c1, const double& c2, const double& c3)
00168 {
00169 glScaled(c1, c2, c3);
00170 }
00171
00172 inline void glRotate(const GLfloat &value, const float& c1, const float& c2, const float& c3)
00173 {
00174 glRotatef(value, c1, c2, c3);
00175 }
00176
00177 inline void glRotate(const GLdouble &value, const double& c1, const double& c2, const double& c3)
00178 {
00179 glRotated(value, c1, c2, c3);
00180 }
00181
00182 inline void glMultMatrix(const float* p)
00183 {
00184 glMultMatrixf(p);
00185 }
00186
00187 inline void glMultMatrix(const double* p)
00188 {
00189 glMultMatrixd(p);
00190 }
00191
00192
00193
00194 }
00195
00196 }
00197
00198 }
00199
00200 #endif