Mercurial > touhou
comparison pytouhou/ui/gamerenderer.pyx @ 511:2e8ceaa85d5c
Don’t type the renderer in GameRunner, so that we can switch it without type issues.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Thu, 28 Nov 2013 18:55:43 +0100 |
parents | bfea9e9a6845 |
children | b39ad30c6620 |
comparison
equal
deleted
inserted
replaced
510:64a72df88de5 | 511:2e8ceaa85d5c |
---|---|
44 self.passthrough_shader = PassthroughShader() | 44 self.passthrough_shader = PassthroughShader() |
45 | 45 |
46 self.framebuffer = Framebuffer(0, 0, 640, 480) | 46 self.framebuffer = Framebuffer(0, 0, 640, 480) |
47 | 47 |
48 | 48 |
49 cdef void load_background(self, background): | 49 property size: |
50 # We never need to get back the computed size, so size is write-only. | |
51 def __set__(self, tuple size): | |
52 self.x, self.y, self.width, self.height = size | |
53 | |
54 | |
55 def load_textures(self, dict anms): | |
56 self.texture_manager.load(anms) | |
57 | |
58 | |
59 def load_background(self, background): | |
50 if background is not None: | 60 if background is not None: |
51 self.background_renderer = BackgroundRenderer(self.use_fixed_pipeline) | 61 self.background_renderer = BackgroundRenderer(self.use_fixed_pipeline) |
52 self.background_renderer.load(background) | 62 self.background_renderer.load(background) |
53 else: | 63 else: |
54 self.background_renderer = None | 64 self.background_renderer = None |
55 | 65 |
56 | 66 |
57 cdef void start(self, common): | 67 def start(self, common): |
58 self.proj = perspective(30, float(common.width) / float(common.height), | 68 self.proj = perspective(30, float(common.width) / float(common.height), |
59 101010101./2010101., 101010101./10101.) | 69 101010101./2010101., 101010101./10101.) |
60 game_view = setup_camera(0, 0, 1) | 70 game_view = setup_camera(0, 0, 1) |
61 self.game_mvp = game_view * self.proj | 71 self.game_mvp = game_view * self.proj |
62 self.interface_mvp = ortho_2d(0., float(common.interface.width), | 72 self.interface_mvp = ortho_2d(0., float(common.interface.width), |
63 float(common.interface.height), 0.) | 73 float(common.interface.height), 0.) |
64 | 74 |
65 | 75 |
66 cdef void render(self, Game game): | 76 def render(self, Game game): |
67 if not self.use_fixed_pipeline: | 77 if not self.use_fixed_pipeline: |
68 self.framebuffer.bind() | 78 self.framebuffer.bind() |
69 | 79 |
70 self.render_game(game) | 80 self.render_game(game) |
71 self.render_text(game.texts + game.native_texts) | 81 self.render_text(game.texts + game.native_texts) |