## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# 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
    00034
    00035 struct csShaderVarMapping
    00036 {
    00038   csStringID name;
    00040   csString destination;
    00041   csShaderVarMapping (csStringID n, const char* d)
    00042     : name(n), destination(d) {}
    00043 };
    00044
    00045
    00050 struct iShaderDestinationResolver : public virtual iBase
    00051 {
    00052   SCF_INTERFACE(iShaderDestinationResolver, 0,0,1);
    00057   virtual int ResolveTU (const char* binding) = 0;
    00058
    00059   virtual csVertexAttrib ResolveBufferDestination (const char* binding) = 0;
    00060 };
    00061
    00066 struct iShaderProgram : public virtual iBase
    00067 {
    00068   SCF_INTERFACE(iShaderProgram, 2,0,0);
    00070   virtual void Activate() = 0;
    00071
    00073   virtual void Deactivate() = 0;
    00074
    00076   virtual void SetupState (const csRenderMesh* mesh,
    00077                            csRenderMeshModes& modes,
    00078                            const csShaderVarStack &stacks) = 0;
    00079
    00081   virtual void ResetState () = 0;
    00082
    00084   virtual bool Load (iShaderDestinationResolver* resolve,
    00085     iDocumentNode* node) = 0;
    00086
    00088   virtual bool Load (iShaderDestinationResolver* resolve, const char* program,
    00089     csArray<csShaderVarMapping>& mappings) = 0;
    00090
    00092   virtual bool Compile () = 0;
    00093 };
    00094
    00099 struct iShaderProgramPlugin : public virtual iBase
    00100 {
    00101   SCF_INTERFACE(iShaderProgramPlugin,2,0,0);
    00102   virtual csPtr<iShaderProgram> CreateProgram(const char* type) = 0;
    00103   virtual bool SupportType(const char* type) = 0;
    00104 };
    00105
    00108 #endif
    00109