comparison pytouhou/utils/matrix.pyx @ 424:f4d76d3d6f2a

Make the Shader class use cython too.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:07:15 +0200
parents d8630c086926
children 878273a984c4
comparison
equal deleted inserted replaced
423:d8630c086926 424:f4d76d3d6f2a
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details. 12 ## GNU General Public License for more details.
13 ## 13 ##
14 14
15 from libc.math cimport sin, cos 15 from libc.math cimport sin, cos
16 from ctypes import c_float
17 from libc.stdlib cimport malloc, free 16 from libc.stdlib cimport malloc, free
18 17
19 18
20 cdef float* matrix_to_floats(Matrix self): 19 cdef float* matrix_to_floats(Matrix self):
21 for i in xrange(4): 20 for i in xrange(4):
47 d3 = out.data 46 d3 = out.data
48 for i in xrange(4): 47 for i in xrange(4):
49 for j in xrange(4): 48 for j in xrange(4):
50 d3[i][j] = sum(d1[i][k] * d2[k][j] for k in xrange(4)) 49 d3[i][j] = sum(d1[i][k] * d2[k][j] for k in xrange(4))
51 return out 50 return out
52
53
54 def get_c_data(self):
55 data = sum(self.data, [])
56 return (c_float * 16)(*data)
57 51
58 52
59 cpdef flip(self): 53 cpdef flip(self):
60 data = self.data 54 data = self.data
61 a, b, c, d = data[0] 55 a, b, c, d = data[0]