source: OGRE/trunk/ogrenew/OgreMain/include/OgreGpuProgramUsage.h @ 692

Revision 692, 5.6 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

RevLine 
[692]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __GpuProgramUsage_H__
26#define __GpuProgramUsage_H__
27
28#include "OgrePrerequisites.h"
29#include "OgreGpuProgram.h"
30
31
32namespace Ogre
33{
34    /** This class makes the usage of a vertex and fragment programs (low-level or high-level),
35        with a given set of parameters, explicit.
36    @remarks
37        Using a vertex or fragment program can get fairly complex; besides the fairly rudimentary
38        process of binding a program to the GPU for rendering, managing usage has few
39        complications, such as:
40        <ul>
41        <li>Programs can be high level (e.g. Cg, RenderMonkey) or low level (assembler). Using
42        either should be relatively seamless, although high-level programs give you the advantage
43        of being able to use named parameters, instead of just indexed registers</li>
44        <li>Programs and parameters can be shared between multiple usages, in order to save
45        memory</li>
46        <li>When you define a user of a program, such as a material, you often want to be able to
47        set up the definition but not load / compile / assemble the program at that stage, because
48        it is not needed just yet. The program should be loaded when it is first needed, or
49        earlier if specifically requested. The program may not be defined at this time, you
50        may want to have scripts that can set up the definitions independent of the order in which
51        those scripts are loaded.</li>
52        </ul>
53        This class packages up those details so you don't have to worry about them. For example,
54        this class lets you define a high-level program and set up the parameters for it, without
55        having loaded the program (which you normally could not do). When the program is loaded and
56        compiled, this class will then validate the parameters you supplied earlier and turn them
57        into runtime parameters.
58    @par
59        Just incase it wasn't clear from the above, this class provides linkage to both
60        GpuProgram and HighLevelGpuProgram, despite its name.
61    */
62    class _OgreExport GpuProgramUsage
63    {
64    protected:
65        GpuProgramType mType;
66        // The program link
67        GpuProgramPtr mProgram;
68
69        /// program parameters
70        GpuProgramParametersSharedPtr mParameters;
71
72
73    public:
74        /** Default constructor.
75        @param gptype The type of program to link to
76        */
77        GpuProgramUsage(GpuProgramType gptype);
78
79                /** Copy constructor */
80                GpuProgramUsage(const GpuProgramUsage& rhs);
81
82        /** Gets the type of program we're trying to link to. */
83        GpuProgramType getType(void) const { return mType; }
84
85                /** Sets the name of the program to use.
86        @param name The name of the program to use
87        @param resetParams
88            If true, this will create a fresh set of parameters from the
89            new program being linked, so if you had previously set parameters
90            you will have to set them again. If you set this to false, you must
91            be absolutely sure that the parameters match perfectly, and in the
92            case of named parameters refers to the indexes underlying them,
93            not just the names.
94        */
95                void setProgramName(const String& name, bool resetParams = true);
96                /** Sets the program to use.
97        @remarks
98            Note that this will create a fresh set of parameters from the
99            new program being linked, so if you had previously set parameters
100            you will have to set them again.
101        */
102        void setProgram(GpuProgramPtr& prog);
103                /** Gets the program being used. */
104        const GpuProgramPtr& getProgram() const { return mProgram; }
105                /** Gets the program being used. */
106        const String& getProgramName(void) const { return mProgram->getName(); }
107
108        /** Sets the program parameters that should be used; because parameters can be
109            shared between multiple usages for efficiency, this method is here for you
110            to register externally created parameter objects. Otherwise, the parameters
111            will be created for you when a program is linked.
112        */
113        void setParameters(GpuProgramParametersSharedPtr params);
114        /** Gets the parameters being used here.
115        */
116        GpuProgramParametersSharedPtr getParameters(void);
117
118        /// Load this usage (and ensure program is loaded)
119        void _load(void);
120        /// Unload this usage
121        void _unload(void);
122
123    };
124}
125#endif
Note: See TracBrowser for help on using the repository browser.