summaryrefslogtreecommitdiff
path: root/src/glm/core/type_half.hpp
blob: b6bcd48804c6c667850c9e08c53270032e90e833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-08-17
// Updated : 2010-02-17
// Licence : This source is under MIT License
// File    : glm/core/type_half.hpp
///////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef glm_core_type_half
#define glm_core_type_half

#include <cstdlib>

namespace glm{
namespace detail
{
	typedef short hdata;

	float toFloat32(hdata value);
	hdata toFloat16(float const & value);

	///16-bit floating point type.
	/// \ingroup gtc_half_float
	class thalf
	{
	public: 
		// Constructors
		GLM_FUNC_DECL thalf();
		GLM_FUNC_DECL thalf(thalf const & s);
			
		template <typename U>
		GLM_FUNC_DECL explicit thalf(U const & s);

		// Cast
		//operator float();
		GLM_FUNC_DECL operator float() const;
		//operator double();
		//operator double() const;

		// Unary updatable operators
		GLM_FUNC_DECL thalf& operator= (thalf const & s);
		GLM_FUNC_DECL thalf& operator+=(thalf const & s);
		GLM_FUNC_DECL thalf& operator-=(thalf const & s);
		GLM_FUNC_DECL thalf& operator*=(thalf const & s);
		GLM_FUNC_DECL thalf& operator/=(thalf const & s);
		GLM_FUNC_DECL thalf& operator++();
		GLM_FUNC_DECL thalf& operator--();
	
		GLM_FUNC_DECL float toFloat() const{return toFloat32(data);}

		GLM_FUNC_DECL hdata _data() const{return data;}

	private:
		hdata data;
	};

	thalf operator+ (thalf const & s1, thalf const & s2);

	thalf operator- (thalf const & s1, thalf const & s2);

	thalf operator* (thalf const & s1, thalf const & s2);

	thalf operator/ (thalf const & s1, thalf const & s2);

	// Unary constant operators
	thalf operator- (thalf const & s);

	thalf operator-- (thalf const & s, int);

	thalf operator++ (thalf const & s, int);

}//namespace detail
}//namespace glm

#include "type_half.inl"

#endif//glm_core_type_half