"L. Spiro Engine"
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes

lsg::CShaderBase Class Reference

The base class for shaders. More...

#include <LSGShaderBase.h>

Inheritance diagram for lsg::CShaderBase:
lsg::CDirectX11Shader lsg::CShader

List of all members.

Classes

struct  LSG_DEFINE
struct  LSG_INCLUDES
struct  LSG_PREPROC_DEFINE

Public Types

enum  LSG_SHADER_ERRORS {
  LSG_SE_SUCCESS, LSG_SE_INVALIDINPUT, LSG_SE_STREAMERROR, LSG_SE_PARSERERROR,
  LSG_SE_TRANSLATIONRERROR, LSG_SE_FILENOTFOUND, LSG_SE_OUTOFMEMORY, LSG_SE_SYNTAX,
  LSG_SE_INCLUDERECURSE, LSG_SE_INVALIDSHADERTYPE, LSG_SE_GFXAPIERROR, LSG_SE_NOENDIF,
  LSG_SE_PREPROC
}
typedef LSUINT32 LSG_HANDLE
typedef struct
lsg::CShaderBase::LSG_DEFINE
LPLSG_DEFINE
typedef struct
lsg::CShaderBase::LSG_DEFINE 
LPCLSG_DEFINE

Public Member Functions

LSVOID LSE_CALL Reset ()
virtual LSUINT64 LSE_CALL GetId () const
LSG_SHADER_ERRORS LSE_CALL Compile (CString &_sError)
LSG_SHADER_ERRORS LSE_CALL CompileFromFiles (const LSCHAR *_pcVertexFile, const LSCHAR *_pcPixelFile, CString *_psError=NULL)
LSBOOL LSE_CALL SetVertexShader (const LSCHAR *_pcShader, LSUINT32 _ui32Length=0)
LSBOOL LSE_CALL SetPixelShader (const LSCHAR *_pcShader, LSUINT32 _ui32Length=0)
LSG_SHADER_ERRORS LSE_CALL SetShaderFromFile (const LSCHAR *_pcPath, CShaderLanguageParser::LSG_SHADER_TYPES _stShaderType, CString &_sError)
LSG_SHADER_ERRORS LSE_CALL SetShaderFromMemory (const LSUINT8 *_pui8Src, LSUINT32 _ui32Length, const LSCHAR *_pcPath, CShaderLanguageParser::LSG_SHADER_TYPES _stShaderType, CString &_sError)
LSBOOL LSE_CALL SetMacros (const LSG_DEFINE *_pdDefines, LSUINT32 _ui32Total, CShaderLanguageParser::LSG_SHADER_TYPES _stShaderType)
virtual LSBOOL LSE_CALL Activate (LSVOID *_pvSysValue)=0
virtual LSVOID LSE_CALL Deactivate ()=0
virtual LSVOID LSE_CALL PreRender ()
virtual LSG_HANDLE LSE_CALL GetConstantByName (const LSCHAR *_pcName)=0
virtual LSBOOL LSE_CALL SetFloat (LSG_HANDLE _hHandle, LSFLOAT _fValue)=0
virtual LSBOOL LSE_CALL SetFloatArray (LSG_HANDLE _hHandle, const LSFLOAT *_pfValues, LSUINT32 _ui32Total)=0
virtual LSBOOL LSE_CALL SetInt (LSG_HANDLE _hHandle, LSINT32 _iValue)=0
virtual LSBOOL LSE_CALL SetIntArray (LSG_HANDLE _hHandle, const LSINT32 *_piValues, LSUINT32 _ui32Total)=0
virtual LSBOOL LSE_CALL SetBool (LSG_HANDLE _hHandle, LSBOOL _bValue)=0
virtual LSBOOL LSE_CALL SetBoolArray (LSG_HANDLE _hHandle, const LSBOOL *_pbValues, LSUINT32 _ui32Total)=0
virtual LSBOOL LSE_CALL SetVector2 (LSG_HANDLE _hHandle, const CVector2 &_vValue)=0
virtual LSBOOL LSE_CALL SetVector2Array (LSG_HANDLE _hHandle, const CVector2 *_pvValues, LSUINT32 _ui32Total)=0
virtual LSBOOL LSE_CALL SetVector3 (LSG_HANDLE _hHandle, const CVector3 &_vValue)=0
virtual LSBOOL LSE_CALL SetVector3Array (LSG_HANDLE _hHandle, const CVector3 *_pvValues, LSUINT32 _ui32Total)=0
virtual LSBOOL LSE_CALL SetVector4 (LSG_HANDLE _hHandle, const CVector4 &_vValue)=0
virtual LSBOOL LSE_CALL SetVector4Array (LSG_HANDLE _hHandle, const CVector4 *_pvValues, LSUINT32 _ui32Total)=0
virtual LSBOOL LSE_CALL SetMatrix2x2 (LSG_HANDLE _hHandle, const CMatrix2x2 &_mValue)=0
virtual LSBOOL LSE_CALL SetMatrix3x3 (LSG_HANDLE _hHandle, const CMatrix3x3 &_mValue)=0
virtual LSBOOL LSE_CALL SetMatrix4x4 (LSG_HANDLE _hHandle, const CMatrix4x4 &_mValue)=0
virtual LSBOOL LSE_CALL SetMatrix4x4Array (LSG_HANDLE _hHandle, const CMatrix4x4 *_pmValues, LSUINT32 _ui32Total)=0

