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

OgreGpuProgramManager.cpp

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 #include "OgreStableHeaders.h"
00026 #include "OgreGpuProgramManager.h"
00027 #include "OgreHighLevelGpuProgramManager.h"
00028 
00029 namespace Ogre {
00030     //-----------------------------------------------------------------------
00031     template<> GpuProgramManager* Singleton<GpuProgramManager>::ms_Singleton = 0;
00032     //---------------------------------------------------------------------------
00033     GpuProgram* GpuProgramManager::load(const String& name, const String& filename, 
00034         GpuProgramType gptype, const String& syntaxCode, int priority)
00035     {
00036         GpuProgram* prg = create(name, gptype, syntaxCode);
00037         prg->setSourceFile(filename);
00038         ResourceManager::load(prg, priority);
00039         return prg;
00040     }
00041     //---------------------------------------------------------------------------
00042     GpuProgram* GpuProgramManager::loadFromString(const String& name, const String& code, 
00043         GpuProgramType gptype, const String& syntaxCode, int priority)
00044     {
00045         GpuProgram* prg = create(name, gptype, syntaxCode);
00046         prg->setSource(code);
00047         ResourceManager::load(prg, priority);
00048         return prg;
00049     }
00050     //---------------------------------------------------------------------------
00051     GpuProgramManager& GpuProgramManager::getSingleton(void)
00052     {
00053         return Singleton<GpuProgramManager>::getSingleton();
00054     }
00055     //---------------------------------------------------------------------------
00056     GpuProgram* GpuProgramManager::createProgram(const String& name, const String& filename, 
00057         GpuProgramType gptype, const String& syntaxCode, int priority)
00058     {
00059         GpuProgram* prg = create(name, gptype, syntaxCode);
00060         prg->setSourceFile(filename);
00061         ResourceManager::add(prg);
00062         return prg;
00063     }
00064     //---------------------------------------------------------------------------
00065     GpuProgram* GpuProgramManager::createProgramFromString(const String& name, 
00066         const String& code, GpuProgramType gptype, const String& syntaxCode, int priority)
00067     {
00068         GpuProgram* prg = create(name, gptype, syntaxCode);
00069         prg->setSource(code);
00070         ResourceManager::add(prg);
00071         return prg;
00072     }
00073     //---------------------------------------------------------------------------
00074     bool GpuProgramManager::isSyntaxSupported(const String& syntaxCode) const
00075     {
00076         if (std::find(mSyntaxCodes.begin(), mSyntaxCodes.end(), syntaxCode) != mSyntaxCodes.end())
00077         {
00078             return true;
00079         }
00080         else
00081         {
00082             return false;
00083         }
00084     }
00085     //---------------------------------------------------------------------------
00086     Resource* GpuProgramManager::getByName(const String& name, bool preferHighLevelPrograms)
00087     {
00088         Resource* ret;
00089         if (preferHighLevelPrograms)
00090         {
00091             ret = HighLevelGpuProgramManager::getSingleton().getByName(name);
00092             if (ret)
00093                 return ret;
00094         }
00095         return ResourceManager::getByName(name);
00096     }
00097 
00098 }

Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:12 2004