comparison pytouhou/ui/gamerunner.py @ 421:b1248bab2d0f

Add back music and SFX playback using SDL_mixer instead of pyglet, and add FLAC and Vorbis support.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 16 Jul 2013 21:07:15 +0200
parents 3a7b36324611
children 52829ebe2561
comparison
equal deleted inserted replaced
420:3a7b36324611 421:b1248bab2d0f
87 def __init__(self, resource_loader, game=None, background=None, replay=None, double_buffer=True, fps_limit=60, fixed_pipeline=False, skip=False): 87 def __init__(self, resource_loader, game=None, background=None, replay=None, double_buffer=True, fps_limit=60, fixed_pipeline=False, skip=False):
88 GameRenderer.__init__(self, resource_loader, game, background) 88 GameRenderer.__init__(self, resource_loader, game, background)
89 89
90 sdl.init(sdl.INIT_VIDEO) 90 sdl.init(sdl.INIT_VIDEO)
91 sdl.img_init(sdl.INIT_PNG) 91 sdl.img_init(sdl.INIT_PNG)
92 sdl.mix_init(0)
93
92 sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, 2) 94 sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, 2)
93 sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, 1) 95 sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, 1)
94 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer)) 96 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer))
95 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24) 97 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24)
96 98
98 self.win = sdl.Window('PyTouhou', 100 self.win = sdl.Window('PyTouhou',
99 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, 101 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED,
100 self.width, self.height, 102 self.width, self.height,
101 sdl.WINDOW_OPENGL | sdl.WINDOW_SHOWN) 103 sdl.WINDOW_OPENGL | sdl.WINDOW_SHOWN)
102 self.win.gl_create_context() 104 self.win.gl_create_context()
105
106 sdl.mix_open_audio(44100, sdl.DEFAULT_FORMAT, 2, 4096)
107 sdl.mix_allocate_channels(26) #TODO: make it dependent on the SFX number.
103 108
104 self.fps_limit = fps_limit 109 self.fps_limit = fps_limit
105 self.use_fixed_pipeline = fixed_pipeline 110 self.use_fixed_pipeline = fixed_pipeline
106 self.replay_level = None 111 self.replay_level = None
107 self.skip = skip 112 self.skip = skip
187 vbo_array = (c_uint * 2)(self.vbo, self.back_vbo) 192 vbo_array = (c_uint * 2)(self.vbo, self.back_vbo)
188 glDeleteBuffers(2, vbo_array) 193 glDeleteBuffers(2, vbo_array)
189 194
190 self.win.gl_delete_context() 195 self.win.gl_delete_context()
191 self.win.destroy_window() 196 self.win.destroy_window()
197 sdl.mix_close_audio()
198 sdl.mix_quit()
192 sdl.img_quit() 199 sdl.img_quit()
193 sdl.quit() 200 sdl.quit()
194 201
195 202
196 def update(self): 203 def update(self):