Mercurial > touhou
comparison pytouhou/ui/renderer.pyx @ 411:2428296cccab
Remove indirect access to Matrix values.
| author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
|---|---|
| date | Wed, 12 Jun 2013 16:07:22 +0200 |
| parents | 9d790ca73c13 |
| children | 5fe6cd6ceb48 |
comparison
equal
deleted
inserted
replaced
| 410:9d790ca73c13 | 411:2428296cccab |
|---|---|
| 174 glBindBuffer(GL_ARRAY_BUFFER, 0) | 174 glBindBuffer(GL_ARRAY_BUFFER, 0) |
| 175 | 175 |
| 176 | 176 |
| 177 cpdef ortho_2d(self, left, right, bottom, top): | 177 cpdef ortho_2d(self, left, right, bottom, top): |
| 178 mat = Matrix() | 178 mat = Matrix() |
| 179 mat[0][0] = 2 / (right - left) | 179 data = mat.data |
| 180 mat[1][1] = 2 / (top - bottom) | 180 data[0][0] = 2 / (right - left) |
| 181 mat[2][2] = -1 | 181 data[1][1] = 2 / (top - bottom) |
| 182 mat[3][0] = -(right + left) / (right - left) | 182 data[2][2] = -1 |
| 183 mat[3][1] = -(top + bottom) / (top - bottom) | 183 data[3][0] = -(right + left) / (right - left) |
| 184 data[3][1] = -(top + bottom) / (top - bottom) | |
| 184 return mat | 185 return mat |
| 185 | 186 |
| 186 | 187 |
| 187 cpdef look_at(self, eye, center, up): | 188 cpdef look_at(self, eye, center, up): |
| 188 eye = Vector(eye) | 189 eye = Vector(eye) |
| 205 bottom = -top | 206 bottom = -top |
| 206 left = -top * aspect | 207 left = -top * aspect |
| 207 right = top * aspect | 208 right = top * aspect |
| 208 | 209 |
| 209 mat = Matrix() | 210 mat = Matrix() |
| 210 mat[0][0] = (2 * z_near) / (right - left) | 211 data = mat.data |
| 211 mat[1][1] = (2 * z_near) / (top - bottom) | 212 data[0][0] = (2 * z_near) / (right - left) |
| 212 mat[2][2] = -(z_far + z_near) / (z_far - z_near) | 213 data[1][1] = (2 * z_near) / (top - bottom) |
| 213 mat[2][3] = -1 | 214 data[2][2] = -(z_far + z_near) / (z_far - z_near) |
| 214 mat[3][2] = -(2 * z_far * z_near) / (z_far - z_near) | 215 data[2][3] = -1 |
| 215 mat[3][3] = 0 | 216 data[3][2] = -(2 * z_far * z_near) / (z_far - z_near) |
| 217 data[3][3] = 0 | |
| 216 return mat | 218 return mat |
| 217 | 219 |
| 218 | 220 |
| 219 cpdef setup_camera(self, dx, dy, dz): | 221 cpdef setup_camera(self, dx, dy, dz): |
| 220 # Some explanations on the magic constants: | 222 # Some explanations on the magic constants: |
