source: OGRE/trunk/ogrenew/RenderSystems/GL/src/GLSL/include/OgreGLSLProgram.h @ 692

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

adding ogre 1.2 and dependencies

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-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 __GLSLProgram_H__
26#define __GLSLProgram_H__
27
28#include "OgreGLPrerequisites.h"
29#include "OgreHighLevelGpuProgram.h"
30
31namespace Ogre {
32    /** Specialisation of HighLevelGpuProgram to provide support for OpenGL
33        Shader Language (GLSL).
34    @remarks
35                GLSL has no target assembler or entry point specification like DirectX 9 HLSL.
36                Vertex and Fragment shaders only have one entry point called "main". 
37                When a shader is compiled, microcode is generated but can not be accessed by
38                the application.
39                GLSL also does not provide assembler low level output after compiling.  The GL Render
40                system assumes that the Gpu program is a GL Gpu program so GLSLProgram will create a
41                GLSLGpuProgram that is subclassed from GLGpuProgram for the low level implementation.
42                The GLSLProgram class will create a shader object and compile the source but will
43                not create a program object.  It's up to GLSLGpuProgram class to request a program object
44                to link the shader object to.
45
46        @note
47                GLSL supports multiple modular shader objects that can be attached to one program
48                object to form a single shader.  This is supported through the "attach" material script
49                command.  All the modules to be attached are listed on the same line as the attach command
50                seperated by white space.
51       
52    */
53    class GLSLProgram : public HighLevelGpuProgram
54    {
55    public:
56        /// Command object for attaching another GLSL Program
57        class CmdAttach : public ParamCommand
58        {
59        public:
60            String doGet(const void* target) const;
61            void doSet(void* target, const String& shaderNames);
62        };
63
64        GLSLProgram(ResourceManager* creator,
65            const String& name, ResourceHandle handle,
66            const String& group, bool isManual, ManualResourceLoader* loader);
67                ~GLSLProgram();
68
69                const GLhandleARB getGLHandle() const { return mGLHandle; }
70                void attachToProgramObject( const GLhandleARB programObject );
71                String getAttachedShaderNames() const { return mAttachedShaderNames; }
72
73        /** Attach another GLSL Shader to this one. */
74        void attachChildShader(const String& name);
75        /// Overridden from GpuProgram
76        const String& getLanguage(void) const;
77
78        protected:
79        static CmdAttach msCmdAttach;
80
81        /** Internal load implementation, must be implemented by subclasses.
82        */
83        void loadFromSource(void);
84        /** Internal method for creating a dummy low-level program for this
85        high-level program.     GLSL does not give access to the low level implementation of the
86                shader so this method creates an object sub-classed from GLGpuProgram just to be
87                compatible with GLRenderSystem.
88                */
89                void createLowLevelImpl(void);
90        /// Internal unload implementation, must be implemented by subclasses
91        void unloadHighLevelImpl(void);
92        /// Populate the passed parameters with name->index map, must be overridden
93        void populateParameterNames(GpuProgramParametersSharedPtr params);
94                /// compile source into shader object
95                bool compile( const bool checkErrors = true);
96
97        private:
98                /// GL handle for shader object
99                GLhandleARB mGLHandle;
100                /// flag indicating if shader object successfully compiled
101                GLint mCompiled;
102                /// attached Shader names
103                String mAttachedShaderNames;
104                /// container of attached programs
105                typedef std::vector< GLSLProgram* > GLSLProgramContainer;
106                typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator;
107                GLSLProgramContainer mAttachedGLSLPrograms;
108
109    };
110}
111
112#endif // __GLSLProgram_H__
Note: See TracBrowser for help on using the repository browser.