ShaderDataFile.h
Go to the documentation of this file.
1 #ifndef B_SHADER_DATA_FILE_H
2 #define B_SHADER_DATA_FILE_H
3 
4 #include "IShaderData.h"
5 
9 class ShaderDataFile : public IShaderData
10 {
11 public:
12 
13  /* Functions */
14 
26  ShaderDataFile(const std::string &shaderFileName, const std::string &shaderVersionDesktop, const std::string &shaderVersionES, GLuint maxLights, bool variableNumberOfLights, bool ambientLighting, bool diffuseLighting, bool specularLighting, bool cubicReflectionMap);
27 
40  ShaderDataFile(const std::string &vertShaderFileName, const std::string &fragShaderFileName, const std::string &shaderVersionDesktop, const std::string &shaderVersionES, GLuint maxLights, bool variableNumberOfLights, bool ambientLighting, bool diffuseLighting, bool specularLighting, bool cubicReflectionMap);
41 
44  virtual ~ShaderDataFile() {}
45 
49  ShaderDataFile &load(const std::string &shaderFileName);
50 
55  ShaderDataFile &load(const std::string &vertShaderFileName, const std::string &fragShaderFileName);
56 
59  std::string getVertShaderSrc() const { return _vertShaderSrc; }
60 
63  std::string getFragShaderSrc() const { return _fragShaderSrc; }
64 
67  GLuint getMaxLights() const { return _maxLights; }
68 
71  bool supportsVariableNumberOfLights() const { return _variableNumberOfLights; }
72 
75  bool supportsAmbientLighting() const { return _ambientLighting; }
76 
79  bool supportsDiffuseLighting() const { return _diffuseLighting; }
80 
83  bool supportsSpecularLighting() const { return _specularLighting; }
84 
87  bool supportsCubicReflectionMap() const { return _cubicReflectionMap; }
88 
91  bool isValid() const { return _valid; }
92 
93 private:
94 
95  /* Functions */
96 
97  std::string loadSrc(const std::string &fileName);
98 
99  void replaceMacro(const std::string &macro, const std::string &value);
100 
101  /* Variables */
102 
103  std::string _vertShaderSrc;
104  std::string _fragShaderSrc;
105  std::string _shaderVersionDesktop;
106  std::string _shaderVersionES;
107  GLuint _maxLights;
108  bool _variableNumberOfLights;
109  bool _ambientLighting;
110  bool _diffuseLighting;
111  bool _specularLighting;
112  bool _cubicReflectionMap;
113  bool _valid;
114 
115 };
116 
117 #endif /* defined(B_SHADER_DATA_FILE_H) */
ShaderDataFile & load(const std::string &shaderFileName)
Loads shader from file.
Definition: ShaderDataFile.cpp:22
bool supportsCubicReflectionMap() const
Returns true if the shader supports a cubic reflection map.
Definition: ShaderDataFile.h:87
An interface for the underlying data of a shader.
Definition: IShaderData.h:10
std::string getFragShaderSrc() const
Gets the source code of the fragment shader as a string.
Definition: ShaderDataFile.h:63
GLuint getMaxLights() const
Get the maximum number of lights.
Definition: ShaderDataFile.h:67
bool supportsAmbientLighting() const
Returns true if the shader supports ambient lighting.
Definition: ShaderDataFile.h:75
bool supportsDiffuseLighting() const
Returns true if the shader supports diffuse lighting.
Definition: ShaderDataFile.h:79
bool supportsVariableNumberOfLights() const
Returns true if the number of lights is variable in the shader.
Definition: ShaderDataFile.h:71
bool isValid() const
Returns true if the shader is valid.
Definition: ShaderDataFile.h:91
std::string getVertShaderSrc() const
Gets the source code of the vertex shader as a string.
Definition: ShaderDataFile.h:59
bool supportsSpecularLighting() const
Returns true if the shader supports specular lighting.
Definition: ShaderDataFile.h:83
virtual ~ShaderDataFile()
Virtual destructor.
Definition: ShaderDataFile.h:44
ShaderDataFile(const std::string &shaderFileName, const std::string &shaderVersionDesktop, const std::string &shaderVersionES, GLuint maxLights, bool variableNumberOfLights, bool ambientLighting, bool diffuseLighting, bool specularLighting, bool cubicReflectionMap)
Constructor.
Definition: ShaderDataFile.cpp:10
The underlying data of a shader is loaded from shader files.
Definition: ShaderDataFile.h:9