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 ()
 
virtual ~GLSLShader ()
 
General Methods
void Delete ()
 
GLuint GetID () const
 
bool IsNull () const
 
Compilation Methods
bool CompileFile (const char *filename, GLenum shaderType, std::ostream *outStream=&std::cout)
 
bool CompileFile (const char *filename, GLenum shaderType, const char *prependSource, std::ostream *outStream=&std::cout)
 
bool CompileFile (const char *filename, GLenum shaderType, int prependSourceCount, const char **prependSources, std::ostream *outStream=&std::cout)
 
bool Compile (const char *shaderSourceCode, GLenum shaderType, std::ostream *outStream=&std::cout)
 
bool Compile (const char *shaderSourceCode, GLenum shaderType, const char *prependSource, std::ostream *outStream=&std::cout)
 
bool Compile (const char *shaderSourceCode, GLenum shaderType, int prependSourceCount, const char **prependSources, std::ostream *outStream=&std::cout)
 

Constructor & Destructor Documentation

§ GLSLShader()

Constructor.

§ ~GLSLShader()

virtual ~GLSLShader ( )
virtual

Destructor that deletes the shader.

Member Function Documentation

§ Delete()

void Delete ( )

Deletes the shader.

§ GetID()

GLuint GetID ( ) const

Returns the shader ID.

§ IsNull()

bool IsNull ( ) const

Returns true if the OpenGL shader object is not generated, i.e. the shader id is invalid.

§ CompileFile() [1/3]

bool CompileFile ( const char *  filename,
GLenum  shaderType,
std::ostream *  outStream = &std::cout 
)

Compiles the shader using the given file. If the shader was previously compiled, it is deleted.

§ CompileFile() [2/3]

bool CompileFile ( const char *  filename,
GLenum  shaderType,
const char *  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.

§ CompileFile() [3/3]

bool CompileFile ( const char *  filename,
GLenum  shaderType,
int  prependSourceCount,
const char **  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.

§ Compile() [1/3]

bool Compile ( const char *  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.

§ Compile() [2/3]

bool Compile ( const char *  shaderSourceCode,
GLenum  shaderType,
const char *  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.

§ Compile() [3/3]

bool Compile ( const char *  shaderSourceCode,
GLenum  shaderType,
int  prependSourceCount,
const char **  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.