Thread: [PyOpenGL-Users] Shader linking problems...
Brought to you by:
mcfletch
From: Nick K. <bod...@gm...> - 2009-03-17 22:21:42
|
Hi all, I've been having some problems getting some basic shaders to link when loading from a file. If I hard code the shaders as a python string, I have no problems. Here's how I'm loading the shaders. f = open('test.vert') vertex = f.read() f.close() f = open('test.frag') fragment = f.read() f.close program = compile_program(vertex, fragment) I know that the file's are loading from doing a print of the two vars. Here's my compile functions: def compile_shader(source, shader_type): shader = glCreateShaderObjectARB(shader_type) glShaderSourceARB(shader, source) glCompileShaderARB(shader) status = glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB) if not status: print_log(shader) glDeleteObjectARB(shader) raise ValueError, 'Shader compilation failed' return shader def compile_program(vertex_source, fragment_source): glInitShaderObjectsARB() glInitVertexShaderARB() glInitFragmentShaderARB() program = glCreateProgramObjectARB() if vertex_source: vertex_shader = compile_shader(vertex_source, GL_VERTEX_SHADER_ARB) glAttachObjectARB(program, vertex_shader) if fragment_source: fragment_shader = compile_shader(fragment_source, GL_FRAGMENT_SHADER_ARB) glAttachObjectARB(program, fragment_shader) glLinkProgramARB(program) status = glGetObjectParameterivARB(program, GL_OBJECT_LINK_STATUS_ARB) if not status: print_program_log(program) raise ValueError, 'Program link failed' if vertex_shader: glDeleteObjectARB(vertex_shader) if fragment_shader: glDeleteObjectARB(fragment_shader) return program def print_log(shader): length = glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB) if length > 0: log = glGetInfoLogARB(shader) print log def print_program_log(program): length = glGetObjectParameterivARB(program, GL_OBJECT_INFO_LOG_LENGTH_ARB) if length > 0: log = glGetInfoLogARB(program) print log else: print 'An error occurred in the program.' Any ideas? Thanks! -bodiddlie |
From: Ian M. <geo...@gm...> - 2009-03-17 22:35:40
|
Perhaps newlines are getting mixed in when the file is read? |
From: <bod...@gm...> - 2009-03-17 23:55:27
|
Maybe, but I'm thinking not. The shaders compile fine, then error on linking. -----Original Message----- From: Ian Mallett <geo...@gm...> Date: Tue, 17 Mar 2009 15:35:37 To: PyOpenGL Users<pyo...@li...> Subject: [PyOpenGL-Users] Shader linking problems... ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com |
From: Gijs <in...@bs...> - 2009-03-18 14:01:29
|
On 3/18/09 2:36 PM, Nick Klepinger wrote: > On Wed, Mar 18, 2009 at 6:12 AM, Gijs <in...@bs... > <mailto:in...@bs...>> wrote: > > On 3/17/09 11:58 PM, bod...@gm... > <mailto:bod...@gm...> wrote: > > Maybe, but I'm thinking not. The shaders compile fine, then > error on linking. > -----Original Message----- > From: Ian Mallett<geo...@gm... > <mailto:geo...@gm...>> > > Date: Tue, 17 Mar 2009 15:35:37 > To: PyOpenGL Users<pyo...@li... > <mailto:pyo...@li...>> > Subject: [PyOpenGL-Users] Shader linking problems... > > What is the error that you get? > > Regards, Gijs > > > This is the what shows in the info log: > > Fragment shader(s) failed to link, vertex shader(s) failed to link. > ERROR: 0:1: 'v' : syntax error parse error > ERROR: compilation errors. No code generated. > > ERROR: 0:1: 'v' : syntax error parse error > ERROR: compilation errors. No code generated. > > Here's the shaders I'm trying to load. > > varying vec3 pos; > void main() { > pos = gl_Vertex.xyz; > gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; > } > > varying vec3 pos; > void main() { > gl_FragColor.rgb = pos.xyz; > } > > > Also, tried this last night on my laptop running Ubuntu Hardy, and it > ran fine. This is error is showing up on XP. > > -bodiddlie > I've only seen this error occur when you print your log using the program-object instead of the shader-object. You sure you're printing the log from the correct object? (I'm sure there is an error otherwise it would just run fine) Regards, Gijs PS: You also need to send a reply to the mailinglist :) |
From: Nick K. <bod...@gm...> - 2009-03-18 14:32:58
|
On Wed, Mar 18, 2009 at 7:15 AM, Mike C. Fletcher <mcf...@vr...>wrote: > Gijs wrote: > >> On 3/18/09 2:36 PM, Nick Klepinger wrote: >> >> > ... > >> This is the what shows in the info log: >>> >>> Fragment shader(s) failed to link, vertex shader(s) failed to link. >>> ERROR: 0:1: 'v' : syntax error parse error >>> ERROR: compilation errors. No code generated. >>> >>> >> Definitely sounds like you're passing a string instead of a > list-of-strings. > > Enjoy, > > Mike > > -- > ________________________________________________ > Mike C. Fletcher > Designer, VR Plumber, Coder > http://www.vrplumber.com > http://blog.vrplumber.com > > Sure enough, that did the trick. Interesting it runs perfectly fine on Linux. Thanks for all the help everyone! -bodiddlie |
From: Gijs <in...@bs...> - 2009-03-20 08:33:09
|
On 3/18/09 3:32 PM, Nick Klepinger wrote: > > > On Wed, Mar 18, 2009 at 7:15 AM, Mike C. Fletcher > <mcf...@vr... <mailto:mcf...@vr...>> wrote: > > Gijs wrote: > > On 3/18/09 2:36 PM, Nick Klepinger wrote: > > ... > > This is the what shows in the info log: > > Fragment shader(s) failed to link, vertex shader(s) > failed to link. > ERROR: 0:1: 'v' : syntax error parse error > ERROR: compilation errors. No code generated. > > Definitely sounds like you're passing a string instead of a > list-of-strings. > > Enjoy, > > Mike > > -- > ________________________________________________ > Mike C. Fletcher > Designer, VR Plumber, Coder > http://www.vrplumber.com > http://blog.vrplumber.com > > > > Sure enough, that did the trick. Interesting it runs perfectly fine > on Linux. Thanks for all the help everyone! > > -bodiddlie Would be nice if PyOpenGL could warn us about it. The last time I had this problem, it took me almost 2 days to find the cause. Since it was running without any errors on Mac OS X and only begin to throw errors at me in WinXP when I upgraded my videocard/updated videocard driver. Linux didn't like it either. Since the error itself doesn't quite explain what is going on, I only found the problem after having checked every status of the compile/link/validate-step. Regards, Gijs |
From: Mike C. F. <mcf...@vr...> - 2009-03-18 14:03:41
|
Nick Klepinger wrote: > Hi all, > > I've been having some problems getting some basic shaders to link when > loading from a file. If I hard code the shaders as a python string, I > have no problems. Here's how I'm loading the shaders. Only thing that jumps out at me is that you're compiling a single string, while glShaderSource normally takes a list-of-strings. I know I've seen that fail before. Other big difference might be that you've got a unicode value popping up from somewhere, with a null-byte value terminating the string as far as OpenGL is concerned. Good luck, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Mike C. F. <mcf...@vr...> - 2009-03-18 14:15:30
|
Gijs wrote: > On 3/18/09 2:36 PM, Nick Klepinger wrote: > ... >> This is the what shows in the info log: >> >> Fragment shader(s) failed to link, vertex shader(s) failed to link. >> ERROR: 0:1: 'v' : syntax error parse error >> ERROR: compilation errors. No code generated. >> Definitely sounds like you're passing a string instead of a list-of-strings. Enjoy, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |