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>

Classes

class  Source
 GLSL Shader Source class. More...
 

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 CompileFileEx (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. Unlike the CompileFile method, it parses the source code for include statements and recursively inserts the included files.
 
bool CompileFileEx (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. Unlike the CompileFile method, it parses the source code for include statements and recursively inserts the included files.
 
bool CompileFileEx (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. Unlike the CompileFile method, it parses the source code for include statements and recursively inserts the included files.
 
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.
 
template<bool file, bool parse>
bool Compile (char const *shaderSource, GLenum shaderType, int prependSourceCount, char const **prependSources, std::ostream *outStream=&std::cout)
 Compiles the shader using the given file or 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. If file is true, the source is treated as a file name, otherwise it is treated as the source code. If parse is true, it parses the source code for include statements and recursively inserts the included files.
 

Static Public Member Functions

Source File Management
static Source LoadSourceFile (char const *filename, std::ostream *outStream=&std::cout)
 Loads the given source file into a source string and returns it. If load fails, an error message is printed to the given out stream and an empty string is returned.