comparison pytouhou/ui/window.pyx @ 513:5e3e0b09a531

Move the OpenGL backend to its own package.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 05 Dec 2013 02:16:31 +0100
parents b39ad30c6620
children de778a80820a
comparison
equal deleted inserted replaced
512:b39ad30c6620 513:5e3e0b09a531
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of 10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 ## GNU General Public License for more details. 12 ## GNU General Public License for more details.
13 ## 13 ##
14 14
15 from pytouhou.lib.opengl cimport \ 15 IF USE_OPENGL:
16 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND, 16 from pytouhou.lib.opengl cimport \
17 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, 17 (glEnable, glHint, glEnableClientState, GL_TEXTURE_2D, GL_BLEND,
18 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY) 18 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST,
19 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY)
19 20
20 IF USE_GLEW: 21 IF USE_GLEW:
21 from pytouhou.lib.opengl cimport glewInit 22 from pytouhou.lib.opengl cimport glewInit
22 23
23 24
24 cdef class Clock: 25 cdef class Clock:
25 def __init__(self, long fps=-1): 26 def __init__(self, long fps=-1):
26 self._target_fps = 0 27 self._target_fps = 0
92 self.use_fixed_pipeline = fixed_pipeline 93 self.use_fixed_pipeline = fixed_pipeline
93 self.runner = None 94 self.runner = None
94 95
95 flags = sdl.WINDOW_SHOWN 96 flags = sdl.WINDOW_SHOWN
96 97
97 if opengl: 98 if USE_OPENGL and opengl:
98 sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, 2) 99 sdl.gl_set_attribute(sdl.GL_CONTEXT_MAJOR_VERSION, 2)
99 sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, 1) 100 sdl.gl_set_attribute(sdl.GL_CONTEXT_MINOR_VERSION, 1)
100 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer)) 101 sdl.gl_set_attribute(sdl.GL_DOUBLEBUFFER, int(double_buffer))
101 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24) 102 sdl.gl_set_attribute(sdl.GL_DEPTH_SIZE, 24)
102 103
109 self.win = sdl.Window('PyTouhou', 110 self.win = sdl.Window('PyTouhou',
110 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED, 111 sdl.WINDOWPOS_CENTERED, sdl.WINDOWPOS_CENTERED,
111 640, 480, #XXX 112 640, 480, #XXX
112 flags) 113 flags)
113 114
114 if opengl: 115 if USE_OPENGL and opengl:
115 self.win.gl_create_context() 116 self.win.gl_create_context()
116 117
117 IF USE_GLEW: 118 IF USE_GLEW:
118 if glewInit() != 0: 119 if glewInit() != 0:
119 raise Exception('GLEW init fail!') 120 raise Exception('GLEW init fail!')