Mercurial > touhou
comparison pytouhou/ui/opengl/gamerenderer.pyx @ 579:b8df946d394d
Add grouping for OpenGL calls, making traces much more readable.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sun, 17 Aug 2014 16:16:58 +0200 |
parents | b21922a03830 |
children | 6e79756b7f42 |
comparison
equal
deleted
inserted
replaced
578:00f228b57840 | 579:b8df946d394d |
---|---|
18 from pytouhou.lib.opengl cimport \ | 18 from pytouhou.lib.opengl cimport \ |
19 (glClear, glMatrixMode, glLoadIdentity, glLoadMatrixf, glDisable, | 19 (glClear, glMatrixMode, glLoadIdentity, glLoadMatrixf, glDisable, |
20 glEnable, glFogi, glFogf, glFogfv, GL_PROJECTION, GL_MODELVIEW, | 20 glEnable, glFogi, glFogf, glFogfv, GL_PROJECTION, GL_MODELVIEW, |
21 GL_FOG, GL_FOG_MODE, GL_LINEAR, GL_FOG_START, GL_FOG_END, | 21 GL_FOG, GL_FOG_MODE, GL_LINEAR, GL_FOG_START, GL_FOG_END, |
22 GL_FOG_COLOR, GL_COLOR_BUFFER_BIT, GLfloat, glViewport, glScissor, | 22 GL_FOG_COLOR, GL_COLOR_BUFFER_BIT, GLfloat, glViewport, glScissor, |
23 GL_SCISSOR_TEST, GL_DEPTH_BUFFER_BIT) | 23 GL_SCISSOR_TEST, GL_DEPTH_BUFFER_BIT, glPushDebugGroup, |
24 GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup) | |
24 | 25 |
25 from pytouhou.utils.matrix cimport mul, new_identity | 26 from pytouhou.utils.matrix cimport mul, new_identity |
26 from pytouhou.utils.maths cimport perspective, setup_camera, ortho_2d | 27 from pytouhou.utils.maths cimport perspective, setup_camera, ortho_2d |
27 from pytouhou.game.text cimport NativeText, GlyphCollection | 28 from pytouhou.game.text cimport NativeText, GlyphCollection |
28 from .shaders.eosd import GameShader, BackgroundShader, PassthroughShader | 29 from .shaders.eosd import GameShader, BackgroundShader, PassthroughShader |
91 self.render_game(game) | 92 self.render_game(game) |
92 self.render_text(game.texts) | 93 self.render_text(game.texts) |
93 self.render_interface(game.interface, game.boss) | 94 self.render_interface(game.interface, game.boss) |
94 | 95 |
95 if not is_legacy: | 96 if not is_legacy: |
97 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Scaled rendering") | |
96 self.passthrough_shader.bind() | 98 self.passthrough_shader.bind() |
97 self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp) | 99 self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp) |
98 self.render_framebuffer(self.framebuffer) | 100 self.render_framebuffer(self.framebuffer) |
101 glPopDebugGroup() | |
99 | 102 |
100 | 103 |
101 cdef void render_game(self, Game game): | 104 cdef void render_game(self, Game game): |
102 cdef long game_x, game_y | 105 cdef long game_x, game_y |
103 cdef float x, y, z, dx, dy, dz | 106 cdef float x, y, z, dx, dy, dz |
104 cdef float fog_data[4] | 107 cdef float fog_data[4] |
105 cdef float fog_start, fog_end | 108 cdef float fog_start, fog_end |
106 cdef unsigned char fog_r, fog_g, fog_b | 109 cdef unsigned char fog_r, fog_g, fog_b |
107 cdef Matrix *mvp | 110 cdef Matrix *mvp |
111 | |
112 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Game rendering") | |
108 | 113 |
109 game_x, game_y = game.interface.game_pos | 114 game_x, game_y = game.interface.game_pos |
110 glViewport(game_x, game_y, game.width, game.height) | 115 glViewport(game_x, game_y, game.width, game.height) |
111 glClear(GL_DEPTH_BUFFER_BIT) | 116 glClear(GL_DEPTH_BUFFER_BIT) |
112 glScissor(game_x, game_y, game.width, game.height) | 117 glScissor(game_x, game_y, game.width, game.height) |
202 color1 = Color(0, 0, 0, 192) | 207 color1 = Color(0, 0, 0, 192) |
203 color2 = Color(0, 0, 0, 128) | 208 color2 = Color(0, 0, 0, 128) |
204 self.render_quads([rect], [(color1, color1, color2, color2)], 0) | 209 self.render_quads([rect], [(color1, color1, color2, color2)], 0) |
205 | 210 |
206 glDisable(GL_SCISSOR_TEST) | 211 glDisable(GL_SCISSOR_TEST) |
212 glPopDebugGroup() | |
207 | 213 |
208 | 214 |
209 cdef void render_text(self, dict texts): | 215 cdef void render_text(self, dict texts): |
210 cdef NativeText label | 216 cdef NativeText label |
211 | 217 |
232 cdef void render_interface(self, interface, game_boss): | 238 cdef void render_interface(self, interface, game_boss): |
233 cdef GlyphCollection label | 239 cdef GlyphCollection label |
234 | 240 |
235 elements = [] | 241 elements = [] |
236 | 242 |
243 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Interface rendering") | |
237 if is_legacy: | 244 if is_legacy: |
238 glMatrixMode(GL_MODELVIEW) | 245 glMatrixMode(GL_MODELVIEW) |
239 glLoadMatrixf(<GLfloat*>self.interface_mvp) | 246 glLoadMatrixf(<GLfloat*>self.interface_mvp) |
240 glDisable(GL_FOG) | 247 glDisable(GL_FOG) |
241 else: | 248 else: |
260 | 267 |
261 elements.extend(labels) | 268 elements.extend(labels) |
262 self.render_elements(elements) | 269 self.render_elements(elements) |
263 for label in labels: | 270 for label in labels: |
264 label.changed = False | 271 label.changed = False |
272 glPopDebugGroup() |