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-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 
29 #ifndef __GLGpuProgram_H__
30 #define __GLGpuProgram_H__
31 
32 #include "OgreGLPrerequisites.h"
33 #include "OgreGpuProgram.h"
34 #include "OgreHardwareVertexBuffer.h"
35 
36 namespace Ogre {
37 
38     /** Generalised low-level GL program, can be applied to multiple types (eg ARB and NV) */
39     class _OgreGLExport GLGpuProgram : public GpuProgram
40     {
41     public:
42         GLGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
43             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
44         virtual ~GLGpuProgram();
45 
46         /// Execute the binding functions for this program
bindProgram(void)47         virtual void bindProgram(void) {}
48         /// Execute the binding functions for this program
unbindProgram(void)49         virtual void unbindProgram(void) {}
50 
51         /// Execute the param binding functions for this program
bindProgramParameters(GpuProgramParametersSharedPtr params,uint16 mask)52         virtual void bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask) {}
53         /// Bind just the pass iteration parameters
bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params)54         virtual void bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params) {}
55 
56         /// @copydoc Resource::calculateSize
57         virtual size_t calculateSize(void) const;
58 
59         /** Test whether attribute index for a given semantic is valid.
60         */
61         virtual bool isAttributeValid(VertexElementSemantic semantic, uint index);
62 
63     protected:
64         /** Overridden from GpuProgram, do nothing */
loadFromSource(void)65         void loadFromSource(void) {}
66         /// @copydoc Resource::unloadImpl
unloadImpl(void)67         void unloadImpl(void) {}
68 
69         GLuint mProgramID;
70     };
71 
72     /** Specialisation of the GL low-level program for ARB programs. */
73     class _OgreGLExport GLArbGpuProgram : public GLGpuProgram
74     {
75     public:
76         GLArbGpuProgram(ResourceManager* creator, const String& name, ResourceHandle handle,
77             const String& group, bool isManual = false, ManualResourceLoader* loader = 0);
78         virtual ~GLArbGpuProgram();
79 
80         /// Execute the binding functions for this program
81         void bindProgram(void);
82         /// Execute the unbinding functions for this program
83         void unbindProgram(void);
84         /// Execute the param binding functions for this program
85         void bindProgramParameters(GpuProgramParametersSharedPtr params, uint16 mask);
86         /// Bind just the pass iteration parameters
87         void bindProgramPassIterationParameters(GpuProgramParametersSharedPtr params);
88 
89         /// Get the GL type for the program
90         GLenum getProgramType(void) const;
91 
92     protected:
93         void loadFromSource(void);
94         /// @copydoc Resource::unloadImpl
95         void unloadImpl(void);
96 
97     };
98 
99 
100 
101 } // namespace Ogre
102 
103 #endif // __GLGpuProgram_H__
104