Pioneer
Program.h
Go to the documentation of this file.
1 // Copyright © 2008-2023 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #pragma once
5 
6 #include "OpenGLLibs.h"
7 
8 #include <string>
9 #include <vector>
10 
11 namespace Graphics {
12 
13  namespace OGL {
14 
16  struct ProgramException {};
17 
18  struct ProgramDef;
19  class Shader;
20 
21  /*
22  * A Program is a specific, immutable variant of a shader that maps closely to
23  * the underlying API's terminology (Program, GraphicsPipeline, etc.)
24  */
25  class Program {
26  public:
27  Program(Shader *shader, const ProgramDef &def);
28  ~Program();
29 
30  void Reload(Shader *shader, const ProgramDef &def);
31  bool Loaded() const { return success; }
32 
33  GLuint GetConstantLocation(uint32_t index) const { return m_constants[index]; }
34  GLuint GetProgramID() const { return m_program; }
35 
36  protected:
37  GLuint LoadShaders(const ProgramDef &def);
38  void InitUniforms(Shader *shader);
39 
40  GLuint m_program;
41  bool success;
42 
43  // map of push constant bindings to glUniform locations
44  std::vector<GLuint> m_constants;
45  };
46 
47  } // namespace OGL
48 
49 } // namespace Graphics
Definition: Program.h:25
GLuint GetConstantLocation(uint32_t index) const
Definition: Program.h:33
void Reload(Shader *shader, const ProgramDef &def)
Definition: Program.cpp:227
GLuint GetProgramID() const
Definition: Program.h:34
void InitUniforms(Shader *shader)
Definition: Program.cpp:286
std::vector< GLuint > m_constants
Definition: Program.h:44
GLuint LoadShaders(const ProgramDef &def)
Definition: Program.cpp:238
bool Loaded() const
Definition: Program.h:31
bool success
Definition: Program.h:41
~Program()
Definition: Program.cpp:221
GLuint m_program
Definition: Program.h:40
Program(Shader *shader, const ProgramDef &def)
Definition: Program.cpp:212
Definition: Shader.h:67
Definition: Background.h:14
Definition: Shader.h:50
Definition: Program.h:16