annotate pytouhou/ui/window.pyx @ 606:3c2f96f1d715

Fix compilation under Cython 0.22, by making the pyx and the pxd declarations’ except clause similar.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 26 Nov 2014 13:36:38 +0100
parents ab131d04987d
children a6af3ff86612
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 ##
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 ## Copyright (C) 2013 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 ##
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 ## This program is free software; you can redistribute it and/or modify
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 ## it under the terms of the GNU General Public License as published
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 ## by the Free Software Foundation; version 3 only.
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 ##
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9 ## This program is distributed in the hope that it will be useful,
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 ## GNU General Public License for more details.
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 ##
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14
533
de778a80820a Optimise Clock a bit more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
15 cimport cython
de778a80820a Optimise Clock a bit more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
16
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
18 cdef class Clock:
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
19 def __init__(self, long fps=-1):
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 self._target_fps = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 self._ref_tick = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 self._ref_frame = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23 self._fps_tick = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 self._fps_frame = 0
533
de778a80820a Optimise Clock a bit more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
25 self.fps = 0
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 self.set_target_fps(fps)
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
29 cdef void set_target_fps(self, long fps) nogil:
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 self._target_fps = fps
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31 self._ref_tick = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 self._fps_tick = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34
533
de778a80820a Optimise Clock a bit more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
35 @cython.cdivision(True)
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
36 cdef void tick(self) nogil except *:
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 current = sdl.get_ticks()
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39 if not self._ref_tick:
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 self._ref_tick = current
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 self._ref_frame = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42
452
1f5156093785 By default, only enable fps limiting if vsync doesn't do the job.
Thibaut Girka <thib@sitedethib.com>
parents: 450
diff changeset
43 if self._fps_frame >= (self._target_fps if self._target_fps > 0 else 60):
533
de778a80820a Optimise Clock a bit more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
44 self.fps = self._fps_frame * 1000. / (current - self._fps_tick)
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 self._fps_tick = current
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 self._fps_frame = 0
452
1f5156093785 By default, only enable fps limiting if vsync doesn't do the job.
Thibaut Girka <thib@sitedethib.com>
parents: 450
diff changeset
47 # If we are relying on vsync, but vsync doesn't work or is higher
1f5156093785 By default, only enable fps limiting if vsync doesn't do the job.
Thibaut Girka <thib@sitedethib.com>
parents: 450
diff changeset
48 # than 60 fps, limit ourselves to 60 fps.
533
de778a80820a Optimise Clock a bit more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
49 if self._target_fps < 0 and self.fps > 64.:
452
1f5156093785 By default, only enable fps limiting if vsync doesn't do the job.
Thibaut Girka <thib@sitedethib.com>
parents: 450
diff changeset
50 self._target_fps = 60
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 self._ref_frame += 1
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 self._fps_frame += 1
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 target_tick = self._ref_tick
496
104c737ce8b3 Test target FPS for natural instead of non-zero.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 491
diff changeset
56 if self._target_fps > 0:
491
2276229282fd Fix gcc’s warnings with -Wall -Wextra.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 469
diff changeset
57 target_tick += <unsigned long>(self._ref_frame * 1000 / self._target_fps)
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 if current <= target_tick:
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 sdl.delay(target_tick - current)
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 else:
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 self._ref_tick = current
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 self._ref_frame = 0
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66
463
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
67 cdef class Runner:
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
68 cdef void start(self) except *:
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
69 pass
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
70
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
71 cdef void finish(self) except *:
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
72 pass
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
73
606
3c2f96f1d715 Fix compilation under Cython 0.22, by making the pyx and the pxd declarations’ except clause similar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 596
diff changeset
74 cpdef bint update(self, bint render) except -1:
463
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
75 return False
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
76
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
77
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
78
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
79 cdef class Window:
596
ab131d04987d Fix a regression introduced in the previous commit when the interface has a different resolution than 640×480 and framebuffer_blit is enabled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 594
diff changeset
80 def __init__(self, backend, int width=640, int height=480, long fps_limit=-1, frameskip=1):
553
8f51e34d911c Refactor graphics backend selection, to make them fallbackable and optional.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 552
diff changeset
81 if backend is not None:
8f51e34d911c Refactor graphics backend selection, to make them fallbackable and optional.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 552
diff changeset
82 self.win = backend.create_window(
8f51e34d911c Refactor graphics backend selection, to make them fallbackable and optional.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 552
diff changeset
83 'PyTouhou',
8f51e34d911c Refactor graphics backend selection, to make them fallbackable and optional.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 552
diff changeset
84 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED,
596
ab131d04987d Fix a regression introduced in the previous commit when the interface has a different resolution than 640×480 and framebuffer_blit is enabled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 594
diff changeset
85 width, height,
589
0768122da817 Add a frameskip option, and use swap interval to implement it.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
86 frameskip)
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87
552
aad758aef26d Don’t store framerate limit in the Window while it already is in the Clock.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 533
diff changeset
88 self.clock = Clock(fps_limit)
589
0768122da817 Add a frameskip option, and use swap interval to implement it.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
89 self.frame = 0
0768122da817 Add a frameskip option, and use swap interval to implement it.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
90 self.frameskip = frameskip
596
ab131d04987d Fix a regression introduced in the previous commit when the interface has a different resolution than 640×480 and framebuffer_blit is enabled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 594
diff changeset
91 self.width = width
ab131d04987d Fix a regression introduced in the previous commit when the interface has a different resolution than 640×480 and framebuffer_blit is enabled.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 594
diff changeset
92 self.height = height
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
95 cdef void set_size(self, int width, int height) nogil:
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 self.win.set_window_size(width, height)
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98
463
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
99 cpdef set_runner(self, Runner runner=None):
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 self.runner = runner
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
101 if runner is not None:
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
102 runner.start()
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
105 cpdef run(self):
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 try:
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107 while self.run_frame():
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 pass
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109 finally:
588
7a82c4b52b16 Prevent a traceback when we call Window.run without a runner set.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 578
diff changeset
110 if self.runner is not None:
7a82c4b52b16 Prevent a traceback when we call Window.run without a runner set.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 578
diff changeset
111 self.runner.finish()
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113
594
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
114 @cython.cdivision(True)
606
3c2f96f1d715 Fix compilation under Cython 0.22, by making the pyx and the pxd declarations’ except clause similar.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 596
diff changeset
115 cdef bint run_frame(self) except -1:
594
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
116 cdef bint render = (self.win is not None and
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
117 (self.frameskip <= 1 or not self.frame % self.frameskip))
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
118
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
119 running = False
455
6864a38b2413 Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 452
diff changeset
120 if self.runner is not None:
594
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
121 running = self.runner.update(render)
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
122 if render:
553
8f51e34d911c Refactor graphics backend selection, to make them fallbackable and optional.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 552
diff changeset
123 self.win.present()
594
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
124
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 self.clock.tick()
589
0768122da817 Add a frameskip option, and use swap interval to implement it.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 588
diff changeset
126 self.frame += 1
594
12756994a92c Make frameskip actually skip the rendering part, not just the buffer swap.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 589
diff changeset
127
422
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
128 return running
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129
52829ebe2561 Refactor window management in its own class.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
130
463
11708a1d0a1a Make GameRunner inherit from a Runner base class, to bypass Python calls in Window.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 460
diff changeset
131 cdef double get_fps(self) nogil:
533
de778a80820a Optimise Clock a bit more.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 513
diff changeset
132 return self.clock.fps