Mercurial > touhou
comparison pytouhou/opengl/gamerenderer.pyx @ 174:c0183515a0a3
Use integers instead of floats to avoid filtering and ugly approximations (like the official game)
author | Thibaut Girka <thib@sitedethib.com> |
---|---|
date | Fri, 21 Oct 2011 19:20:03 +0200 |
parents | dcf32488a2c9 |
children | 46793ccfedca |
comparison
equal
deleted
inserted
replaced
173:35d850502d1f | 174:c0183515a0a3 |
---|---|
27 | 27 |
28 MAX_ELEMENTS = 10000 | 28 MAX_ELEMENTS = 10000 |
29 | 29 |
30 | 30 |
31 cdef struct Vertex: | 31 cdef struct Vertex: |
32 float x, y, z | 32 int x, y, z |
33 float u, v | 33 float u, v |
34 unsigned char r, g, b, a | 34 unsigned char r, g, b, a |
35 | 35 |
36 | 36 |
37 cdef class GameRenderer: | 37 cdef class GameRenderer: |
84 rec.extend((index, index + 1, index + 2, index + 3)) | 84 rec.extend((index, index + 1, index + 2, index + 3)) |
85 | 85 |
86 nb_vertices += 4 | 86 nb_vertices += 4 |
87 | 87 |
88 for (texture_key, blendfunc), indices in indices_by_texture.items(): | 88 for (texture_key, blendfunc), indices in indices_by_texture.items(): |
89 glVertexPointer(3, GL_FLOAT, 24, <long> &self.vertex_buffer[0].x) | 89 glVertexPointer(3, GL_INT, 24, <long> &self.vertex_buffer[0].x) |
90 glTexCoordPointer(2, GL_FLOAT, 24, <long> &self.vertex_buffer[0].u) | 90 glTexCoordPointer(2, GL_FLOAT, 24, <long> &self.vertex_buffer[0].u) |
91 glColorPointer(4, GL_UNSIGNED_BYTE, 24, <long> &self.vertex_buffer[0].r) | 91 glColorPointer(4, GL_UNSIGNED_BYTE, 24, <long> &self.vertex_buffer[0].r) |
92 | 92 |
93 nb_indices = len(indices) | 93 nb_indices = len(indices) |
94 indices = struct.pack(str(nb_indices) + 'H', *indices) | 94 indices = struct.pack(str(nb_indices) + 'H', *indices) |