source: OGRE/trunk/ogrenew/OgreMain/include/OgreHighLevelGpuProgramManager.h @ 692

Revision 692, 6.0 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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