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) 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 mParameters = mProgram->createParameters(); 00060 00061 } 00062 //----------------------------------------------------------------------------- 00063 void GpuProgramUsage::setParameters(GpuProgramParametersSharedPtr params) 00064 { 00065 mParameters = params; 00066 } 00067 //----------------------------------------------------------------------------- 00068 GpuProgramParametersSharedPtr GpuProgramUsage::getParameters(void) 00069 { 00070 if (mParameters.isNull()) 00071 { 00072 Except(Exception::ERR_INVALIDPARAMS, "You must specify a program before " 00073 "you can retrieve parameters.", "GpuProgramUsage::getParameters"); 00074 } 00075 00076 return mParameters; 00077 } 00078 //----------------------------------------------------------------------------- 00079 void GpuProgramUsage::setProgram(GpuProgram* prog) 00080 { 00081 mProgram = prog; 00082 // Reset parameters 00083 mParameters = mProgram->createParameters(); 00084 } 00085 //----------------------------------------------------------------------------- 00086 void GpuProgramUsage::_load(void) 00087 { 00088 if (!mProgram->isLoaded()) 00089 mProgram->load(); 00090 } 00091 //----------------------------------------------------------------------------- 00092 void GpuProgramUsage::_unload(void) 00093 { 00094 // TODO? 00095 } 00096 00097 }
Copyright © 2002-2003 by The OGRE Team
Last modified Wed Jan 21 00:10:12 2004