comparison pytouhou/ui/renderer.pyx @ 397:c5ba11ede097

Don’t duplicate values in sprite rendering data.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 06 Feb 2013 21:41:05 +0100
parents 34a91f918e7c
children 8d252cdb495f
comparison
equal deleted inserted replaced
396:34a91f918e7c 397:c5ba11ede097
68 key, (vertices, uvs, colors) = get_sprite_rendering_data(sprite) 68 key, (vertices, uvs, colors) = get_sprite_rendering_data(sprite)
69 rec = indices_by_texture.setdefault(key, []) 69 rec = indices_by_texture.setdefault(key, [])
70 70
71 # Pack data in buffer 71 # Pack data in buffer
72 (x1, y1, z1), (x2, y2, z2), (x3, y3, z3), (x4, y4, z4) = vertices 72 (x1, y1, z1), (x2, y2, z2), (x3, y3, z3), (x4, y4, z4) = vertices
73 r1, g1, b1, a1, r2, g2, b2, a2, r3, g3, b3, a3, r4, g4, b4, a4 = colors 73 left, right, bottom, top = uvs
74 u1, v1, u2, v2, u3, v3, u4, v4 = uvs 74 r, g, b, a = colors
75 self.vertex_buffer[nb_vertices] = Vertex(x1 + ox, y1 + oy, z1, u1, v1, r1, g1, b1, a1) 75 self.vertex_buffer[nb_vertices] = Vertex(x1 + ox, y1 + oy, z1, left, bottom, r, g, b, a)
76 self.vertex_buffer[nb_vertices+1] = Vertex(x2 + ox, y2 + oy, z2, u2, v2, r2, g2, b2, a2) 76 self.vertex_buffer[nb_vertices+1] = Vertex(x2 + ox, y2 + oy, z2, right, bottom, r, g, b, a)
77 self.vertex_buffer[nb_vertices+2] = Vertex(x3 + ox, y3 + oy, z3, u3, v3, r3, g3, b3, a3) 77 self.vertex_buffer[nb_vertices+2] = Vertex(x3 + ox, y3 + oy, z3, right, top, r, g, b, a)
78 self.vertex_buffer[nb_vertices+3] = Vertex(x4 + ox, y4 + oy, z4, u4, v4, r4, g4, b4, a4) 78 self.vertex_buffer[nb_vertices+3] = Vertex(x4 + ox, y4 + oy, z4, left, top, r, g, b, a)
79 79
80 # Add indices 80 # Add indices
81 index = nb_vertices 81 index = nb_vertices
82 rec.extend((index, index + 1, index + 2, index + 2, index + 3, index)) 82 rec.extend((index, index + 1, index + 2, index + 2, index + 3, index))
83 83