Mercurial > touhou
comparison pytouhou/ui/sprite.pyx @ 505:bfea9e9a6845
Manage the texture-specific indices in the Texture, and some more renderer optimisations.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 01 Nov 2013 14:45:53 +0100 |
parents | d56536ef28e8 |
children | b39ad30c6620 |
comparison
equal
deleted
inserted
replaced
504:69c73023f7a0 | 505:bfea9e9a6845 |
---|---|
14 | 14 |
15 | 15 |
16 from libc.math cimport M_PI as pi | 16 from libc.math cimport M_PI as pi |
17 | 17 |
18 from pytouhou.utils.matrix cimport Matrix | 18 from pytouhou.utils.matrix cimport Matrix |
19 from pytouhou.ui.renderer cimport Texture #XXX | |
19 | 20 |
20 | 21 |
21 cpdef object get_sprite_rendering_data(Sprite sprite): | 22 cpdef object get_sprite_rendering_data(Sprite sprite): |
22 cdef Matrix vertmat | 23 cdef Matrix vertmat |
23 cdef double tx, ty, tw, th, sx, sy, rx, ry, rz, tox, toy | 24 cdef double tx, ty, tw, th, sx, sy, rx, ry, rz, tox, toy |
65 uvs = (tx * x_1 + tox, | 66 uvs = (tx * x_1 + tox, |
66 (tx + tw) * x_1 + tox, | 67 (tx + tw) * x_1 + tox, |
67 ty * y_1 + toy, | 68 ty * y_1 + toy, |
68 (ty + th) * y_1 + toy) | 69 (ty + th) * y_1 + toy) |
69 | 70 |
70 key = MAX_TEXTURES * sprite.blendfunc + <long>sprite.anm.texture | 71 key = ((<Texture>sprite.anm.texture).texture << 1) | sprite.blendfunc |
71 r, g, b = sprite.color | 72 r, g, b = sprite.color |
72 values = tuple([x for x in vertmat.data[:12]]), uvs, (r, g, b, sprite.alpha) | 73 values = tuple([x for x in vertmat.data[:12]]), uvs, (r, g, b, sprite.alpha) |
73 sprite._rendering_data = key, values | 74 sprite._rendering_data = key, values |
74 sprite.changed = False | 75 sprite.changed = False |
75 | 76 |