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

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