Castor3D  ..
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Castor3D::ShaderObject Class Referenceabstract

Base shader class. More...

+ Collaboration diagram for Castor3D::ShaderObject:

Classes

class  BinaryParser
 ShaderObject loader. More...
 
class  TextLoader
 ShaderObject loader. More...
 

Public Member Functions

C3D_API ShaderObject (ShaderProgram *p_parent, eSHADER_TYPE p_type)
 Constructor. More...
 
virtual C3D_API ~ShaderObject ()
 Destructor. More...
 
virtual C3D_API bool Create ()=0
 Creates the program on GPU. More...
 
virtual C3D_API void Destroy ()=0
 Destroys the program on GPU. More...
 
virtual C3D_API void Detach ()=0
 Detaches this shader from it's program. More...
 
virtual C3D_API void AttachTo (ShaderProgram &p_program)=0
 Attaches this shader to the given program. More...
 
C3D_API void SetFile (eSHADER_MODEL p_eModel, Castor::Path const &p_pathFile)
 Sets the shader file for given model. More...
 
C3D_API bool HasFile () const
 Tells if the shader object has a source file, whatever model it is. More...
 
C3D_API void SetSource (eSHADER_MODEL p_eModel, Castor::String const &p_strSource)
 Sets the shader source for given model. More...
 
C3D_API bool HasSource () const
 Tells if the shader object has a source code, whatever model it is. More...
 
C3D_API void Bind ()
 Activates the shader. More...
 
C3D_API void Unbind ()
 Deactivates the shader. More...
 
virtual C3D_API bool Compile ()
 Compiles the shader. More...
 
virtual C3D_API void AddFrameVariable (OneIntFrameVariableSPtr p_variable)
 Adds a uniform variable to pass to the shader objects. More...
 
C3D_API OneIntFrameVariableSPtr FindFrameVariable (Castor::String const &p_name) const
 Finds a variable. More...
 
virtual C3D_API void FlushFrameVariables ()
 Removes all frame variables. More...
 
FrameVariablePtrList & GetFrameVariables ()
 Retrieves the frame variables bound to this shader. More...
 
FrameVariablePtrList const & GetFrameVariables () const
 Retrieves the frame variables bound to this shader. More...
 
virtual bool HasParameter (Castor::String const &p_name)
 Tells if the compiled shader has the given parameter. More...
 
Castor::String const & GetSource (eSHADER_MODEL p_eModel) const
 Retrieves the shader source for given model. More...
 
Castor::String const & GetLoadedSource () const
 Retrieves the compiled shader source. More...
 
Castor::Path const & GetFile (eSHADER_MODEL p_eModel) const
 Retrieves the shader file for given model. More...
 
Castor::Path const & GetCurrentFile () const
 Retrieves the shader file for current model. More...
 
Castor::String GetStrType () const
 Retrieves the name of this object type. More...
 
eSHADER_TYPE GetType () const
 Retrieves the this object type. More...
 
void SetInputType (eTOPOLOGY p_topology)
 Sets the input primitives type. More...
 
eTOPOLOGY GetInputType () const
 Retrieves the intput primitives type. More...
 
void SetOutputType (eTOPOLOGY p_topology)
 Sets the output primitives type. More...
 
eTOPOLOGY GetOutputType () const
 Retrieves the output primitives type. More...
 
void SetOutputVtxCount (uint8_t p_count)
 Sets the output vertex count. More...
 
uint8_t GetOutputVtxCount () const
 Retrieves the output vertex count. More...
 
eSHADER_STATUS GetStatus () const
 Retrieves the object compile status. More...
 
ShaderProgramGetParent () const
 Retrieves the object parent. More...
 
virtual void SetParameter (Castor::String const &p_name, Castor::Matrix4x4r const &p_value)
 Defines the given parameter value. More...
 
virtual void SetParameter (Castor::String const &p_name, Castor::Matrix3x3r const &p_value)
 Defines the given parameter value. More...
 

Protected Member Functions

