GLM Version 0.9.0
|
00001 00002 // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net) 00004 // Created : 2008-08-17 00005 // Updated : 2010-02-17 00006 // Licence : This source is under MIT License 00007 // File : glm/core/type_half.hpp 00009 00010 #ifndef glm_core_type_half 00011 #define glm_core_type_half 00012 00013 #include <cstdlib> 00014 00015 namespace glm 00016 { 00017 namespace test 00018 { 00019 bool main_type_half(); 00020 00021 }//namespace test 00022 00023 namespace detail 00024 { 00025 typedef short hdata; 00026 00027 float toFloat32(hdata value); 00028 hdata toFloat16(float const & value); 00029 00030 class thalf 00031 { 00032 public: 00033 // Constructors 00034 thalf(); 00035 thalf(thalf const & s); 00036 00037 template <typename U> 00038 explicit thalf(U const & s); 00039 00040 // Cast 00041 //operator float(); 00042 operator float() const; 00043 //operator double(); 00044 //operator double() const; 00045 00046 // Unary updatable operators 00047 thalf& operator= (thalf const & s); 00048 thalf& operator+=(thalf const & s); 00049 thalf& operator-=(thalf const & s); 00050 thalf& operator*=(thalf const & s); 00051 thalf& operator/=(thalf const & s); 00052 thalf& operator++(); 00053 thalf& operator--(); 00054 00055 float toFloat() const{return toFloat32(data);} 00056 00057 hdata _data() const{return data;} 00058 00059 private: 00060 hdata data; 00061 }; 00062 00063 thalf operator+ (thalf const & s1, thalf const & s2); 00064 00065 thalf operator- (thalf const & s1, thalf const & s2); 00066 00067 thalf operator* (thalf const & s1, thalf const & s2); 00068 00069 thalf operator/ (thalf const & s1, thalf const & s2); 00070 00071 // Unary constant operators 00072 thalf operator- (thalf const & s); 00073 00074 thalf operator-- (thalf const & s, int); 00075 00076 thalf operator++ (thalf const & s, int); 00077 00078 }//namespace detail 00079 00080 00081 }//namespace glm 00082 00083 #include "type_half.inl" 00084 00085 #endif//glm_core_type_half