OgreGLSLProgram.h
Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org/
    00006
    00007 Copyright (c) 2000-2012 Torus Knot Software Ltd
    00008
    00009 Permission is hereby granted, free of charge, to any person obtaining a copy
    00010 of this software and associated documentation files (the "Software"), to deal
    00011 in the Software without restriction, including without limitation the rights
    00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00013 copies of the Software, and to permit persons to whom the Software is
    00014 furnished to do so, subject to the following conditions:
    00015
    00016 The above copyright notice and this permission notice shall be included in
    00017 all copies or substantial portions of the Software.
    00018
    00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00025 THE SOFTWARE.
    00026 -----------------------------------------------------------------------------
    00027 */
    00028 #ifndef __GLSLProgram_H__
    00029 #define __GLSLProgram_H__
    00030
    00031 #include "OgreGLPrerequisites.h"
    00032 #include "OgreHighLevelGpuProgram.h"
    00033
    00034 namespace Ogre {
    00056     class _OgreGLExport GLSLProgram : public HighLevelGpuProgram
    00057     {
    00058     public:
    00060         class CmdAttach : public ParamCommand
    00061         {
    00062         public:
    00063             String doGet(const void* target) const;
    00064             void doSet(void* target, const String& shaderNames);
    00065         };
    00066
    00067         GLSLProgram(ResourceManager* creator,
    00068             const String& name, ResourceHandle handle,
    00069             const String& group, bool isManual, ManualResourceLoader* loader);
    00070         ~GLSLProgram();
    00071
    00072         GLhandleARB getGLHandle() const { return mGLHandle; }
    00073         void attachToProgramObject( const GLhandleARB programObject );
    00074         void detachFromProgramObject( const GLhandleARB programObject );
    00075         String getAttachedShaderNames() const { return mAttachedShaderNames; }
    00076
    00078         bool getPassTransformStates(void) const;
    00079         bool getPassSurfaceAndLightStates(void) const;
    00080
    00082         void attachChildShader(const String& name);
    00083
    00085         void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
    00087         const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
    00088
    00090         const String& getLanguage(void) const;
    00091
    00095         virtual RenderOperation::OperationType getInputOperationType(void) const
    00096         { return mInputOperationType; }
    00099         virtual RenderOperation::OperationType getOutputOperationType(void) const
    00100         { return mOutputOperationType; }
    00104         virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; }
    00105
    00108         virtual void setInputOperationType(RenderOperation::OperationType operationType)
    00109         { mInputOperationType = operationType; }
    00112         virtual void setOutputOperationType(RenderOperation::OperationType operationType)
    00113         { mOutputOperationType = operationType; }
    00117         virtual void setMaxOutputVertices(int maxOutputVertices)
    00118         { mMaxOutputVertices = maxOutputVertices; }
    00119
    00121         bool compile( const bool checkErrors = true);
    00122
    00124         class CmdPreprocessorDefines : public ParamCommand
    00125         {
    00126         public:
    00127             String doGet(const void* target) const;
    00128             void doSet(void* target, const String& val);
    00129         };
    00131         class _OgreGLExport CmdInputOperationType : public ParamCommand
    00132         {
    00133         public:
    00134             String doGet(const void* target) const;
    00135             void doSet(void* target, const String& val);
    00136         };
    00138         class _OgreGLExport CmdOutputOperationType : public ParamCommand
    00139         {
    00140         public:
    00141             String doGet(const void* target) const;
    00142             void doSet(void* target, const String& val);
    00143         };
    00145         class _OgreGLExport CmdMaxOutputVertices : public ParamCommand
    00146         {
    00147         public:
    00148             String doGet(const void* target) const;
    00149             void doSet(void* target, const String& val);
    00150         };
    00151     protected:
    00152         static CmdPreprocessorDefines msCmdPreprocessorDefines;
    00153         static CmdAttach msCmdAttach;
    00154         static CmdInputOperationType msInputOperationTypeCmd;
    00155         static CmdOutputOperationType msOutputOperationTypeCmd;
    00156         static CmdMaxOutputVertices msMaxOutputVerticesCmd;
    00157
    00160         void loadFromSource(void);
    00166         void createLowLevelImpl(void);
    00168         void unloadHighLevelImpl(void);
    00170         void unloadImpl(void);
    00171
    00173         void populateParameterNames(GpuProgramParametersSharedPtr params);
    00175         void buildConstantDefinitions() const;
    00176
    00177     private:
    00179         GLhandleARB mGLHandle;
    00181         GLint mCompiled;
    00183         RenderOperation::OperationType mInputOperationType;
    00185         RenderOperation::OperationType mOutputOperationType;
    00187         int mMaxOutputVertices;
    00189         String mAttachedShaderNames;
    00191         String mPreprocessorDefines;
    00193         typedef vector< GLSLProgram* >::type GLSLProgramContainer;
    00194         typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator;
    00195         GLSLProgramContainer mAttachedGLSLPrograms;
    00196
    00197     };
    00198 }
    00199
    00200 #endif // __GLSLProgram_H__

Copyright © 2012 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Sun Sep 2 2012 07:27:21