C3D_API bool DoCheckErrors ()
 Checks for compiler errors. More...
 
virtual Castor::String DoRetrieveCompilerLog ()=0
 

Protected Attributes

ShaderProgramm_parent
 The parent shader program. More...
 
eSHADER_TYPE m_type
 
std::array< Castor::Path, eSHADER_MODEL_COUNT > m_arrayFiles
 Array of files path, sorted by shader model. More...
 
std::array< Castor::String, eSHADER_MODEL_COUNT > m_arraySources
 Array of source codes, sorted by shader model. More...
 
Castor::String m_loadedSource
 Actually loaded file path. More...
 
Castor::Path m_pathLoadedFile
 The shader compile status. More...
 
eSHADER_STATUS m_status
 
FrameVariablePtrStrMap m_mapFrameVariables
 The frame variables map, ordered by name. More...
 
FrameVariablePtrList m_listFrameVariables
 The frame variables map. More...
 
eTOPOLOGY m_eInputType
 The input primitive type (for geometry shaders) More...
 
eTOPOLOGY m_eOutputType
 The output primitive type (for geometry shaders) More...
 
uint8_t m_uiOutputVtxCount
 The output vertex count (for geometry shaders) More...
 
eSHADER_MODEL m_eShaderModel
 The current shader model. More...
 

Detailed Description

Base shader class.

Author
Sylvain DOREMUS
Version
0.6.1.0
Date
03/01/2011
Remarks
Used to share functions through the supported shader languages

Constructor & Destructor Documentation

◆ ShaderObject()

C3D_API Castor3D::ShaderObject::ShaderObject ( ShaderProgram p_parent,
eSHADER_TYPE  p_type 
)

Constructor.

Parameters
[in]p_parentParent program
[in]p_typeShader type

◆ ~ShaderObject()

virtual C3D_API Castor3D::ShaderObject::~ShaderObject ( )
virtual

Destructor.

Member Function Documentation

◆ AddFrameVariable()

virtual C3D_API void Castor3D::ShaderObject::AddFrameVariable ( OneIntFrameVariableSPtr  p_variable)
virtual

Adds a uniform variable to pass to the shader objects.

Parameters
[in]p_variableThe variable to pass

◆ AttachTo()

virtual C3D_API void Castor3D::ShaderObject::AttachTo ( ShaderProgram p_program)
pure virtual

Attaches this shader to the given program.

Parameters
[in]p_programThe program

◆ Bind()

C3D_API void Castor3D::ShaderObject::Bind ( )

Activates the shader.

◆ Compile()

virtual C3D_API bool Castor3D::ShaderObject::Compile ( )
virtual

Compiles the shader.

Returns
true on success

◆ Create()

virtual C3D_API bool Castor3D::ShaderObject::Create ( )
pure virtual

Creates the program on GPU.

◆ Destroy()

virtual C3D_API void Castor3D::ShaderObject::Destroy ( )
pure virtual

Destroys the program on GPU.

◆ Detach()

virtual C3D_API void Castor3D::ShaderObject::Detach ( )
pure virtual

Detaches this shader from it's program.

◆ DoCheckErrors()

C3D_API bool Castor3D::ShaderObject::DoCheckErrors ( )
protected

Checks for compiler errors.

Returns
true if no error.

◆ DoRetrieveCompilerLog()

virtual Castor::String Castor3D::ShaderObject::DoRetrieveCompilerLog ( )
protectedpure virtual
Returns
Retrieve compiler messages.
Les messages du compilateur.

◆ FindFrameVariable()

C3D_API OneIntFrameVariableSPtr Castor3D::ShaderObject::FindFrameVariable ( Castor::String const &  p_name) const

Finds a variable.

Returns
The found variable, nullptr if failed

◆ FlushFrameVariables()

virtual C3D_API void Castor3D::ShaderObject::FlushFrameVariables ( )
virtual

Removes all frame variables.

◆ GetCurrentFile()

