Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
shaderprogram.h
00001 /* 00002 Copyright (C) 2004 by Jorrit Tyberghein 00003 (C) 2004 by Frank Richter 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 */ 00019 00020 #ifndef __CS_SHADERPLUGINS_COMMON_SHADERPROGRAM_H__ 00021 #define __CS_SHADERPLUGINS_COMMON_SHADERPROGRAM_H__ 00022 00023 #include "csextern.h" 00024 #include "csutil/array.h" 00025 #include "csutil/csstring.h" 00026 #include "csutil/ref.h" 00027 #include "csutil/strhash.h" 00028 #include "csgfx/shadervar.h" 00029 #include "csgfx/shadervarcontext.h" 00030 00031 #include "csutil/leakguard.h" 00032 #include "iutil/databuff.h" 00033 #include "iutil/document.h" 00034 #include "iutil/objreg.h" 00035 #include "iutil/strset.h" 00036 #include "iutil/vfs.h" 00037 #include "imap/services.h" 00038 00039 #include "shaderplugin.h" 00040 00041 struct iDataBuffer; 00042 00043 class CS_CSPLUGINCOMMON_EXPORT csShaderProgram : public iShaderProgram 00044 { 00045 protected: 00046 csStringHash commonTokens; 00047 #define CS_INIT_TOKEN_TABLE_NAME InitCommonTokens 00048 #define CS_TOKEN_ITEM_FILE \ 00049 "csplugincommon/shader/shaderprogram.tok" 00050 #include "cstool/tokenlist.h" 00051 #undef CS_TOKEN_ITEM_FILE 00052 #undef CS_INIT_TOKEN_TABLE_NAME 00053 00054 protected: 00055 iObjectRegistry* objectReg; 00056 csRef<iSyntaxService> synsrv; 00057 csRef<iStringSet> strings; 00058 00059 struct VariableMapEntry : public csShaderVarMapping 00060 { 00061 // Variables that can be resolved statically at shader load 00062 // or compilation is put in "statlink" 00063 csRef<csShaderVariable> statlink; 00064 int userInt; 00065 void* userPtr; 00066 00067 VariableMapEntry (csStringID s, const char* d) : 00068 csShaderVarMapping (s, d) 00069 { 00070 userInt = 0; 00071 userPtr = 0; 00072 } 00073 VariableMapEntry (const csShaderVarMapping& other) : 00074 csShaderVarMapping (other.name, other.destination) 00075 { 00076 userInt = 0; 00077 userPtr = 0; 00078 } 00079 }; 00080 csArray<VariableMapEntry> variablemap; 00081 00082 struct ProgramParam 00083 { 00084 bool valid; 00085 csVector4 vectorValue; 00086 csMatrix3 matrixValue; 00087 csStringID name; 00088 csRef<csShaderVariable> var; 00089 00090 ProgramParam() : valid (false), vectorValue (0.0f), 00091 name(csInvalidStringID) { } 00092 ProgramParam(const csVector4& def) : valid (false), 00093 vectorValue (def), name(csInvalidStringID) { } 00094 }; 00095 enum ProgramParamType 00096 { 00097 ParamInvalid = 0, 00098 ParamFloat = 0x01, 00099 ParamVector2 = 0x02, 00100 ParamVector3 = 0x04, 00101 ParamVector4 = 0x08, 00102 ParamMatrix = 0x10 00103 }; 00104 void ResolveParamStatic (ProgramParam& param, 00105 csArray<iShaderVariableContext*> &staticContexts); 00106 bool ParseProgramParam (iDocumentNode* node, 00107 ProgramParam& param, uint types = ~0); 00108 bool RetrieveParamValue (ProgramParam& param, 00109 const csShaderVarStack& stacks); 00110 00111 char* description; 00112 csRef<iDocumentNode> programNode; 00113 csRef<iFile> programFile; 00114 csString programFileName; 00115 00116 csShaderVariableContext svcontext; 00117 00118 bool ParseCommon (iDocumentNode* child); 00119 iDocumentNode* GetProgramNode (); 00120 csPtr<iDataBuffer> GetProgramData (); 00121 void ResolveStaticVars (csArray<iShaderVariableContext*> &staticContexts); 00122 void DumpProgramInfo (csString& output); 00123 void DumpVariableMappings (csString& output); 00124 public: 00125 SCF_DECLARE_IBASE; 00126 00127 CS_LEAKGUARD_DECLARE (csShaderProgram); 00128 00129 csShaderProgram (iObjectRegistry* objectReg); 00130 virtual ~csShaderProgram (); 00131 }; 00132 00133 #endif // __CS_SHADERPLUGINS_COMMON_SHADERPROGRAM_H__
Generated for Crystal Space by doxygen 1.3.9.1