comparison pytouhou/ui/gamerenderer.pyx @ 458:1b56d62250ab

Make pytouhou.ui.{window,shader,game{runner,renderer}} extension types.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 05 Sep 2013 23:11:54 +0200
parents 878273a984c4
children 6e733ed817bd
comparison
equal deleted inserted replaced
457:4ccc47828002 458:1b56d62250ab
18 (glClear, glMatrixMode, glLoadIdentity, glLoadMatrixf, glDisable, 18 (glClear, glMatrixMode, glLoadIdentity, glLoadMatrixf, glDisable,
19 glEnable, glFogi, glFogf, glFogfv, 19 glEnable, glFogi, glFogf, glFogfv,
20 GL_PROJECTION, GL_MODELVIEW, GL_FOG, GL_FOG_MODE, GL_LINEAR, 20 GL_PROJECTION, GL_MODELVIEW, GL_FOG, GL_FOG_MODE, GL_LINEAR,
21 GL_FOG_START, GL_FOG_END, GL_FOG_COLOR, GL_COLOR_BUFFER_BIT, GLfloat) 21 GL_FOG_START, GL_FOG_END, GL_FOG_COLOR, GL_COLOR_BUFFER_BIT, GLfloat)
22 22
23 from pytouhou.utils.matrix cimport Matrix
24 from pytouhou.utils.maths cimport setup_camera 23 from pytouhou.utils.maths cimport setup_camera
25 24
26 from .renderer import Renderer
27 25
28 26 cdef class GameRenderer(Renderer):
29
30 class GameRenderer(Renderer):
31 def __init__(self, resource_loader): 27 def __init__(self, resource_loader):
32 Renderer.__init__(self, resource_loader) 28 Renderer.__init__(self, resource_loader)
33 29
34 30
35 def render(self): 31 def render(self):
36 cdef float fog_data[4] 32 cdef float x, y, z, dx, dy, dz, fog_data[4], fog_start, fog_end
37 cdef Matrix view, mvp 33 cdef unsigned char fog_r, fog_g, fog_b
34 cdef Matrix mvp
38 35
39 back = self.background 36 back = self.background
40 game = self.game 37 game = self.game
41 38
42 if self.use_fixed_pipeline: 39 if self.use_fixed_pipeline:
44 glLoadIdentity() 41 glLoadIdentity()
45 42
46 if game is not None and game.spellcard_effect is not None: 43 if game is not None and game.spellcard_effect is not None:
47 if self.use_fixed_pipeline: 44 if self.use_fixed_pipeline:
48 glMatrixMode(GL_MODELVIEW) 45 glMatrixMode(GL_MODELVIEW)
49 glLoadMatrixf((<Matrix>self.game_mvp).data) 46 glLoadMatrixf(self.game_mvp.data)
50 glDisable(GL_FOG) 47 glDisable(GL_FOG)
51 else: 48 else:
52 self.game_shader.bind() 49 self.game_shader.bind()
53 self.game_shader.uniform_matrix('mvp', self.game_mvp) 50 self.game_shader.uniform_matrix('mvp', self.game_mvp)
54 51
101 glClear(GL_COLOR_BUFFER_BIT) 98 glClear(GL_COLOR_BUFFER_BIT)
102 99
103 if game is not None: 100 if game is not None:
104 if self.use_fixed_pipeline: 101 if self.use_fixed_pipeline:
105 glMatrixMode(GL_MODELVIEW) 102 glMatrixMode(GL_MODELVIEW)
106 glLoadMatrixf((<Matrix>self.game_mvp).data) 103 glLoadMatrixf(self.game_mvp.data)
107 glDisable(GL_FOG) 104 glDisable(GL_FOG)
108 else: 105 else:
109 self.game_shader.bind() 106 self.game_shader.bind()
110 self.game_shader.uniform_matrix('mvp', self.game_mvp) 107 self.game_shader.uniform_matrix('mvp', self.game_mvp)
111 108