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

OgreCgProgram.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 © 2000-2003 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __CgProgram_H__
00026 #define __CgProgram_H__
00027 
00028 #include "OgreCgPrerequisites.h"
00029 #include "OgreHighLevelGpuProgram.h"
00030 
00031 namespace Ogre {
00041     class CgProgram : public HighLevelGpuProgram
00042     {
00043     public:
00045         class CmdEntryPoint : public ParamCommand
00046         {
00047         public:
00048             String doGet(const void* target) const;
00049             void doSet(void* target, const String& val);
00050         };
00052         class CmdProfiles : public ParamCommand
00053         {
00054         public:
00055             String doGet(const void* target) const;
00056             void doSet(void* target, const String& val);
00057         };
00059         class CmdArgs : public ParamCommand
00060         {
00061         public:
00062             String doGet(const void* target) const;
00063             void doSet(void* target, const String& val);
00064         };
00065 
00066     protected:
00067 
00068         static CmdEntryPoint msCmdEntryPoint;
00069         static CmdProfiles msCmdProfiles;
00070         static CmdArgs msCmdArgs;
00071 
00073         CGcontext mCgContext;
00075         CGprogram mCgProgram;
00078         void loadFromSource(void);
00081         void createLowLevelImpl(void);
00083         void unloadImpl(void);
00085         void populateParameterNames(GpuProgramParametersSharedPtr params);
00086 
00087         StringVector mProfiles;
00088         String mEntryPoint;
00089         String mSelectedProfile;
00090         CGprofile mSelectedCgProfile;
00091         String mCompileArgs;
00092         // Unfortunately Cg uses char** for arguments - bleh
00093         // This is a null-terminated list of char* (each null terminated)
00094         char** mCgArguments;
00095 
00097         void selectProfile(void);
00099         void buildArgs(void);
00101         void freeCgArgs(void);
00102 
00103 
00104     public:
00105         CgProgram(const String& name, GpuProgramType gpType, const String& language, 
00106             CGcontext context);
00107         ~CgProgram();
00108 
00110         void setEntryPoint(const String& entryPoint) { mEntryPoint = entryPoint; }
00112         const String& getEntryPoint(void) const { return mEntryPoint; }
00114         void setProfiles(const StringVector& profiles);
00116         const StringVector& getProfiles(void) const { return mProfiles; }
00118         void setCompileArguments(const String& args) { mCompileArgs = args; }
00120         const String& getCompileArguments(void) const { return mCompileArgs; }
00122         bool isSupported(void) const;
00123     };
00124 }
00125 
00126 #endif

Copyright © 2002-2003 by The OGRE Team
Last modified Sun Nov 28 19:48:17 2004