comparison pytouhou/ui/gamerenderer.py @ 399:1c773544eaeb

Make the background use a single vbo and offsets, just like the 2D code.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 12 Feb 2013 19:19:31 +0100
parents 8d252cdb495f
children 3ce4065840e9
comparison
equal deleted inserted replaced
398:8d252cdb495f 399:1c773544eaeb
41 self.background = background 41 self.background = background
42 42
43 if game: 43 if game:
44 # Preload textures 44 # Preload textures
45 self.texture_manager.preload(game.resource_loader.instanced_anms.values()) 45 self.texture_manager.preload(game.resource_loader.instanced_anms.values())
46 self.prerender_background(background)
46 47
47 48
48 def render(self): 49 def render(self):
49 glClear(GL_DEPTH_BUFFER_BIT) 50 glClear(GL_DEPTH_BUFFER_BIT)
50 51
64 self.game_shader.bind() 65 self.game_shader.bind()
65 self.game_shader.uniform_matrixf('mvp', self.game_mvp.get_c_data()) 66 self.game_shader.uniform_matrixf('mvp', self.game_mvp.get_c_data())
66 67
67 self.render_elements([game.spellcard_effect]) 68 self.render_elements([game.spellcard_effect])
68 elif back is not None: 69 elif back is not None:
69 if self.use_fixed_pipeline:
70 glEnable(GL_FOG)
71 else:
72 self.background_shader.bind()
73 fog_b, fog_g, fog_r, fog_start, fog_end = back.fog_interpolator.values
74 x, y, z = back.position_interpolator.values 70 x, y, z = back.position_interpolator.values
75 dx, dy, dz = back.position2_interpolator.values 71 dx, dy, dz = back.position2_interpolator.values
72 fog_b, fog_g, fog_r, fog_start, fog_end = back.fog_interpolator.values
73
74 model = Matrix()
75 model.data[3] = [-x, -y, -z, 1]
76 view = self.setup_camera(dx, dy, dz)
76 77
77 glFogi(GL_FOG_MODE, GL_LINEAR) 78 glFogi(GL_FOG_MODE, GL_LINEAR)
78 glFogf(GL_FOG_START, fog_start) 79 glFogf(GL_FOG_START, fog_start)
79 glFogf(GL_FOG_END, fog_end) 80 glFogf(GL_FOG_END, fog_end)
80 glFogfv(GL_FOG_COLOR, (GLfloat * 4)(fog_r / 255., fog_g / 255., fog_b / 255., 1.)) 81 glFogfv(GL_FOG_COLOR, (GLfloat * 4)(fog_r / 255., fog_g / 255., fog_b / 255., 1.))
81 82
82 model = Matrix() 83 if self.use_fixed_pipeline:
83 model.data[3] = [-x, -y, -z, 1] 84 glEnable(GL_FOG)
84 view = self.setup_camera(dx, dy, dz)
85 85
86 if self.use_fixed_pipeline:
87 model_view_projection = model * view * self.proj 86 model_view_projection = model * view * self.proj
88 glMatrixMode(GL_MODELVIEW) 87 glMatrixMode(GL_MODELVIEW)
89 glLoadMatrixf(model_view_projection.get_c_data()) 88 glLoadMatrixf(model_view_projection.get_c_data())
90 else: 89 else:
90 self.background_shader.bind()
91
91 model_view = model * view 92 model_view = model * view
92 self.background_shader.uniform_matrixf('model_view', model_view.get_c_data()) 93 self.background_shader.uniform_matrixf('model_view', model_view.get_c_data())
93 self.background_shader.uniform_matrixf('projection', self.proj.get_c_data()) 94 self.background_shader.uniform_matrixf('projection', self.proj.get_c_data())
94 95
95 self.render_background(back) 96 self.render_background()
96 else: 97 else:
97 glClear(GL_COLOR_BUFFER_BIT) 98 glClear(GL_COLOR_BUFFER_BIT)
98 99
99 if game is not None: 100 if game is not None:
100 if self.use_fixed_pipeline: 101 if self.use_fixed_pipeline: