comparison pytouhou/ui/renderer.pyx @ 371:6702bc0215dc

Replace GL_QUADS with GL_TRIANGLES, to be GLES compatible.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 27 Jul 2012 18:57:40 +0200
parents 74471afbac37
children 0537af9125a7
comparison
equal deleted inserted replaced
370:74471afbac37 371:6702bc0215dc
69 self.vertex_buffer[nb_vertices+2] = Vertex(x3 + ox, y3 + oy, z3, u3, v3, r3, g3, b3, a3) 69 self.vertex_buffer[nb_vertices+2] = Vertex(x3 + ox, y3 + oy, z3, u3, v3, r3, g3, b3, a3)
70 self.vertex_buffer[nb_vertices+3] = Vertex(x4 + ox, y4 + oy, z4, u4, v4, r4, g4, b4, a4) 70 self.vertex_buffer[nb_vertices+3] = Vertex(x4 + ox, y4 + oy, z4, u4, v4, r4, g4, b4, a4)
71 71
72 # Add indices 72 # Add indices
73 index = nb_vertices 73 index = nb_vertices
74 rec.extend((index, index + 1, index + 2, index + 3)) 74 rec.extend((index, index + 1, index + 2, index + 2, index + 3, index))
75 75
76 nb_vertices += 4 76 nb_vertices += 4
77 77
78 for (texture_key, blendfunc), indices in indices_by_texture.items(): 78 for (texture_key, blendfunc), indices in indices_by_texture.items():
79 glVertexPointer(3, GL_INT, 24, <long> &self.vertex_buffer[0].x) 79 glVertexPointer(3, GL_INT, 24, <long> &self.vertex_buffer[0].x)
82 82
83 nb_indices = len(indices) 83 nb_indices = len(indices)
84 indices = pack(str(nb_indices) + 'H', *indices) 84 indices = pack(str(nb_indices) + 'H', *indices)
85 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc]) 85 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc])
86 glBindTexture(GL_TEXTURE_2D, self.texture_manager[texture_key].id) 86 glBindTexture(GL_TEXTURE_2D, self.texture_manager[texture_key].id)
87 glDrawElements(GL_QUADS, nb_indices, GL_UNSIGNED_SHORT, indices) 87 glDrawElements(GL_TRIANGLES, nb_indices, GL_UNSIGNED_SHORT, indices)
88 88
89 89
90 cpdef ortho_2d(self, left, right, bottom, top): 90 cpdef ortho_2d(self, left, right, bottom, top):
91 mat = Matrix() 91 mat = Matrix()
92 mat[0][0] = 2 / (right - left) 92 mat[0][0] = 2 / (right - left)