comparison pytouhou/ui/opengl/shader.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 0f2af7552462
children 6e79756b7f42
comparison
equal deleted inserted replaced
578:00f228b57840 579:b8df946d394d
13 (glCreateProgram, glCreateShader, GL_VERTEX_SHADER, 13 (glCreateProgram, glCreateShader, GL_VERTEX_SHADER,
14 GL_FRAGMENT_SHADER, glShaderSource, glCompileShader, glGetShaderiv, 14 GL_FRAGMENT_SHADER, glShaderSource, glCompileShader, glGetShaderiv,
15 GL_COMPILE_STATUS, GL_INFO_LOG_LENGTH, glGetShaderInfoLog, 15 GL_COMPILE_STATUS, GL_INFO_LOG_LENGTH, glGetShaderInfoLog,
16 glAttachShader, glLinkProgram, glGetProgramiv, glGetProgramInfoLog, 16 glAttachShader, glLinkProgram, glGetProgramiv, glGetProgramInfoLog,
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 20
20 from libc.stdlib cimport malloc, free 21 from libc.stdlib cimport malloc, free
21 from .backend cimport shader_header 22 from .backend cimport shader_header
22 23
23 24
27 28
28 cdef class Shader: 29 cdef class Shader:
29 # 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
30 # concattenated into one string by OpenGL 31 # concattenated into one string by OpenGL
31 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")
34
32 # create the program handle 35 # create the program handle
33 self.handle = glCreateProgram() 36 self.handle = glCreateProgram()
34 # we are not linked yet 37 # we are not linked yet
35 self.linked = False 38 self.linked = False
36 39
47 glBindAttribLocation(self.handle, 1, 'in_texcoord') 50 glBindAttribLocation(self.handle, 1, 'in_texcoord')
48 glBindAttribLocation(self.handle, 2, 'in_color') 51 glBindAttribLocation(self.handle, 2, 'in_color')
49 52
50 # attempt to link the program 53 # attempt to link the program
51 self.link() 54 self.link()
55
56 glPopDebugGroup()
52 57
53 cdef void create_shader(self, const GLchar *string, GLenum shader_type): 58 cdef void create_shader(self, const GLchar *string, GLenum shader_type):
54 cdef GLint temp 59 cdef GLint temp
55 cdef const GLchar *strings[2] 60 cdef const GLchar *strings[2]
56 strings[:] = [shader_header, string] 61 strings[:] = [shader_header, string]