JNGL
ShaderProgram.hpp
Go to the documentation of this file.
1 // Copyright 2018-2020 Jan Niklas Hasse <[email protected]>
2 // For conditions of distribution and use, see copyright notice in LICENSE.txt
5 #pragma once
6 
7 #include "Finally.hpp"
8 
9 #include <memory>
10 #include <string>
11 
12 namespace jngl {
13 
14 class Shader;
15 
18 public:
19  ShaderProgram(const Shader& vertex, const Shader& fragment);
20  ~ShaderProgram();
21  ShaderProgram(const ShaderProgram&) = delete;
22  ShaderProgram(ShaderProgram&&) = delete;
23  ShaderProgram& operator=(const ShaderProgram&) = delete;
24  ShaderProgram& operator=(ShaderProgram&&) = delete;
25 
26  struct Impl;
28  struct Context {
29  explicit Context(const Impl&);
30  ~Context();
31  Context(const Context&) = delete;
32  Context& operator=(const Context&) = delete;
33  Context(Context&&) noexcept;
34  Context& operator=(Context&&) = delete;
35 
36  static void setUniform(int location, float v0, float v1);
37  static void setUniform(int location, float v0, float v1, float v2, float v3);
38 
39  private:
40  static int referenceCount;
41  static const Impl* activeImpl;
42  };
43 
44 #if __cplusplus >= 201703L
45  [[nodiscard]]
46 #endif
47  Context
48  use() const;
49 
50  [[nodiscard]] int getAttribLocation(const std::string& name) const;
51  [[nodiscard]] int getUniformLocation(const std::string& name) const;
52 
53 private:
55 };
56 
57 void setUniform(int location, float v0, float v1);
58 
59 } // namespace jngl
std::string
Finally.hpp
jngl::Shader
Fragment or vertex GLSL shader.
Definition: Shader.hpp:12
jngl
JNGL's main namespace.
Definition: App.hpp:9
jngl::ShaderProgram::Context
Lifetime object when the ShaderProgram is in use.
Definition: ShaderProgram.hpp:28
memory
std::unique_ptr< Impl >
jngl::ShaderProgram
Linked vertex and fragment shaders.
Definition: ShaderProgram.hpp:17
string