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