Mercurial > touhou
comparison pytouhou/ui/gamerenderer.pyx @ 462:a71b912b45b7
Render to framebuffers first, and reposition some interface elements in the game area.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Wed, 11 Sep 2013 00:36:50 +0200 |
parents | 6e733ed817bd |
children | 36bc577b2392 |
comparison
equal
deleted
inserted
replaced
461:6af3854ed826 | 462:a71b912b45b7 |
---|---|
20 GL_FOG, GL_FOG_MODE, GL_LINEAR, GL_FOG_START, GL_FOG_END, | 20 GL_FOG, GL_FOG_MODE, GL_LINEAR, GL_FOG_START, GL_FOG_END, |
21 GL_FOG_COLOR, GL_COLOR_BUFFER_BIT, GLfloat, glViewport, glScissor, | 21 GL_FOG_COLOR, GL_COLOR_BUFFER_BIT, GLfloat, glViewport, glScissor, |
22 GL_SCISSOR_TEST, GL_DEPTH_BUFFER_BIT) | 22 GL_SCISSOR_TEST, GL_DEPTH_BUFFER_BIT) |
23 | 23 |
24 from pytouhou.utils.maths cimport perspective, setup_camera, ortho_2d | 24 from pytouhou.utils.maths cimport perspective, setup_camera, ortho_2d |
25 from .shaders.eosd import GameShader, BackgroundShader | 25 from .shaders.eosd import GameShader, BackgroundShader, PassthroughShader |
26 | 26 |
27 from collections import namedtuple | 27 from collections import namedtuple |
28 Rect = namedtuple('Rect', 'x y w h') | 28 Rect = namedtuple('Rect', 'x y w h') |
29 Color = namedtuple('Color', 'r g b a') | 29 Color = namedtuple('Color', 'r g b a') |
30 | 30 |
37 | 37 |
38 if not self.use_fixed_pipeline: | 38 if not self.use_fixed_pipeline: |
39 self.game_shader = GameShader() | 39 self.game_shader = GameShader() |
40 self.background_shader = BackgroundShader() | 40 self.background_shader = BackgroundShader() |
41 self.interface_shader = self.game_shader | 41 self.interface_shader = self.game_shader |
42 self.passthrough_shader = PassthroughShader() | |
43 | |
44 self.framebuffer = Framebuffer(0, 0, 640, 480) | |
42 | 45 |
43 | 46 |
44 cdef void load_background(self, background): | 47 cdef void load_background(self, background): |
45 if background is not None: | 48 if background is not None: |
46 self.background_renderer = BackgroundRenderer(self.use_fixed_pipeline) | 49 self.background_renderer = BackgroundRenderer(self.use_fixed_pipeline) |
56 self.game_mvp = game_view * self.proj | 59 self.game_mvp = game_view * self.proj |
57 self.interface_mvp = ortho_2d(0., float(game.interface.width), float(game.interface.height), 0.) | 60 self.interface_mvp = ortho_2d(0., float(game.interface.width), float(game.interface.height), 0.) |
58 | 61 |
59 | 62 |
60 cdef void render(self, game): | 63 cdef void render(self, game): |
64 if not self.use_fixed_pipeline: | |
65 self.framebuffer.bind() | |
66 | |
61 self.render_game(game) | 67 self.render_game(game) |
62 self.render_text(game.texts + game.native_texts) | 68 self.render_text(game.texts + game.native_texts) |
63 self.render_interface(game.interface, game.boss) | 69 self.render_interface(game.interface, game.boss) |
70 | |
71 if not self.use_fixed_pipeline: | |
72 self.passthrough_shader.bind() | |
73 self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp) | |
74 self.render_framebuffer(self.framebuffer) | |
64 | 75 |
65 | 76 |
66 cdef void render_game(self, game): | 77 cdef void render_game(self, game): |
67 cdef long game_x, game_y | 78 cdef long game_x, game_y |
68 cdef float x, y, z, dx, dy, dz, fog_data[4], fog_start, fog_end | 79 cdef float x, y, z, dx, dy, dz, fog_data[4], fog_start, fog_end |