Castor::Path const& Castor3D::ShaderObject::GetCurrentFile ( ) const
inline

Retrieves the shader file for current model.

Returns
The file name

References m_arrayFiles, and m_eShaderModel.

◆ GetFile()

Castor::Path const& Castor3D::ShaderObject::GetFile ( eSHADER_MODEL  p_eModel) const
inline

Retrieves the shader file for given model.

Parameters
[in]p_eModelThe shader model
Returns
The file name

References m_arrayFiles.

◆ GetFrameVariables() [1/2]

FrameVariablePtrList& Castor3D::ShaderObject::GetFrameVariables ( )
inline

Retrieves the frame variables bound to this shader.

Returns
The list

References m_listFrameVariables.

◆ GetFrameVariables() [2/2]

FrameVariablePtrList const& Castor3D::ShaderObject::GetFrameVariables ( ) const
inline

Retrieves the frame variables bound to this shader.

Returns
The list

References m_listFrameVariables.

◆ GetInputType()

eTOPOLOGY Castor3D::ShaderObject::GetInputType ( ) const
inline

Retrieves the intput primitives type.

Returns
The primitives type

References m_eInputType.

◆ GetLoadedSource()

Castor::String const& Castor3D::ShaderObject::GetLoadedSource ( ) const
inline

Retrieves the compiled shader source.

Returns
The source code

References m_loadedSource.

◆ GetOutputType()

eTOPOLOGY Castor3D::ShaderObject::GetOutputType ( ) const
inline

Retrieves the output primitives type.

Returns
The primitives type

References m_eOutputType.

◆ GetOutputVtxCount()

uint8_t Castor3D::ShaderObject::GetOutputVtxCount ( ) const
inline

Retrieves the output vertex count.

Returns
The count

References m_uiOutputVtxCount.

◆ GetParent()

ShaderProgram* Castor3D::ShaderObject::GetParent ( ) const
inline

Retrieves the object parent.

Returns
The parent

References m_parent.

◆ GetSource()

Castor::String const& Castor3D::ShaderObject::GetSource ( eSHADER_MODEL  p_eModel) const
inline

Retrieves the shader source for given model.

Parameters
[in]p_eModelThe shader model
Returns
The source code

References m_arraySources.

◆ GetStatus()

eSHADER_STATUS Castor3D::ShaderObject::GetStatus ( ) const
inline

Retrieves the object compile status.

Returns
The status

References m_status.

◆ GetStrType()

Castor::String Castor3D::ShaderObject::GetStrType ( ) const
inline

Retrieves the name of this object type.

Returns
The type name

References m_type.

◆ GetType()

eSHADER_TYPE Castor3D::ShaderObject::GetType ( ) const
inline

Retrieves the this object type.

Returns
The type

References m_type.

◆ HasFile()

C3D_API bool Castor3D::ShaderObject::HasFile ( ) const

Tells if the shader object has a source file, whatever model it is.

Returns
true if the shader object has a source file

◆ HasParameter()

virtual bool Castor3D::ShaderObject::HasParameter ( Castor::String const &  p_name)
inlinevirtual

Tells if the compiled shader has the given parameter.

Parameters
[in]p_nameThe parameter name
Returns
true if the parameter was found

◆ HasSource()

C3D_API bool Castor3D::ShaderObject::HasSource ( ) const

Tells if the shader object has a source code, whatever model it is.

Returns
true if the shader object has a source code

◆ SetFile()

C3D_API void Castor3D::ShaderObject::SetFile ( eSHADER_MODEL  p_eModel,
Castor::Path const &  p_pathFile 
)

Sets the shader file for given model.

Remarks
The loaded file will be the one of the highest supported profile
Parameters
[in]p_eModelThe shader model
[in]p_pathFileThe file name

◆ SetInputType()

void Castor3D::ShaderObject::SetInputType ( eTOPOLOGY  p_topology)
inline

Sets the input primitives type.

Parameters
[in]p_topologyThe input primitives type

References m_eInputType.

◆ SetOutputType()

