Mercurial > touhou
comparison pytouhou/ui/window.pyx @ 594:12756994a92c
Make frameskip actually skip the rendering part, not just the buffer swap.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 18 Oct 2014 18:04:43 +0200 |
parents | 0768122da817 |
children | ab131d04987d |
comparison
equal
deleted
inserted
replaced
593:974decb8df4f | 594:12756994a92c |
---|---|
69 pass | 69 pass |
70 | 70 |
71 cdef void finish(self) except *: | 71 cdef void finish(self) except *: |
72 pass | 72 pass |
73 | 73 |
74 cpdef bint update(self) except? False: | 74 cpdef bint update(self, bint render) except? False: |
75 return False | 75 return False |
76 | 76 |
77 | 77 |
78 | 78 |
79 cdef class Window: | 79 cdef class Window: |
107 finally: | 107 finally: |
108 if self.runner is not None: | 108 if self.runner is not None: |
109 self.runner.finish() | 109 self.runner.finish() |
110 | 110 |
111 | 111 |
112 @cython.cdivision(True) | |
112 cdef bint run_frame(self) except? False: | 113 cdef bint run_frame(self) except? False: |
113 cdef bint running = False | 114 cdef bint render = (self.win is not None and |
115 (self.frameskip <= 1 or not self.frame % self.frameskip)) | |
116 | |
117 running = False | |
114 if self.runner is not None: | 118 if self.runner is not None: |
115 running = self.runner.update() | 119 running = self.runner.update(render) |
116 if self.win is not None and (self.frameskip <= 1 or not self.frame % self.frameskip): | 120 if render: |
117 self.win.present() | 121 self.win.present() |
122 | |
118 self.clock.tick() | 123 self.clock.tick() |
119 self.frame += 1 | 124 self.frame += 1 |
125 | |
120 return running | 126 return running |
121 | 127 |
122 | 128 |
123 cdef double get_fps(self) nogil: | 129 cdef double get_fps(self) nogil: |
124 return self.clock.fps | 130 return self.clock.fps |