Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreUnifiedHighLevelGpuProgram.h @ 3

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

=update

File size: 6.0 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 __UnifiedHighLevelGpuProgram_H__
30#define __UnifiedHighLevelGpuProgram_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreHighLevelGpuProgram.h"
34#include "OgreHighLevelGpuProgramManager.h"
35
36namespace Ogre {
37
38        /** Specialisation of HighLevelGpuProgram which just delegates its implementation
39                to one other high level program, allowing a single program definition
40                to represent one supported program from a number of options
41        @remarks
42                Whilst you can use Technique to implement several ways to render an object
43                depending on hardware support, if the only reason to need multiple paths is
44                because of the high-level shader language supported, this can be
45                cumbersome. For example you might want to implement the same shader
46                in HLSL and     GLSL for portability but apart from the implementation detail,
47                the shaders do the same thing and take the same parameters. If the materials
48                in question are complex, duplicating the techniques just to switch language
49                is not optimal, so instead you can define high-level programs with a
50                syntax of 'unified', and list the actual implementations in order of
51                preference via repeated use of the 'delegate' parameter, which just points
52                at another program name. The first one which has a supported syntax
53                will be used.
54        */
55        class _OgreExport UnifiedHighLevelGpuProgram : public HighLevelGpuProgram
56        {
57        public:
58                /// Command object for setting delegate (can set more than once)
59                class CmdDelegate : public ParamCommand
60                {
61                public:
62                        String doGet(const void* target) const;
63                        void doSet(void* target, const String& val);
64                };
65
66        protected:
67                static CmdDelegate msCmdDelegate;
68
69                /// Ordered list of potential delegates
70                StringVector mDelegateNames;
71                /// The chosen delegate
72                mutable HighLevelGpuProgramPtr mChosenDelegate;
73
74                /// Choose the delegate to use
75                void chooseDelegate() const;
76
77                void createLowLevelImpl(void);
78                void unloadHighLevelImpl(void);
79                void buildConstantDefinitions() const;
80                void loadFromSource(void);
81
82        public:
83                /** Constructor, should be used only by factory classes. */
84                UnifiedHighLevelGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
85                        const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
86                ~UnifiedHighLevelGpuProgram();
87
88
89                /** Adds a new delegate program to the list.
90                @remarks
91                        Delegates are tested in order so earlier ones are preferred.
92                */
93                void addDelegateProgram(const String& name);
94
95                /// Remove all delegate programs
96                void clearDelegatePrograms();
97
98                /// Get the chosen delegate
99                const HighLevelGpuProgramPtr& _getDelegate() const;
100
101                /** @copydoc GpuProgram::getLanguage */
102        const String& getLanguage(void) const;
103
104                /** Creates a new parameters object compatible with this program definition.
105                @remarks
106                Unlike low-level assembly programs, parameters objects are specific to the
107                program and therefore must be created from it rather than by the
108                HighLevelGpuProgramManager. This method creates a new instance of a parameters
109                object containing the definition of the parameters this program understands.
110                */
111                GpuProgramParametersSharedPtr createParameters(void);
112                /** @copydoc GpuProgram::getBindingDelegate */
113                GpuProgram* _getBindingDelegate(void);
114
115                // All the following methods must delegate to the implementation
116
117                /** @copydoc GpuProgram::isSupported */
118                bool isSupported(void) const;
119               
120                /** @copydoc GpuProgram::isSkeletalAnimationIncluded */
121                bool isSkeletalAnimationIncluded(void) const;
122
123                bool isMorphAnimationIncluded(void) const;
124
125                bool isPoseAnimationIncluded(void) const;
126
127                bool isVertexTextureFetchRequired(void) const;
128                GpuProgramParametersSharedPtr getDefaultParameters(void);
129                bool hasDefaultParameters(void) const;
130                bool getPassSurfaceAndLightStates(void) const;
131                bool hasCompileError(void) const;
132                void resetCompileError(void);
133
134                void load(bool backgroundThread = false);
135                void reload(void);
136                bool isReloadable(void) const;
137                bool isLoaded(void) const;
138                LoadingState isLoading() const;
139                LoadingState getLoadingState() const;
140                void unload(void);
141                size_t getSize(void) const;
142                void touch(void);
143                bool isBackgroundLoaded(void) const;
144                void setBackgroundLoaded(bool bl);
145                void escalateLoading();
146                void addListener(Listener* lis);
147                void removeListener(Listener* lis);
148
149        };
150
151        /** Factory class for Unified programs. */
152        class UnifiedHighLevelGpuProgramFactory : public HighLevelGpuProgramFactory
153        {
154        public:
155                UnifiedHighLevelGpuProgramFactory();
156                ~UnifiedHighLevelGpuProgramFactory();
157                /// Get the name of the language this factory creates programs for
158                const String& getLanguage(void) const;
159                HighLevelGpuProgram* create(ResourceManager* creator, 
160                        const String& name, ResourceHandle handle,
161                        const String& group, bool isManual, ManualResourceLoader* loader);
162                void destroy(HighLevelGpuProgram* prog);
163
164        };
165
166
167}
168#endif
Note: See TracBrowser for help on using the repository browser.