comparison pytouhou/ui/opengl/shader.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 538b52aafbca
comparison
equal deleted inserted replaced
581:cb8a443bc046 582:6e79756b7f42
17 GL_LINK_STATUS, glUseProgram, glGetUniformLocation, glUniform1fv, 17 GL_LINK_STATUS, glUseProgram, glGetUniformLocation, glUniform1fv,
18 glUniform4fv, glUniformMatrix4fv, glBindAttribLocation, 18 glUniform4fv, glUniformMatrix4fv, glBindAttribLocation,
19 glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup) 19 glPushDebugGroup, GL_DEBUG_SOURCE_APPLICATION, glPopDebugGroup)
20 20
21 from libc.stdlib cimport malloc, free 21 from libc.stdlib cimport malloc, free
22 from .backend cimport shader_header 22 from .backend cimport shader_header, use_debug_group
23 23
24 24
25 class GLSLException(Exception): 25 class GLSLException(Exception):
26 pass 26 pass
27 27
28 28
29 cdef class Shader: 29 cdef class Shader:
30 # vert and frag take arrays of source strings the arrays will be 30 # vert and frag take arrays of source strings the arrays will be
31 # concattenated into one string by OpenGL 31 # concattenated into one string by OpenGL
32 def __init__(self, vert=None, frag=None): 32 def __init__(self, vert=None, frag=None):
33 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Program creation") 33 if use_debug_group:
34 glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, -1, "Program creation")
34 35
35 # create the program handle 36 # create the program handle
36 self.handle = glCreateProgram() 37 self.handle = glCreateProgram()
37 # we are not linked yet 38 # we are not linked yet
38 self.linked = False 39 self.linked = False
51 glBindAttribLocation(self.handle, 2, 'in_color') 52 glBindAttribLocation(self.handle, 2, 'in_color')
52 53
53 # attempt to link the program 54 # attempt to link the program
54 self.link() 55 self.link()
55 56
56 glPopDebugGroup() 57 if use_debug_group:
58 glPopDebugGroup()
57 59
58 cdef void create_shader(self, const GLchar *string, GLenum shader_type): 60 cdef void create_shader(self, const GLchar *string, GLenum shader_type):
59 cdef GLint temp 61 cdef GLint temp
60 cdef const GLchar *strings[2] 62 cdef const GLchar *strings[2]
61 strings[:] = [shader_header, string] 63 strings[:] = [shader_header, string]