A short tutorial; a more detailed one is available here.
A Passthrough Program
Geometry programs are not yet exposed in Cg so for now you have to use GLSL:
Setting Input Type
You must tell GL what kind of primitives your geometry shader will accept as input before linking your program. Note that this does not necessarily correspond to the parameter of
glBegin():
Setting Output Type
Likewise, you must tell GL what kind of primitives your geometry shader will output before
linking your program. This does not necessarily correspond to the value of GL_GEOMETRY_INPUT_TYPE_EXT:
Setting Max Output Vertices
Since you may not emit an unbounded number of points from a geometry shader, you are required to let OpenGL know the maximum number of points any instance of the shader will emit. Set this parameter after creating the program, but before linking:
To query the maximum number of emitted vertices your implementation of OpenGL supports:
And the maximum number of total components:
Emulating Geometry Programs on Older Cards

If you don't have access to a DX10 graphics card you can make the driver emulate new extensions on older NVIDIA hardware. Here's how:
- Download NVEmulate
- Install a driver at least as new as Release 95. Currently only available to registered developers.
- Run NVEmulate.
- Select G80 (GeForce 8800 GTS, Quadro FX) in both drop down boxes.
- Click Apply
- Run your program
Clicking restore will restore the driver to the default settings.
Exposing G80 GLSL Features
Geometry shader functionality is not exposed by default in the current NVIDIA drivers. Even if you do not need to emulate a G80 in software, you must tell the driver to expose the geometry shader compiler. Do this by selecting G80 in the second drop down box. If you do not do this, your program will crash in glProgramParameteriEXT().
Geometry Shader Built-In Attributes Reference
From spec:
Notes
- It is an error to attach a geometry shader to a program without attaching a vertex shader.
- It is an error to use a geometry shader without specifying GL_GEOMETRY_VERTICES_OUT_EXT.
- The shader will not compile correctly without the #version and #extension pragmas.
- In general, you must specify the type of the primitives input and output to and from the geometry shader. These need not necessarily be the same type. By default, this is set to GL_TRIANGLES. Forgetting to set this parameter may result in a black screen.
Links