/usr/include/OGRE/RenderSystems/GL/OgreGLSLProgram.h is in libogre-dev 1.7.4-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | /*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2011 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __GLSLProgram_H__
#define __GLSLProgram_H__
#include "OgreGLPrerequisites.h"
#include "OgreHighLevelGpuProgram.h"
namespace Ogre {
/** Specialisation of HighLevelGpuProgram to provide support for OpenGL
Shader Language (GLSL).
@remarks
GLSL has no target assembler or entry point specification like DirectX 9 HLSL.
Vertex and Fragment shaders only have one entry point called "main".
When a shader is compiled, microcode is generated but can not be accessed by
the application.
GLSL also does not provide assembler low level output after compiling. The GL Render
system assumes that the Gpu program is a GL Gpu program so GLSLProgram will create a
GLSLGpuProgram that is subclassed from GLGpuProgram for the low level implementation.
The GLSLProgram class will create a shader object and compile the source but will
not create a program object. It's up to GLSLGpuProgram class to request a program object
to link the shader object to.
@note
GLSL supports multiple modular shader objects that can be attached to one program
object to form a single shader. This is supported through the "attach" material script
command. All the modules to be attached are listed on the same line as the attach command
seperated by white space.
*/
class _OgreGLExport GLSLProgram : public HighLevelGpuProgram
{
public:
/// Command object for attaching another GLSL Program
class CmdAttach : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& shaderNames);
};
GLSLProgram(ResourceManager* creator,
const String& name, ResourceHandle handle,
const String& group, bool isManual, ManualResourceLoader* loader);
~GLSLProgram();
const GLhandleARB getGLHandle() const { return mGLHandle; }
void attachToProgramObject( const GLhandleARB programObject );
void detachFromProgramObject( const GLhandleARB programObject );
String getAttachedShaderNames() const { return mAttachedShaderNames; }
/// Overridden
bool getPassTransformStates(void) const;
bool getPassSurfaceAndLightStates(void) const;
/** Attach another GLSL Shader to this one. */
void attachChildShader(const String& name);
/** Sets the preprocessor defines use to compile the program. */
void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
/** Sets the preprocessor defines use to compile the program. */
const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
/// Overridden from GpuProgram
const String& getLanguage(void) const;
/** Returns the operation type that this geometry program expects to
receive as input
*/
virtual RenderOperation::OperationType getInputOperationType(void) const
{ return mInputOperationType; }
/** Returns the operation type that this geometry program will emit
*/
virtual RenderOperation::OperationType getOutputOperationType(void) const
{ return mOutputOperationType; }
/** Returns the maximum number of vertices that this geometry program can
output in a single run
*/
virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; }
/** Sets the operation type that this geometry program expects to receive
*/
virtual void setInputOperationType(RenderOperation::OperationType operationType)
{ mInputOperationType = operationType; }
/** Set the operation type that this geometry program will emit
*/
virtual void setOutputOperationType(RenderOperation::OperationType operationType)
{ mOutputOperationType = operationType; }
/** Set the maximum number of vertices that a single run of this geometry program
can emit.
*/
virtual void setMaxOutputVertices(int maxOutputVertices)
{ mMaxOutputVertices = maxOutputVertices; }
/// Command object for setting macro defines
class CmdPreprocessorDefines : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Command object for setting the input operation type (geometry shader only)
class _OgreGLExport CmdInputOperationType : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Command object for setting the output operation type (geometry shader only)
class _OgreGLExport CmdOutputOperationType : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
/// Command object for setting the maximum output vertices (geometry shader only)
class _OgreGLExport CmdMaxOutputVertices : public ParamCommand
{
public:
String doGet(const void* target) const;
void doSet(void* target, const String& val);
};
protected:
static CmdPreprocessorDefines msCmdPreprocessorDefines;
static CmdAttach msCmdAttach;
static CmdInputOperationType msInputOperationTypeCmd;
static CmdOutputOperationType msOutputOperationTypeCmd;
static CmdMaxOutputVertices msMaxOutputVerticesCmd;
/** Internal load implementation, must be implemented by subclasses.
*/
void loadFromSource(void);
/** Internal method for creating a dummy low-level program for this
high-level program. GLSL does not give access to the low level implementation of the
shader so this method creates an object sub-classed from GLGpuProgram just to be
compatible with GLRenderSystem.
*/
void createLowLevelImpl(void);
/// Internal unload implementation, must be implemented by subclasses
void unloadHighLevelImpl(void);
/// Overridden from HighLevelGpuProgram
void unloadImpl(void);
/// Populate the passed parameters with name->index map
void populateParameterNames(GpuProgramParametersSharedPtr params);
/// Populate the passed parameters with name->index map, must be overridden
void buildConstantDefinitions() const;
/// compile source into shader object
bool compile( const bool checkErrors = true);
private:
/// GL handle for shader object
GLhandleARB mGLHandle;
/// flag indicating if shader object successfully compiled
GLint mCompiled;
/// The input operation type for this (geometry) program
RenderOperation::OperationType mInputOperationType;
/// The output operation type for this (geometry) program
RenderOperation::OperationType mOutputOperationType;
/// The maximum amount of vertices that this (geometry) program can output
int mMaxOutputVertices;
/// attached Shader names
String mAttachedShaderNames;
/// Preprocessor options
String mPreprocessorDefines;
/// container of attached programs
typedef vector< GLSLProgram* >::type GLSLProgramContainer;
typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator;
GLSLProgramContainer mAttachedGLSLPrograms;
};
}
#endif // __GLSLProgram_H__
|