Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages
shader.h
Go to the documentation of this file.00001 /* 00002 Copyright (C) 2002 by Marten Svanfeldt 00003 Anders Stenberg 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 00021 #ifndef __CS_IVIDEO_SHADER_H__ 00022 #define __CS_IVIDEO_SHADER_H__ 00023 00028 #include "csgeom/vector4.h" 00029 #include "csutil/hash.h" 00030 #include "csutil/ref.h" 00031 #include "csutil/refarr.h" 00032 #include "csutil/scf.h" 00033 #include "csutil/strhash.h" 00034 #include "ivideo/graph3d.h" 00035 #include "csgfx/shadervar.h" 00036 00037 struct iString; 00038 struct iDataBuffer; 00039 struct iDocumentNode; 00040 struct iMaterial; 00041 struct iObject; 00042 00043 struct iShaderManager; 00044 struct iShaderRenderInterface; 00045 struct iShader; 00046 struct iShaderCompiler; 00047 00048 struct csRenderMesh; 00049 00055 typedef csArray< csArray<csShaderVariable*> > csShaderVarStack; 00056 00057 SCF_VERSION (iShaderVariableContext, 0, 0, 1); 00058 00063 struct iShaderVariableContext : public iBase 00064 { 00066 virtual void AddVariable (csShaderVariable *variable) = 0; 00067 00069 virtual csShaderVariable* GetVariable (csStringID name) const = 0; 00070 00072 csShaderVariable* GetVariableAdd (csStringID name) 00073 { 00074 csShaderVariable* sv; 00075 sv = GetVariable (name); 00076 if (sv == 0) 00077 { 00078 csRef<csShaderVariable> nsv ( 00079 csPtr<csShaderVariable> (new csShaderVariable (name))); 00080 AddVariable (nsv); 00081 sv = nsv; // OK, sv won't be destructed, SV context takes ownership 00082 } 00083 return sv; 00084 } 00085 00087 virtual const csRefArray<csShaderVariable>& GetShaderVariables () const = 0; 00088 00093 virtual void PushVariables (csShaderVarStack &stacks) const = 0; 00094 00099 virtual void PopVariables (csShaderVarStack &stacks) const = 0; 00100 }; 00101 00102 SCF_VERSION (iShaderManager, 0, 1, 0); 00103 00107 enum csShaderTagPresence 00108 { 00113 TagNeutral, 00117 TagForbidden, 00123 TagRequired 00124 }; 00125 00129 struct iShaderManager : public iShaderVariableContext 00130 { 00135 virtual void RegisterShader (iShader* shader) = 0; 00137 virtual void UnregisterShader (iShader* shader) = 0; 00139 virtual iShader* GetShader (const char* name) = 0; 00141 virtual const csRefArray<iShader> &GetShaders () = 0; 00142 00144 virtual void RegisterCompiler (iShaderCompiler* compiler) = 0; 00146 virtual iShaderCompiler* GetCompiler(const char* name) = 0; 00147 00149 virtual csShaderVarStack& GetShaderVariableStack () = 0; 00150 00159 virtual void SetTagOptions (csStringID tag, csShaderTagPresence presence, 00160 int priority = 0) = 0; 00165 virtual void GetTagOptions (csStringID tag, csShaderTagPresence& presence, 00166 int& priority) = 0; 00167 00171 virtual const csSet<csStringID>& GetTags (csShaderTagPresence presence, 00172 int& count) = 0; 00173 }; 00174 00175 SCF_VERSION (iShaderRenderInterface, 0,0,1); 00176 00178 struct iShaderRenderInterface : public iBase 00179 { 00181 virtual void* GetPrivateObject(const char* name) = 0; 00182 }; 00183 00184 SCF_VERSION (iShader, 0, 3, 0); 00185 00190 struct iShader : public iShaderVariableContext 00191 { 00193 virtual iObject* QueryObject () = 0; 00194 00196 virtual const char* GetFileName () = 0; 00197 00199 virtual void SetFileName (const char* filename) = 0; 00200 00211 virtual size_t GetTicket (const csRenderMeshModes& modes, 00212 const csShaderVarStack& stacks) = 0; 00213 00215 virtual size_t GetNumberOfPasses (size_t ticket) = 0; 00216 00218 virtual bool ActivatePass (size_t ticket, size_t number) = 0; 00219 00221 virtual bool SetupPass (size_t ticket, const csRenderMesh *mesh, 00222 csRenderMeshModes& modes, 00223 const csShaderVarStack& stacks) = 0; 00224 00229 virtual bool TeardownPass (size_t ticket) = 0; 00230 00232 virtual bool DeactivatePass (size_t ticket) = 0; 00233 }; 00234 00235 00236 SCF_VERSION (iShaderPriorityList, 0,0,1); 00240 struct iShaderPriorityList : public iBase 00241 { 00243 virtual size_t GetCount () const = 0; 00245 virtual int GetPriority (size_t idx) const = 0; 00246 }; 00247 00248 SCF_VERSION (iShaderCompiler, 0,0,1); 00254 struct iShaderCompiler : iBase 00255 { 00257 virtual const char* GetName() = 0; 00258 00267 virtual csPtr<iShader> CompileShader (iDocumentNode *templ, 00268 int forcepriority = -1) = 0; 00269 00271 virtual bool ValidateTemplate (iDocumentNode *templ) = 0; 00272 00274 virtual bool IsTemplateToCompiler (iDocumentNode *templ) = 0; 00275 00281 virtual csPtr<iShaderPriorityList> GetPriorities ( 00282 iDocumentNode* templ) = 0; 00283 }; 00284 00285 #endif // __CS_IVIDEO_SHADER_H__
Generated for Crystal Space by doxygen 1.3.9.1