Mercurial > touhou
comparison pytouhou/ui/opengl/renderer.pyx @ 590:e15672733c93
Switch to Python 3.x instead of 2.7.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Tue, 30 Sep 2014 17:14:24 +0200 |
parents | 6c9d8a3d853f |
children | 974decb8df4f |
comparison
equal
deleted
inserted
replaced
589:0768122da817 | 590:e15672733c93 |
---|---|
42 cdef class Texture: | 42 cdef class Texture: |
43 def __cinit__(self, GLuint texture, Renderer renderer): | 43 def __cinit__(self, GLuint texture, Renderer renderer): |
44 self.texture = texture | 44 self.texture = texture |
45 | 45 |
46 # Find an unused key in the textures array. | 46 # Find an unused key in the textures array. |
47 for key in xrange(MAX_TEXTURES): | 47 for key in range(MAX_TEXTURES): |
48 if renderer.textures[key] == 0: | 48 if renderer.textures[key] == 0: |
49 break | 49 break |
50 else: | 50 else: |
51 raise MemoryError('Too many textures currently loaded, consider increasing MAX_TEXTURES (currently %d).' % MAX_TEXTURES) | 51 raise MemoryError('Too many textures currently loaded, consider increasing MAX_TEXTURES (currently %d).' % MAX_TEXTURES) |
52 | 52 |
53 self.key = key | 53 self.key = key |
54 self.pointer = &renderer.textures[key] | 54 self.pointer = &renderer.textures[key] |
55 self.pointer[0] = texture | 55 self.pointer[0] = texture |
56 for i in xrange(2): | 56 for i in range(2): |
57 renderer.indices[key][i] = self.indices[i] | 57 renderer.indices[key][i] = self.indices[i] |
58 | 58 |
59 #XXX: keep a reference so that when __dealloc__ is called self.pointer is still valid. | 59 #XXX: keep a reference so that when __dealloc__ is called self.pointer is still valid. |
60 self.renderer = renderer | 60 self.renderer = renderer |
61 | 61 |
139 return | 139 return |
140 | 140 |
141 nb_vertices = 0 | 141 nb_vertices = 0 |
142 memset(self.last_indices, 0, sizeof(self.last_indices)) | 142 memset(self.last_indices, 0, sizeof(self.last_indices)) |
143 | 143 |
144 for element_idx in xrange(nb_elements): | 144 for element_idx in range(nb_elements): |
145 element = <object>self.elements[element_idx] | 145 element = <object>self.elements[element_idx] |
146 ox, oy = <short>element.x, <short>element.y | 146 ox, oy = <short>element.x, <short>element.y |
147 data = get_sprite_rendering_data(element.sprite) | 147 data = get_sprite_rendering_data(element.sprite) |
148 key = data.key | 148 key = data.key |
149 | 149 |
199 | 199 |
200 # Don’t change the state when it’s not needed. | 200 # Don’t change the state when it’s not needed. |
201 previous_blendfunc = -1 | 201 previous_blendfunc = -1 |
202 previous_texture = -1 | 202 previous_texture = -1 |
203 | 203 |
204 for key in xrange(2 * MAX_TEXTURES): | 204 for key in range(2 * MAX_TEXTURES): |
205 nb_indices = self.last_indices[key] | 205 nb_indices = self.last_indices[key] |
206 if not nb_indices: | 206 if not nb_indices: |
207 continue | 207 continue |
208 | 208 |
209 blendfunc = key & 1 | 209 blendfunc = key & 1 |