1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __GLSLLinkProgramManager_H__
|
---|
26 | #define __GLSLLinkProgramManager_H__
|
---|
27 |
|
---|
28 | #include "OgreGLPrerequisites.h"
|
---|
29 | #include "OgreSingleton.h"
|
---|
30 |
|
---|
31 | #include "OgreGLSLExtSupport.h"
|
---|
32 |
|
---|
33 | namespace Ogre {
|
---|
34 |
|
---|
35 | /** Ogre assumes that there are seperate vertex and fragment programs to deal with but
|
---|
36 | GLSL has one program object that represents the active vertex and fragment shader objects
|
---|
37 | during a rendering state. GLSL Vertex and fragment
|
---|
38 | shader objects are compiled seperately and then attached to a program object and then the
|
---|
39 | program object is linked. Since Ogre can only handle one vertex program and one fragment
|
---|
40 | program being active in a pass, the GLSL Link Program Manager does the same. The GLSL Link
|
---|
41 | program manager acts as a state machine and activates a program object based on the active
|
---|
42 | vertex and fragment program. Previously created program objects are stored along with a unique
|
---|
43 | key in a hash_map for quick retrieval the next time the program object is required.
|
---|
44 |
|
---|
45 | */
|
---|
46 |
|
---|
47 | class GLSLLinkProgramManager : public Singleton<GLSLLinkProgramManager>
|
---|
48 | {
|
---|
49 |
|
---|
50 | private:
|
---|
51 |
|
---|
52 | typedef HashMap<GLuint, GLSLLinkProgram*> LinkProgramMap;
|
---|
53 | typedef LinkProgramMap::iterator LinkProgramIterator;
|
---|
54 |
|
---|
55 | /// container holding previously created program objects
|
---|
56 | LinkProgramMap LinkPrograms;
|
---|
57 |
|
---|
58 | /// active objects defining the active rendering gpu state
|
---|
59 | GLSLGpuProgram* mActiveVertexGpuProgram;
|
---|
60 | GLSLGpuProgram* mActiveFragmentGpuProgram;
|
---|
61 | GLSLLinkProgram* mActiveLinkProgram;
|
---|
62 |
|
---|
63 | public:
|
---|
64 |
|
---|
65 | GLSLLinkProgramManager(void);
|
---|
66 |
|
---|
67 | ~GLSLLinkProgramManager(void);
|
---|
68 |
|
---|
69 | /**
|
---|
70 | Get the program object that links the two active shader objects together
|
---|
71 | if a program object was not already created and linked a new one is created and linked
|
---|
72 | */
|
---|
73 | GLSLLinkProgram* getActiveLinkProgram(void);
|
---|
74 |
|
---|
75 | /** Set the active fragment shader for the next rendering state.
|
---|
76 | The active program object will be cleared.
|
---|
77 | Normally called from the GLSLGpuProgram::bindProgram and unbindProgram methods
|
---|
78 | */
|
---|
79 | void setActiveFragmentShader(GLSLGpuProgram* fragmentGpuProgram);
|
---|
80 | /** Set the active vertex shader for the next rendering state.
|
---|
81 | The active program object will be cleared.
|
---|
82 | Normally called from the GLSLGpuProgram::bindProgram and unbindProgram methods
|
---|
83 | */
|
---|
84 | void setActiveVertexShader(GLSLGpuProgram* vertexGpuProgram);
|
---|
85 |
|
---|
86 | static GLSLLinkProgramManager& getSingleton(void);
|
---|
87 | static GLSLLinkProgramManager* getSingletonPtr(void);
|
---|
88 |
|
---|
89 | };
|
---|
90 |
|
---|
91 | }
|
---|
92 |
|
---|
93 | #endif // __GLSLLinkProgramManager_H__
|
---|