Static Public Member Functions

static LSBOOL LSE_CALL AddSearchPath (const LSCHAR *_pcPath)
static LSVOID LSE_CALL RemoveSearchPath (const LSCHAR *_pcPath)
static LSUINT32 LSE_CALL TotalSearchPaths ()
static const CString &LSE_CALL GetSearchPath (LSUINT32 _ui32Index)

Protected Types

enum  LSG_CLEAR_STATE { LSG_CS_NONE, LSG_CS_CLEAR, LSG_CS_SEEKING_ENDIF }
typedef struct
lsg::CShaderBase::LSG_INCLUDES
LPLSG_INCLUDES
typedef struct
lsg::CShaderBase::LSG_INCLUDES 
LPCLSG_INCLUDES
typedef struct
lsg::CShaderBase::LSG_PREPROC_DEFINE
LPLSG_PREPROC_DEFINE
typedef struct
lsg::CShaderBase::LSG_PREPROC_DEFINE 
LPCLSG_PREPROC_DEFINE
typedef CMap< CString, LSUINT32 > CIncludeSet

Protected Member Functions

LSVOID LSE_CALL ResetParsers ()
LSG_SHADER_ERRORS LSE_CALL Compile (const LSCHAR *_pcShader, LSUINT32 _ui32Length, CShaderLanguageParser::LSG_SHADER_TYPES _stShaderType, CString &_sError)
LSG_SHADER_ERRORS LSE_CALL CompileFromFile (const LSCHAR *_pcPath, CShaderLanguageParser::LSG_SHADER_TYPES _stShaderType, CString &_sError)
LSG_SHADER_ERRORS LSE_CALL CompileFromFile (const LSCHAR *_pcPath, CStringList &_slData, LSUINT32 _ui32Line, CShaderLanguageParser::LSG_SHADER_TYPES _stShaderType, CIncludeSet &_isIncludes, CPreProc::LSG_MACROS &_mMacros, CString &_sError)
LSG_SHADER_ERRORS LSE_CALL CompileFromMemory (const LSUINT8 *_pui8Src, LSUINT32 _ui32Length, const LSCHAR *_pcPath, CStringList &_slData, LSUINT32 _ui32Line, CShaderLanguageParser::LSG_SHADER_TYPES _stShaderType, CIncludeSet &_isIncludes, CPreProc::LSG_MACROS &_mMacros, CString &_sError)
virtual LSG_SHADER_ERRORS LSE_CALL PostCompile (CString &_sError)
virtual LSVOID LSE_CALL CreateTranslator ()=0
virtual LSVOID LSE_CALL DestroyTranslator ()=0

