comparison pytouhou/ui/opengl/gamerenderer.pyx @ 582:6e79756b7f42

Don’t call gl*DebugGroup if it isn’t exposed by the driver.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sun, 05 Oct 2014 17:46:51 +0200
parents b8df946d394d
children 4b0593da29d5
comparison
equal deleted inserted replaced
581:cb8a443bc046 582:6e79756b7f42
26 from pytouhou.utils.matrix cimport mul, new_identity 26 from pytouhou.utils.matrix cimport mul, new_identity
27 from pytouhou.utils.maths cimport perspective, setup_camera, ortho_2d 27 from pytouhou.utils.maths cimport perspective, setup_camera, ortho_2d
28 from pytouhou.game.text cimport NativeText, GlyphCollection 28 from pytouhou.game.text cimport NativeText, GlyphCollection
29 from .shaders.eosd import GameShader, BackgroundShader, PassthroughShader 29 from .shaders.eosd import GameShader, BackgroundShader, PassthroughShader
30 from .renderer cimport Texture 30 from .renderer cimport Texture
31 from .backend cimport is_legacy 31 from .backend cimport is_legacy, use_debug_group
32 32
33 from collections import namedtuple 33 from collections import namedtuple
34 Rect = namedtuple('Rect', 'x y w h') 34 Rect = namedtuple('Rect', 'x y w h')
35 Color = namedtuple('Color', 'r g b a') 35 Color = namedtuple('Color', 'r g b a')
36 36
92 self.render_game(game) 92 self.render_game(game)
93 self.render_text(game.texts) 93 self.render_text(game.texts)
94 self.render_interface(game.interface, game.boss) 94 self.render_interface(game.interface, game.boss)
95 95
96 if not is_legacy: 96 if not is_legacy:
97 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Scaled rendering") 97 if use_debug_group:
98 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Scaled rendering")
99
98 self.passthrough_shader.bind() 100 self.passthrough_shader.bind()
99 self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp) 101 self.passthrough_shader.uniform_matrix('mvp', self.interface_mvp)
100 self.render_framebuffer(self.framebuffer) 102 self.render_framebuffer(self.framebuffer)
101 glPopDebugGroup() 103
104 if use_debug_group:
105 glPopDebugGroup()
102 106
103 107
104 cdef void render_game(self, Game game): 108 cdef void render_game(self, Game game):
105 cdef long game_x, game_y 109 cdef long game_x, game_y
106 cdef float x, y, z, dx, dy, dz 110 cdef float x, y, z, dx, dy, dz
107 cdef float fog_data[4] 111 cdef float fog_data[4]
108 cdef float fog_start, fog_end 112 cdef float fog_start, fog_end
109 cdef unsigned char fog_r, fog_g, fog_b 113 cdef unsigned char fog_r, fog_g, fog_b
110 cdef Matrix *mvp 114 cdef Matrix *mvp
111 115
112 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Game rendering") 116 if use_debug_group:
117 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Game rendering")
113 118
114 game_x, game_y = game.interface.game_pos 119 game_x, game_y = game.interface.game_pos
115 glViewport(game_x, game_y, game.width, game.height) 120 glViewport(game_x, game_y, game.width, game.height)
116 glClear(GL_DEPTH_BUFFER_BIT) 121 glClear(GL_DEPTH_BUFFER_BIT)
117 glScissor(game_x, game_y, game.width, game.height) 122 glScissor(game_x, game_y, game.width, game.height)
207 color1 = Color(0, 0, 0, 192) 212 color1 = Color(0, 0, 0, 192)
208 color2 = Color(0, 0, 0, 128) 213 color2 = Color(0, 0, 0, 128)
209 self.render_quads([rect], [(color1, color1, color2, color2)], 0) 214 self.render_quads([rect], [(color1, color1, color2, color2)], 0)
210 215
211 glDisable(GL_SCISSOR_TEST) 216 glDisable(GL_SCISSOR_TEST)
212 glPopDebugGroup() 217
218 if use_debug_group:
219 glPopDebugGroup()
213 220
214 221
215 cdef void render_text(self, dict texts): 222 cdef void render_text(self, dict texts):
216 cdef NativeText label 223 cdef NativeText label
217 224
238 cdef void render_interface(self, interface, game_boss): 245 cdef void render_interface(self, interface, game_boss):
239 cdef GlyphCollection label 246 cdef GlyphCollection label
240 247
241 elements = [] 248 elements = []
242 249
243 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Interface rendering") 250 if use_debug_group:
251 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Interface rendering")
252
244 if is_legacy: 253 if is_legacy:
245 glMatrixMode(GL_MODELVIEW) 254 glMatrixMode(GL_MODELVIEW)
246 glLoadMatrixf(<GLfloat*>self.interface_mvp) 255 glLoadMatrixf(<GLfloat*>self.interface_mvp)
247 glDisable(GL_FOG) 256 glDisable(GL_FOG)
248 else: 257 else:
267 276
268 elements.extend(labels) 277 elements.extend(labels)
269 self.render_elements(elements) 278 self.render_elements(elements)
270 for label in labels: 279 for label in labels:
271 label.changed = False 280 label.changed = False
272 glPopDebugGroup() 281
282 if use_debug_group:
283 glPopDebugGroup()