diff pytouhou/ui/window.pyx @ 460:ec327e58b477

Add a context manager to initialize and shut down SDL outside of Window.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 06 Sep 2013 23:29:19 +0200
parents 1b56d62250ab
children 11708a1d0a1a
line wrap: on
line diff
--- a/pytouhou/ui/window.pyx
+++ b/pytouhou/ui/window.pyx
@@ -81,14 +81,6 @@ cdef class Window:
         self.use_fixed_pipeline = fixed_pipeline
         self.runner = None
 
-        IF UNAME_SYSNAME == "Windows":
-            sdl.set_main_ready()
-        sdl.init(sdl.INIT_VIDEO)
-        sdl.img_init(sdl.INIT_PNG)
-        sdl.ttf_init()
-        if sound:
-            sdl.mix_init(0)
-
         sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, 2)
         sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, 1)
         sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer))
@@ -116,11 +108,6 @@ cdef class Window:
             glEnableClientState(GL_VERTEX_ARRAY)
             glEnableClientState(GL_TEXTURE_COORD_ARRAY)
 
-        # Initialize sound
-        if sound:
-            sdl.mix_open_audio(44100, sdl.DEFAULT_FORMAT, 2, 4096)
-            sdl.mix_allocate_channels(26) #TODO: make it dependent on the SFX number.
-
         self.clock = Clock(self.fps_limit)
 
 
@@ -153,11 +140,3 @@ cdef class Window:
 
     cpdef double get_fps(self):
         return self.clock.get_fps()
-
-
-    def __dealloc__(self):
-        sdl.mix_close_audio()
-        sdl.mix_quit()
-        sdl.ttf_quit()
-        sdl.img_quit()
-        sdl.quit()