Static Protected Member Functions

static CString LSE_CALL GetFilePart (const CString &_sDirective)
static CString LSE_CALL FindHeader (const LSCHAR *_pcIncluder, const CString &_sFileToInclude)
static LSBOOL LSE_CALL ParseDefine (const CString &_sLine, CPreProc::LSG_MACROS &_mMacros)
static LSVOID LSE_CALL RemoveComments (CStringList &_slText)
static LSVOID LSE_CALL SkipString (const CString &_sLine, LSUINT32 &_ui32Pos)
static LSBOOL LSE_CALL ExpandMacros (CString &_sString, const CPreProc::LSG_MACROS &_mMacros, CString &_sError)
static LSBOOL LSE_CALL ExpandMacros (CString &_sString, const CPreProc::LSG_MACROS &_mMacros, const CSet< CString > &_sUsedValues, CString &_sError)
static LSBOOL LSE_CALL GetMacroParms (const CString &_sString, LSUINT32 _ui32Pos, LSUINT32 &_ui32NewPos, CVector< CString > &_vRet)
static LSBOOL LSE_CALL GetMacroReplacementString (LSUINT32 _ui32MacroIndex, CVector< CString > &_vParms, const CPreProc::LSG_MACROS &_mMacros, const CSet< CString > &_sUsedValues, CString &_sRet, CString &_sError)

Protected Attributes

CShaderParserWrapperm_pspwParser
CShaderLexerm_pslLexer
CVector< LSG_PREPROC_DEFINEm_vDefs [CShaderLanguageParser::LSG_ST_TOTAL]
CString m_sVertexShader
CString m_sPixelShader
CString m_sFinalVertex
CString m_sFinalPixel
CShaderTranslationProcessorBase::LSG_ERROR_CODES m_ecTranslationResult
CShaderTranslationProcessorBasem_pstpbTranslator
CShaderTranslationProcessorBase::LSG_UNIFORM_SEMANTIC_LIST m_uslSemantics [CShaderLanguageParser::LSG_ST_TOTAL]
CShaderTranslationProcessorBase::LSG_UNIFORM_LIST m_ulUniforms [CShaderLanguageParser::LSG_ST_TOTAL]
CShaderTranslationProcessorBase::LSG_ATTRIBUTE_LIST m_ulAttributes [CShaderLanguageParser::LSG_ST_TOTAL]

Static Protected Attributes

static CStringList m_slHeaderPaths

Detailed Description

The base class for shaders.

Class CShaderBase Description: The base class for shaders. This is overridden by classes specific to a given graphics API.


Member Typedef Documentation

typedef CMap<CString, LSUINT32> lsg::CShaderBase::CIncludeSet [protected]

Included files.

A preprocessor define.

Included files.

Preprocessor defines.

typedef LSUINT32 lsg::CShaderBase::LSG_HANDLE

A uniform handle.


Member Enumeration Documentation

Clear states for internal use.

Error codes returned by the parser.


Member Function Documentation

virtual LSBOOL LSE_CALL lsg::CShaderBase::Activate ( LSVOID *  _pvSysValue) [pure virtual]

Activation callback. A system value is passed that is to be used internally and changes meaning depending on the graphics API.

Parameters:
_pvSysValueA value with special system meaning.
Returns:
Returns false if there is a failure to apply the shader via the current graphics API.

Implemented in lsg::CDirectX11Shader, and lsg::CShader.

static LSBOOL LSE_CALL lsg::CShaderBase::AddSearchPath ( const LSCHAR *  _pcPath) [static]

Add a folder to search for headers when #include and #import directives are reached in shader files.

Parameters:
_pcPathThe UTF-8 path of the folder to include in the search routine when seeking headers.
Returns:
Returns true if the path was added to the list of search paths.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::Compile ( CString &  _sError)

