psychopy.tools.gltools.createProgramObjectARB

psychopy.tools.gltools.createProgramObjectARB()[source]

Create an empty program object for shaders.

This creates an Architecture Review Board (ARB) program variant which is compatible with older GLSL versions and OpenGL coding practices (eg. immediate mode) on some platforms. Use *ARB variants of shader helper functions (eg. compileShaderObjectARB instead of compileShader) when working with these ARB program objects. This was included for legacy support of existing PsychoPy shaders. However, it is recommended that you use createShader() and follow more recent OpenGL design patterns for new code (if possible of course).

Returns:

OpenGL program object handle retrieved from a glCreateProgramObjectARB call.

Return type:

int

Examples

Building a program with vertex and fragment shader attachments:

myProgram = createProgramObjectARB()  # new shader object

# compile vertex and fragment shader sources
vertexShader = compileShaderObjectARB(
    vertShaderSource, GL.GL_VERTEX_SHADER_ARB)
fragmentShader = compileShaderObjectARB(
    fragShaderSource, GL.GL_FRAGMENT_SHADER_ARB)

# attach shaders to program
attachObjectARB(myProgram, vertexShader)
attachObjectARB(myProgram, fragmentShader)

# link the shader, makes `myProgram` attachments executable by their
# respective processors and available for use
linkProgramObjectARB(myProgram)

# optional, validate the program
validateProgramARB(myProgram)

# optional, detach and discard shader objects
detachObjectARB(myProgram, vertexShader)
detachObjectARB(myProgram, fragmentShader)

deleteObjectARB(vertexShader)
deleteObjectARB(fragmentShader)

Use the program in the current OpenGL state:

useProgramObjectARB(myProgram)

Back to top