OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WGETYPETRAITS_H 00026 #define WGETYPETRAITS_H 00027 00028 #include <stdint.h> 00029 00030 #include <osg/Image> 00031 00032 00033 00034 namespace wge 00035 { 00036 /** 00037 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00038 */ 00039 template< typename T > 00040 class GLType 00041 { 00042 public: 00043 /** 00044 * The best matching OpenGL type for the specified template parameter. 00045 */ 00046 typedef T Type; 00047 00048 /** 00049 * The enum type of OpenGL 00050 */ 00051 static const GLenum TypeEnum = GL_BYTE; 00052 }; 00053 00054 /** 00055 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00056 */ 00057 template <> 00058 class GLType< double > 00059 { 00060 public: 00061 /** 00062 * The best matching OpenGL type for the specified template parameter. 00063 */ 00064 typedef float Type; 00065 00066 /** 00067 * The enum type of OpenGL 00068 */ 00069 static const GLenum TypeEnum = GL_FLOAT; 00070 00071 /** 00072 * The value for full intensity. 00073 * 00074 * \return the full intensity value 00075 */ 00076 static Type FullIntensity(){ return 1.0; } // NOLINT 00077 }; 00078 00079 00080 /** 00081 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00082 */ 00083 template <> 00084 class GLType< long double > 00085 { 00086 public: 00087 /** 00088 * The best matching OpenGL type for the specified template parameter. 00089 */ 00090 typedef float Type; 00091 00092 /** 00093 * The enum type of OpenGL 00094 */ 00095 static const GLenum TypeEnum = GL_FLOAT; 00096 00097 /** 00098 * The value for full intensity. 00099 * 00100 * \return the full intensity value 00101 */ 00102 static Type FullIntensity(){ return 1.0; } // NOLINT 00103 }; 00104 00105 /** 00106 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00107 */ 00108 template <> 00109 class GLType< float > 00110 { 00111 public: 00112 /** 00113 * The best matching OpenGL type for the specified template parameter. 00114 */ 00115 typedef float Type; 00116 00117 /** 00118 * The enum type of OpenGL 00119 */ 00120 static const GLenum TypeEnum = GL_FLOAT; 00121 00122 /** 00123 * The value for full intensity. 00124 * 00125 * \return the full intensity value 00126 */ 00127 static Type FullIntensity(){ return 1.0; } // NOLINT 00128 }; 00129 00130 /** 00131 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00132 */ 00133 template <> 00134 class GLType< int8_t > 00135 { 00136 public: 00137 /** 00138 * The best matching OpenGL type for the specified template parameter. 00139 */ 00140 typedef int8_t Type; 00141 00142 /** 00143 * The enum type of OpenGL 00144 */ 00145 static const GLenum TypeEnum = GL_BYTE; 00146 00147 /** 00148 * The value for full intensity. 00149 * 00150 * \return the full intensity value 00151 */ 00152 static Type FullIntensity(){ return 127; } // NOLINT 00153 }; 00154 00155 /** 00156 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00157 */ 00158 template <> 00159 class GLType< uint8_t > 00160 { 00161 public: 00162 /** 00163 * The best matching OpenGL type for the specified template parameter. 00164 */ 00165 typedef uint8_t Type; 00166 00167 /** 00168 * The enum type of OpenGL 00169 */ 00170 static const GLenum TypeEnum = GL_UNSIGNED_BYTE; 00171 00172 /** 00173 * The value for full intensity. 00174 * 00175 * \return the full intensity value 00176 */ 00177 static Type FullIntensity(){ return 255; } // NOLINT 00178 }; 00179 00180 /** 00181 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00182 * 00183 * \note integral types get downscaled to float. This is done for easiness but might be better if the real type is used instead. 00184 */ 00185 template <> 00186 class GLType< int16_t > 00187 { 00188 public: 00189 /** 00190 * The best matching OpenGL type for the specified template parameter. 00191 */ 00192 typedef float Type; 00193 00194 /** 00195 * The enum type of OpenGL 00196 */ 00197 static const GLenum TypeEnum = GL_FLOAT; 00198 00199 /** 00200 * The value for full intensity. 00201 * 00202 * \return the full intensity value 00203 */ 00204 static Type FullIntensity(){ return 1.0; } // NOLINT 00205 }; 00206 00207 /** 00208 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00209 * 00210 * \note integral types get downscaled to float. This is done for easiness but might be better if the real type is used instead. 00211 */ 00212 template <> 00213 class GLType< uint16_t > 00214 { 00215 public: 00216 /** 00217 * The best matching OpenGL type for the specified template parameter. 00218 */ 00219 typedef float Type; 00220 00221 /** 00222 * The enum type of OpenGL 00223 */ 00224 static const GLenum TypeEnum = GL_FLOAT; 00225 00226 /** 00227 * The value for full intensity. 00228 * 00229 * \return the full intensity value 00230 */ 00231 static Type FullIntensity(){ return 1.0; } // NOLINT 00232 }; 00233 00234 /** 00235 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00236 * 00237 * \note integral types get downscaled to float. This is done for easiness but might be better if the real type is used instead. 00238 */ 00239 template <> 00240 class GLType< int32_t > 00241 { 00242 public: 00243 /** 00244 * The best matching OpenGL type for the specified template parameter. 00245 */ 00246 typedef float Type; 00247 00248 /** 00249 * The enum type of OpenGL 00250 */ 00251 static const GLenum TypeEnum = GL_FLOAT; 00252 00253 /** 00254 * The value for full intensity. 00255 * 00256 * \return the full intensity value 00257 */ 00258 static Type FullIntensity(){ return 1.0; } // NOLINT 00259 }; 00260 00261 /** 00262 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00263 * 00264 * \note integral types get downscaled to float. This is done for easiness but might be better if the real type is used instead. 00265 */ 00266 template <> 00267 class GLType< uint32_t > 00268 { 00269 public: 00270 /** 00271 * The best matching OpenGL type for the specified template parameter. 00272 */ 00273 typedef float Type; 00274 00275 /** 00276 * The enum type of OpenGL 00277 */ 00278 static const GLenum TypeEnum = GL_FLOAT; 00279 00280 /** 00281 * The value for full intensity. 00282 * 00283 * \return the full intensity value 00284 */ 00285 static Type FullIntensity(){ return 1.0; } // NOLINT 00286 }; 00287 00288 /** 00289 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00290 * 00291 * \note integral types get downscaled to float. This is done for easiness but might be better if the real type is used instead. 00292 */ 00293 template <> 00294 class GLType< int64_t > 00295 { 00296 public: 00297 /** 00298 * The best matching OpenGL type for the specified template parameter. 00299 */ 00300 typedef float Type; 00301 00302 /** 00303 * The enum type of OpenGL 00304 */ 00305 static const GLenum TypeEnum = GL_FLOAT; 00306 00307 /** 00308 * The value for full intensity. 00309 * 00310 * \return the full intensity value 00311 */ 00312 static Type FullIntensity(){ return 1.0; } // NOLINT 00313 }; 00314 00315 /** 00316 * Class helping to adapt types specified as template parameter into the best matching OpenGL type. 00317 * 00318 * \note integral types get downscaled to float. This is done for easiness but might be better if the real type is used instead. 00319 */ 00320 template <> 00321 class GLType< uint64_t > 00322 { 00323 public: 00324 /** 00325 * The best matching OpenGL type for the specified template parameter. 00326 */ 00327 typedef float Type; 00328 00329 /** 00330 * The enum type of OpenGL 00331 */ 00332 static const GLenum TypeEnum = GL_FLOAT; 00333 00334 /** 00335 * The value for full intensity. 00336 * 00337 * \return the full intensity value 00338 */ 00339 static Type FullIntensity(){ return 1.0; } // NOLINT 00340 }; 00341 } 00342 00343 #endif // WGETYPETRAITS_H 00344