SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLGLProgramManager.h
Go to the documentation of this file.
1 /**
2  * \file SLGLProgramManager.h
3  * \date March 2020
4  * \authors Michael Goettlicher, Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #ifndef SLGLPROGRAM_MANAGER_H
11 #define SLGLPROGRAM_MANAGER_H
12 
13 #include <string>
14 #include <map>
15 
16 using std::string;
17 
18 class SLGLProgram;
19 class SLGLProgramGeneric;
20 
21 //-----------------------------------------------------------------------------
22 //! Enumeration for standard shader programs
24 {
33 };
34 
35 //-----------------------------------------------------------------------------
36 //! Static container for standard shader programs
37 /*!
38  * Static container for standard shader programs that are not deleted after
39  * scene deallocation. The shader program allocation and compilation will be
40  * done at the first use. ONLY shader programs that are scene independent
41  * should be stored here. Shader programs that depend e.g. on the number of
42  * lights must be created at scene loading time and deallocation at scene
43  * destruction.
44  */
46 {
47 public:
48  //! Init by providing path to standard shader files
49  static void init(string shaderPath, string configPath);
50 
51  //! Get program reference for given id
52  static SLGLProgramGeneric* get(SLStdShaderProg id) { return _programs[id]; }
53 
54  //! Instantiate and load all programs
55  static void loadPrograms();
56 
57  //! Delete all instantiated programs
58  static void deletePrograms();
59 
60  //! Returns the size of the program map
61  static size_t size() { return _programs.size(); }
62 
63  //! Contains the global shader path
64  static string shaderPath;
65 
66  //! Contains the global writable configuration path
67  static string configPath;
68 
69 private:
70  //! Make a new program and insert it into _programs
72  string vertShaderFilename,
73  string fragShaderFilename);
74 
75  //! Instantiated programs
76  static std::map<SLStdShaderProg, SLGLProgramGeneric*> _programs;
77 };
78 //-----------------------------------------------------------------------------
79 
80 #endif
SLStdShaderProg
Enumeration for standard shader programs.
@ SP_colorUniform
@ SP_colorUniformPoint
@ SP_colorAttribute
@ SP_textureOnly
@ SP_errorTex
@ SP_fontTex
@ SP_textureOnlyExternal
@ SP_depth
Generic Shader Program class inherited from SLGLProgram.
Encapsulation of an OpenGL shader program object.
Definition: SLGLProgram.h:56
Static container for standard shader programs.
static string configPath
Contains the global writable configuration path.
static void init(string shaderPath, string configPath)
Init by providing path to standard shader files.
static string shaderPath
Contains the global shader path.
static SLGLProgramGeneric * loadProgram(SLStdShaderProg id, string vertShaderFilename, string fragShaderFilename)
Make a new program and insert it into _programs.
static size_t size()
Returns the size of the program map.
static std::map< SLStdShaderProg, SLGLProgramGeneric * > _programs
Instantiated programs.
static void deletePrograms()
Delete all instantiated programs.
static void loadPrograms()
Instantiate and load all programs.
static SLGLProgramGeneric * get(SLStdShaderProg id)
Get program reference for given id.