Parse the set shaders. In the case of OpenGL and DirectX, the shaders are converted to either GLSL or HLSL, respectively, and sent to the respective sub-compiler, which may throw its own errors. These errors are sent back through _sError, and may contain code not present in the original shaders. This is due to the conversion. The engine compiler does its best to maintain synchrony, but this is not always possible. The primary guarantee of the compiler is that any shader recognized as valid by this compiler will be valid and run in the same manner on all supported platforms.

Parameters:
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::Compile ( const LSCHAR *  _pcShader,
LSUINT32  _ui32Length,
CShaderLanguageParser::LSG_SHADER_TYPES  _stShaderType,
CString &  _sError 
) [protected]

Parse a shader. The shader must be in finalized format. That is, #include directives must have been fully expanded and all the parts for the shader included in the given string. The string must be NULL-terminated if _ui32Length is 0. New-lines can consist of either
pairs or just
. Specifically, is ignored entirely. In the case of OpenGL and DirectX, the shader is converted to either GLSL or HLSL, respectively, and sent to the respective sub-compiler, which may throw its own errors. These errors are sent back through _sError, and may contain code not present in the original shader. This is due to the conversion. The engine compiler does its best to maintain synchrony, but this is not always possible. The primary guarantee of the compiler is that any shader recognized as valid by this compiler will be valid and run in the same manner on all supported platforms.

Parameters:
_pcShaderThe shader to compile.
_ui32LengthThe length of the string to which _pcShader points or 0 if _pcShader is NULL-terminated.
_stShaderTypeType of the shader.
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::CompileFromFile ( const LSCHAR *  _pcPath,
CShaderLanguageParser::LSG_SHADER_TYPES  _stShaderType,
CString &  _sError 
) [protected]

Compile a shader from a file. The path must be in UTF-8 format. The file data is treated as UTF-8.

Parameters:
_pcPathThe path to the file to compile.
_stShaderTypeType of the shader.
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::CompileFromFile ( const LSCHAR *  _pcPath,
CStringList &  _slData,
LSUINT32  _ui32Line,
CShaderLanguageParser::LSG_SHADER_TYPES  _stShaderType,
CIncludeSet _isIncludes,
CPreProc::LSG_MACROS _mMacros,
CString &  _sError 
) [protected]

Compile a shader from a file. The path must be in UTF-8 format. The file data is treated as UTF-8.

Parameters:
_pcPathThe path to the file to compile.
_slDataString list to which the file data is added.
_ui32LineLine at which the file data is added.
_stShaderTypeType of the shader.
_isIncludesSet of included files.
_mMacrosDefines macros.
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::CompileFromFiles ( const LSCHAR *  _pcVertexFile,
const LSCHAR *  _pcPixelFile,
CString *  _psError = NULL 
)

Sets and parses shaders from the provided files.

Parameters:
_pcVertexFileThe vertex shader file to compile.
_pcPixelFileThe pixel shader file to compile.
_psErrorThe returned error if any.
Returns:
Returns an error code or LSG_SE_SUCCESS.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::CompileFromMemory ( const LSUINT8 *  _pui8Src,
LSUINT32  _ui32Length,
const LSCHAR *  _pcPath,
CStringList &  _slData,
LSUINT32  _ui32Line,
CShaderLanguageParser::LSG_SHADER_TYPES  _stShaderType,
CIncludeSet _isIncludes,
CPreProc::LSG_MACROS _mMacros,
CString &  _sError 
) [protected]

Compile a shader from memory. Performs preprocessing.

Parameters:
_pui8SrcThe code to compile.
_ui32LengthLength of the buffered code to compile.
_pcPathThe path to the code being compiled. May be NULL if there is no source file.
_slDataString list to which the file data is added.
_ui32LineLine at which the file data is added.
_stShaderTypeType of shader being compiled.
_isIncludesSet of included files.
_mMacrosDefines macros.
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.
virtual LSVOID LSE_CALL lsg::CShaderBase::CreateTranslator ( ) [protected, pure virtual]

