type_half.hpp

Go to the documentation of this file.
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 
00028 
00029 #ifndef glm_core_type_half
00030 #define glm_core_type_half
00031 
00032 #include <cstdlib>
00033 
00034 namespace glm{
00035 namespace detail
00036 {
00037         typedef short hdata;
00038 
00039         float toFloat32(hdata value);
00040         hdata toFloat16(float const & value);
00041 
00044         class thalf
00045         {
00046         public: 
00047                 // Constructors
00048                 GLM_FUNC_DECL thalf();
00049                 GLM_FUNC_DECL thalf(thalf const & s);
00050                         
00051                 template <typename U>
00052                 GLM_FUNC_DECL explicit thalf(U const & s);
00053 
00054                 // Cast
00055                 template <typename U>
00056                 GLM_FUNC_DECL operator U() const;
00057 
00058                 // Unary updatable operators
00059                 GLM_FUNC_DECL thalf& operator= (thalf const & s);
00060                 GLM_FUNC_DECL thalf& operator+=(thalf const & s);
00061                 GLM_FUNC_DECL thalf& operator-=(thalf const & s);
00062                 GLM_FUNC_DECL thalf& operator*=(thalf const & s);
00063                 GLM_FUNC_DECL thalf& operator/=(thalf const & s);
00064                 GLM_FUNC_DECL thalf& operator++();
00065                 GLM_FUNC_DECL thalf& operator--();
00066         
00067                 GLM_FUNC_DECL float toFloat() const{return toFloat32(data);}
00068 
00069                 GLM_FUNC_DECL hdata _data() const{return data;}
00070 
00071         private:
00072                 hdata data;
00073         };
00074 
00075         thalf operator+ (thalf const & s1, thalf const & s2);
00076 
00077         thalf operator- (thalf const & s1, thalf const & s2);
00078 
00079         thalf operator* (thalf const & s1, thalf const & s2);
00080 
00081         thalf operator/ (thalf const & s1, thalf const & s2);
00082 
00083         // Unary constant operators
00084         thalf operator- (thalf const & s);
00085 
00086         thalf operator-- (thalf const & s, int);
00087 
00088         thalf operator++ (thalf const & s, int);
00089 
00090         bool operator==(
00091                 detail::thalf const & x, 
00092                 detail::thalf const & y);
00093 
00094         bool operator!=(
00095                 detail::thalf const & x, 
00096                 detail::thalf const & y);
00097 
00098         bool operator<(
00099                 detail::thalf const & x, 
00100                 detail::thalf const & y);
00101 
00102         bool operator<=(
00103                 detail::thalf const & x, 
00104                 detail::thalf const & y);
00105 
00106         bool operator>(
00107                 detail::thalf const & x, 
00108                 detail::thalf const & y);
00109 
00110         bool operator>=(
00111                 detail::thalf const & x, 
00112                 detail::thalf const & y);
00113 
00114 }//namespace detail
00115 }//namespace glm
00116 
00117 #include "type_half.inl"
00118 
00119 #endif//glm_core_type_half