void Castor3D::ShaderObject::SetOutputType ( eTOPOLOGY  p_topology)
inline

Sets the output primitives type.

Parameters
[in]p_topologyThe primitives type

References m_eOutputType.

◆ SetOutputVtxCount()

void Castor3D::ShaderObject::SetOutputVtxCount ( uint8_t  p_count)
inline

Sets the output vertex count.

Parameters
[in]p_countThe count

References m_uiOutputVtxCount.

◆ SetParameter() [1/2]

virtual void Castor3D::ShaderObject::SetParameter ( Castor::String const &  p_name,
Castor::Matrix4x4r const &  p_value 
)
inlinevirtual

Defines the given parameter value.

Parameters
[in]p_nameThe parameter name
[in]p_valueThe parameter value

◆ SetParameter() [2/2]

virtual void Castor3D::ShaderObject::SetParameter ( Castor::String const &  p_name,
Castor::Matrix3x3r const &  p_value 
)
inlinevirtual

Defines the given parameter value.

Parameters
[in]p_nameThe parameter name
[in]p_valueThe parameter value

◆ SetSource()

C3D_API void Castor3D::ShaderObject::SetSource ( eSHADER_MODEL  p_eModel,
Castor::String const &  p_strSource 
)

Sets the shader source for given model.

Remarks
The loaded source will be the one of the highest supported profile
Parameters
[in]p_eModelThe shader model
[in]p_strSourceThe source code

◆ Unbind()

C3D_API void Castor3D::ShaderObject::Unbind ( )

Deactivates the shader.

Member Data Documentation

◆ m_arrayFiles

std::array< Castor::Path, eSHADER_MODEL_COUNT > Castor3D::ShaderObject::m_arrayFiles
protected

Array of files path, sorted by shader model.

Referenced by GetCurrentFile(), and GetFile().

◆ m_arraySources

std::array< Castor::String, eSHADER_MODEL_COUNT > Castor3D::ShaderObject::m_arraySources
protected

Array of source codes, sorted by shader model.

Actually loaded ASCII Source-Code

Referenced by GetSource().

◆ m_eInputType

eTOPOLOGY Castor3D::ShaderObject::m_eInputType
protected

The input primitive type (for geometry shaders)

Referenced by GetInputType(), and SetInputType().

◆ m_eOutputType

eTOPOLOGY Castor3D::ShaderObject::m_eOutputType
protected

The output primitive type (for geometry shaders)

Referenced by GetOutputType(), and SetOutputType().

◆ m_eShaderModel

eSHADER_MODEL Castor3D::ShaderObject::m_eShaderModel
protected

The current shader model.

Referenced by GetCurrentFile().

◆ m_listFrameVariables

FrameVariablePtrList Castor3D::ShaderObject::m_listFrameVariables
protected

The frame variables map.

Referenced by GetFrameVariables().

◆ m_loadedSource

Castor::String Castor3D::ShaderObject::m_loadedSource
protected

Actually loaded file path.

Referenced by GetLoadedSource().

◆ m_mapFrameVariables

FrameVariablePtrStrMap Castor3D::ShaderObject::m_mapFrameVariables
protected

The frame variables map, ordered by name.

◆ m_parent

ShaderProgram* Castor3D::ShaderObject::m_parent
protected

The parent shader program.

The shader type

Referenced by GetParent().

◆ m_pathLoadedFile

Castor::Path Castor3D::ShaderObject::m_pathLoadedFile
protected

The shader compile status.

◆ m_status

eSHADER_STATUS Castor3D::ShaderObject::m_status
protected

Referenced by GetStatus().

◆ m_type

eSHADER_TYPE Castor3D::ShaderObject::m_type
protected

Referenced by GetStrType(), and GetType().

◆ m_uiOutputVtxCount

uint8_t Castor3D::ShaderObject::m_uiOutputVtxCount
protected

The output vertex count (for geometry shaders)

Referenced by GetOutputVtxCount(), and SetOutputVtxCount().


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