Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreUnifiedHighLevelGpuProgram.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 6.3 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-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef __UnifiedHighLevelGpuProgram_H__
29#define __UnifiedHighLevelGpuProgram_H__
30
31#include "OgrePrerequisites.h"
32#include "OgreHighLevelGpuProgram.h"
33#include "OgreHighLevelGpuProgramManager.h"
34
35namespace Ogre {
36
37        /** \addtogroup Core
38        *  @{
39        */
40        /** \addtogroup Resources
41        *  @{
42        */
43        /** Specialisation of HighLevelGpuProgram which just delegates its implementation
44                to one other high level program, allowing a single program definition
45                to represent one supported program from a number of options
46        @remarks
47                Whilst you can use Technique to implement several ways to render an object
48                depending on hardware support, if the only reason to need multiple paths is
49                because of the high-level shader language supported, this can be
50                cumbersome. For example you might want to implement the same shader
51                in HLSL and     GLSL for portability but apart from the implementation detail,
52                the shaders do the same thing and take the same parameters. If the materials
53                in question are complex, duplicating the techniques just to switch language
54                is not optimal, so instead you can define high-level programs with a
55                syntax of 'unified', and list the actual implementations in order of
56                preference via repeated use of the 'delegate' parameter, which just points
57                at another program name. The first one which has a supported syntax
58                will be used.
59        */
60        class _OgreExport UnifiedHighLevelGpuProgram : public HighLevelGpuProgram
61        {
62        public:
63                /// Command object for setting delegate (can set more than once)
64                class CmdDelegate : public ParamCommand
65                {
66                public:
67                        String doGet(const void* target) const;
68                        void doSet(void* target, const String& val);
69                };
70
71        protected:
72                static CmdDelegate msCmdDelegate;
73
74                /// Ordered list of potential delegates
75                StringVector mDelegateNames;
76                /// The chosen delegate
77                mutable HighLevelGpuProgramPtr mChosenDelegate;
78
79                /// Choose the delegate to use
80                void chooseDelegate() const;
81
82                void createLowLevelImpl(void);
83                void unloadHighLevelImpl(void);
84                void buildConstantDefinitions() const;
85                void loadFromSource(void);
86
87        public:
88                /** Constructor, should be used only by factory classes. */
89                UnifiedHighLevelGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
90                        const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
91                ~UnifiedHighLevelGpuProgram();
92
93                virtual size_t calculateSize(void) const;
94
95                /** Adds a new delegate program to the list.
96                @remarks
97                        Delegates are tested in order so earlier ones are preferred.
98                */
99                void addDelegateProgram(const String& name);
100
101                /// Remove all delegate programs
102                void clearDelegatePrograms();
103
104                /// Get the chosen delegate
105                const HighLevelGpuProgramPtr& _getDelegate() const;
106
107                /** @copydoc GpuProgram::getLanguage */
108        const String& getLanguage(void) const;
109
110                /** Creates a new parameters object compatible with this program definition.
111                @remarks
112                Unlike low-level assembly programs, parameters objects are specific to the
113                program and therefore must be created from it rather than by the
114                HighLevelGpuProgramManager. This method creates a new instance of a parameters
115                object containing the definition of the parameters this program understands.
116                */
117                GpuProgramParametersSharedPtr createParameters(void);
118                /** @copydoc GpuProgram::_getBindingDelegate */
119                GpuProgram* _getBindingDelegate(void);
120
121                // All the following methods must delegate to the implementation
122
123                /** @copydoc GpuProgram::isSupported */
124                bool isSupported(void) const;
125               
126                /** @copydoc GpuProgram::isSkeletalAnimationIncluded */
127                bool isSkeletalAnimationIncluded(void) const;
128
129                bool isMorphAnimationIncluded(void) const;
130
131                bool isPoseAnimationIncluded(void) const;
132
133                bool isVertexTextureFetchRequired(void) const;
134                GpuProgramParametersSharedPtr getDefaultParameters(void);
135                bool hasDefaultParameters(void) const;
136                bool getPassSurfaceAndLightStates(void) const;
137                bool getPassFogStates(void) const;
138                bool getPassTransformStates(void) const;
139                bool hasCompileError(void) const;
140                void resetCompileError(void);
141
142                void load(bool backgroundThread = false);
143                void reload(void);
144                bool isReloadable(void) const;
145                bool isLoaded(void) const;
146                bool isLoading() const;
147                LoadingState getLoadingState() const;
148                void unload(void);
149                size_t getSize(void) const;
150                void touch(void);
151                bool isBackgroundLoaded(void) const;
152                void setBackgroundLoaded(bool bl);
153                void escalateLoading();
154                void addListener(Listener* lis);
155                void removeListener(Listener* lis);
156
157        };
158
159        /** Factory class for Unified programs. */
160        class UnifiedHighLevelGpuProgramFactory : public HighLevelGpuProgramFactory
161        {
162        public:
163                UnifiedHighLevelGpuProgramFactory();
164                ~UnifiedHighLevelGpuProgramFactory();
165                /// Get the name of the language this factory creates programs for
166                const String& getLanguage(void) const;
167                HighLevelGpuProgram* create(ResourceManager* creator, 
168                        const String& name, ResourceHandle handle,
169                        const String& group, bool isManual, ManualResourceLoader* loader);
170                void destroy(HighLevelGpuProgram* prog);
171
172        };
173
174        /** @} */
175        /** @} */
176
177}
178#endif
Note: See TracBrowser for help on using the repository browser.