Create a new translator. Must be overridden.

Implemented in lsg::CDirectX11Shader.

virtual LSVOID LSE_CALL lsg::CShaderBase::Deactivate ( ) [pure virtual]

Deactivation callback. Calls by the system when the shader is deactivated.

Implemented in lsg::CDirectX11Shader.

virtual LSVOID LSE_CALL lsg::CShaderBase::DestroyTranslator ( ) [protected, pure virtual]

Destroys the translator. Must be overridden.

Implemented in lsg::CDirectX11Shader.

static LSBOOL LSE_CALL lsg::CShaderBase::ExpandMacros ( CString &  _sString,
const CPreProc::LSG_MACROS _mMacros,
CString &  _sError 
) [static, protected]

Replace all macros in a given string.

Parameters:
_sStringThe string in which to expand macros.
_mMacrosThe macro dictionary.
_sErrorThe error string if the return is false.
Returns:
Returns true if the expansion succeeds. Otherwise filles _sError with the error string and returns false.
static LSBOOL LSE_CALL lsg::CShaderBase::ExpandMacros ( CString &  _sString,
const CPreProc::LSG_MACROS _mMacros,
const CSet< CString > &  _sUsedValues,
CString &  _sError 
) [static, protected]

Replace all macros in a given string.

Parameters:
_sStringThe string in which to expand macros.
_mMacrosThe macro dictionary.
_sUsedValuesValues that have already been expanded.
_sErrorThe error string if the return is false.
Returns:
Returns true if the expansion succeeds. Otherwise filles _sError with the error string and returns false.
static CString LSE_CALL lsg::CShaderBase::FindHeader ( const LSCHAR *  _pcIncluder,
const CString &  _sFileToInclude 
) [static, protected]

Find a header file. Searches first the relative path from the main includer, then each of the search paths set by the engine user.

Parameters:
_pcIncluderPath to the file that is including the
_sFileToIncludeThe file to include.
Returns:
Returns the path to the file to include or an empty string if the file could not be found.
virtual LSG_HANDLE LSE_CALL lsg::CShaderBase::GetConstantByName ( const LSCHAR *  _pcName) [pure virtual]

Get a handle for a uniform variable in the shader.

Parameters:
_pcNameName of the variable whose handle is to be obtained.
Returns:
Returns the handle to the given variable or ~0UL if the given name does not exist.

Implemented in lsg::CDirectX11Shader.

static CString LSE_CALL lsg::CShaderBase::GetFilePart ( const CString &  _sDirective) [static, protected]

Get the file part of an #include or #import directive.

Parameters:
_sDirectiveThe line to scan for the file name.
Returns:
Returns the file path part of the line or an empty string indicating a syntax error.
virtual LSUINT64 LSE_CALL lsg::CShaderBase::GetId ( ) const [virtual]

Get the uniqe ID of this shader. The ID is 0 if the shader is not actually ready to be activated (that is, has not been compiled and registered with the graphics API). Activating a shader with a 0 ID causes the fixed-function pipeline to become activated (if the fixed-function pipeline is supported). Because this base class cannot perform the hardware-specific operations, it always returns 0. It is up to the specialization classes to return a valid ID.

Returns:
Returns the unique ID for this shader.

Reimplemented in lsg::CDirectX11Shader.

static LSBOOL LSE_CALL lsg::CShaderBase::GetMacroParms ( const CString &  _sString,
LSUINT32  _ui32Pos,
LSUINT32 &  _ui32NewPos,
CVector< CString > &  _vRet 
) [static, protected]

Get the parameters for a function-style macro. If no parameters are given, returns false.

