Mercurial > touhou
comparison pytouhou/ui/opengl/background.pyx @ 532:dacdcca59b66
Don’t put back the rendering data into a tuple, use a specialised struct inside Sprite to pass it to the renderer.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 19 Dec 2013 21:55:26 +0100 |
parents | b18f0bd30ad0 |
children | 94725968dabb |
comparison
equal
deleted
inserted
replaced
531:a7dc55ad9380 | 532:dacdcca59b66 |
---|---|
80 indices = <GLushort*> malloc(65536 * sizeof(GLushort)) | 80 indices = <GLushort*> malloc(65536 * sizeof(GLushort)) |
81 | 81 |
82 for ox, oy, oz, model_id, model in background.object_instances: | 82 for ox, oy, oz, model_id, model in background.object_instances: |
83 for ox2, oy2, oz2, width_override, height_override, sprite in model: | 83 for ox2, oy2, oz2, width_override, height_override, sprite in model: |
84 #TODO: view frustum culling | 84 #TODO: view frustum culling |
85 key, (vertices, uvs, colors) = get_sprite_rendering_data(sprite) | 85 data = get_sprite_rendering_data(sprite) |
86 x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4 = vertices | 86 key = data.key |
87 left, right, bottom, top = uvs | 87 |
88 r, g, b, a = colors | 88 x1, x2, x3, x4, y1, y2, y3, y4, z1, z2, z3, z4 = data.pos[0], data.pos[1], data.pos[2], data.pos[3], data.pos[4], data.pos[5], data.pos[6], data.pos[7], data.pos[8], data.pos[9], data.pos[10], data.pos[11] |
89 r, g, b, a = data.color[0], data.color[1], data.color[2], data.color[3] | |
89 | 90 |
90 # Pack data | 91 # Pack data |
91 vertex_buffer[nb_vertices] = Vertex(x1 + ox + ox2, y1 + oy + oy2, z1 + oz + oz2, left, bottom, r, g, b, a) | 92 vertex_buffer[nb_vertices] = Vertex(x1 + ox + ox2, y1 + oy + oy2, z1 + oz + oz2, data.left, data.bottom, r, g, b, a) |
92 vertex_buffer[nb_vertices+1] = Vertex(x2 + ox + ox2, y2 + oy + oy2, z2 + oz + oz2, right, bottom, r, g, b, a) | 93 vertex_buffer[nb_vertices+1] = Vertex(x2 + ox + ox2, y2 + oy + oy2, z2 + oz + oz2, data.right, data.bottom, r, g, b, a) |
93 vertex_buffer[nb_vertices+2] = Vertex(x3 + ox + ox2, y3 + oy + oy2, z3 + oz + oz2, right, top, r, g, b, a) | 94 vertex_buffer[nb_vertices+2] = Vertex(x3 + ox + ox2, y3 + oy + oy2, z3 + oz + oz2, data.right, data.top, r, g, b, a) |
94 vertex_buffer[nb_vertices+3] = Vertex(x4 + ox + ox2, y4 + oy + oy2, z4 + oz + oz2, left, top, r, g, b, a) | 95 vertex_buffer[nb_vertices+3] = Vertex(x4 + ox + ox2, y4 + oy + oy2, z4 + oz + oz2, data.left, data.top, r, g, b, a) |
95 | 96 |
96 # Add indices | 97 # Add indices |
97 indices[nb_indices] = nb_vertices | 98 indices[nb_indices] = nb_vertices |
98 indices[nb_indices+1] = nb_vertices + 1 | 99 indices[nb_indices+1] = nb_vertices + 1 |
99 indices[nb_indices+2] = nb_vertices + 2 | 100 indices[nb_indices+2] = nb_vertices + 2 |