10.02.2014 Views

spec - OpenGL

spec - OpenGL

spec - OpenGL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

2.14. VERTEX SHADERS 107<br />

LINK_STATUS is FALSE, its program binary length is zero, and a call to GetProgramBinary<br />

will generate an INVALID_OPERATION error.<br />

The command<br />

void ProgramBinary( uint program, enum binaryFormat,<br />

const void *binary, sizei length );<br />

loads a program object with a program binary previously returned from GetProgramBinary.<br />

This is useful for future instantiations of the GL to avoid online compilation,<br />

while still using <strong>OpenGL</strong> Shading Language source shaders as a portable<br />

initial format. binaryFormat and binary must be those returned by a previous<br />

call to GetProgramBinary, and length must be the length of the program binary<br />

as returned by GetProgramBinary or GetProgramiv with pname PROGRAM_-<br />

BINARY_LENGTH. The program binary will fail, setting the LINK_STATUS of program<br />

to FALSE, if these conditions are not met.<br />

A program binary may also fail if the implementation determines that there has<br />

been a change in hardware or software configuration from when the program binary<br />

was produced such as having been compiled with an incompatible or outdated<br />

version of the compiler. In this case the application should fall back to providing<br />

the original <strong>OpenGL</strong> Shading Language source shaders, and perhaps again retrieve<br />

the program binary for future use.<br />

A program object’s program binary is replaced by calls to LinkProgram or<br />

ProgramBinary. Where linking success or failure is concerned, ProgramBinary<br />

can be considered to perform an implicit linking operation. LinkProgram and<br />

ProgramBinary both set the program object’s LINK_STATUS to TRUE or FALSE,<br />

as queried with GetProgramiv, to reflect success or failure and update the information<br />

log, queried with GetProgramInfoLog, to provide details about warnings<br />

or errors.<br />

A successful call to ProgramBinary will reset all uniform variables to their<br />

initial values. The initial value is either the value of the variable’s initializer as<br />

<strong>spec</strong>ified in the original shader source, or zero if no initializer was present.<br />

Additionally, all vertex shader input and fragment shader output assignments<br />

that were in effect when the program was linked before saving are restored when<br />

ProgramBinary is called.<br />

If ProgramBinary failed, any information about a previous link or load of that<br />

program object is lost. Thus, a failed load does not restore the old state of program.<br />

The failure does not alter other program state not affected by linking such as the<br />

attached shaders, and the vertex attribute and fragment data location bindings as<br />

set by BindAttribLocation and BindFragDataLocation.<br />

Queries of values NUM_PROGRAM_BINARY_FORMATS and PROGRAM_-<br />

BINARY_FORMATS return the number of program binary formats and the list of<br />

<strong>OpenGL</strong> 4.2 (Compatibility Profile) - August 22, 2011

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

Saved successfully!

Ooh no, something went wrong!