Files Class List
GLSLShader Class Reference

Detailed Description

GLSL shader class.

This class provides basic functionality for compiling GLSL shaders either from a given source string or a given file. It only stores the shader ID and it can be safely deleted after the shader is used for building (linking) a GLSL program.

#include <cyGL.h>

Public Member Functions

 GLSLShader ()
 Constructor.
 
virtual ~GLSLShader ()
 Destructor that deletes the shader.
 
General Methods
void Delete ()
 Deletes the shader.
 
GLuint GetID () const
 Returns the shader ID.
 
bool IsNull () const
 Returns true if the OpenGL shader object is not generated, i.e. the shader id is invalid.
 
Compilation Methods
bool CompileFile (char const *filename, GLenum shaderType, std::ostream *outStream=&std::cout)
 Compiles the shader using the given file. If the shader was previously compiled, it is deleted.
 
bool CompileFile (char const *filename, GLenum shaderType, char const *prependSource, std::ostream *outStream=&std::cout)
 Compiles the shader using the given file. If the shader was previously compiled, it is deleted. The prependSource string is added to the beginning of the shader code, so it must begin with the "#version" statement.
 
bool CompileFile (char const *filename, GLenum shaderType, int prependSourceCount, char const **prependSources, std::ostream *outStream=&std::cout)
 Compiles the shader using the given file. If the shader was previously compiled, it is deleted. The prependSources strings are added to the beginning of the shader code, so the first string must begin with "#version" statement.
 
bool Compile (char const *shaderSourceCode, GLenum shaderType, std::ostream *outStream=&std::cout)
 Compiles the shader using the given source code. If the shader was previously compiled, it is deleted.
 
bool Compile (char const *shaderSourceCode, GLenum shaderType, char const *prependSource, std::ostream *outStream=&std::cout)
 Compiles the shader using the given source code. If the shader was previously compiled, it is deleted. The prependSource string is added to the beginning of the shader code, so it must begin with the "#version" statement.
 
bool Compile (char const *shaderSourceCode, GLenum shaderType, int prependSourceCount, char const **prependSources, std::ostream *outStream=&std::cout)
 Compiles the shader using the given source code. If the shader was previously compiled, it is deleted. The prependSources strings are added to the beginning of the shader code, so the first string must begin with "#version" statement.