Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | Namespace Members | Class Members | Related Pages

Shader Class Reference
[XEngineCore Library]

Inheritance diagram for Shader:

Inheritance graph
[legend]
List of all members.

Detailed Description

This class serves as abstract base class for all other shaders. For XEngine, a shader is a piece of code used to program certain parts of the graphics pipeline. Shader types are distinguished by their computational frequency, for example per vertex or per fragment.

To use a shader you must first add source code to it and then compile it. Once a shader has been compiled, no more source code can be appended to it and it cannot be compiled again. You need to create a new shader to do this. To be able to use a shader, you need to attach it to a ShaderProgram object. It is allowed to attach a not compiled shader to a ShaderProgram. However, when the ShaderProgram object gets linked, all shaders attached to it must have been compiled, or else you'll get an assert in the debug build of the library.

For details on shading language peculiarities, limitations and dependencies, see the "Related Pages".

See also:
ShaderProgram


Public Types

enum  ShaderType { VertexShader = 0, FragmentShader }
 The available shader types. More...

Public Member Functions

wxString GetSource () const
 Returns the source code of this shader.
ShaderType GetShaderType () const
 Returns the type of this shader.
const ShadingLanguageGetShadingLanguage () const
 Returns the shading language used by this shader.
const ShadingLanguageCapsGetShadingLanguageCaps () const
 Returns the shading language capabilities of the language of this shader.
void AppendSource (const wxString &source)
 Appends the given source code part to this shader.
void AppendSource (const wxFileName &fileName)
 Loads the given text file and appends it as source code to this shader.
void AppendSource (wxInputStream &inputStream)
 Reads shader source code from the given text input stream and appends it to this shader.
wxString Compile ()
 Compiles the shader.
bool IsCompiled () const
 Returns true if this shader has already been compiled.
bool IsActive () const
 Returns true if this shader is attached to the currently active shader program.


Member Enumeration Documentation

enum ShaderType
 

This enum lists the available shader types.

Enumeration values:
VertexShader  Vertex shader.
FragmentShader  Fragment shader.


Member Function Documentation

void AppendSource wxInputStream &  inputStream  ) 
 

Reads shader source code from the given input stream and appends it to this shader. The input stream must represent textual data.

Warning:
Do not call this after the shader has been compiled.

void AppendSource const wxFileName &  fileName  ) 
 

Loads the given text file and appends it as source code to this shader.

Warning:
Do not call this after the shader has been compiled.

void AppendSource const wxString &  source  ) 
 

Appends the given source code part to this shader.

Warning:
Do not call this after the shader has been compiled.

wxString Compile  ) 
 

Compiles the shader. After successful compilation, appending more source to the shader is no longer possible. The returned string can contain warning messages on successful compilation.

Exceptions:
A ShaderCompileException will be thrown with an appropriate error message as exception text in case of a compilation error.
Warning:
After successful compilation, don't call AppendSource anymore. Also calling Compile again is not allowed.

Shader::ShaderType GetShaderType  )  const
 

Returns the type of this shader.

const ShadingLanguage & GetShadingLanguage  )  const
 

Returns the shading language used by this shader.

const ShadingLanguageCaps & GetShadingLanguageCaps  )  const
 

Returns the shading language capabilities of the language of this shader.

wxString GetSource  )  const
 

Returns the source code of this shader.

bool IsActive  )  const
 

Returns true if this shader is attached to the currently active shader program.

bool IsCompiled  )  const
 

Returns true if this shader has already been compiled.


The documentation for this class was generated from the following files: