Using Shaders in an IDL Application
The IDLgrShader object class exposes OpenGL Shader Language (GLSL) code within an IDL application. Using shader object properties, you can define the required vertex shader and fragment shader components (described in Vertex and Fragment Shaders) by either passing in a string containing the GLSL program or by passing in a filename. Always associate a shader object with an atomic graphic object using the SHADER property. SHADER is a property of the following objects:
| IDLgrAxis |
IDLgrPlot |
IDLgrROIGroup |
| IDLgrContour |
IDLgrPolygon |
IDLgrSurface |
| IDLgrImage |
IDLgrPolyline |
IDLgrText |
| IDLgrLight |
IDLgrROI |
IDLgrVolume |
Although a shader object can be associated with any number of the listed graphic objects, a shader program is typically written with a specific object in mind since the IDL application will likely pass object-specific parameters to the shader program. For example, a byte-scale image processing shader would have little applicability to a text object. Additional shader-related properties exist on IDLgrImage, IDLgrLight, IDLgrPlot, IDLgrPolygon, IDLgrPolyline, and IDLgrSurface. These are described in the example sections.
Warning
Setting IDLgrImage RENDER_METHOD=1 (do not render image as texture-mapped polygon) disables all shader functionality including the software-based alternative.
Note
In an image processing application, more than a single shader can be associated with an IDLgrImage object through the use of an IDLgrFilterChain object. See Filter Chain Shaders for details.
Note
Shaders are a hardware-based feature. Be sure to specify the hardware renderer (for example, set the IDLgrWindow RENDERER property to 0).
Display-Only Effects of Shaders
Unless a shader program is associated with an IDLgrImage object, processing results are visible only on the display. The non-display objects (IDLgrBuffer, IDLgrClipboard, IDLgrPrinter and IDLgrVRML) do not support shader functionality.
If the shader is associated with an IDLgrImage object, there are two exceptions to this display-only limitation. You can capture image data after the application of a shader using the IDLgrImage::ReadFilteredData method. See Capturing Image Data During Shader Execution. You can also access full resolution image data if you have implemented a software-based alternative to an image processing shader application. See Providing a Software Alternative to Shaders for details.
Note
As long as there is hardware support for a shader program, shader program parameters take precedence over any OpenGL fixed pipeline parameters defined using object properties.