Mercurial > touhou
annotate pytouhou/ui/gamerenderer.py @ 391:84b151962708
Convert pytouhou.ui.gamerenderer back to pure python, it doesn’t use or need any cython feature.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Mon, 07 Jan 2013 21:13:32 +0100 |
parents | pytouhou/ui/gamerenderer.pyx@690b5faaa0e6 |
children | 9e2cbb2c2c64 |
rev | line source |
---|---|
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
2 ## |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
3 ## Copyright (C) 2011 Thibaut Girka <thib@sitedethib.com> |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
4 ## |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
5 ## This program is free software; you can redistribute it and/or modify |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
6 ## it under the terms of the GNU General Public License as published |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
7 ## by the Free Software Foundation; version 3 only. |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
8 ## |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
9 ## This program is distributed in the hope that it will be useful, |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
10 ## but WITHOUT ANY WARRANTY; without even the implied warranty of |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
11 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
12 ## GNU General Public License for more details. |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
13 ## |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
14 |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
130
diff
changeset
|
15 |
201 | 16 from itertools import chain |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
130
diff
changeset
|
17 |
383
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
18 from pyglet.gl import (glClear, glMatrixMode, glLoadIdentity, glLoadMatrixf, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
19 glDisable, glEnable, glFogi, glFogf, glFogfv, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
20 glBlendFunc, glBindTexture, glVertexPointer, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
21 glTexCoordPointer, glColorPointer, glDrawArrays, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
22 GL_DEPTH_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
23 GL_FOG, GL_FOG_MODE, GL_LINEAR, GL_FOG_START, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
24 GL_FOG_END, GL_FOG_COLOR, GL_DEPTH_TEST, GL_SRC_ALPHA, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
25 GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_TEXTURE_2D, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
26 GL_UNSIGNED_BYTE, GL_FLOAT, GL_QUADS, |
0537af9125a7
Replace wildcard imports with normal ones.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
370
diff
changeset
|
27 GL_COLOR_BUFFER_BIT, GLfloat) |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
28 |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
29 from pytouhou.utils.matrix import Matrix |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
30 |
391
84b151962708
Convert pytouhou.ui.gamerenderer back to pure python, it doesn’t use or need any cython feature.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
31 from .renderer import Renderer |
84b151962708
Convert pytouhou.ui.gamerenderer back to pure python, it doesn’t use or need any cython feature.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
32 from .background import get_background_rendering_data |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
33 |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
34 |
125
0313ca2c50e9
Small refactoring and massive performance improvements
Thibaut Girka <thib@sitedethib.com>
parents:
123
diff
changeset
|
35 |
391
84b151962708
Convert pytouhou.ui.gamerenderer back to pure python, it doesn’t use or need any cython feature.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
36 class GameRenderer(Renderer): |
84b151962708
Convert pytouhou.ui.gamerenderer back to pure python, it doesn’t use or need any cython feature.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
37 __slots__ = ('game', 'background') |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
130
diff
changeset
|
38 |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
39 def __init__(self, resource_loader, game=None, background=None): |
222
5cac48b328ad
Refactor rendering code a bit.
Thibaut Girka <thib@sitedethib.com>
parents:
221
diff
changeset
|
40 Renderer.__init__(self, resource_loader) |
341
61caded6b4f5
Clean music playback API a little.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
330
diff
changeset
|
41 if game: |
61caded6b4f5
Clean music playback API a little.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
330
diff
changeset
|
42 self.load_game(game, background) |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
43 |
330
16ed1ab1e14b
Add a GameRunner.load_game method to allow level changes.
Thibaut Girka <thib@sitedethib.com>
parents:
327
diff
changeset
|
44 |
391
84b151962708
Convert pytouhou.ui.gamerenderer back to pure python, it doesn’t use or need any cython feature.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
384
diff
changeset
|
45 def load_game(self, game=None, background=None): |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
46 self.game = game |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
47 self.background = background |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
48 |
254
6bd565019f9a
Preload textures to avoid slowdowns during gameplay
Thibaut Girka <thib@sitedethib.com>
parents:
242
diff
changeset
|
49 if game: |
6bd565019f9a
Preload textures to avoid slowdowns during gameplay
Thibaut Girka <thib@sitedethib.com>
parents:
242
diff
changeset
|
50 # Preload textures |
6bd565019f9a
Preload textures to avoid slowdowns during gameplay
Thibaut Girka <thib@sitedethib.com>
parents:
242
diff
changeset
|
51 self.texture_manager.preload(game.resource_loader.instanced_anms.values()) |
6bd565019f9a
Preload textures to avoid slowdowns during gameplay
Thibaut Girka <thib@sitedethib.com>
parents:
242
diff
changeset
|
52 |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
53 |
131
fab7ad2f0d8b
Use Cython, improve performances!
Thibaut Girka <thib@sitedethib.com>
parents:
130
diff
changeset
|
54 def render(self): |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
55 glClear(GL_DEPTH_BUFFER_BIT) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
56 |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
57 back = self.background |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
58 game = self.game |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
59 texture_manager = self.texture_manager |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
60 |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
61 if self.use_fixed_pipeline: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
62 glMatrixMode(GL_PROJECTION) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
63 glLoadIdentity() |
217
577f45454402
Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
205
diff
changeset
|
64 |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
65 if game is not None and game.spellcard_effect is not None: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
66 if self.use_fixed_pipeline: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
67 glMatrixMode(GL_MODELVIEW) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
68 glLoadMatrixf(self.game_mvp.get_c_data()) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
69 glDisable(GL_FOG) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
70 else: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
71 self.game_shader.bind() |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
72 self.game_shader.uniform_matrixf('mvp', self.game_mvp.get_c_data()) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
73 |
306
52d791bb7c32
Rename a few attributes/methods to make a little more sense.
Thibaut Girka <thib@sitedethib.com>
parents:
304
diff
changeset
|
74 self.render_elements([game.spellcard_effect]) |
217
577f45454402
Change background during spellcards.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
205
diff
changeset
|
75 elif back is not None: |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
76 if self.use_fixed_pipeline: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
77 glEnable(GL_FOG) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
78 else: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
79 self.background_shader.bind() |
111
340fcda8e64a
Fix a few, minor things
Thibaut Girka <thib@sitedethib.com>
parents:
108
diff
changeset
|
80 fog_b, fog_g, fog_r, fog_start, fog_end = back.fog_interpolator.values |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
81 x, y, z = back.position_interpolator.values |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
82 dx, dy, dz = back.position2_interpolator.values |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
83 |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
84 glFogi(GL_FOG_MODE, GL_LINEAR) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
85 glFogf(GL_FOG_START, fog_start) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
86 glFogf(GL_FOG_END, fog_end) |
119
fad7b44cebf2
Switch from pygame + PyOpenGL to pyglet
Thibaut Girka <thib@sitedethib.com>
parents:
111
diff
changeset
|
87 glFogfv(GL_FOG_COLOR, (GLfloat * 4)(fog_r / 255., fog_g / 255., fog_b / 255., 1.)) |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
88 |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
89 model = Matrix() |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
90 model.data[3] = [-x, -y, -z, 1] |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
91 view = self.setup_camera(dx, dy, dz) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
92 model_view = model * view |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
93 model_view_projection = model * view * self.proj |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
94 |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
95 if self.use_fixed_pipeline: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
96 glMatrixMode(GL_MODELVIEW) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
97 glLoadMatrixf(model_view_projection.get_c_data()) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
98 else: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
99 self.background_shader.uniform_matrixf('model_view', model_view.get_c_data()) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
100 self.background_shader.uniform_matrixf('projection', self.proj.get_c_data()) |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
101 |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
102 glEnable(GL_DEPTH_TEST) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
103 for (texture_key, blendfunc), (nb_vertices, vertices, uvs, colors) in get_background_rendering_data(back): |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
104 glBlendFunc(GL_SRC_ALPHA, (GL_ONE_MINUS_SRC_ALPHA, GL_ONE)[blendfunc]) |
119
fad7b44cebf2
Switch from pygame + PyOpenGL to pyglet
Thibaut Girka <thib@sitedethib.com>
parents:
111
diff
changeset
|
105 glBindTexture(GL_TEXTURE_2D, texture_manager[texture_key].id) |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
106 glVertexPointer(3, GL_FLOAT, 0, vertices) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
107 glTexCoordPointer(2, GL_FLOAT, 0, uvs) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
108 glColorPointer(4, GL_UNSIGNED_BYTE, 0, colors) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
109 glDrawArrays(GL_QUADS, 0, nb_vertices) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
110 glDisable(GL_DEPTH_TEST) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
111 else: |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
112 glClear(GL_COLOR_BUFFER_BIT) |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
113 |
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
114 if game is not None: |
370
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
115 if self.use_fixed_pipeline: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
116 glMatrixMode(GL_MODELVIEW) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
117 glLoadMatrixf(self.game_mvp.get_c_data()) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
118 glDisable(GL_FOG) |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
119 else: |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
120 self.game_shader.bind() |
74471afbac37
Add a programmable pipeline renderer, and a --fixed-pipeline switch to use the old one.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
345
diff
changeset
|
121 self.game_shader.uniform_matrixf('mvp', self.game_mvp.get_c_data()) |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
122 |
304
f3099ebf4f61
Update attribute names to reflect the actual interface.
Thibaut Girka <thib@sitedethib.com>
parents:
294
diff
changeset
|
123 self.render_elements(enemy for enemy in game.enemies if enemy.visible) |
166
dcf32488a2c9
Better enemy death, with animation and (hopefully) correct flags handling.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
164
diff
changeset
|
124 self.render_elements(game.effects) |
201 | 125 self.render_elements(chain(game.players_bullets, |
294
94c636f8f863
Add player lasers for MarisaB.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
286
diff
changeset
|
126 game.lasers_sprites(), |
201 | 127 game.players, |
384
690b5faaa0e6
Make rendering of multiple-sprites elements work like single-sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
383
diff
changeset
|
128 game.msg_sprites())) |
315
e935ed8dc5e6
Add out-of-screen item indicators.
Thibaut Girka <thib@sitedethib.com>
parents:
306
diff
changeset
|
129 self.render_elements(chain(game.bullets, game.lasers, |
e935ed8dc5e6
Add out-of-screen item indicators.
Thibaut Girka <thib@sitedethib.com>
parents:
306
diff
changeset
|
130 game.cancelled_bullets, game.items, |
384
690b5faaa0e6
Make rendering of multiple-sprites elements work like single-sprites.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
383
diff
changeset
|
131 game.labels)) |
108
2a03940deea3
Move everything graphical to pytouhou.opengl!
Thibaut Girka <thib@sitedethib.com>
parents:
diff
changeset
|
132 |