
252 III Bending the Pipeline
in vec3 position [];
out vec4 color ;
void main () {
gl_Position = vec4 ( -0.5 ,0.0 ,0.0 ,1.0);
color = vec4 (+ position [0] ,1.0);
EmitVertex();
gl_Position = vec4 (+0.5 ,0.0 ,0.0 ,1.0);
color = vec4(-position [0] ,1.0);
EmitVertex();
}
Listing 18.2. Bounding-box update geometry shader.
•
Read back the bounding box texture in a buffer attached to the GL PIXEL
PACK BUFFER target.
The vertex shader just passes the local vertex position to the geometry stage. This
position is set as a color of the first pixel by the geometry shader, while the negated
position is written to the second pixel color (see Listing 18.2). We negate the position ...