simd_mat4.hpp
00001 
00002 // OpenGL Mathematics Copyright (c) 2005 - 2011 G-Truc Creation (www.g-truc.net)
00004 // Created : 2009-05-07
00005 // Updated : 2009-05-07
00006 // Licence : This source is under MIT License
00007 // File    : glm/gtx/simd_vec4.hpp
00009 // Dependency:
00010 // - GLM core
00011 // - intrinsic
00013 
00014 #ifndef glm_gtx_simd_mat4
00015 #define glm_gtx_simd_mat4
00016 
00017 // Dependency:
00018 #include "../glm.hpp"
00019 
00020 #if(GLM_ARCH & GLM_ARCH_SSE2)
00021 #       include "../core/intrinsic_matrix.hpp"
00022 #       include "../gtx/simd_vec4.hpp"
00023 #else
00024 #       error "GLM: GLM_GTX_simd_mat4 requires compiler support of SSE2 through intrinsics"
00025 #endif
00026 
00027 #if(defined(GLM_MESSAGES) && !defined(glm_ext))
00028 #       pragma message("GLM: GLM_GTX_simd_mat4 extension included")
00029 #endif
00030 
00031 namespace glm{
00032 namespace detail
00033 {
00036         GLM_ALIGNED_STRUCT(16) fmat4x4SIMD
00037         {
00038                 enum ctor{null};
00039 
00040                 typedef float value_type;
00041                 typedef fvec4SIMD col_type;
00042                 typedef fvec4SIMD row_type;
00043                 typedef std::size_t size_type;
00044                 static size_type value_size();
00045                 static size_type col_size();
00046                 static size_type row_size();
00047                 static bool is_matrix();
00048 
00049                 fvec4SIMD Data[4];
00050 
00052                 // Constructors
00053 
00054                 fmat4x4SIMD();
00055                 explicit fmat4x4SIMD(float const & s);
00056                 explicit fmat4x4SIMD(
00057                         float const & x0, float const & y0, float const & z0, float const & w0,
00058                         float const & x1, float const & y1, float const & z1, float const & w1,
00059                         float const & x2, float const & y2, float const & z2, float const & w2,
00060                         float const & x3, float const & y3, float const & z3, float const & w3);
00061                 explicit fmat4x4SIMD(
00062                         fvec4SIMD const & v0,
00063                         fvec4SIMD const & v1,
00064                         fvec4SIMD const & v2,
00065                         fvec4SIMD const & v3);
00066                 explicit fmat4x4SIMD(
00067                         tmat4x4<float> const & m);
00068 
00069                 // Conversions
00070                 //template <typename U> 
00071                 //explicit tmat4x4(tmat4x4<U> const & m);
00072 
00073                 //explicit tmat4x4(tmat2x2<T> const & x);
00074                 //explicit tmat4x4(tmat3x3<T> const & x);
00075                 //explicit tmat4x4(tmat2x3<T> const & x);
00076                 //explicit tmat4x4(tmat3x2<T> const & x);
00077                 //explicit tmat4x4(tmat2x4<T> const & x);
00078                 //explicit tmat4x4(tmat4x2<T> const & x);
00079                 //explicit tmat4x4(tmat3x4<T> const & x);
00080                 //explicit tmat4x4(tmat4x3<T> const & x);
00081 
00082                 // Accesses
00083                 fvec4SIMD & operator[](size_type i);
00084                 fvec4SIMD const & operator[](size_type i) const;
00085 
00086                 // Unary updatable operators
00087                 fmat4x4SIMD & operator= (fmat4x4SIMD const & m);
00088                 fmat4x4SIMD & operator+= (float const & s);
00089                 fmat4x4SIMD & operator+= (fmat4x4SIMD const & m);
00090                 fmat4x4SIMD & operator-= (float const & s);
00091                 fmat4x4SIMD & operator-= (fmat4x4SIMD const & m);
00092                 fmat4x4SIMD & operator*= (float const & s);
00093                 fmat4x4SIMD & operator*= (fmat4x4SIMD const & m);
00094                 fmat4x4SIMD & operator/= (float const & s);
00095                 fmat4x4SIMD & operator/= (fmat4x4SIMD const & m);
00096                 fmat4x4SIMD & operator++ ();
00097                 fmat4x4SIMD & operator-- ();
00098         };
00099 
00100         // Binary operators
00101         fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s);
00102         fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m);
00103         fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00104             
00105         fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s);
00106         fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m);
00107         fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00108 
00109         fmat4x4SIMD operator* (fmat4x4SIMD const & m, float const & s);
00110         fmat4x4SIMD operator* (float const & s, fmat4x4SIMD const & m);
00111 
00112         fvec4SIMD operator* (fmat4x4SIMD const & m, fvec4SIMD const & v);
00113         fvec4SIMD operator* (fvec4SIMD const & v, fmat4x4SIMD const & m);
00114 
00115         fmat4x4SIMD operator* (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00116 
00117         fmat4x4SIMD operator/ (fmat4x4SIMD const & m, float const & s);
00118         fmat4x4SIMD operator/ (float const & s, fmat4x4SIMD const & m);
00119 
00120         fvec4SIMD operator/ (fmat4x4SIMD const & m, fvec4SIMD const & v);
00121         fvec4SIMD operator/ (fvec4SIMD const & v, fmat4x4SIMD const & m);
00122 
00123         fmat4x4SIMD operator/ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
00124 
00125         // Unary constant operators
00126         fmat4x4SIMD const operator-  (fmat4x4SIMD const & m);
00127         fmat4x4SIMD const operator-- (fmat4x4SIMD const & m, int);
00128         fmat4x4SIMD const operator++ (fmat4x4SIMD const & m, int);
00129 }//namespace detail
00130 
00131 namespace gtx{
00132 namespace simd_mat4 
00133 {
00134         typedef detail::fmat4x4SIMD simdMat4;
00135 
00138 
00141         detail::tmat4x4<float> mat4_cast(
00142                 detail::fmat4x4SIMD const & x);
00143 
00147         detail::fmat4x4SIMD matrixCompMult(
00148                 detail::fmat4x4SIMD const & x,
00149                 detail::fmat4x4SIMD const & y);
00150 
00155         detail::fmat4x4SIMD outerProduct(
00156                 detail::fvec4SIMD const & c,
00157                 detail::fvec4SIMD const & r);
00158 
00161         detail::fmat4x4SIMD transpose(
00162                 detail::fmat4x4SIMD const & x);
00163 
00166         float determinant(
00167                 detail::fmat4x4SIMD const & m);
00168 
00171         detail::fmat4x4SIMD inverse(
00172                 detail::fmat4x4SIMD const & m);
00173 
00175 }// namespace simd_mat4
00176 }// namespace gtx
00177 }// namespace glm
00178 
00179 #include "simd_mat4.inl"
00180 
00181 namespace glm{using namespace gtx::simd_mat4;}
00182 
00183 #endif//glm_gtx_simd_mat4