Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreHighLevelGpuProgramManager.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.9 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 __HighLevelGpuProgramManager_H__
29#define __HighLevelGpuProgramManager_H__
30
31#include "OgrePrerequisites.h"
32#include "OgreResourceManager.h"
33#include "OgreSingleton.h"
34#include "OgreException.h"
35#include "OgreHighLevelGpuProgram.h"
36#include "OgreHeaderPrefix.h"
37
38namespace Ogre {
39
40        /** \addtogroup Core
41        *  @{
42        */
43        /** \addtogroup Resources
44        *  @{
45        */
46        /** Interface definition for factories of HighLevelGpuProgram. */
47        class _OgreExport HighLevelGpuProgramFactory : public FactoryAlloc
48        {
49        public:
50        HighLevelGpuProgramFactory() {}
51        virtual ~HighLevelGpuProgramFactory();
52                /// Get the name of the language this factory creates programs for
53                virtual const String& getLanguage(void) const = 0;
54        virtual HighLevelGpuProgram* create(ResourceManager* creator, 
55            const String& name, ResourceHandle handle,
56            const String& group, bool isManual, ManualResourceLoader* loader) = 0;
57                virtual void destroy(HighLevelGpuProgram* prog) = 0;
58        };
59        /** This ResourceManager manages high-level vertex and fragment programs.
60        @remarks
61                High-level vertex and fragment programs can be used instead of assembler programs
62                as managed by GpuProgramManager; however they typically result in a GpuProgram
63                being created as a derivative of the high-level program. High-level programs are
64                easier to write, and can often be API-independent, unlike assembler programs.
65        @par
66                This class not only manages the programs themselves, it also manages the factory
67                classes which allow the creation of high-level programs using a variety of high-level
68                syntaxes. Plugins can be created which register themselves as high-level program
69                factories and as such the engine can be extended to accept virtually any kind of
70                program provided a plugin is written.
71        */
72        class _OgreExport HighLevelGpuProgramManager 
73                : public ResourceManager, public Singleton<HighLevelGpuProgramManager>
74        {
75        public:
76                typedef map<String, HighLevelGpuProgramFactory*>::type FactoryMap;
77        protected:
78                /// Factories capable of creating HighLevelGpuProgram instances
79                FactoryMap mFactories;
80
81                /// Factory for dealing with programs for languages we can't create
82                HighLevelGpuProgramFactory* mNullFactory;
83                /// Factory for unified high-level programs
84                HighLevelGpuProgramFactory* mUnifiedFactory;
85
86                HighLevelGpuProgramFactory* getFactory(const String& language);
87
88        /// @copydoc ResourceManager::createImpl
89        Resource* createImpl(const String& name, ResourceHandle handle, 
90            const String& group, bool isManual, ManualResourceLoader* loader,
91            const NameValuePairList* createParams);
92        public:
93                HighLevelGpuProgramManager();
94                ~HighLevelGpuProgramManager();
95                /** Add a new factory object for high-level programs of a given language. */
96                void addFactory(HighLevelGpuProgramFactory* factory);
97                /** Remove a factory object for high-level programs of a given language. */
98                void removeFactory(HighLevelGpuProgramFactory* factory);
99
100                /** Returns whether a given high-level language is supported. */
101                bool isLanguageSupported(const String& lang);
102
103                /// Get a resource by name
104                /// @see ResourceManager::getResourceByName
105                HighLevelGpuProgramPtr getByName(const String& name, const String& groupName = ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME);
106
107        /** Create a new, unloaded HighLevelGpuProgram.
108                @par
109                        This method creates a new program of the type specified as the second and third parameters.
110                        You will have to call further methods on the returned program in order to
111                        define the program fully before you can load it.
112                @param name The identifying name of the program
113        @param groupName The name of the resource group which this program is
114            to be a member of
115                @param language Code of the language to use (e.g. "cg")
116                @param gptype The type of program to create
117                */
118                HighLevelGpuProgramPtr createProgram(
119                        const String& name, const String& groupName, 
120            const String& language, GpuProgramType gptype);
121
122        /** Override standard Singleton retrieval.
123        @remarks
124        Why do we do this? Well, it's because the Singleton
125        implementation is in a .h file, which means it gets compiled
126        into anybody who includes it. This is needed for the
127        Singleton template to work, but we actually only want it
128        compiled into the implementation of the class based on the
129        Singleton, not all of them. If we don't change this, we get
130        link errors when trying to use the Singleton-based class from
131        an outside dll.
132        @par
133        This method just delegates to the template version anyway,
134        but the implementation stays in this single compilation unit,
135        preventing link errors.
136        */
137        static HighLevelGpuProgramManager& getSingleton(void);
138        /** Override standard Singleton retrieval.
139        @remarks
140        Why do we do this? Well, it's because the Singleton
141        implementation is in a .h file, which means it gets compiled
142        into anybody who includes it. This is needed for the
143        Singleton template to work, but we actually only want it
144        compiled into the implementation of the class based on the
145        Singleton, not all of them. If we don't change this, we get
146        link errors when trying to use the Singleton-based class from
147        an outside dll.
148        @par
149        This method just delegates to the template version anyway,
150        but the implementation stays in this single compilation unit,
151        preventing link errors.
152        */
153        static HighLevelGpuProgramManager* getSingletonPtr(void);
154
155
156        };
157        /** @} */
158        /** @} */
159
160}
161
162#include "OgreHeaderSuffix.h"
163
164#endif
Note: See TracBrowser for help on using the repository browser.