comparison pytouhou/ui/opengl/shader.pyx @ 557:0f2af7552462

Don’t hardcode GLSL version in our shaders, instead make them dependent on GL version.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 30 May 2014 16:40:36 +0200
parents 6e3b3d5d4691
children b8df946d394d
comparison
equal deleted inserted replaced
556:c34b23e29d16 557:0f2af7552462
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 19
20 from libc.stdlib cimport malloc, free 20 from libc.stdlib cimport malloc, free
21 from .backend cimport shader_header
21 22
22 23
23 class GLSLException(Exception): 24 class GLSLException(Exception):
24 pass 25 pass
25 26
49 # attempt to link the program 50 # attempt to link the program
50 self.link() 51 self.link()
51 52
52 cdef void create_shader(self, const GLchar *string, GLenum shader_type): 53 cdef void create_shader(self, const GLchar *string, GLenum shader_type):
53 cdef GLint temp 54 cdef GLint temp
54 cdef const GLchar **strings = &string 55 cdef const GLchar *strings[2]
56 strings[:] = [shader_header, string]
55 57
56 # create the shader handle 58 # create the shader handle
57 shader = glCreateShader(shader_type) 59 shader = glCreateShader(shader_type)
58 60
59 # upload the source strings 61 # upload the source strings
60 glShaderSource(shader, 1, strings, NULL) 62 glShaderSource(shader, 2, strings, NULL)
61 63
62 # compile the shader 64 # compile the shader
63 glCompileShader(shader) 65 glCompileShader(shader)
64 66
65 # retrieve the compile status 67 # retrieve the compile status