def log(self, shader):
    """Get the error log for a shader.
       shader = object to get log from

       Returns a string containing the log or None if there is no log."""

    length = glGetObjectParameterivARB(shader, GL_INFO_LOG_LENGTH)
    if length > 0:
      log = glGetInfoLogARB(shader)
      return log
  def compileShader(self, source, shaderType):
    """Compile shader source of given type.
       source     = file object open to shader source code
                    (or something else returning lines of GLSL code when iterated over)
       shaderType = GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB

       Returns the shader object, or raises an exception on error."""

    shader = glCreateShaderObjectARB(shaderType)
    glShaderSourceARB( shader, source )
    glCompileShaderARB( shader )
    status = glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB)
    if not status:
      raise ShaderCompilationError, self.log(shader)
    else:
      return shader