Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
om::graphics::materials::DeviceShader Class Referenceabstract

A class that represents a hardware-executed programmable rendering stage. More...

#include <omGraphicsDeviceShader.h>

Inheritance diagram for om::graphics::materials::DeviceShader:
om::graphics::devices::DeviceResource om::graphics::devices::opengl::OpenGLShader

Public Member Functions

const ShaderTypegetType () const
 Return an object indicating the type of shader this is. More...
 
virtual ShaderSourceString getSource () const =0
 Return the source code used by this shader. More...
 
virtual Bool setSource (const ShaderSourceString &newSource, const ShaderLanguage &newLanguage)=0
 Set the source code used by the shader. More...
 
virtual Bool compile (StringOutputStream *compilationLog=((void *) 0))=0
 Compile the shader's source code and return whether or not the operation was successful. More...
 
virtual Bool isCompiled () const =0
 Return whether or not this shader has been compiled. More...
 
- Public Member Functions inherited from om::graphics::devices::DeviceResource
virtual ~DeviceResource ()
 Destroy a device object, releasing all internal state. More...
 
GraphicsContextgetContext () const
 Return a pointer to the graphics context associated with this DeviceResource. More...
 
virtual Bool isValid () const =0
 Return whether or not the state of this device resource is valid and able to be used for rendering. More...
 

Protected Member Functions

 DeviceShader (devices::GraphicsContext *newContext, ShaderType newShaderType)
 Create a device shader for the specified context with the given shader type. More...
 
- Protected Member Functions inherited from om::graphics::devices::DeviceResource
 DeviceResource (GraphicsContext *newContext)
 Create a new device object that is associated with the specified graphics context. More...
 

Protected Attributes

ShaderType shaderType
 An enum value that is set by subclasses that specifies the kind of shader this is. More...
 

Detailed Description

A class that represents a hardware-executed programmable rendering stage.

A shader is defined by its source code, a string of characters which uses an implementation-defined language to perform graphics operations such as lighting and shading.

Constructor & Destructor Documentation

om::graphics::materials::DeviceShader::DeviceShader ( devices::GraphicsContext newContext,
ShaderType  newShaderType 
)
inlineprotected

Create a device shader for the specified context with the given shader type.

Member Function Documentation

const ShaderType& om::graphics::materials::DeviceShader::getType ( ) const
inline

Return an object indicating the type of shader this is.

virtual ShaderSourceString om::graphics::materials::DeviceShader::getSource ( ) const
pure virtual

Return the source code used by this shader.

This method downloads the shader source code from the driver/GPU and returns a string containing the previously submitted source code, or an empty string if there is no source code or the shader is invalid.

Implemented in om::graphics::devices::opengl::OpenGLShader.

virtual Bool om::graphics::materials::DeviceShader::setSource ( const ShaderSourceString newSource,
const ShaderLanguage newLanguage 
)
pure virtual

Set the source code used by the shader.

This method replaces the current source code for this shader. The shader must be compiled before the new source code takes effect.

The method allows the user to specify the language of the shader's source code. This allows the implementation to choose the correct compiler for the shader.

If there is an error or the specified language is not supported, FALSE is returned and the source code for the shader is unchanged. Otherwise, the method succeeds and TRUE is returned.

Implemented in om::graphics::devices::opengl::OpenGLShader.

virtual Bool om::graphics::materials::DeviceShader::compile ( StringOutputStream compilationLog = ((void *) 0))
pure virtual

Compile the shader's source code and return whether or not the operation was successful.

If the result of compilation was not successful, the error output of the compilation is sent to the specified string output stream.

Implemented in om::graphics::devices::opengl::OpenGLShader.

virtual Bool om::graphics::materials::DeviceShader::isCompiled ( ) const
pure virtual

Return whether or not this shader has been compiled.

The return value indicates whether or not a compilation operation has been attempted since the last source code change, not whether or not the compilation was without error.

Implemented in om::graphics::devices::opengl::OpenGLShader.

Member Data Documentation

ShaderType om::graphics::materials::DeviceShader::shaderType
protected

An enum value that is set by subclasses that specifies the kind of shader this is.


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