Mercurial > touhou
diff pytouhou/ui/window.pyx @ 503:c622eaf64428
Optimize GameRunner some more, fix replay, and remove Window dependency in Renderer.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 04 Oct 2013 14:27:11 +0200 |
parents | 104c737ce8b3 |
children | 64a72df88de5 |
line wrap: on
line diff
--- a/pytouhou/ui/window.pyx +++ b/pytouhou/ui/window.pyx @@ -12,8 +12,6 @@ ## GNU General Public License for more details. ## -cimport cython - from pytouhou.lib.opengl cimport \ (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND, GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, @@ -88,7 +86,7 @@ cdef class Runner: cdef class Window: - def __init__(self, tuple size=None, bint double_buffer=True, long fps_limit=-1, + def __init__(self, bint double_buffer=True, long fps_limit=-1, bint fixed_pipeline=False, bint sound=True): self.fps_limit = fps_limit self.use_fixed_pipeline = fixed_pipeline @@ -99,15 +97,13 @@ cdef class Window: sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer)) sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24) - self.width, self.height = size if size is not None else (640, 480) - flags = sdl.WINDOW_OPENGL | sdl.WINDOW_SHOWN if not self.use_fixed_pipeline: flags |= sdl.WINDOW_RESIZABLE self.win = sdl.Window('PyTouhou', sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, - self.width, self.height, + 640, 480, #XXX flags) self.win.gl_create_context() @@ -128,22 +124,9 @@ cdef class Window: self.clock = Clock(self.fps_limit) - @cython.cdivision(True) cdef void set_size(self, int width, int height) nogil: self.win.set_window_size(width, height) - runner_width = float(self.runner.width) - runner_height = float(self.runner.height) - - scale = min(width / runner_width, - height / runner_height) - - self.width = int(runner_width * scale) - self.height = int(runner_height * scale) - - self.x = (width - self.width) // 2 - self.y = (height - self.height) // 2 - cpdef set_runner(self, Runner runner=None): self.runner = runner