CrystalSpace

Public API Reference

csplugincommon/shader/shaderplugin.h
Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2003 by Marten Svanfeldt
00003 
00004   This library is free software; you can redistribute it and/or
00005   modify it under the terms of the GNU Library General Public
00006   License as published by the Free Software Foundation; either
00007   version 2 of the License, or (at your option) any later version.
00008 
00009   This library is distributed in the hope that it will be useful,
00010   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00012   Library General Public License for more details.
00013 
00014   You should have received a copy of the GNU Library General Public
00015   License along with this library; if not, write to the Free
00016   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 */
00018 
00019 #ifndef __CS_SHADERPLUGIN_H__
00020 #define __CS_SHADERPLUGIN_H__
00021 
00026 #include "csutil/scf.h"
00027 #include "csutil/strhash.h"
00028 
00029 #include "ivideo/shader/shader.h"
00030 
00031 struct iString;
00032 
00036 
00037 struct csShaderVarMapping
00038 {
00040   CS::ShaderVarStringID name;
00042   csString destination;
00043   csShaderVarMapping (CS::ShaderVarStringID n, const char* d) : name(n),
00044     destination(d) {}
00045 };
00046 
00047 
00052 struct iShaderDestinationResolver : public virtual iBase
00053 {
00054   SCF_INTERFACE(iShaderDestinationResolver, 0,0,1);
00059   virtual int ResolveTU (const char* binding) = 0;
00060 
00061   virtual csVertexAttrib ResolveBufferDestination (const char* binding) = 0;
00062 };
00063 
00068 struct iShaderProgram : public virtual iBase
00069 {
00070   SCF_INTERFACE(iShaderProgram, 7, 0, 0);
00072   virtual void Activate() = 0;
00073 
00075   virtual void Deactivate() = 0;
00076 
00078   virtual void SetupState (const CS::Graphics::RenderMesh* mesh, 
00079                            CS::Graphics::RenderMeshModes& modes,
00080                            const csShaderVariableStack& stack) = 0;
00081 
00083   virtual void ResetState () = 0;
00084 
00086   virtual bool Load (iShaderDestinationResolver* resolve, 
00087     iDocumentNode* node) = 0;
00088 
00090   virtual bool Load (iShaderDestinationResolver* resolve, const char* program, 
00091     csArray<csShaderVarMapping>& mappings) = 0;
00092 
00100   virtual bool Compile (iHierarchicalCache* cacheTo,
00101     csRef<iString>* cacheTag = 0) = 0;
00102   
00115   virtual void GetUsedShaderVars (csBitArray& bits) const = 0;
00116   
00117   enum CacheLoadResult
00118   {
00119     loadFail,
00120     loadSuccessShaderInvalid,
00121     loadSuccessShaderValid
00122   };
00124   virtual CacheLoadResult LoadFromCache (iHierarchicalCache* cache,
00125     iBase* previous, iDocumentNode* programNode,
00126     csRef<iString>* failReason = 0, csRef<iString>* cacheTag = 0) = 0;
00127 };
00128 
00133 struct iShaderProgramPlugin : public virtual iBase
00134 {
00135   SCF_INTERFACE(iShaderProgramPlugin,3,0,0);
00136   virtual csPtr<iShaderProgram> CreateProgram (const char* type) = 0;
00137   virtual bool SupportType (const char* type) = 0;
00138   
00139   virtual csPtr<iStringArray> QueryPrecacheTags (const char* type) = 0;
00144   virtual bool Precache (const char* type, const char* tag,
00145     iBase* previous, iDocumentNode* node, 
00146     iHierarchicalCache* cacheTo, csRef<iBase>* outObj = 0) = 0;
00147 };
00148 
00151 #endif
00152 

Generated for Crystal Space 2.0 by doxygen 1.7.6.1