OpenGL Volumizer 2.9 Reference Pages


NAME
vzTMFragmentShader - Class for using fragment Shaders.

INHERITS FROM
vzTMShader

HEADER FILE
#include <Volumizer2/TMFragmentShader.h>

PUBLIC METHOD SUMMARY
static vzTMFragmentShader* load ( const char* filename);
vzTMFragmentShader ( char* fragmentShader);
void setShader ( char* fragmentShader);
char* getShader (  );

PROTECTED METHOD SUMMARY
virtual ~vzTMFragmentShader (  );

CLASS DESCRIPTION
The vzTMFragmentShader is a built-in shader to be used with the vzTMRenderAction. The class is derived from vzTMShader and provides an interface for programmable shading using the ARB_fragment_shader extension. The shader accepts the fragment shader string as an argument to its constructor. The fragment shader is applied to each polygon being rendered for the shape's geometry. The program string can be updated using the appropriate set method. The OpenGL state for the shader can be set and restored using the pre and post shape callbacks. The volume is rendered using 3D texture mapping with the given "volume" texture as the currently bound texture.

PARAMETERS
The shader uses a single parameter:


METHOD DESCRIPTIONS

   vzTMFragmentShader()
vzTMFragmentShader ( char* fragmentShader);

Constructor. The program string is shallow copied internally to the fragment shader program and hence should not be deleted.

   ~vzTMFragmentShader()
virtual ~vzTMFragmentShader (  );

Destructor.

   getShader()
char* getShader (  );

Get the program string for this shader.

   load()
static vzTMFragmentShader* load ( const char* filename);

Factory used to load the fragment shader program from the given file name.
For example, the following code  illustrates the use of a fragment shader.This shader computes the
final color of a fragment by multiplying the color values from two volumes.

   static char FragmentShader[] = "void main(void){\n"
                                  "vec4 color , color1;\n"
                                  "color = texture3D(volume,volume_TexCoord.stp);\n"
                                  "color1 = texture3D(volume2,volume2_TexCoord.stp);\n"
                                  "gl_FragColor = color * color1;\n"
                                  "}"

   // Load the fragment shader
   vzTMFragmentShader *fs = new vzTMFragmentShader(FragmentShader);

volume_TexCoord and volume2_TexCoord are the internal Volumizer variables as explained in programming
guide.

   setShader()
void setShader ( char* fragmentShader);

Update the program string for the fragment shader.

SEE ALSO
vzParameterVolumeTexture, vzTMRenderAction, vzTMShader

Back to Index