Mercurial > touhou
comparison pytouhou/ui/window.pyx @ 512:b39ad30c6620
Add a pure SDL backend.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 05 Dec 2013 01:55:39 +0100 |
parents | 64a72df88de5 |
children | 5e3e0b09a531 |
comparison
equal
deleted
inserted
replaced
511:2e8ceaa85d5c | 512:b39ad30c6620 |
---|---|
100 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer)) | 100 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer)) |
101 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24) | 101 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24) |
102 | 102 |
103 flags |= sdl.WINDOW_OPENGL | 103 flags |= sdl.WINDOW_OPENGL |
104 | 104 |
105 if not self.use_fixed_pipeline: | 105 #TODO: implement it in the SDL backend too. |
106 flags |= sdl.WINDOW_RESIZABLE | 106 if not self.use_fixed_pipeline: |
107 flags |= sdl.WINDOW_RESIZABLE | |
107 | 108 |
108 self.win = sdl.Window('PyTouhou', | 109 self.win = sdl.Window('PyTouhou', |
109 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, | 110 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, |
110 640, 480, #XXX | 111 640, 480, #XXX |
111 flags) | 112 flags) |
124 glHint(GL_FOG_HINT, GL_NICEST) | 125 glHint(GL_FOG_HINT, GL_NICEST) |
125 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) | 126 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) |
126 glEnableClientState(GL_COLOR_ARRAY) | 127 glEnableClientState(GL_COLOR_ARRAY) |
127 glEnableClientState(GL_VERTEX_ARRAY) | 128 glEnableClientState(GL_VERTEX_ARRAY) |
128 glEnableClientState(GL_TEXTURE_COORD_ARRAY) | 129 glEnableClientState(GL_TEXTURE_COORD_ARRAY) |
130 else: | |
131 self.win.create_renderer(0) | |
129 | 132 |
130 self.clock = Clock(self.fps_limit) | 133 self.clock = Clock(self.fps_limit) |
131 | 134 |
132 | 135 |
133 cdef void set_size(self, int width, int height) nogil: | 136 cdef void set_size(self, int width, int height) nogil: |
150 | 153 |
151 cdef bint run_frame(self) except? False: | 154 cdef bint run_frame(self) except? False: |
152 cdef bint running = False | 155 cdef bint running = False |
153 if self.runner is not None: | 156 if self.runner is not None: |
154 running = self.runner.update() | 157 running = self.runner.update() |
155 self.win.gl_swap_window() | 158 self.win.present() |
156 self.clock.tick() | 159 self.clock.tick() |
157 return running | 160 return running |
158 | 161 |
159 | 162 |
160 cdef double get_fps(self) nogil: | 163 cdef double get_fps(self) nogil: |