Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Shader.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2016 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #ifndef OMNI_VISUAL_SHADER_H_
20 #define OMNI_VISUAL_SHADER_H_
21 
22 #include <functional>
23 #include <memory>
24 #include <set>
27 
28 namespace omni {
29  namespace visual {
30  /// Use shader with and do uniform assignment and drawing inside functor
31  void useShader(QOpenGLShaderProgram& _s, std::function<void(UniformHandler&)> f);
32 
33  /// Initialize shader: load from file and compile.
34  void initShader(QOpenGLShaderProgram& _s, const char* _filename);
35 
36  /// Initialize shader: load from file and compile.
37  void initShader(std::unique_ptr<QOpenGLShaderProgram>& _s, const char* _filename);
38 
39  /// Initialize shader: load from file and compile.
40  void initShader(ContextBoundPtr<QOpenGLShaderProgram>& _s, const char* _filename);
41 
42  /**@brief Adds #include functionality to shader source code
43  @detail Compiles source code file with included files or
44  compiles a shader
45  **/
47  public:
48 
49  static QString compile(QString const& _sourceFile);
50 
51  private:
52 
53  static QString compileRecursive(QString const& _sourceFile, std::set<QString>& _includedFiles);
54 
55  /// Parses filename from the #include macro
56  static QString parseIncludeLine(QString const& _baseDir, QString const& _line);
57  };
58 
59  }
60 }
61 
62 #endif /* OMNI_VISUAL_SHADER_H_ */
void initShader(QOpenGLShaderProgram &_s, const char *_filename)
Initialize shader: load from file and compile.
Definition: Shader.cpp:27
static QString compileRecursive(QString const &_sourceFile, std::set< QString > &_includedFiles)
Definition: Shader.cpp:80
static QString compile(QString const &_sourceFile)
Definition: Shader.cpp:75
void useShader(QOpenGLShaderProgram &_s, std::function< void(UniformHandler &)>f)
Use shader with and do uniform assignment and drawing inside functor.
Definition: Shader.cpp:59
static QString parseIncludeLine(QString const &_baseDir, QString const &_line)
Parses filename from the #include macro.
Definition: Shader.cpp:107
Adds #include functionality to shader source code Compiles source code file with included files or c...
Definition: Shader.h:46