Mercurial > touhou
comparison eclviewer.py @ 92:85f3b8ba3f24
Minor refactoring and optimizations. Drop stageviewer.
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Sun, 04 Sep 2011 17:33:40 +0200 |
parents | fc0294c745b6 |
children | ca571697ec83 |
comparison
equal
deleted
inserted
replaced
91:f7525fa66bb0 | 92:85f3b8ba3f24 |
---|---|
152 gluLookAt(192., 224., - 835.979370 * dz, | 152 gluLookAt(192., 224., - 835.979370 * dz, |
153 192. + dx, 224. - dy, 0., 0., -1., 0.) | 153 192. + dx, 224. - dy, 0., 0., -1., 0.) |
154 glTranslatef(-x, -y, -z) | 154 glTranslatef(-x, -y, -z) |
155 | 155 |
156 glEnable(GL_DEPTH_TEST) | 156 glEnable(GL_DEPTH_TEST) |
157 for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in background.objects_by_texture.items(): | 157 objects_by_texture = {} |
158 glBlendFunc(GL_SRC_ALPHA, {0: GL_ONE_MINUS_SRC_ALPHA, 1: GL_ONE}[blendfunc]) | 158 background.get_objects_by_texture(objects_by_texture) |
159 for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in objects_by_texture.items(): | |
160 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc]) | |
159 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) | 161 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) |
160 glVertexPointer(3, GL_FLOAT, 0, vertices) | 162 glVertexPointer(3, GL_FLOAT, 0, vertices) |
161 glTexCoordPointer(2, GL_FLOAT, 0, uvs) | 163 glTexCoordPointer(2, GL_FLOAT, 0, uvs) |
162 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors) | 164 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors) |
163 glDrawArrays(GL_QUADS, 0, nb_vertices) | 165 glDrawArrays(GL_QUADS, 0, nb_vertices) |
173 # This is so that objects on the (O, x, y) plane use pixel coordinates | 175 # This is so that objects on the (O, x, y) plane use pixel coordinates |
174 gluLookAt(192., 224., - 835.979370, | 176 gluLookAt(192., 224., - 835.979370, |
175 192., 224., 0., 0., -1., 0.) | 177 192., 224., 0., 0., -1., 0.) |
176 | 178 |
177 glDisable(GL_FOG) | 179 glDisable(GL_FOG) |
178 for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in enemy_manager.objects_by_texture.items(): | 180 objects_by_texture = {} |
179 glBlendFunc(GL_SRC_ALPHA, {0: GL_ONE_MINUS_SRC_ALPHA, 1: GL_ONE}[blendfunc]) | 181 enemy_manager.get_objects_by_texture(objects_by_texture) |
182 for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in objects_by_texture.items(): | |
183 nb_vertices = len(vertices) | |
184 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc]) | |
180 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) | 185 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) |
181 glVertexPointer(3, GL_FLOAT, 0, vertices) | 186 glVertexPointer(3, GL_FLOAT, 0, struct.pack(str(3 * nb_vertices) + 'f', *chain(*vertices))) |
182 glTexCoordPointer(2, GL_FLOAT, 0, uvs) | 187 glTexCoordPointer(2, GL_FLOAT, 0, struct.pack(str(2 * nb_vertices) + 'f', *chain(*uvs))) |
183 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors) | 188 glColorPointer(4, GL_UNSIGNED_BYTE, 0, struct.pack(str(4 * nb_vertices) + 'B', *chain(*colors))) |
184 glDrawArrays(GL_QUADS, 0, nb_vertices) | 189 glDrawArrays(GL_QUADS, 0, nb_vertices) |
185 glEnable(GL_FOG) | 190 glEnable(GL_FOG) |
186 | 191 |
187 pygame.display.flip() | 192 pygame.display.flip() |
188 clock.tick(120) | 193 clock.tick(120) |