Graphics Reference
In-Depth Information
Figure 14.1. The GLSL shader-creation process from shader source to shader use.
glman , you probably realize that glman is handling a lot of infrastructure for
you. Well, it's time to pull back the curtain and talk about how to hook GLSL
shaders into an application.
As we have seen, shader programs replace fixed-function graphics opera-
tions that handle vertex, geometry, and fragment processing. When we use
shaders, we must not only provide these files, but we must also carry out sev-
eral steps, diagrammed in Figure 14.1, to integrate the shaders with our appli-
cation. These steps are
1. Create the necessary shader source file(s).
2. Read each shader source file into a null-terminated text string to be com-
piled.
3. Create an empty shader object for each shader.
4. Give each shader object the text string of its shader source.
5. Compile each shader object.
6. Create an overall shader program.
7. Atach the shader objects to the program.
8. Link the shader program.
9. Specify that the shader program is to be used in place of the fixed-func-
tion pipeline.
When these are done, OpenGL will replace the fixed-function processing
with your shaders until the application finishes or you deactivate or delete the
shader program.
Search WWH ::




Custom Search