CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ivideo/shader/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 
00042 struct iShaderManager;
00043 struct iShaderRenderInterface;
00044 struct iShader;
00045 struct iShaderCompiler;
00046 
00047 struct csRenderMesh;
00048 
00054 typedef csArray< csArray<csShaderVariable*> > csShaderVarStack;
00055 
00056 SCF_VERSION (iShaderVariableContext, 0, 0, 1);
00057 
00062 struct iShaderVariableContext : public iBase
00063 {
00065   virtual void AddVariable (csShaderVariable *variable) = 0;
00066   
00068   virtual csShaderVariable* GetVariable (csStringID name) const = 0;
00069 
00071   csShaderVariable* GetVariableAdd (csStringID name)
00072   {
00073     csShaderVariable* sv;
00074     sv = GetVariable (name);
00075     if (sv == 0)
00076     {
00077       csRef<csShaderVariable> nsv (
00078         csPtr<csShaderVariable> (new csShaderVariable (name)));
00079       AddVariable (nsv);
00080       sv = nsv; // OK, sv won't be destructed, SV context takes ownership
00081     }
00082     return sv;
00083   }
00084 
00089   virtual void PushVariables (csShaderVarStack &stacks) const = 0;
00090 
00095   virtual void PopVariables (csShaderVarStack &stacks) const = 0;
00096 };
00097 
00098 SCF_VERSION (iShaderManager, 0, 1, 0);
00099 
00103 enum csShaderTagPresence
00104 {
00109   TagNeutral,
00113   TagForbidden,
00119   TagRequired
00120 };
00121 
00125 struct iShaderManager : public iShaderVariableContext
00126 {
00131   virtual void RegisterShader(iShader* shader) = 0;
00133   virtual iShader* GetShader(const char* name) = 0;
00135   virtual const csRefArray<iShader> &GetShaders ()  = 0;
00136 
00138   virtual void RegisterCompiler (iShaderCompiler* compiler) = 0;
00140   virtual iShaderCompiler* GetCompiler(const char* name) = 0;
00141 
00143   virtual csShaderVarStack& GetShaderVariableStack () = 0;
00144 
00153   virtual void SetTagOptions (csStringID tag, csShaderTagPresence presence, 
00154     int priority = 0) = 0;
00159   virtual void GetTagOptions (csStringID tag, csShaderTagPresence& presence, 
00160     int& priority) = 0;
00161 
00165   virtual const csSet<csStringID>& GetTags (csShaderTagPresence presence,
00166     int& count) = 0;
00167 };
00168 
00169 SCF_VERSION (iShaderRenderInterface, 0,0,1);
00170 
00172 struct iShaderRenderInterface : public iBase
00173 {
00175   virtual void* GetPrivateObject(const char* name) = 0;
00176 };
00177 
00178 SCF_VERSION (iShader, 0, 1, 0);
00179 
00184 struct iShader : public iShaderVariableContext
00185 {
00187   virtual const char* GetName() = 0;
00188 
00190   virtual int GetNumberOfPasses() = 0;
00191 
00193   virtual bool ActivatePass(unsigned int number) = 0;
00194 
00196   virtual bool SetupPass (const csRenderMesh *mesh,
00197     csRenderMeshModes& modes,
00198     const csShaderVarStack &stacks) = 0;
00199 
00204   virtual bool TeardownPass() = 0;
00205 
00207   virtual bool DeactivatePass() = 0;
00208 };
00209 
00210 
00211 SCF_VERSION (iShaderCompiler, 0,0,1);
00217 struct iShaderCompiler : iBase
00218 {
00220   virtual const char* GetName() = 0;
00221 
00223   virtual csPtr<iShader> CompileShader (iDocumentNode *templ) = 0;
00224 
00226   virtual bool ValidateTemplate (iDocumentNode *templ) = 0;
00227 
00229   virtual bool IsTemplateToCompiler (iDocumentNode *templ) = 0;
00230 };
00231 
00232 #endif // __CS_IVIDEO_SHADER_H__

Generated for Crystal Space by doxygen 1.2.18