Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/OgreMain/include/OgreHighLevelGpuProgramManager.h @ 20

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

=hoffentlich gehts jetzt

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