Parameters:
_psStringThe string from which to extract function-style macro parameters.
_ui32PosThe position at which to begin the extraction.
_ui32NewPosThe position after successful extraction.
_vRetThe returned parameters, as strings.
Returns:
Returns true if the parameters were extracted. False indicates no parameters present or an invalid parameter string.
static LSBOOL LSE_CALL lsg::CShaderBase::GetMacroReplacementString ( LSUINT32  _ui32MacroIndex,
CVector< CString > &  _vParms,
const CPreProc::LSG_MACROS _mMacros,
const CSet< CString > &  _sUsedValues,
CString &  _sRet,
CString &  _sError 
) [static, protected]

Get the replacement string for a given macro and optional parameters. Returns false if there is an error expanding the macro.

Parameters:
_ui32MacroIndexIndex of the macro to expand.
_vParmsOptional macro parameters. If this does not match the number of parameters the macro receives, false is returned.
_mMacrosThe macro dictionary.
_sUsedValuesValues that have already been expanded. Allows recursion to be avoided.
_sRetThe returned fully expanded string.
_sErrorThe error report string if there is an error during macro expansion.
Returns:
Returns true if there were no errors during macro expansion.
static const CString& LSE_CALL lsg::CShaderBase::GetSearchPath ( LSUINT32  _ui32Index) [static]

Get a header search path by index.

Parameters:
_ui32IndexIndex of the header search path to get.
Returns:
Returns a constant reference to the search path at the given index.
static LSBOOL LSE_CALL lsg::CShaderBase::ParseDefine ( const CString &  _sLine,
CPreProc::LSG_MACROS _mMacros 
) [static, protected]

Handle a #define.

Parameters:
_sLineThe text after "#define". Parsed to determin the name, parameters, and definition of a macro.
_mMacrosSet of macros to which to add the new macro.
Returns:
Returns true if the text is valid and the macro was added.
virtual LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::PostCompile ( CString &  _sError) [protected, virtual]

Post compile. If all shaders are compiled successfully, this is called, meant to be overridden by the classes that specialize towards specific graphics API's.

Parameters:
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.

Reimplemented in lsg::CDirectX11Shader, and lsg::CShader.

virtual LSVOID LSE_CALL lsg::CShaderBase::PreRender ( ) [virtual]

Called once prior to each render.

Reimplemented in lsg::CDirectX11Shader.

static LSVOID LSE_CALL lsg::CShaderBase::RemoveComments ( CStringList &  _slText) [static, protected]

Remove comments from code.

Parameters:
_slTextThe text from which to remove comments.
static LSVOID LSE_CALL lsg::CShaderBase::RemoveSearchPath ( const LSCHAR *  _pcPath) [static]

Remove a folder from the paths to search for headers when #include and #import directives are reached in shader files.

Parameters:
_pcPathThe UTF-8 path of the folder to remove from the search routine when seeking headers.
LSVOID LSE_CALL lsg::CShaderBase::Reset ( )

Reset everything.

Reimplemented in lsg::CDirectX11Shader, and lsg::CShader.

LSVOID LSE_CALL lsg::CShaderBase::ResetParsers ( ) [protected]

Reset only the parser classes. Retains the shader texts.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetBool ( LSG_HANDLE  _hHandle,
LSBOOL  _bValue 
) [pure virtual]

Set a single scalar value in the shader of type bool. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_bValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetBoolArray ( LSG_HANDLE  _hHandle,
const LSBOOL *  _pbValues,
LSUINT32  _ui32Total 
) [pure virtual]

Set an array of scalar values in the shader of type bool. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_pbValuesNew values.
_ui32TotalTotal ints to set.
Returns:
Returns true if the values were set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetFloat ( LSG_HANDLE  _hHandle,
LSFLOAT  _fValue 
) [pure virtual]

Set a single scalar value in the shader of type float. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_fValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetFloatArray ( LSG_HANDLE  _hHandle,
const LSFLOAT *  _pfValues,
LSUINT32  _ui32Total 
) [pure virtual]

Set an array of scalar values in the shader of type float. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_pfValuesNew values.
_ui32TotalTotal floats to set.
Returns:
Returns true if the values were set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetInt ( LSG_HANDLE  _hHandle,
LSINT32  _iValue 
) [pure virtual]

