comparison pytouhou/ui/opengl/gamerenderer.pyx @ 560:c759b97f4f81

Remove all reference to the old fixed pipeline option in the OpenGL backend, use the newer is_legacy one.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 30 May 2014 16:51:38 +0200
parents 8f51e34d911c
children b21922a03830
comparison
equal deleted inserted replaced
559:1be60813f7cb 560:c759b97f4f81
34 Color = namedtuple('Color', 'r g b a') 34 Color = namedtuple('Color', 'r g b a')
35 35
36 36
37 cdef class GameRenderer(Renderer): 37 cdef class GameRenderer(Renderer):
38 def __init__(self, resource_loader, _): 38 def __init__(self, resource_loader, _):
39 self.use_fixed_pipeline = is_legacy #XXX
40
41 Renderer.__init__(self, resource_loader) 39 Renderer.__init__(self, resource_loader)
42 40
43 if not self.use_fixed_pipeline: 41 if not is_legacy:
44 self.game_shader = GameShader() 42 self.game_shader = GameShader()
45 self.background_shader = BackgroundShader() 43 self.background_shader = BackgroundShader()
46 self.interface_shader = self.game_shader 44 self.interface_shader = self.game_shader
47 self.passthrough_shader = PassthroughShader() 45 self.passthrough_shader = PassthroughShader()
48 46
69 67
70 68
71 def load_background(self, background): 69 def load_background(self, background):
72 self.background = background 70 self.background = background
73 if background is not None: 71 if background is not None:
74 self.background_renderer = BackgroundRenderer(self.use_fixed_pipeline) 72 self.background_renderer = BackgroundRenderer()
75 self.background_renderer.load(background, self) 73 self.background_renderer.load(background, self)
76 else: 74 else:
77 self.background_renderer = None 75 self.background_renderer = None
78 76
79 77
85 self.interface_mvp = ortho_2d(0., float(common.interface.width), 83 self.interface_mvp = ortho_2d(0., float(common.interface.width),
86 float(common.interface.height), 0.) 84 float(common.interface.height), 0.)
87 85
88 86
89 def render(self, Game game): 87 def render(self, Game game):
90 if not self.use_fixed_pipeline: 88 if not is_legacy:
91 self.framebuffer.bind() 89 self.framebuffer.bind()
92 90
93 self.render_game(game) 91 self.render_game(game)
94 self.render_text(game.texts) 92 self.render_text(game.texts)
95 self.render_interface(game.interface, game.boss) 93 self.render_interface(game.interface, game.boss)
96 94
97 if not self.use_fixed_pipeline: 95 if not is_legacy:
98 self.passthrough_shader.bind() 96 self.passthrough_shader.bind()
99 self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp) 97 self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp)
100 self.render_framebuffer(self.framebuffer) 98 self.render_framebuffer(self.framebuffer)
101 99
102 100
112 glViewport(game_x, game_y, game.width, game.height) 110 glViewport(game_x, game_y, game.width, game.height)
113 glClear(GL_DEPTH_BUFFER_BIT) 111 glClear(GL_DEPTH_BUFFER_BIT)
114 glScissor(game_x, game_y, game.width, game.height) 112 glScissor(game_x, game_y, game.width, game.height)
115 glEnable(GL_SCISSOR_TEST) 113 glEnable(GL_SCISSOR_TEST)
116 114
117 if self.use_fixed_pipeline: 115 if is_legacy:
118 glMatrixMode(GL_PROJECTION) 116 glMatrixMode(GL_PROJECTION)
119 glLoadIdentity() 117 glLoadIdentity()
120 118
121 if game is not None and game.spellcard_effect is not None: 119 if game is not None and game.spellcard_effect is not None:
122 if self.use_fixed_pipeline: 120 if is_legacy:
123 glMatrixMode(GL_MODELVIEW) 121 glMatrixMode(GL_MODELVIEW)
124 glLoadMatrixf(<GLfloat*>self.game_mvp) 122 glLoadMatrixf(<GLfloat*>self.game_mvp)
125 glDisable(GL_FOG) 123 glDisable(GL_FOG)
126 else: 124 else:
127 self.game_shader.bind() 125 self.game_shader.bind()
151 view = setup_camera(dx, dy, dz) 149 view = setup_camera(dx, dy, dz)
152 mul(mvp, view) 150 mul(mvp, view)
153 free(view) 151 free(view)
154 mul(mvp, self.proj) 152 mul(mvp, self.proj)
155 153
156 if self.use_fixed_pipeline: 154 if is_legacy:
157 glMatrixMode(GL_MODELVIEW) 155 glMatrixMode(GL_MODELVIEW)
158 glLoadMatrixf(mvp_data) 156 glLoadMatrixf(mvp_data)
159 157
160 glEnable(GL_FOG) 158 glEnable(GL_FOG)
161 glFogi(GL_FOG_MODE, GL_LINEAR) 159 glFogi(GL_FOG_MODE, GL_LINEAR)
179 self.background_renderer.render_background() 177 self.background_renderer.render_background()
180 else: 178 else:
181 glClear(GL_COLOR_BUFFER_BIT) 179 glClear(GL_COLOR_BUFFER_BIT)
182 180
183 if game is not None: 181 if game is not None:
184 if self.use_fixed_pipeline: 182 if is_legacy:
185 glMatrixMode(GL_MODELVIEW) 183 glMatrixMode(GL_MODELVIEW)
186 glLoadMatrixf(<GLfloat*>self.game_mvp) 184 glLoadMatrixf(<GLfloat*>self.game_mvp)
187 glDisable(GL_FOG) 185 glDisable(GL_FOG)
188 else: 186 else:
189 self.game_shader.bind() 187 self.game_shader.bind()
234 cdef void render_interface(self, interface, game_boss): 232 cdef void render_interface(self, interface, game_boss):
235 cdef GlyphCollection label 233 cdef GlyphCollection label
236 234
237 elements = [] 235 elements = []
238 236
239 if self.use_fixed_pipeline: 237 if is_legacy:
240 glMatrixMode(GL_MODELVIEW) 238 glMatrixMode(GL_MODELVIEW)
241 glLoadMatrixf(<GLfloat*>self.interface_mvp) 239 glLoadMatrixf(<GLfloat*>self.interface_mvp)
242 glDisable(GL_FOG) 240 glDisable(GL_FOG)
243 else: 241 else:
244 self.interface_shader.bind() 242 self.interface_shader.bind()