Advertisement
WeltEnSTurm

Fuck it.

Sep 9th, 2011
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.95 KB | None | 0 0
  1. // File: matrix.hpp, created on Sep 8, 2011 by WeltEnSTurm
  2.  
  3.  
  4. #ifndef MATRIX_HPP_
  5. #define MATRIX_HPP_
  6.  
  7. template<typename T>
  8. struct matrix3 {
  9.     T
  10.         x1, y1, z1,
  11.         x2, y2, z2,
  12.         x3, y3, z3;
  13.  
  14.     matrix3(const T* f){
  15.         x1 = f[0], y1 = f[1], z1 = f[2];
  16.         x2 = f[3], y2 = f[4], z2 = f[5];
  17.         x3 = f[6], y3 = f[7], z3 = f[8];
  18.     }
  19.  
  20.     static const matrix3<T> identity = {
  21.             1, 0, 0,
  22.             0, 1, 0,
  23.             0, 0, 1
  24.     };
  25. };
  26.  
  27. typedef matrix3<float> matrix3f;
  28. typedef matrix3<double> matrix3d;
  29.  
  30. template<typename T>
  31. struct matrix4 {
  32.     T
  33.         x1, y1, z1, w1,
  34.         x2, y2, z2, w2,
  35.         x3, y3, z3, w3,
  36.         x4, y4, z4, w4;
  37.  
  38.     matrix4(const T* f){
  39.         x1 = f[0],  y1 = f[1],  z1 = f[2],  w1 = f[3];
  40.         x2 = f[4],  y2 = f[5],  z2 = f[6],  w2 = f[7];
  41.         x3 = f[8],  y3 = f[9],  z3 = f[10], w3 = f[11];
  42.         x4 = f[12], y4 = f[13], z4 = f[14], w4 = f[15];
  43.     }
  44.  
  45.     static const matrix4<T> identity = {
  46.             1, 0, 0, 0,
  47.             0, 1, 0, 0,
  48.             0, 0, 1, 0,
  49.             0, 0, 0, 1
  50.     };
  51. };
  52.  
  53. typedef matrix4<float> matrix4f;
  54. typedef matrix4<double> matrix4d;
  55.  
  56. #endif /* MATRIX_HPP_ */
  57.  
  58. /*
  59.  
  60. **** Build of configuration Debug for project Game Engine ****
  61.  
  62. **** Internal Builder is used for build               ****
  63. g++ -std=gnu++0x -IC:/Users/WeltEnSTurm/Dropbox/Programming/lib/GLTools/include -IC:\Users\WeltEnSTurm\workspace\Game Engine\include -IC:\Users\WeltEnSTurm\Dropbox\Programming\lib\freetype-2.4.6\include -O0 -g3 -Wall -c -fmessage-length=0 -o src\main.o ..\src\main.cpp
  64. In file included from C:\Users\WeltEnSTurm\workspace\Game Engine\include/engine/render/shader.hpp:10:0,
  65.                  from ..\src\main.cpp:10:
  66. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:20:37: error:
  67. a brace-enclosed initializer is not allowed here before '{' token
  68. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:45:37: error:
  69. a brace-enclosed initializer is not allowed here before '{' token
  70. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:
  71. In instantiation of 'matrix3<float>':
  72. ..\src\main.cpp:76:49:   instantiated from here
  73. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:24:2:
  74. error: invalid in-class initialization of static data member of
  75. non-integral type 'const matrix3<float>'
  76. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:
  77. In instantiation of 'matrix4<float>':
  78. ..\src\main.cpp:76:49:   instantiated from here
  79. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:50:2:
  80. error: invalid in-class initialization of static data member of
  81. non-integral type 'const matrix4<float>'
  82. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:
  83. In instantiation of 'const matrix4<float> matrix4<float>::identity':
  84. ..\src\main.cpp:95:47:   instantiated from here
  85. C:\Users\WeltEnSTurm\workspace\Game Engine\include/math/matrix.hpp:50:2:
  86. error: 'matrix4<float>::identity' cannot be initialized
  87. by a non-constant expression when being declared
  88. Build error occurred, build is stopped
  89. Time consumed: 1223  ms.  
  90.  
  91.  
  92. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement