Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreGpuProgramUsage.h @ 5

Last change on this file since 5 was 5, checked in by anonymous, 17 years ago

=hoffentlich gehts jetzt

File size: 5.6 KB
Line 
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __GpuProgramUsage_H__
30#define __GpuProgramUsage_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreGpuProgram.h"
34
35
36namespace Ogre
37{
38    /** This class makes the usage of a vertex and fragment programs (low-level or high-level),
39        with a given set of parameters, explicit.
40    @remarks
41        Using a vertex or fragment program can get fairly complex; besides the fairly rudimentary
42        process of binding a program to the GPU for rendering, managing usage has few
43        complications, such as:
44        <ul>
45        <li>Programs can be high level (e.g. Cg, RenderMonkey) or low level (assembler). Using
46        either should be relatively seamless, although high-level programs give you the advantage
47        of being able to use named parameters, instead of just indexed registers</li>
48        <li>Programs and parameters can be shared between multiple usages, in order to save
49        memory</li>
50        <li>When you define a user of a program, such as a material, you often want to be able to
51        set up the definition but not load / compile / assemble the program at that stage, because
52        it is not needed just yet. The program should be loaded when it is first needed, or
53        earlier if specifically requested. The program may not be defined at this time, you
54        may want to have scripts that can set up the definitions independent of the order in which
55        those scripts are loaded.</li>
56        </ul>
57        This class packages up those details so you don't have to worry about them. For example,
58        this class lets you define a high-level program and set up the parameters for it, without
59        having loaded the program (which you normally could not do). When the program is loaded and
60        compiled, this class will then validate the parameters you supplied earlier and turn them
61        into runtime parameters.
62    @par
63        Just incase it wasn't clear from the above, this class provides linkage to both
64        GpuProgram and HighLevelGpuProgram, despite its name.
65    */
66    class _OgreExport GpuProgramUsage
67    {
68    protected:
69        GpuProgramType mType;
70        // The program link
71        GpuProgramPtr mProgram;
72
73        /// program parameters
74        GpuProgramParametersSharedPtr mParameters;
75
76
77    public:
78        /** Default constructor.
79        @param gptype The type of program to link to
80        */
81        GpuProgramUsage(GpuProgramType gptype);
82
83                /** Copy constructor */
84                GpuProgramUsage(const GpuProgramUsage& rhs);
85
86        /** Gets the type of program we're trying to link to. */
87        GpuProgramType getType(void) const { return mType; }
88
89                /** Sets the name of the program to use.
90        @param name The name of the program to use
91        @param resetParams
92            If true, this will create a fresh set of parameters from the
93            new program being linked, so if you had previously set parameters
94            you will have to set them again. If you set this to false, you must
95            be absolutely sure that the parameters match perfectly, and in the
96            case of named parameters refers to the indexes underlying them,
97            not just the names.
98        */
99                void setProgramName(const String& name, bool resetParams = true);
100                /** Sets the program to use.
101        @remarks
102            Note that this will create a fresh set of parameters from the
103            new program being linked, so if you had previously set parameters
104            you will have to set them again.
105        */
106        void setProgram(GpuProgramPtr& prog);
107                /** Gets the program being used. */
108        const GpuProgramPtr& getProgram() const { return mProgram; }
109                /** Gets the program being used. */
110        const String& getProgramName(void) const { return mProgram->getName(); }
111
112        /** Sets the program parameters that should be used; because parameters can be
113            shared between multiple usages for efficiency, this method is here for you
114            to register externally created parameter objects. Otherwise, the parameters
115            will be created for you when a program is linked.
116        */
117        void setParameters(GpuProgramParametersSharedPtr params);
118        /** Gets the parameters being used here.
119        */
120        GpuProgramParametersSharedPtr getParameters(void);
121
122        /// Load this usage (and ensure program is loaded)
123        void _load(void);
124        /// Unload this usage
125        void _unload(void);
126
127    };
128}
129#endif
Note: See TracBrowser for help on using the repository browser.