comparison pytouhou/ui/window.pyx @ 463:11708a1d0a1a

Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 11 Sep 2013 00:36:52 +0200
parents ec327e58b477
children 36bc577b2392
comparison
equal deleted inserted replaced
462:a71b912b45b7 463:11708a1d0a1a
72 self._ref_tick = current 72 self._ref_tick = current
73 self._ref_frame = 0 73 self._ref_frame = 0
74 74
75 75
76 76
77 cdef class Runner:
78 cdef void start(self) except *:
79 pass
80
81 cdef void finish(self) except *:
82 pass
83
84 cdef bint update(self) except *:
85 return False
86
87
88
77 cdef class Window: 89 cdef class Window:
78 def __init__(self, tuple size=None, bint double_buffer=True, long fps_limit=-1, 90 def __init__(self, tuple size=None, bint double_buffer=True, long fps_limit=-1,
79 bint fixed_pipeline=False, bint sound=True): 91 bint fixed_pipeline=False, bint sound=True):
80 self.fps_limit = fps_limit 92 self.fps_limit = fps_limit
81 self.use_fixed_pipeline = fixed_pipeline 93 self.use_fixed_pipeline = fixed_pipeline
113 125
114 cdef void set_size(self, int width, int height) nogil: 126 cdef void set_size(self, int width, int height) nogil:
115 self.win.set_window_size(width, height) 127 self.win.set_window_size(width, height)
116 128
117 129
118 cpdef set_runner(self, runner=None): 130 cpdef set_runner(self, Runner runner=None):
119 self.runner = runner 131 self.runner = runner
120 if runner is not None: 132 if runner is not None:
121 runner.start() 133 runner.start()
122 134
123 135
136 self.win.gl_swap_window() 148 self.win.gl_swap_window()
137 self.clock.tick() 149 self.clock.tick()
138 return running 150 return running
139 151
140 152
141 cpdef double get_fps(self): 153 cdef double get_fps(self) nogil:
142 return self.clock.get_fps() 154 return self.clock.get_fps()