Graphics Reference
In-Depth Information
Standard OpenGL Function
Built-in Atribute Variable
glVertex(...)
gl_Vertex
glColor(...)
gl_Color
glNormal(...)
gl_Normal
glSecondaryColor(...)
gl_SecondaryColor
glMultiTexCoord(i, ...)
gl_MultiTexCoordi, i=1..N
glFogCoordf(...)
gl_FogCoord
Table 14.2. Atribute variables deined by compatibility-mode OpenGL vertex functions.
A C++ Class to Handle Shader Program Creation
Appendix A shows a C++ class that is handy for shader creation and use. As a
preview, here is how such an application would look:
#include “glslprogram.h”
float Ad, Bd, NoiseAmp, NoiseFreq, Tol;
GLSLProgram * Ovals;
During setup:
Ovals = new GLSLProgram( );
Ovals->SetVerbose( true );
Ovals->SetGstap( true );
bool good = Ovals->Create( “ovalnoise.vert”, “ovalnoise.frag” );
if( ! good )
{
fprintf( stderr, “GLSL Program Ovals wasn't created.\n” );
<<handle the fact that the shaders did not compile or link>>
}
In the display callback:
Ovals->Use( );
// we assume the user has interactively changed the uniform
// vars:
Ovals->SetUniform( “uAd”, Ad );
Ovals->SetUniform( “uBd”, Bd );
Ovals->SetUniform( “uNoiseAmp”, NoiseAmp );
Ovals->SetUniform( “uNoiseFreq”, NoiseFreq );
Ovals->SetUniform( “uTol”, Tol );
Search WWH ::




Custom Search