23.06.2013 Views

The OpenGL Graphics System: A Specification

The OpenGL Graphics System: A Specification

The OpenGL Graphics System: A Specification

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.15. VERTEX SHADERS 71<br />

2.14.9 Final Color Processing<br />

For an RGBA color, each color component (which lies in [0, 1]) is converted<br />

(by rounding to nearest) to a fixed-point value with m bits. We assume that<br />

the fixed-point representation used represents each value k/(2 m − 1), where<br />

k ∈ {0, 1, . . . , 2 m − 1}, as k (e.g. 1.0 is represented in binary as a string of<br />

all ones). m must be at least as large as the number of bits in the corresponding<br />

component of the framebuffer. m must be at least 2 for A if the framebuffer does<br />

not contain an A component, or if there is only 1 bit of A in the framebuffer. A<br />

color index is converted (by rounding to nearest) to a fixed-point value with at least<br />

as many bits as there are in the color index portion of the framebuffer.<br />

Because a number of the form k/(2 m − 1) may not be represented exactly as<br />

a limited-precision floating-point quantity, we place a further requirement on the<br />

fixed-point conversion of RGBA components. Suppose that lighting is disabled, the<br />

color associated with a vertex has not been clipped, and one of Colorub, Colorus,<br />

or Colorui was used to specify that color. When these conditions are satisfied, an<br />

RGBA component must convert to a value that matches the component as specified<br />

in the Color command: if m is less than the number of bits b with which the<br />

component was specified, then the converted value must equal the most significant<br />

m bits of the specified value; otherwise, the most significant b bits of the converted<br />

value must equal the specified value.<br />

2.15 Vertex Shaders<br />

<strong>The</strong> sequence of operations described in sections 2.11 through 2.14 is a fixedfunction<br />

method for processing vertex data. Applications can more generally describe<br />

the operations that occur on vertex values and their associated data by using<br />

a vertex shader.<br />

A vertex shader is an array of strings containing source code for the operations<br />

that are meant to occur on each vertex that is processed. <strong>The</strong> language used for<br />

vertex shaders is described in the <strong>OpenGL</strong> Shading Language <strong>Specification</strong>.<br />

To use a vertex shader, shader source code is first loaded into a shader object<br />

and then compiled. One or more vertex shader objects are then attached to a program<br />

object. A program object is then linked, which generates executable code<br />

from all the compiled shader objects attached to to the program. When a linked<br />

program object is used as the current program object, the executable code for the<br />

vertex shaders it contains is used to process vertices.<br />

In addition to vertex shaders, fragment shaders can be created, compiled, and<br />

linked into program objects. Fragment shaders affect the processing of fragments<br />

Version 2.0 - October 22, 2004

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

Saved successfully!

Ooh no, something went wrong!