Set a single scalar value in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_iValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetIntArray ( LSG_HANDLE  _hHandle,
const LSINT32 *  _piValues,
LSUINT32  _ui32Total 
) [pure virtual]

Set an array of scalar values in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_piValuesNew values.
_ui32TotalTotal ints to set.
Returns:
Returns true if the values were set in the shader.

Implemented in lsg::CDirectX11Shader.

LSBOOL LSE_CALL lsg::CShaderBase::SetMacros ( const LSG_DEFINE _pdDefines,
LSUINT32  _ui32Total,
CShaderLanguageParser::LSG_SHADER_TYPES  _stShaderType 
)

Set preprocessor macros for a given shader type.

Parameters:
_pdDefinesThe preprocessor macros.
_ui32TotalTotal macros.
_stShaderTypeThe shader type to which to assign the macros.
Returns:
Returns true if there is enough memory to assign the macros.
virtual LSBOOL LSE_CALL lsg::CShaderBase::SetMatrix2x2 ( LSG_HANDLE  _hHandle,
const CMatrix2x2 &  _mValue 
) [pure virtual]

Set a 2-by-2 matrix in a shader. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_mValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetMatrix3x3 ( LSG_HANDLE  _hHandle,
const CMatrix3x3 &  _mValue 
) [pure virtual]

Set a 3-by-3 matrix in a shader. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_mValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetMatrix4x4 ( LSG_HANDLE  _hHandle,
const CMatrix4x4 &  _mValue 
) [pure virtual]

Set a 4-by-4 matrix in a shader. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_mValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetMatrix4x4Array ( LSG_HANDLE  _hHandle,
const CMatrix4x4 *  _pmValues,
LSUINT32  _ui32Total 
) [pure virtual]

Set an array of 4-by-4 matrices in a shader. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_pmValuesNew values.
_ui32TotalTotal ints to set.
Returns:
Returns true if the values were set in the shader.

Implemented in lsg::CDirectX11Shader.

LSBOOL LSE_CALL lsg::CShaderBase::SetPixelShader ( const LSCHAR *  _pcShader,
LSUINT32  _ui32Length = 0 
)

Set the pixel shader. The shader must be in finalized format. That is, #include directives must have been fully expanded and all the parts for the shader included in the given string. The string must be NULL-terminated if _ui32Length is 0. New-lines can consist of either
pairs or just
. Specifically, is ignored entirely.

Parameters:
_pcShaderThe shader to set.
_ui32LengthThe length of the string to which _pcShader points or 0 if _pcShader is NULL-terminated.
Returns:
Returns false if there is not enough memory to store the shader text.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::SetShaderFromFile ( const LSCHAR *  _pcPath,
CShaderLanguageParser::LSG_SHADER_TYPES  _stShaderType,
CString &  _sError 
)

Load a shader from a file. Whether the shader is vertex or pixel must be specified. Proper workflow is to load both the vertex and pixel shaders, then compile, then use.

Parameters:
_pcPathThe path to the file to compile.
_stShaderTypeType of the shader.
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.
LSG_SHADER_ERRORS LSE_CALL lsg::CShaderBase::SetShaderFromMemory ( const LSUINT8 *  _pui8Src,
LSUINT32  _ui32Length,
const LSCHAR *  _pcPath,
CShaderLanguageParser::LSG_SHADER_TYPES  _stShaderType,
CString &  _sError 
)

Load a shader from from memory. Whether the shader is vertex or pixel must be specified. Proper workflow is to load both the vertex and pixel shaders, then compile, then use.

Parameters:
_pui8SrcThe code to compile.
_ui32LengthLength of the buffered code to compile.
_pcPathThe path to the code being compiled. May be NULL if there is no source file.
_stShaderTypeType of shader being compiled.
_sErrorThe returned error string if there is an error.
Returns:
Returns an error code or LSG_SE_SUCCESS.
virtual LSBOOL LSE_CALL lsg::CShaderBase::SetVector2 ( LSG_HANDLE  _hHandle,
const CVector2 &  _vValue 
) [pure virtual]

