How it works...

The vertex shader is almost as simple as it can get. It converts the point's position to camera coordinates by multiplying by the model-view matrix, and assigns the result to the built-in output variable, gl_Position.

In the geometry shader, we start by defining the kind of primitive that this geometry shader expects to receive. The first layout statement indicates that this geometry shader will receive point primitives:

layout( points ) in; 

The next layout statement indicates the kind of primitives produced by this geometry shader, and the maximum number of vertices that will be output:

layout( triangle_strip, max_vertices = 4 ) out; 

In this case, we want to produce a single quad for each point received, so we indicate ...

Get OpenGL 4 Shading Language Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.