CrystalSpace

Public API Reference

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

shader.h

00001 /*
00002     Copyright (C) 2002 by Mårten 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 
00024 #include "csgeom/vector4.h"
00025 #include "csutil/ref.h"
00026 #include "csutil/refarr.h"
00027 #include "csutil/scf.h"
00028 #include "csutil/strhash.h"
00029 #include "ivideo/graph3d.h"
00030 #include "ivideo/rendermesh.h"
00031 #include "csutil/symtable.h"
00032 #include "csgfx/shadervar.h"
00033 
00034 struct iString;
00035 struct iDataBuffer;
00036 struct iDocumentNode;
00037 struct iMaterial;
00038 
00039 struct iShaderManager;
00040 struct iShaderRenderInterface;
00041 struct iShader;
00042 struct iShaderWrapper;
00043 struct iShaderTechnique;
00044 struct iShaderPass;
00045 struct iShaderProgram;
00046 struct iShaderProgramPlugin;
00047 struct iShaderRenderInterface;
00048 
00049 SCF_VERSION (iShaderBranch, 0, 0, 1);
00050 
00055 struct iShaderBranch : public iBase
00056 {
00058   virtual void AddChild(iShaderBranch *child) = 0;
00059 
00061   virtual void AddVariable(csShaderVariable* variable) = 0;
00062 
00064   virtual csShaderVariable* GetVariable(csStringID name) = 0;
00065 
00067   virtual csSymbolTable* GetSymbolTable() = 0;
00068 
00073   virtual csSymbolTable* GetSymbolTable(int index) = 0;
00074 
00079   virtual void SelectSymbolTable(int index) = 0;
00080 };
00081 
00082 SCF_VERSION (iShaderManager, 0, 1, 0);
00083 
00087 struct iShaderManager : iShaderBranch
00088 {
00090   virtual csPtr<iShader> CreateShader() = 0;
00092   virtual iShaderWrapper* GetShader(const char* name) = 0;
00094   virtual csPtr<iShaderWrapper> CreateWrapper(iShader* shader) = 0;
00096   virtual const csRefArray<iShaderWrapper> &GetShaders () = 0;
00097 
00099   virtual csPtr<csShaderVariable> CreateVariable(csStringID name) const = 0;
00100 
00102   virtual csPtr<iShaderProgram> CreateShaderProgram(const char* type) = 0;
00103 
00105   virtual void PrepareShaders () = 0;
00106 };
00107 
00108 SCF_VERSION (iShaderRenderInterface, 0,0,1);
00109 
00111 struct iShaderRenderInterface : iBase
00112 {
00114   virtual void* GetPrivateObject(const char* name) = 0;
00115 };
00116 
00117 SCF_VERSION (iShader, 0,0,1);
00118 
00122 struct iShader : iShaderBranch
00123 {
00125   virtual void SetName(const char* name) = 0;
00127   virtual const char* GetName() = 0;
00128 
00130   virtual csPtr<iShaderTechnique> CreateTechnique() = 0;
00132   virtual int GetTechniqueCount() const = 0;
00134   virtual iShaderTechnique* GetTechnique(int technique) = 0;
00136   virtual iShaderTechnique* GetBestTechnique() = 0;
00137 
00142   virtual bool IsValid() const = 0;
00143 
00145   virtual bool Load(iDataBuffer* program) = 0;
00146 
00148   virtual bool Load(iDocumentNode* node) = 0;
00149 
00154   virtual bool Prepare() = 0;
00155 };
00156 
00157 SCF_VERSION(iShaderWrapper, 0, 0, 1);
00158 
00163 struct iShaderWrapper : iShaderBranch
00164 {
00166   virtual iShader* GetShader() = 0;
00167 
00169   virtual void SelectMaterial(iMaterial *mat) = 0;
00170 };
00171 
00172 SCF_VERSION (iShaderTechnique, 0,0,1);
00173 
00177 struct iShaderTechnique : iShaderBranch
00178 {
00183   virtual int GetPriority() const = 0;
00184 
00186   virtual void SetPriority(int priority) = 0;
00187 
00189   virtual csPtr<iShaderPass> CreatePass() = 0;
00191   virtual int GetPassCount() const = 0;
00193   virtual iShaderPass* GetPass( int pass ) = 0;
00194 
00196   virtual bool IsValid() const = 0;
00197 
00199   virtual bool Load(iDataBuffer* program) = 0;
00200 
00202   virtual bool Load(iDocumentNode* node) = 0;
00203 
00205   virtual bool Prepare() = 0;
00206 };
00207 
00208 SCF_VERSION (iShaderPass, 0,0,1);
00209 
00213 struct iShaderPass : iShaderBranch
00214 {
00216   virtual void AddStreamMapping (csStringID name, csVertexAttrib attribute) = 0;
00218   virtual csStringID GetStreamMapping (csVertexAttrib attribute) const = 0;
00219 
00221   virtual void AddTextureMapping (csStringID name, int unit) = 0;
00223   virtual csStringID GetTextureMapping (int unit) const = 0;
00224 
00226   virtual uint GetMixmodeOverride () const = 0;
00227 
00229   virtual iShaderProgram* GetVertexProgram() = 0;
00230 
00232   virtual void SetVertexProgram(iShaderProgram* program) = 0;
00233 
00235   virtual iShaderProgram* GetFragmentProgram() = 0;
00236 
00238   virtual void SetFragmentProgram(iShaderProgram* program) = 0;
00239 
00241   virtual bool IsValid() const = 0;
00242 
00244   virtual void Activate(csRenderMesh* mesh) = 0;
00245 
00247   virtual void Deactivate() = 0;
00248 
00250   virtual void SetupState (csRenderMesh* mesh) = 0;
00251 
00253   virtual void ResetState () = 0;
00254 
00256   virtual bool Load(iDataBuffer* program) = 0;
00257 
00259   virtual bool Load(iDocumentNode* node) = 0;
00260 
00262   virtual bool Prepare() = 0;
00263 };
00264 
00265 SCF_VERSION (iShaderProgram, 0,0,1);
00266 
00271 struct iShaderProgram : iShaderBranch
00272 {
00274   virtual csPtr<iString> GetProgramID() = 0;
00275 
00277   virtual void Activate(iShaderPass* current, csRenderMesh* mesh) = 0;
00278 
00280   virtual void Deactivate(iShaderPass* current) = 0;
00281 
00283   virtual void SetupState (iShaderPass* current, csRenderMesh* mesh) = 0;
00284 
00286   virtual void ResetState () = 0;
00287 
00289   virtual bool IsValid() = 0;
00290 
00292   virtual bool Load(iDataBuffer* program) = 0;
00293 
00295   virtual bool Load(iDocumentNode* node) = 0;
00296 
00301   virtual bool Prepare() = 0;
00302 };
00303 
00304 SCF_VERSION(iShaderProgramPlugin, 0,0,1);
00305 
00307 struct iShaderProgramPlugin : iBase
00308 {
00309   virtual csPtr<iShaderProgram> CreateProgram(const char* type) = 0;
00310   virtual bool SupportType(const char* type) = 0;
00311   virtual void Open() = 0;
00312 };
00313 
00314 #endif // __CS_IVIDEO_SHADER_H__

Generated for Crystal Space by doxygen 1.2.14