
i
i
i
i
i
i
i
i
358 14. High-Quality 3D with OpenGL 2
14.1.2 Compiling, Installing and Using OpenGL Shaders
Putting this is terms of a simple recipe:
1. Read the shader source code from text files or store them in character
memory buffers. The vertex and fragment programs are separate pieces
of code; a typical shader will have one of each. The shader file or text
buffer will contain text like this:
varying float LightIntensity;
void main(void){
gl_FragColor = gl_Color
*
LightIntensity;
}
In a C text array, this might look like:
char gouraud_fragment_shader[] = "varying float LightIntensity;void main(void){"
"gl_FragColor = gl_Color
*
LightIntensity;}";
2. Create a shader ...