comparison pytouhou/ui/gamerunner.py @ 412:5fe6cd6ceb48

Refactor the maths functions out of Renderer.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 12 Jun 2013 18:30:08 +0200
parents 1c773544eaeb
children 63f59be04a54
comparison
equal deleted inserted replaced
411:2428296cccab 412:5fe6cd6ceb48
23 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST, 23 GL_PERSPECTIVE_CORRECTION_HINT, GL_FOG_HINT, GL_NICEST,
24 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY, 24 GL_COLOR_ARRAY, GL_VERTEX_ARRAY, GL_TEXTURE_COORD_ARRAY,
25 GL_SCISSOR_TEST) 25 GL_SCISSOR_TEST)
26 26
27 from pytouhou.utils.helpers import get_logger 27 from pytouhou.utils.helpers import get_logger
28 from pytouhou.utils.matrix import Matrix 28 from pytouhou.utils.maths import perspective, setup_camera, ortho_2d
29 29
30 from .gamerenderer import GameRenderer 30 from .gamerenderer import GameRenderer
31 from .music import MusicPlayer, SFXPlayer, NullPlayer 31 from .music import MusicPlayer, SFXPlayer, NullPlayer
32 from .shaders.eosd import GameShader, BackgroundShader 32 from .shaders.eosd import GameShader, BackgroundShader
33 33
107 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) 107 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
108 glEnableClientState(GL_COLOR_ARRAY) 108 glEnableClientState(GL_COLOR_ARRAY)
109 glEnableClientState(GL_VERTEX_ARRAY) 109 glEnableClientState(GL_VERTEX_ARRAY)
110 glEnableClientState(GL_TEXTURE_COORD_ARRAY) 110 glEnableClientState(GL_TEXTURE_COORD_ARRAY)
111 111
112 self.proj = self.perspective(30, float(self.game.width) / float(self.game.height), 112 self.proj = perspective(30, float(self.game.width) / float(self.game.height),
113 101010101./2010101., 101010101./10101.) 113 101010101./2010101., 101010101./10101.)
114 game_view = self.setup_camera(0, 0, 1) 114 game_view = setup_camera(0, 0, 1)
115 self.game_mvp = game_view * self.proj 115 self.game_mvp = game_view * self.proj
116 self.interface_mvp = self.ortho_2d(0., float(self.width), float(self.height), 0.) 116 self.interface_mvp = ortho_2d(0., float(self.width), float(self.height), 0.)
117 117
118 if self.fps_limit > 0: 118 if self.fps_limit > 0:
119 pyglet.clock.set_fps_limit(self.fps_limit) 119 pyglet.clock.set_fps_limit(self.fps_limit)
120 while not self.has_exit: 120 while not self.has_exit:
121 if not self.skip: 121 if not self.skip: