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

# OgreGpuProgramUsage.cpp

Go to the documentation of this file.

    00001
    00002 /*
    00003 -----------------------------------------------------------------------------
    00004 This source file is part of OGRE
    00005     (Object-oriented Graphics Rendering Engine)
    00006 For the latest info, see http://www.ogre3d.org/
    00007
    00008 Copyright © 2000-2003 The OGRE Team
    00009 Also see acknowledgements in Readme.html
    00010
    00011 This program is free software you can redistribute it and/or modify it under
    00012 the terms of the GNU Lesser General Public License as published by the Free Software
    00013 Foundation either version 2 of the License, or (at your option) any later
    00014 version.
    00015
    00016 This program is distributed in the hope that it will be useful, but WITHOUT
    00017 ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
    00018 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
    00019
    00020 You should have received a copy of the GNU Lesser General Public License along with
    00021 this program if not, write to the Free Software Foundation, Inc., 59 Temple
    00022 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
    00023 http://www.gnu.org/copyleft/lesser.txt.
    00024 -----------------------------------------------------------------------------
    00025 */
    00026 #include "OgreStableHeaders.h"
    00027 #include "OgreGpuProgramUsage.h"
    00028 #include "OgreGpuProgramManager.h"
    00029 #include "OgreException.h"
    00030
    00031 namespace Ogre
    00032 {
    00033     //-----------------------------------------------------------------------------
    00034     GpuProgramUsage::GpuProgramUsage(GpuProgramType gptype) :
    00035         mType(gptype), mProgram(NULL)
    00036     {
    00037     }
    00038     //-----------------------------------------------------------------------------
    00039     GpuProgramUsage::GpuProgramUsage(const GpuProgramUsage& oth)
    00040     {
    00041         mType = oth.mType;
    00042         mProgram = oth.mProgram;
    00043         mParameters =  oth.mParameters;
    00044     }
    00045     //-----------------------------------------------------------------------------
    00046     void GpuProgramUsage::setProgramName(const String& name, bool resetParams)
    00047     {
    00048         mProgram = static_cast<GpuProgram*>(
    00049             GpuProgramManager::getSingleton().getByName(name));
    00050
    00051         if (!mProgram)
    00052         {
    00053             String progType = (mType == GPT_VERTEX_PROGRAM ? "vertex" : "fragment");
    00054             Except(Exception::ERR_ITEM_NOT_FOUND,
    00055                 "Unable to locate " + progType + " program called " + name + ".",
    00056                 "GpuProgramUsage::setProgramName");
    00057         }
    00058         // Reset parameters
    00059         if (resetParams || mParameters.isNull())
    00060             mParameters = mProgram->createParameters();
    00061
    00062     }
    00063     //-----------------------------------------------------------------------------
    00064     void GpuProgramUsage::setParameters(GpuProgramParametersSharedPtr params)
    00065     {
    00066         mParameters = params;
    00067     }
    00068     //-----------------------------------------------------------------------------
    00069     GpuProgramParametersSharedPtr GpuProgramUsage::getParameters(void)
    00070     {
    00071         if (mParameters.isNull())
    00072         {
    00073             Except(Exception::ERR_INVALIDPARAMS, "You must specify a program before "
    00074                 "you can retrieve parameters.", "GpuProgramUsage::getParameters");
    00075         }
    00076
    00077         return mParameters;
    00078     }
    00079     //-----------------------------------------------------------------------------
    00080     void GpuProgramUsage::setProgram(GpuProgram* prog)
    00081     {
    00082         mProgram = prog;
    00083         // Reset parameters
    00084         mParameters = mProgram->createParameters();
    00085     }
    00086     //-----------------------------------------------------------------------------
    00087     void GpuProgramUsage::_load(void)
    00088     {
    00089         if (!mProgram->isLoaded())
    00090             mProgram->load();
    00091     }
    00092     //-----------------------------------------------------------------------------
    00093     void GpuProgramUsage::_unload(void)
    00094     {
    00095         // TODO?
    00096     }
    00097
    00098 }

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