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

Revision 690, 3.6 KB checked in by mattausch, 18 years ago (diff)

added ogre 1.07 main

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                mParameters =  oth.mParameters;
44        }
45        //-----------------------------------------------------------------------------
46        void GpuProgramUsage::setProgramName(const String& name, bool resetParams)
47        {
48                mProgram = GpuProgramManager::getSingleton().getByName(name);
49
50        if (mProgram.isNull())
51        {
52            String progType = (mType == GPT_VERTEX_PROGRAM ? "vertex" : "fragment");
53            OGRE_EXCEPT(Exception::ERR_ITEM_NOT_FOUND,
54                "Unable to locate " + progType + " program called " + name + ".",
55                "GpuProgramUsage::setProgramName");
56        }
57        // Reset parameters
58        if (resetParams || mParameters.isNull())
59            mParameters = mProgram->createParameters();
60
61        }
62    //-----------------------------------------------------------------------------
63    void GpuProgramUsage::setParameters(GpuProgramParametersSharedPtr params)
64    {
65        mParameters = params;
66    }
67    //-----------------------------------------------------------------------------
68    GpuProgramParametersSharedPtr GpuProgramUsage::getParameters(void)
69    {
70        if (mParameters.isNull())
71        {
72            OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS, "You must specify a program before "
73                "you can retrieve parameters.", "GpuProgramUsage::getParameters");
74        }
75
76        return mParameters;
77    }
78    //-----------------------------------------------------------------------------
79        void GpuProgramUsage::setProgram(GpuProgramPtr& prog)
80        {
81        mProgram = prog;
82        // Reset parameters
83        mParameters = mProgram->createParameters();
84    }
85    //-----------------------------------------------------------------------------
86    void GpuProgramUsage::_load(void)
87    {
88        if (!mProgram->isLoaded())
89            mProgram->load();
90    }
91    //-----------------------------------------------------------------------------
92    void GpuProgramUsage::_unload(void)
93    {
94        // TODO?
95    }
96
97}
Note: See TracBrowser for help on using the repository browser.