comparison pytouhou/ui/background.pyx @ 426:5d7bb2fd74f7

Never keep texture on the host when it has been uploaded, and prevent them from being decoded again.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:11:35 +0200
parents d8630c086926
children 878273a984c4
comparison
equal deleted inserted replaced
425:1104dc2553ee 426:5d7bb2fd74f7
33 33
34 def __dealloc__(self): 34 def __dealloc__(self):
35 free(self.vertex_buffer) 35 free(self.vertex_buffer)
36 36
37 37
38 def __init__(self, texture_manager, use_fixed_pipeline): 38 def __init__(self, use_fixed_pipeline):
39 self.texture_manager = texture_manager
40 self.use_fixed_pipeline = use_fixed_pipeline 39 self.use_fixed_pipeline = use_fixed_pipeline
41 40
42 if not use_fixed_pipeline: 41 if not use_fixed_pipeline:
43 glGenBuffers(1, &self.vbo) 42 glGenBuffers(1, &self.vbo)
44 43
59 glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, True, sizeof(Vertex), <void*>20) 58 glVertexAttribPointer(2, 4, GL_UNSIGNED_BYTE, True, sizeof(Vertex), <void*>20)
60 glEnableVertexAttribArray(2) 59 glEnableVertexAttribArray(2)
61 60
62 glEnable(GL_DEPTH_TEST) 61 glEnable(GL_DEPTH_TEST)
63 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[self.blendfunc]) 62 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[self.blendfunc])
64 glBindTexture(GL_TEXTURE_2D, self.texture_manager[self.texture_key]) 63 glBindTexture(GL_TEXTURE_2D, self.texture)
65 glDrawArrays(GL_QUADS, 0, self.nb_vertices) 64 glDrawArrays(GL_QUADS, 0, self.nb_vertices)
66 glDisable(GL_DEPTH_TEST) 65 glDisable(GL_DEPTH_TEST)
67 66
68 if not self.use_fixed_pipeline: 67 if not self.use_fixed_pipeline:
69 glBindBuffer(GL_ARRAY_BUFFER, 0) 68 glBindBuffer(GL_ARRAY_BUFFER, 0)
89 vertex_buffer[nb_vertices+2] = Vertex(x3 + ox + ox2, y3 + oy + oy2, z3 + oz + oz2, right, top, r, g, b, a) 88 vertex_buffer[nb_vertices+2] = Vertex(x3 + ox + ox2, y3 + oy + oy2, z3 + oz + oz2, right, top, r, g, b, a)
90 vertex_buffer[nb_vertices+3] = Vertex(x4 + ox + ox2, y4 + oy + oy2, z4 + oz + oz2, left, top, r, g, b, a) 89 vertex_buffer[nb_vertices+3] = Vertex(x4 + ox + ox2, y4 + oy + oy2, z4 + oz + oz2, left, top, r, g, b, a)
91 90
92 nb_vertices += 4 91 nb_vertices += 4
93 92
94 self.texture_key, self.blendfunc = key 93 self.texture, self.blendfunc = key
95 self.nb_vertices = nb_vertices 94 self.nb_vertices = nb_vertices
96 self.vertex_buffer = <Vertex*> realloc(vertex_buffer, nb_vertices * sizeof(Vertex)) 95 self.vertex_buffer = <Vertex*> realloc(vertex_buffer, nb_vertices * sizeof(Vertex))
97 96
98 if not self.use_fixed_pipeline: 97 if not self.use_fixed_pipeline:
99 glBindBuffer(GL_ARRAY_BUFFER, self.vbo) 98 glBindBuffer(GL_ARRAY_BUFFER, self.vbo)