comparison stageviewer.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 bf225780973f
children e01e88b06a13
comparison
equal deleted inserted replaced
36:f46c18872796 37:a10e3f44a883
38 glEnable(GL_TEXTURE_2D) 38 glEnable(GL_TEXTURE_2D)
39 glEnable(GL_FOG) 39 glEnable(GL_FOG)
40 glHint(GL_FOG_HINT, GL_NICEST) 40 glHint(GL_FOG_HINT, GL_NICEST)
41 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) 41 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
42 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 42 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
43 glEnableClientState(GL_COLOR_ARRAY)
43 glEnableClientState(GL_VERTEX_ARRAY) 44 glEnableClientState(GL_VERTEX_ARRAY)
44 glEnableClientState(GL_TEXTURE_COORD_ARRAY) 45 glEnableClientState(GL_TEXTURE_COORD_ARRAY)
45 46
46 # Load data 47 # Load data
47 with open(path, 'rb') as file: 48 with open(path, 'rb') as file:
93 gluLookAt(192., 224., - 835.979370 * dz, 94 gluLookAt(192., 224., - 835.979370 * dz,
94 192., 224. - dy, 750 - 835.979370 * dz, 0., -1., 0.) #TODO: 750 might not be accurate 95 192., 224. - dy, 750 - 835.979370 * dz, 0., -1., 0.) #TODO: 750 might not be accurate
95 #print(glGetFloat(GL_MODELVIEW_MATRIX)) 96 #print(glGetFloat(GL_MODELVIEW_MATRIX))
96 glTranslatef(-x, -y, -z) 97 glTranslatef(-x, -y, -z)
97 98
98 for texture_key, (nb_vertices, vertices, uvs) in background.objects_by_texture.items(): 99 for texture_key, (nb_vertices, vertices, uvs, colors) in background.objects_by_texture.items():
99 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key]) 100 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key])
100 glVertexPointer(3, GL_FLOAT, 0, vertices) 101 glVertexPointer(3, GL_FLOAT, 0, vertices)
101 glTexCoordPointer(2, GL_FLOAT, 0, uvs) 102 glTexCoordPointer(2, GL_FLOAT, 0, uvs)
103 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors)
102 glDrawArrays(GL_QUADS, 0, nb_vertices) 104 glDrawArrays(GL_QUADS, 0, nb_vertices)
103 105
104 #TODO: show the game itself 106 #TODO: show the game itself
105 # It is displayed on (0, 0, 0), (0, 448, 0), (388, 448, 0), (388, 0, 0) 107 # It is displayed on (0, 0, 0), (0, 448, 0), (388, 448, 0), (388, 0, 0)
106 # using a camera at (192, 224, -835.979370) looking right behind itself 108 # using a camera at (192, 224, -835.979370) looking right behind itself