comparison pytouhou/ui/opengl/backend.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 47cf4e3d159d
comparison
equal deleted inserted replaced
581:cb8a443bc046 582:6e79756b7f42
10 10
11 GameRenderer = None 11 GameRenderer = None
12 12
13 13
14 def init(options): 14 def init(options):
15 global flavor, version, major, minor, double_buffer, is_legacy, use_vao, shader_header, GameRenderer 15 global flavor, version, major, minor, double_buffer, is_legacy, use_debug_group, use_vao, shader_header, GameRenderer
16 16
17 flavor_name = options['flavor'] 17 flavor_name = options['flavor']
18 assert flavor_name in ('core', 'es', 'compatibility', 'legacy') 18 assert flavor_name in ('core', 'es', 'compatibility', 'legacy')
19 flavor = (sdl.GL_CONTEXT_PROFILE_CORE if flavor_name == 'core' else 19 flavor = (sdl.GL_CONTEXT_PROFILE_CORE if flavor_name == 'core' else
20 sdl.GL_CONTEXT_PROFILE_ES if flavor_name == 'es' else 20 sdl.GL_CONTEXT_PROFILE_ES if flavor_name == 'es' else
25 major = int(version[0]) 25 major = int(version[0])
26 minor = int(version[2]) 26 minor = int(version[2])
27 27
28 maybe_double_buffer = options['double-buffer'] 28 maybe_double_buffer = options['double-buffer']
29 double_buffer = maybe_double_buffer if maybe_double_buffer is not None else -1 29 double_buffer = maybe_double_buffer if maybe_double_buffer is not None else -1
30 use_debug_group = (major == 4 and minor >= 3) or major > 4
30 use_vao = (major == 3 and minor >= 1) or major > 3 31 use_vao = (major == 3 and minor >= 1) or major > 3
31 32
32 is_legacy = flavor_name == 'legacy' 33 is_legacy = flavor_name == 'legacy'
33 is_gles = flavor_name == 'es' 34 is_gles = flavor_name == 'es'
34 35
63 flags |= sdl.WINDOW_RESIZABLE 64 flags |= sdl.WINDOW_RESIZABLE
64 65
65 window = Window(title, x, y, width, height, flags) 66 window = Window(title, x, y, width, height, flags)
66 window.gl_create_context() 67 window.gl_create_context()
67 68
69 if use_debug_group:
70 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "OpenGL initialisation")
71
68 # Initialize OpenGL 72 # Initialize OpenGL
69 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "OpenGL initialisation")
70 glEnable(GL_BLEND) 73 glEnable(GL_BLEND)
71 if is_legacy: 74 if is_legacy:
72 glEnable(GL_TEXTURE_2D) 75 glEnable(GL_TEXTURE_2D)
73 glHint(GL_FOG_HINT, GL_NICEST) 76 glHint(GL_FOG_HINT, GL_NICEST)
74 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST) 77 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
75 glEnableClientState(GL_COLOR_ARRAY) 78 glEnableClientState(GL_COLOR_ARRAY)
76 glEnableClientState(GL_VERTEX_ARRAY) 79 glEnableClientState(GL_VERTEX_ARRAY)
77 glEnableClientState(GL_TEXTURE_COORD_ARRAY) 80 glEnableClientState(GL_TEXTURE_COORD_ARRAY)
78 glPopDebugGroup() 81
82 if use_debug_group:
83 glPopDebugGroup()
79 84
80 return window 85 return window