source: OGRE/trunk/ogrenew/OgreMain/src/OgreGpuProgramUsage.cpp @ 692

Revision 692, 3.8 KB checked in by mattausch, 18 years ago (diff)

adding ogre 1.2 and dependencies

Line 
1
2/*
3-----------------------------------------------------------------------------
4This source file is part of OGRE
5    (Object-oriented Graphics Rendering Engine)
6For the latest info, see http://www.ogre3d.org/
7
8Copyright (c) 2000-2005 The OGRE Team
9Also see acknowledgements in Readme.html
10
11This program is free software you can redistribute it and/or modify it under
12the terms of the GNU Lesser General Public License as published by the Free Software
13Foundation either version 2 of the License, or (at your option) any later
14version.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
19
20You should have received a copy of the GNU Lesser General Public License along with
21this program if not, write to the Free Software Foundation, Inc., 59 Temple
22Place - Suite 330, Boston, MA 02111-1307, USA, or go to
23http://www.gnu.org/copyleft/lesser.txt.
24-----------------------------------------------------------------------------
25*/
26#include "OgreStableHeaders.h"
27#include "OgreGpuProgramUsage.h"
28#include "OgreGpuProgramManager.h"
29#include "OgreException.h"
30
31namespace Ogre
32{
33    //-----------------------------------------------------------------------------
34    GpuProgramUsage::GpuProgramUsage(GpuProgramType gptype) :
35        mType(gptype), mProgram(NULL)
36    {
37    }
38        //-----------------------------------------------------------------------------
39        GpuProgramUsage::GpuProgramUsage(const GpuProgramUsage& oth)
40        {
41                mType = oth.mType;
42                mProgram = oth.mProgram;
43        // nfz: parameters should be copied not just use a shared ptr to the original
44                mParameters =  GpuProgramParametersSharedPtr(new GpuProgramParameters(*oth.mParameters));
45        }
46        //-----------------------------------------------------------------------------
47        void GpuProgramUsage::setProgramName(const String& name, bool resetParams)
48        {
49                mProgram = GpuProgramManager::getSingleton().getByName(name);
50
51        if (mProgram.isNull())
52        {
53            String progType = (mType == GPT_VERTEX_PROGRAM ? "vertex" : "fragment");
54            OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
55                "Unable to locate " + progType + " program called " + name + ".",
56                "GpuProgramUsage::setProgramName");
57        }
58        // Reset parameters
59        if (resetParams || mParameters.isNull())
60            mParameters = mProgram->createParameters();
61
62        }
63    //-----------------------------------------------------------------------------
64    void GpuProgramUsage::setParameters(GpuProgramParametersSharedPtr params)
65    {
66        mParameters = params;
67    }
68    //-----------------------------------------------------------------------------
69    GpuProgramParametersSharedPtr GpuProgramUsage::getParameters(void)
70    {
71        if (mParameters.isNull())
72        {
73            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "You must specify a program before "
74                "you can retrieve parameters.", "GpuProgramUsage::getParameters");
75        }
76
77        return mParameters;
78    }
79    //-----------------------------------------------------------------------------
80        void GpuProgramUsage::setProgram(GpuProgramPtr& prog)
81        {
82        mProgram = prog;
83        // Reset parameters
84        mParameters = mProgram->createParameters();
85    }
86    //-----------------------------------------------------------------------------
87    void GpuProgramUsage::_load(void)
88    {
89        if (!mProgram->isLoaded())
90            mProgram->load();
91    }
92    //-----------------------------------------------------------------------------
93    void GpuProgramUsage::_unload(void)
94    {
95        // TODO?
96    }
97
98}
Note: See TracBrowser for help on using the repository browser.