Graphics Reference
In-Depth Information
// draw something:
glColor3f( 0., 1., 0. );
glutSolidTeapot( 1. );
// go back to the fixed-function pipeline:
Ovals->UseFixedFunction( );
. . .
// draw some items with the fixed-function pipeline:
. . .
Notes
This example does not use a geometry shader but it could, just by listing
the name of the .geom file. The Create( ) method accepts any number
of shader file names, up to five.
The handles for the individual shaders are hidden in the class. You really
don't need to know them yourself.
The handle for the overall shader program is hidden in the class. You
really don't need to know it yourself.
The uniform variable locations are also hidden in the class. They are
determined once, and then looked up whenever they are needed.
All compiler and linker error messages are sent to standard error. The
application can determine if something failed, because the return from
the GLSLProgram constructor is NULL.
The structure of this class can be found in the appendix, and the class code can
be found in the online materials for the topic.
Exercises
1. Take a project you wrote for fixed-function OpenGL and rewrite it with
shader programs replacing the fixed-function vertex and fragment pro-
cessing. Choose a straightforward program, not one that uses sophisti-
cated graphics, because the goal of this exercise is simply to get shader
programs working for you. Add something in the shaders that is not
available in the original program, though.
2. We gave a general example of creating a user-deined atribute variable
that holds the value of the pressure (a one-dimensional value) at each
Search WWH ::




Custom Search