Graphics Reference
In-Depth Information
There is an issue about using the function glProgramParameteri( ) in a display
list, which may not be obvious but which can cause some difficulties. Consider the
following example of using a geometry shader within a display list:
GLuint dl = glGenLists( 1 );
glNewList( dl, GL_COMPILE );
. . .
program = glCreateProgram( );
. . .
glProgramParameteriEXT( program,GL_GEOMETRY_INPUT_TYPE,
inputGeometryType);
glProgramParameteriEXT(program,GL_GEOMETRY_OUTPUT_TYPE,
outputGeometryType);
glProgramParameteriEXT(program,GL_GEOMETRY_VERTICES_OUT,101);
glLinkProgram( program );
glUseProgram( program );
. . .
glEndList( );
These glProgramParameteri( ) and glUseProgram(program) function calls will
be deferred until the list is executed by the execution of glCallList( l ) , but the
glCreateProgram( ) and glLinkProgram( program ) calls that are highlighted will
be executed immediately when they are processed, even though the rest of the list is
deferred. So while the parameter setting function can be placed inside a display list
definition, this is usually a bad idea, because that would defer the execution of the
function until glCallList( ) is called for the list you are defining. Then the geometry
shader would be called with the wrong parameters, giving incorrect results. Our ad-
vice is to defer both the setting of program parameters and the linking of the shader
program until after the display list is complete, or, more likely, create the program and
then put just the glUseProgram( ) and drawing commands in the display list. There is
rarely a good reason to have calls to glProgramParameteri( ) in a display list.
If you are using the glProgramParameteri( ) functions instead of the
layout identifiers, those functions must be called, and all these parameters set,
before the shaders are linked in the application.
There are some additional new GLSL functions for geometry shaders.
These are
EmitVertex( ) : send the vertex you have been developing on to the sec-
ond primitive assembly step.
EndPrimitive( ) : take all the vertices that have been sent to primitive
assembly and create a geometric primitive to send on for further process-
ing.
Search WWH ::




Custom Search