From cd40bc28f508a3203180c4fb80ece9339ac27c99 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Sun, 30 Jan 2011 14:23:13 +0100 Subject: [PATCH] shader: fixes for correctly check if the shader have been successfully compiled or not (thanks hansent) --- kivy/graphics/shader.pxd | 1 + kivy/graphics/shader.pyx | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kivy/graphics/shader.pxd b/kivy/graphics/shader.pxd index 7488a3f1d..3cc35643e 100644 --- a/kivy/graphics/shader.pxd +++ b/kivy/graphics/shader.pxd @@ -19,6 +19,7 @@ cdef class Shader: cdef int get_uniform_loc(self, str name) cdef void bind_attrib_locations(self) cdef void build(self) + cdef int is_linked(self) cdef GLuint compile_shader(self, char* source, shadertype) cdef str get_shader_log(self, shader) cdef str get_program_log(self, shader) diff --git a/kivy/graphics/shader.pyx b/kivy/graphics/shader.pyx index 2583adf5a..e40668d22 100644 --- a/kivy/graphics/shader.pyx +++ b/kivy/graphics/shader.pyx @@ -158,6 +158,13 @@ cdef class Shader: glLinkProgram(self.program) self.uniform_locations = dict() self.process_build_log() + if not self.is_linked(): + raise Exception('Shader didnt link, check info log.') + + cdef int is_linked(self): + cdef GLint result + glGetProgramiv(self.program, GL_LINK_STATUS, &result) + return 1 if result == GL_TRUE else 0 cdef GLuint compile_shader(self, char* source, shadertype): shader = glCreateShader(shadertype) @@ -191,8 +198,7 @@ cdef class Shader: cdef void process_message(self, str ctype, str message): message = message.strip() if message and message != 'Success.': - Logger.error('Shader: %s: <%s>' % (ctype, message)) - raise Exception(message) + Logger.info('Shader: %s: <%s>' % (ctype, message)) else: - Logger.debug('Shader: %s compiled successfully' % ctype) + Logger.info('Shader: %s compiled successfully' % ctype)