Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<typename T>
- struct matrix4 {
- T
- x1, y1, z1, w1,
- x2, y2, z2, w2,
- x3, y3, z3, w3,
- x4, y4, z4, w4;
- matrix4(const T* f){
- x1 = f[0], y1 = f[1], z1 = f[2], w1 = f[3];
- x2 = f[4], y2 = f[5], z2 = f[6], w2 = f[7];
- x3 = f[8], y3 = f[9], z3 = f[10], w3 = f[11];
- x4 = f[12], y4 = f[13], z4 = f[14], w4 = f[15];
- }
- static const matrix4<T> identity(){
- static matrix4<T> id = {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
- };
- return id;
- };
- };
- // Does not work.. it can't convert initializer list with int to a float one
- // It also doesn't work if I use a call to matrix4<T>() instead of the initializer list
- template<typename T>
- struct matrix4 {
- T
- x1, y1, z1, w1,
- x2, y2, z2, w2,
- x3, y3, z3, w3,
- x4, y4, z4, w4;
- matrix4(const T* f){
- x1 = f[0], y1 = f[1], z1 = f[2], w1 = f[3];
- x2 = f[4], y2 = f[5], z2 = f[6], w2 = f[7];
- x3 = f[8], y3 = f[9], z3 = f[10], w3 = f[11];
- x4 = f[12], y4 = f[13], z4 = f[14], w4 = f[15];
- }
- static const matrix4<T> identity(){
- static matrix4<T> id = matrix4<T>(
- T(1), T(0), T(0), T(0),
- T(0), T(1), T(0), T(0),
- T(0), T(0), T(1), T(0),
- T(0), T(0), T(0), T(1)
- );
- return id;
- };
- };
- // This also doesn't work. Neither with initializer list or 'constructor'.
- // Complains that it doesn't know a constructor that takes lots of floats
- template<typename T>
- struct matrix4 {
- T
- x1, y1, z1, w1,
- x2, y2, z2, w2,
- x3, y3, z3, w3,
- x4, y4, z4, w4;
- matrix4(const T* f){
- x1 = f[0], y1 = f[1], z1 = f[2], w1 = f[3];
- x2 = f[4], y2 = f[5], z2 = f[6], w2 = f[7];
- x3 = f[8], y3 = f[9], z3 = f[10], w3 = f[11];
- x4 = f[12], y4 = f[13], z4 = f[14], w4 = f[15];
- }
- static const matrix4<T> identity = {
- 1, 0, 0, 0,
- 0, 1, 0, 0,
- 0, 0, 1, 0,
- 0, 0, 0, 1
- };
- };
- // Would of course be the most elegant solution, but guess what.. This one gives the most errors.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement