type_half.hpp
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 namespace detail
00017 {
00018         typedef short hdata;
00019 
00020         float toFloat32(hdata value);
00021         hdata toFloat16(float const & value);
00022 
00025         class thalf
00026         {
00027         public: 
00028                 // Constructors
00029                 GLM_FUNC_DECL thalf();
00030                 GLM_FUNC_DECL thalf(thalf const & s);
00031                         
00032                 template <typename U>
00033                 GLM_FUNC_DECL explicit thalf(U const & s);
00034 
00035                 // Cast
00036                 //operator float();
00037                 GLM_FUNC_DECL operator float() const;
00038                 //operator double();
00039                 //operator double() const;
00040 
00041                 // Unary updatable operators
00042                 GLM_FUNC_DECL thalf& operator= (thalf const & s);
00043                 GLM_FUNC_DECL thalf& operator+=(thalf const & s);
00044                 GLM_FUNC_DECL thalf& operator-=(thalf const & s);
00045                 GLM_FUNC_DECL thalf& operator*=(thalf const & s);
00046                 GLM_FUNC_DECL thalf& operator/=(thalf const & s);
00047                 GLM_FUNC_DECL thalf& operator++();
00048                 GLM_FUNC_DECL thalf& operator--();
00049         
00050                 GLM_FUNC_DECL float toFloat() const{return toFloat32(data);}
00051 
00052                 GLM_FUNC_DECL hdata _data() const{return data;}
00053 
00054         private:
00055                 hdata data;
00056         };
00057 
00058         thalf operator+ (thalf const & s1, thalf const & s2);
00059 
00060         thalf operator- (thalf const & s1, thalf const & s2);
00061 
00062         thalf operator* (thalf const & s1, thalf const & s2);
00063 
00064         thalf operator/ (thalf const & s1, thalf const & s2);
00065 
00066         // Unary constant operators
00067         thalf operator- (thalf const & s);
00068 
00069         thalf operator-- (thalf const & s, int);
00070 
00071         thalf operator++ (thalf const & s, int);
00072 
00073 }//namespace detail
00074 }//namespace glm
00075 
00076 #include "type_half.inl"
00077 
00078 #endif//glm_core_type_half