Geometry shaders are still quite new ( Feb. 2008 ), so your OpenGL implementation might not support this feature. If it does, you can see a third shader type in the editor window, the geometry shader. This shader type is not attached to the program by default, you have to check the check-box first. If you compile and run the initial shader source, you can see the test model without any modifications, because the geometry shader passes through all its input.
Geometry shaders have access to connectivity information of vertices. They can read the vertex attributes of all vertices used in a single primitive. That's the difference between the vertex and the geometry shader, because vertex shader only 'see' one individual vertex.
There is one thing that makes geometry shader more complicated than vertex and fragment shaders. Geometry shaders need to know the primitive type they are processing. And they need to know it at link time! Go to the 'Scene' tab and look at the Geometry Shader group box. There are two values, the input primitive type and the output primitive type. The input primitive type depends on the test model and is almost always GL_TRIANGLES; The output primitive type is what you want your geometry shader to output. It is GL_TRIANGLE_STRIP in most cases. You can change this value to GL_LINE_STRIP for example. If you change it, you have to relink your program. The program then keeps this value, until you relink it again. The input primitive type depends on the selected test model. So you must choose the test model BEFORE linking the shader. If you change the test model and thereby change the input primitive type, you must relink the program.
Now let's modify the initial geometry shader. Reverse the order in which the vertices define the primitive. To do that, replace the access index i with
gl_VerticesIn - i - 1
Now you should see the test model like before. So what is it good for? Choose the cube test model and check the 'Back Face Culling' check box. Because the order of the vertices is reversed, front faces become back faces and vice versa. If you apply a texture map to the cube, you can see the effect even better.
There is a test model called 'Single Point'. And this is really just a single point. Now you have a scenario to use this test model: The geometry shader is executed for every input primitive and with only a single point as input, the geometry shader is executed exactly once! This allows you to create your own geometry on the GPU without overdrawing it several times.