comparison pytouhou/ui/gamerunner.py @ 399:1c773544eaeb

Make the background use a single vbo and offsets, just like the 2D code.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 12 Feb 2013 19:19:31 +0100
parents 34a91f918e7c
children 5fe6cd6ceb48
comparison
equal deleted inserted replaced
398:8d252cdb495f 399:1c773544eaeb
55 if not self.use_fixed_pipeline: 55 if not self.use_fixed_pipeline:
56 self.game_shader = GameShader() 56 self.game_shader = GameShader()
57 self.background_shader = BackgroundShader() 57 self.background_shader = BackgroundShader()
58 self.interface_shader = self.game_shader 58 self.interface_shader = self.game_shader
59 59
60 self.vbo = c_uint(0) 60 vbo_array = (c_uint * 2)()
61 glGenBuffers(2, vbo_array)
62 self.vbo, self.back_vbo = vbo_array
61 63
62 if game: 64 if game:
63 self.load_game(game, background, replay) 65 self.load_game(game, background, replay)
64 66
65 self.clock = pyglet.clock.get_default() 67 self.clock = pyglet.clock.get_default()
104 glHint(GL_FOG_HINT, GL_NICEST) 106 glHint(GL_FOG_HINT, GL_NICEST)
105 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) 107 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
106 glEnableClientState(GL_COLOR_ARRAY) 108 glEnableClientState(GL_COLOR_ARRAY)
107 glEnableClientState(GL_VERTEX_ARRAY) 109 glEnableClientState(GL_VERTEX_ARRAY)
108 glEnableClientState(GL_TEXTURE_COORD_ARRAY) 110 glEnableClientState(GL_TEXTURE_COORD_ARRAY)
109 else:
110 glGenBuffers(1, byref(self.vbo))
111 111
112 self.proj = self.perspective(30, float(self.game.width) / float(self.game.height), 112 self.proj = self.perspective(30, float(self.game.width) / float(self.game.height),
113 101010101./2010101., 101010101./10101.) 113 101010101./2010101., 101010101./10101.)
114 game_view = self.setup_camera(0, 0, 1) 114 game_view = self.setup_camera(0, 0, 1)
115 self.game_mvp = game_view * self.proj 115 self.game_mvp = game_view * self.proj
127 self.flip() 127 self.flip()
128 else: 128 else:
129 self.update() 129 self.update()
130 130
131 if not self.use_fixed_pipeline: 131 if not self.use_fixed_pipeline:
132 glDeleteBuffers(1, byref(self.vbo)) 132 vbo_array = (c_uint * 2)(self.vbo, self.back_vbo)
133 glDeleteBuffers(2, vbo_array)
133 134
134 135
135 def _event_text_symbol(self, ev): 136 def _event_text_symbol(self, ev):
136 # XXX: Ugly workaround to a pyglet bug on X11 137 # XXX: Ugly workaround to a pyglet bug on X11
137 #TODO: fix that bug in pyglet 138 #TODO: fix that bug in pyglet