21.06.2014 Views

OpenGL 4.2 (Compatibility Profile) - April 27, 2012

OpenGL 4.2 (Compatibility Profile) - April 27, 2012

OpenGL 4.2 (Compatibility Profile) - April 27, 2012

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

2.14. VERTEX SHADERS 96<br />

compiled together be specified to LinkProgram. Not specifying an optimized pair<br />

may cause LinkProgram to fail.<br />

2.14.3 Program Objects<br />

The shader objects that are to be used by the programmable stages of the GL are<br />

collected together to form a program object. The programs that are executed by<br />

these programmable stages are called executables. All information necessary for<br />

defining an executable is encapsulated in a program object. A program object is<br />

created with the command<br />

uint CreateProgram( void );<br />

Program objects are empty when they are created. A non-zero name that can be<br />

used to reference the program object is returned. If an error occurs, zero will be<br />

returned.<br />

To attach a shader object to a program object, use the command<br />

void AttachShader( uint program, uint shader );<br />

The error INVALID_OPERATION is generated if shader is already attached to program.<br />

Shader objects may be attached to program objects before source code has<br />

been loaded into the shader object, or before the shader object has been compiled.<br />

Multiple shader objects of the same type may be attached to a single program<br />

object, and a single shader object may be attached to more than one program object.<br />

To detach a shader object from a program object, use the command<br />

void DetachShader( uint program, uint shader );<br />

The error INVALID_OPERATION is generated if shader is not attached to program.<br />

If shader has been flagged for deletion and is not attached to any other program<br />

object, it is deleted.<br />

In order to use the shader objects contained in a program object, the program<br />

object must be linked. The command<br />

void LinkProgram( uint program );<br />

will link the program object named program. Each program object has a boolean<br />

status, LINK_STATUS, that is modified as a result of linking. This status can be<br />

queried with GetProgramiv (see section 6.1.18). This status will be set to TRUE if<br />

a valid executable is created, and FALSE otherwise.<br />

Linking can fail for a variety of reasons as specified in the <strong>OpenGL</strong> Shading<br />

Language Specification, as well as any of the following reasons:<br />

<strong>OpenGL</strong> <strong>4.2</strong> (<strong>Compatibility</strong> <strong>Profile</strong>) - <strong>April</strong> <strong>27</strong>, <strong>2012</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!