Commit b2d10ff1819328bef427c21681b2a80ba9f3e485
1 parent
8e56a0a7
final edits, expanded the matrix class slightly and removed extrenuous operations from gl_spider.
Showing
2 changed files
with
13 additions
and
20 deletions
Show diff stats
stim/gl/gl_spider.h
... | ... | @@ -435,7 +435,7 @@ class gl_spider |
435 | 435 | |
436 | 436 | float curTrans[16]; |
437 | 437 | glGetFloatv(GL_TEXTURE_MATRIX, curTrans); |
438 | - fillTransform(curTrans); | |
438 | + cT.set(curTrans); | |
439 | 439 | printTransform(); |
440 | 440 | |
441 | 441 | CHECK_OPENGL_ERROR |
... | ... | @@ -669,19 +669,6 @@ class gl_spider |
669 | 669 | } |
670 | 670 | return out; |
671 | 671 | } |
672 | - ///Function that fills the transform data from GL output to a matrix format. | |
673 | - ///@param mat, a 16 value matrix representing the transformation in row order. | |
674 | - void | |
675 | - fillTransform(float mat[16]) | |
676 | - { | |
677 | - for(int r = 0; r < 4; r++){ | |
678 | - for(int c = 0; c < 4; c++){ | |
679 | - cT(r,c) = mat[c*4+r]; | |
680 | - } | |
681 | - } | |
682 | - // cT.setMatrix(mat); | |
683 | - | |
684 | - } | |
685 | 672 | |
686 | 673 | ///Function to get back the framebuffer Object attached to the spider. |
687 | 674 | ///For external access. | ... | ... |
stim/math/matrix.h
... | ... | @@ -25,11 +25,17 @@ struct matrix |
25 | 25 | (*this)(r, c) = 0; |
26 | 26 | } |
27 | 27 | |
28 | - CUDA_CALLABLE matrix<T,N> setMatrix(T rhs[]) | |
28 | + CUDA_CALLABLE matrix(T rhs[N*N]) | |
29 | 29 | { |
30 | - M = rhs; | |
30 | + memcpy(M,rhs, sizeof(T)*N*N); | |
31 | + } | |
32 | + | |
33 | + CUDA_CALLABLE matrix<T,N> set(T rhs[N*N]) | |
34 | + { | |
35 | + memcpy(M, rhs, sizeof(T)*N*N); | |
31 | 36 | return *this; |
32 | 37 | } |
38 | + | |
33 | 39 | CUDA_CALLABLE T& operator()(int row, int col) |
34 | 40 | { |
35 | 41 | return M[col * N + row]; |
... | ... | @@ -57,18 +63,18 @@ struct matrix |
57 | 63 | return result; |
58 | 64 | } |
59 | 65 | |
60 | - CUDA_CALLABLE std::string toStr() | |
66 | + std::string toStr() | |
61 | 67 | { |
62 | 68 | std::stringstream ss; |
63 | 69 | |
64 | 70 | for(int r = 0; r < N; r++) |
65 | 71 | { |
66 | - ss<<"| "; | |
72 | + ss << "| "; | |
67 | 73 | for(int c=0; c<N; c++) |
68 | 74 | { |
69 | - ss<<(*this)(r, c)<<" "; | |
75 | + ss << (*this)(r, c) << " "; | |
70 | 76 | } |
71 | - ss<<"|"<<std::endl; | |
77 | + ss << "|" << std::endl; | |
72 | 78 | } |
73 | 79 | |
74 | 80 | return ss.str(); | ... | ... |