comparison eclviewer.py @ 37:a10e3f44a883

Add alpha (anm0 instruction 3) support
author Thibaut Girka <thib@sitedethib.com>
date Sun, 14 Aug 2011 18:00:06 +0200
parents cc864aadc733
children e01e88b06a13
comparison
equal deleted inserted replaced
36:f46c18872796 37:a10e3f44a883
39 glEnable(GL_TEXTURE_2D) 39 glEnable(GL_TEXTURE_2D)
40 glEnable(GL_FOG) 40 glEnable(GL_FOG)
41 glHint(GL_FOG_HINT, GL_NICEST) 41 glHint(GL_FOG_HINT, GL_NICEST)
42 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) 42 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
43 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 43 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
44 glEnableClientState(GL_COLOR_ARRAY)
44 glEnableClientState(GL_VERTEX_ARRAY) 45 glEnableClientState(GL_VERTEX_ARRAY)
45 glEnableClientState(GL_TEXTURE_COORD_ARRAY) 46 glEnableClientState(GL_TEXTURE_COORD_ARRAY)
46 47
47 # Load data 48 # Load data
48 with open(path, 'rb') as file: 49 with open(path, 'rb') as file:
85 # Update game 86 # Update game
86 enemy_manager.update(frame) 87 enemy_manager.update(frame)
87 background.update(frame) 88 background.update(frame)
88 89
89 # Draw everything 90 # Draw everything
90 glClear(GL_COLOR_BUFFER_BIT) 91 # glClearColor(0.0, 0.0, 1.0, 0)
92 # glClear(GL_COLOR_BUFFER_BIT)
91 93
92 fog_b, fog_g, fog_r, _, fog_start, fog_end = background.fog_interpolator.values 94 fog_b, fog_g, fog_r, _, fog_start, fog_end = background.fog_interpolator.values
93 x, y, z = background.position_interpolator.values 95 x, y, z = background.position_interpolator.values
94 unknownx, dy, dz = background.position2_interpolator.values 96 unknownx, dy, dz = background.position2_interpolator.values
95 97
109 gluLookAt(192., 224., - 835.979370 * dz, 111 gluLookAt(192., 224., - 835.979370 * dz,
110 192., 224. - dy, 750 - 835.979370 * dz, 0., -1., 0.) #TODO: 750 might not be accurate 112 192., 224. - dy, 750 - 835.979370 * dz, 0., -1., 0.) #TODO: 750 might not be accurate
111 #print(glGetFloat(GL_MODELVIEW_MATRIX)) 113 #print(glGetFloat(GL_MODELVIEW_MATRIX))
112 glTranslatef(-x, -y, -z) 114 glTranslatef(-x, -y, -z)
113 115
114 for texture_key, (nb_vertices, vertices, uvs) in background.objects_by_texture.items(): 116 for texture_key, (nb_vertices, vertices, uvs, colors) in background.objects_by_texture.items():
115 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) 117 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key])
116 glVertexPointer(3, GL_FLOAT, 0, vertices) 118 glVertexPointer(3, GL_FLOAT, 0, vertices)
117 glTexCoordPointer(2, GL_FLOAT, 0, uvs) 119 glTexCoordPointer(2, GL_FLOAT, 0, uvs)
120 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors)
118 glDrawArrays(GL_QUADS, 0, nb_vertices) 121 glDrawArrays(GL_QUADS, 0, nb_vertices)
119 122
120 #TODO 123 #TODO
121 glMatrixMode(GL_MODELVIEW) 124 glMatrixMode(GL_MODELVIEW)
122 glLoadIdentity() 125 glLoadIdentity()
127 # This is so that objects on the (O, x, y) plane use pixel coordinates 130 # This is so that objects on the (O, x, y) plane use pixel coordinates
128 gluLookAt(192., 224., - 835.979370, 131 gluLookAt(192., 224., - 835.979370,
129 192., 224., 750 - 835.979370, 0., -1., 0.) #TODO: 750 might not be accurate 132 192., 224., 750 - 835.979370, 0., -1., 0.) #TODO: 750 might not be accurate
130 133
131 glDisable(GL_FOG) 134 glDisable(GL_FOG)
132 for texture_key, (nb_vertices, vertices, uvs) in enemy_manager.objects_by_texture.items(): 135 for texture_key, (nb_vertices, vertices, uvs, colors) in enemy_manager.objects_by_texture.items():
133 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) 136 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key])
134 glVertexPointer(3, GL_FLOAT, 0, vertices) 137 glVertexPointer(3, GL_FLOAT, 0, vertices)
135 glTexCoordPointer(2, GL_FLOAT, 0, uvs) 138 glTexCoordPointer(2, GL_FLOAT, 0, uvs)
139 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors)
136 glDrawArrays(GL_QUADS, 0, nb_vertices) 140 glDrawArrays(GL_QUADS, 0, nb_vertices)
137 glEnable(GL_FOG) 141 glEnable(GL_FOG)
138 142
139 pygame.display.flip() 143 pygame.display.flip()
140 clock.tick(120) 144 clock.tick(120)