comparison eclviewer.py @ 94:ca571697ec83

Various minor optimisations and refactoring
author Thibaut Girka <thib@sitedethib.com>
date Sun, 04 Sep 2011 20:04:00 +0200
parents 85f3b8ba3f24
children ac2e5e1c2c3c
comparison
equal deleted inserted replaced
93:d167280a82fc 94:ca571697ec83
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 objects_by_texture = {} 157 for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in background.objects_by_texture.items():
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]) 158 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc])
161 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) 159 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key])
162 glVertexPointer(3, GL_FLOAT, 0, vertices) 160 glVertexPointer(3, GL_FLOAT, 0, vertices)
163 glTexCoordPointer(2, GL_FLOAT, 0, uvs) 161 glTexCoordPointer(2, GL_FLOAT, 0, uvs)
164 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors) 162 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors)
177 192., 224., 0., 0., -1., 0.) 175 192., 224., 0., 0., -1., 0.)
178 176
179 glDisable(GL_FOG) 177 glDisable(GL_FOG)
180 objects_by_texture = {} 178 objects_by_texture = {}
181 enemy_manager.get_objects_by_texture(objects_by_texture) 179 enemy_manager.get_objects_by_texture(objects_by_texture)
182 for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in objects_by_texture.items(): 180 for (texture_key, blendfunc), (vertices, uvs, colors) in objects_by_texture.items():
183 nb_vertices = len(vertices) 181 nb_vertices = len(vertices)
184 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc]) 182 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc])
185 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) 183 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key])
186 glVertexPointer(3, GL_FLOAT, 0, struct.pack(str(3 * nb_vertices) + 'f', *chain(*vertices))) 184 glVertexPointer(3, GL_FLOAT, 0, struct.pack(str(3 * nb_vertices) + 'f', *chain(*vertices)))
187 glTexCoordPointer(2, GL_FLOAT, 0, struct.pack(str(2 * nb_vertices) + 'f', *chain(*uvs))) 185 glTexCoordPointer(2, GL_FLOAT, 0, struct.pack(str(2 * nb_vertices) + 'f', *chain(*uvs)))