201 lines
6.8 KiB
C++
201 lines
6.8 KiB
C++
/*************************************************************************/
|
|
/* File : RCKShaderWrapper.h */
|
|
/* Author : Guillaume Caurant */
|
|
/* */
|
|
/* Virtools SDK */
|
|
/* Copyright (c) Virtools 2006, All Rights Reserved. */
|
|
/*************************************************************************/
|
|
#ifndef RCKSHADERWRAPPER_H
|
|
// {secret}
|
|
#define RCKSHADERWRAPPER_H "$Id:$"
|
|
|
|
#include "CKShader.h"
|
|
|
|
#include "ShaderManagerWrapper.h"
|
|
|
|
#include "RCKShaderCG.h"
|
|
|
|
class ShaderManagerWrapper;
|
|
|
|
typedef struct WCKShader{
|
|
CKShader* shader;
|
|
CK_SHADER_MANAGER_TYPE type;
|
|
}WCKShader;
|
|
|
|
class RCKShaderWrapper : public CKShader
|
|
{
|
|
//-----------------------------------------------------------------------//
|
|
// Shader Technique/Pass feature
|
|
//-----------------------------------------------------------------------//
|
|
public:
|
|
|
|
virtual int Begin( CKRenderContext* rc );
|
|
virtual void End( CKRenderContext* rc );
|
|
virtual void BeginPass( CKDWORD Num, CKRenderContext* rc );
|
|
virtual void EndPass(CKRenderContext* rc );
|
|
virtual void CommitChanges(CKRenderContext* rc );
|
|
|
|
virtual void SetTechnique( const XString &iTechName );
|
|
virtual void SetTechnique( int iTechIndex );
|
|
/**
|
|
* Differs from the ID3DXShader::FindNextValidTechnique, because, if the
|
|
* first technique is ok, it uses it. ID3DXFX starts after the specified
|
|
* technique.
|
|
* It also skips reserved techniques.
|
|
* It returns false if no valid technique is found.
|
|
*/
|
|
virtual bool FindNextValidTechnique( int& ioTechIndex, XString* oTechName=NULL ) const;
|
|
|
|
RCKShaderWrapper(ShaderManagerWrapper *man, XArray<WCKShader>& WCKShaderArray);
|
|
virtual ~RCKShaderWrapper();
|
|
virtual CKBOOL IsSupported() const;
|
|
|
|
//-----------------------------------------------------------------------//
|
|
// Shader Text/Name
|
|
//-----------------------------------------------------------------------//
|
|
|
|
//--- Shader Text Accessors
|
|
virtual void SetText(const XString& Text){
|
|
m_CurrentRCKShader->SetText(Text);
|
|
}
|
|
virtual void SetText(const XString& Text, CK_SHADER_MANAGER_TYPE type){
|
|
CKShader* shader = GetShaderByType(type);
|
|
XASSERT(shader);
|
|
if (shader)
|
|
shader->SetText(Text);
|
|
else
|
|
m_CurrentRCKShader->SetText(Text);
|
|
}
|
|
|
|
virtual const XString& GetText() const{
|
|
return m_CurrentRCKShader->GetText();
|
|
}
|
|
virtual const XString& GetText(CK_SHADER_MANAGER_TYPE type){
|
|
CKShader* shader = GetShaderByType(type);
|
|
XASSERT(shader);
|
|
if (shader)
|
|
return shader->GetText();
|
|
else
|
|
return m_CurrentRCKShader->GetText();
|
|
}
|
|
|
|
virtual void SetName(const XString& Name){
|
|
m_ShaderName = Name;
|
|
}
|
|
virtual const XString& GetName() const{
|
|
return m_ShaderName;
|
|
}
|
|
|
|
virtual void SetHideFlag(CKBOOL hide) {
|
|
m_CurrentRCKShader->SetHideFlag(hide);
|
|
}
|
|
|
|
virtual CKProtectable* GetProtectable()
|
|
{
|
|
return m_CurrentRCKShader->GetProtectable();
|
|
}
|
|
|
|
virtual CKBOOL GetHideFlag() {
|
|
return m_CurrentRCKShader->GetHideFlag();
|
|
}
|
|
|
|
virtual void UnLock(const char* pass) {
|
|
m_CurrentRCKShader->UnLock(pass);
|
|
}
|
|
|
|
virtual void CurrentPass(XString val) { m_CurrentRCKShader->CurrentPass(val); }
|
|
virtual const XString CurrentPass() { return m_CurrentRCKShader->CurrentPass(); }
|
|
|
|
//---F2 Marks
|
|
virtual XArray<int>* GetF2Marks() { return m_CurrentRCKShader->GetF2Marks(); }
|
|
|
|
virtual CKBOOL GetSaveFlag() const { return m_Save; }
|
|
virtual void SetSaveFlag(CKBOOL saveFlag) { m_Save = saveFlag; }
|
|
virtual CKBOOL GetListInEditorFlag() const { return m_ListInEditor; }
|
|
virtual void SetListInEditorFlag(CKBOOL listInEditor) { m_ListInEditor = listInEditor; }
|
|
|
|
protected:
|
|
CKBOOL m_Save;
|
|
CKBOOL m_ListInEditor;
|
|
|
|
XString m_ShaderName;
|
|
|
|
public:
|
|
/************************************************************************
|
|
Special function used with the Shader Wrapper
|
|
*************************************************************************/
|
|
virtual CK_SHADER_MANAGER_TYPE GetCurrentShaderType() const {
|
|
return m_CurrentRCKShader->GetCurrentShaderType();
|
|
}
|
|
|
|
CKShader* GetShaderByType(CK_SHADER_MANAGER_TYPE type) {
|
|
WCKShader* begin = m_WCKShaderArray.Begin();
|
|
WCKShader* end = m_WCKShaderArray.End();
|
|
while (begin->type != type) {
|
|
++begin;
|
|
if (begin == end) return NULL;
|
|
}
|
|
return begin->shader;
|
|
}
|
|
|
|
protected:
|
|
|
|
//--- As many elements as there's Render Contexts
|
|
XArray<WCKShader> m_WCKShaderArray;
|
|
CKShader* m_CurrentRCKShader;
|
|
|
|
#pragma todo("RCKShaderWrapper: use of m_CompID")
|
|
// int m_CompID;
|
|
|
|
ShaderManagerInterface* m_CurrentShaderManager;
|
|
ShaderManagerWrapper* m_ShaderManagerWrapper;
|
|
friend class ShaderManagerWrapper;
|
|
|
|
public:
|
|
|
|
//-----------------------------------------------------------------------//
|
|
// Shader parameters feature
|
|
// The AppData of the CKParameter is set to the handle of the parameter.
|
|
//-----------------------------------------------------------------------//
|
|
public:
|
|
virtual void SetParameters(const XArray<CKParameterLocal*>& params);
|
|
virtual bool LinkTechnique( int& CompID, const XString& tech, BOOL fnvt, int& oTechIndex );
|
|
virtual bool LinkParameters( int& CompID, XArray<CKParameterLocal*>& params, CKBOOL cleanup);
|
|
|
|
virtual int GetAutoParameterCount( CKRenderContext* rc );
|
|
virtual void GetAutoParameterInfo( int paramIndex, ParamInfo& paramInfo, CKRenderContext* rc );
|
|
virtual int GetExposedParameterCount( CKRenderContext* rc );
|
|
virtual void GetExposedParameterInfo( int paramIndex, ParamInfo& paramInfo, CKRenderContext* rc );
|
|
|
|
virtual void ExecuteMeanings( CK3dEntity* iEnt, CKMaterial* iMat, CKMaterialShader* iMatShader, CKRenderContext* iRC );
|
|
virtual void ExecutePerPassMeanings( CK3dEntity* iEnt, CKMaterial* iMat, CKMaterialShader* iMatShader, CKRenderContext* rc );
|
|
|
|
//-----------------------------------------------------------------------//
|
|
// Compilation feature.
|
|
//-----------------------------------------------------------------------//
|
|
public:
|
|
void Compile(CKContext* Context);
|
|
|
|
//-----------------------------------------------------------------------//
|
|
// Technique and passes
|
|
//-----------------------------------------------------------------------//
|
|
public:
|
|
virtual int GetTechniquesCount() const;
|
|
virtual void GetTechniqueInfo( int iTechIndex, TechniqueInfo& oTechInfo ) const;
|
|
virtual bool GetTechIndexByName( const XString& iTechName, int& oPos ) const;
|
|
|
|
virtual int GetTechniqueEnumValue( const XString& iTechName ) const;
|
|
virtual void GetTechniqueEnumString( int num, XString& oName ) const;
|
|
|
|
virtual int GetPassCount( int iTechIndex ) const;
|
|
virtual void GetPassInfo( int iTechIndex, int iPassIndex, PassInfo& oPassInfo ) const;
|
|
virtual bool GetPassIndexByName( int iTechIndex, const char* iPassName, int& oPos ) const;
|
|
|
|
//-----------------------------------------------------------------------//
|
|
// Registering
|
|
//-----------------------------------------------------------------------//
|
|
public:
|
|
static CKSTRING GetClassName(); // {secret}
|
|
};
|
|
|
|
#endif // RCKSHADER_H
|