Set a 2-dimensional vector in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_vValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetVector2Array ( LSG_HANDLE  _hHandle,
const CVector2 *  _pvValues,
LSUINT32  _ui32Total 
) [pure virtual]

Set a 2-dimensional vector array in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_vValueNew values.
_ui32TotalTotal ints to set.
Returns:
Returns true if the values were set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetVector3 ( LSG_HANDLE  _hHandle,
const CVector3 &  _vValue 
) [pure virtual]

Set a 3-dimensional vector in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_vValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetVector3Array ( LSG_HANDLE  _hHandle,
const CVector3 *  _pvValues,
LSUINT32  _ui32Total 
) [pure virtual]

Set a 3-dimensional vector array in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_vValueNew values.
_ui32TotalTotal ints to set.
Returns:
Returns true if the values were set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetVector4 ( LSG_HANDLE  _hHandle,
const CVector4 &  _vValue 
) [pure virtual]

Set a 4-dimensional vector in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_vValueNew value.
Returns:
Returns true if the value was set in the shader.

Implemented in lsg::CDirectX11Shader.

virtual LSBOOL LSE_CALL lsg::CShaderBase::SetVector4Array ( LSG_HANDLE  _hHandle,
const CVector4 *  _pvValues,
LSUINT32  _ui32Total 
) [pure virtual]

Set a 4-dimensional vector array in the shader of type int. Shader must be active.

Parameters:
_hHandleHandle to the value to set in the shader.
_vValueNew values.
_ui32TotalTotal ints to set.
Returns:
Returns true if the values were set in the shader.

Implemented in lsg::CDirectX11Shader.

LSBOOL LSE_CALL lsg::CShaderBase::SetVertexShader ( const LSCHAR *  _pcShader,
LSUINT32  _ui32Length = 0 
)

Set the vertex shader. The shader must be in finalized format. That is, #include directives must have been fully expanded and all the parts for the shader included in the given string. The string must be NULL-terminated if _ui32Length is 0. New-lines can consist of either
pairs or just
. Specifically, is ignored entirely.

Parameters:
_pcShaderThe shader to set.
_ui32LengthThe length of the string to which _pcShader points or 0 if _pcShader is NULL-terminated.
Returns:
Returns false if there is not enough memory to store the shader text.
static LSVOID LSE_CALL lsg::CShaderBase::SkipString ( const CString &  _sLine,
LSUINT32 &  _ui32Pos 
) [static, protected]

Skip strings in code.

Parameters:
_sStringThe string containing the string to skip.
_ui32PosThe position of the string to skip. Upon returning, this holds the new position from where parsing can continue.
static LSUINT32 LSE_CALL lsg::CShaderBase::TotalSearchPaths ( ) [static]

Get the total number of header search paths.

Returns:
Returns the number of header search paths.

Member Data Documentation

The result of translation.

The lexer. Can be deleted when done compiling.

The syntax parser. Can be deleted when done compiling.

The translator.

CString lsg::CShaderBase::m_sFinalPixel [protected]

The final form of the pixel shader.

CString lsg::CShaderBase::m_sFinalVertex [protected]

The final form of the vertex shader.

CStringList lsg::CShaderBase::m_slHeaderPaths [static, protected]

Paths to search for header files.

CString lsg::CShaderBase::m_sPixelShader [protected]

The pixel shader text (in final form). Length() is 0 if there is none.

CString lsg::CShaderBase::m_sVertexShader [protected]

The vertex shader text (in final form). Length() is 0 if there is none.

Uniform globals in the shaders.

Uniform globals in the shaders.

Global semantics in the shaders.

CVector<LSG_PREPROC_DEFINE> lsg::CShaderBase::m_vDefs[CShaderLanguageParser::LSG_ST_TOTAL] [protected]

Definitions for the shaders.


The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator