GlobeEngine
ShaderProgram.h
Go to the documentation of this file.
1 
9 #ifndef GlobeEngine_ShaderProgram_h
10 #define GlobeEngine_ShaderProgram_h
11 
12 #include "OpenGL_Includes.h"
13 #include "ShaderParser.h"
14 #include <vmmlib/vmmlib.hpp>
15 #include <fstream>
16 #include <iostream>
17 #include <string>
18 #include <memory>
19 #include <vector>
20 
21 namespace ge {
22 
24  {
25  public:
28 
29  public:
30  ShaderProgram();
32  ShaderProgram(const std::shared_ptr<ShaderProgram> copy) {
33  this->pathToFile = copy->pathToFile;
34  this->objectID = copy->objectID;
35  this->programtype = copy->programtype;
36  this->attributes = copy->attributes;
37  this->sourceParts = copy->sourceParts;
38  }
39 
40  void clear();
41  void create(std::string _inputPath, ProgramType _type);
42  void createFromSource(std::string _source, ProgramType _type);
43 
44  int addSourcePart(std::string _fileName);
45  void insertSourcePart(std::string _fileName, int _atIdx);
46  void removeSourcePart(int _idx);
47  void reload(ShaderProgram::ReloadType _reloadtype);
48  const std::vector<std::string>& getSourceParts() const;
49  std::string getSource() const;
50 
51  void setProgramType(ProgramType _type);
52  bool compileShader();
53  void parse(std::string _repoUrl);
54 
55  GLuint getShaderObject();
56 
57  void printShaderInfoLog(GLuint obj, std::string _input);
58  bool getCompileResult(std::string _input);
59 
60  bool isInAttribute(std::string _in) const;
61  bool isOutAttribute(std::string _in) const;
62  bool isDefineAttribute(std::string _in) const;
63  void setDefineAttribute(std::string _in, int _value);
64  int getDefineValue(std::string _in) const;
65  void setDefinesToZero();
66  std::string getPathToFile() const;
67  const std::shared_ptr<ge::ShaderAttributes>& getAttributes() const;
68 
69  private:
70  void clearSources();
71  void createShaderObject();
72  std::string getCombinedSources() const;
73  std::string getStringForType(ProgramType _type);
74  std::string getExtensionForType(ProgramType _type);
75 
76  /* vectors to attributes */
77  std::shared_ptr<ge::ShaderAttributes> attributes;
78 
79  /* contains the current source code of this shaderprogram */
80  std::vector<std::string> sourceParts;
81  /* contains the phat to the originally loaded
82  source codefile of this shaderprogram */
83  std::string pathToFile;
84  /* the ID of this shaderprogram given by OpenGL */
85  GLuint objectID;
86  /* The type of this shaderprograms */
87  ProgramType programtype;
88  };
89 
90 
91 }
92 #endif
Definition: ShaderProgram.h:23
~ShaderProgram()
Definition: ShaderProgram.cpp:18
std::string getPathToFile() const
Definition: ShaderProgram.cpp:317
ProgramType
Definition: ShaderProgram.h:26
std::string getSource() const
Definition: ShaderProgram.cpp:179
Definition: ShaderProgram.h:26
bool compileShader()
Definition: ShaderProgram.cpp:127
void insertSourcePart(std::string _fileName, int _atIdx)
int getDefineValue(std::string _in) const
Definition: ShaderProgram.cpp:301
Definition: ShaderProgram.h:27
Definition: ShaderProgram.h:26
Definition: ShaderProgram.h:26
void removeSourcePart(int _idx)
Definition: ShaderProgram.cpp:169
ShaderProgram(const std::shared_ptr< ShaderProgram > copy)
Definition: ShaderProgram.h:32
void create(std::string _inputPath, ProgramType _type)
Definition: ShaderProgram.cpp:41
GLuint getShaderObject()
Definition: ShaderProgram.cpp:187
void setDefineAttribute(std::string _in, int _value)
Definition: ShaderProgram.cpp:291
bool isOutAttribute(std::string _in) const
Definition: ShaderProgram.cpp:267
Definition: ShaderProgram.h:27
const std::shared_ptr< ge::ShaderAttributes > & getAttributes() const
Definition: ShaderProgram.cpp:251
Definition: ShaderProgram.h:26
const std::vector< std::string > & getSourceParts() const
Definition: ShaderProgram.cpp:175
ShaderProgram()
Definition: ShaderProgram.cpp:13
void setProgramType(ProgramType _type)
Definition: ShaderProgram.cpp:183
void reload(ShaderProgram::ReloadType _reloadtype)
Definition: ShaderProgram.cpp:58
Definition: ShaderProgram.h:26
Definition: ShaderProgram.h:27
void parse(std::string _repoUrl)
Definition: ShaderProgram.cpp:116
ReloadType
Definition: ShaderProgram.h:27
Definition: AvalancheTrainingSimulationEngine.h:28
bool isDefineAttribute(std::string _in) const
Definition: ShaderProgram.cpp:279
void createFromSource(std::string _source, ProgramType _type)
Definition: ShaderProgram.cpp:50
int addSourcePart(std::string _fileName)
Definition: ShaderProgram.cpp:164
bool isInAttribute(std::string _in) const
Definition: ShaderProgram.cpp:255
Definition: ShaderProgram.h:26
void clear()
Definition: ShaderProgram.cpp:28
bool getCompileResult(std::string _input)
Definition: ShaderProgram.cpp:150
void printShaderInfoLog(GLuint obj, std::string _input)
Definition: ShaderProgram.cpp:223
void setDefinesToZero()
Definition: ShaderProgram.cpp:311
Definition: ShaderProgram.h:26