JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
ShaderProgram.hpp
Go to the documentation of this file.
1// Copyright 2018-2020 Jan Niklas Hasse <jhasse@bixense.com>
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
12namespace jngl {
13
14class Shader;
15
18public:
19 ShaderProgram(const Shader& vertex, const Shader& fragment);
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
38 static void setUniform(int location, int v0);
39 static void setUniform(int location, float v0, float v1);
40 static void setUniform(int location, float v0, float v1, float v2, float v3);
41
42 private:
43 static int referenceCount;
44 static const Impl* activeImpl;
45 };
46
47#if __cplusplus >= 201703L
48 [[nodiscard]]
49#endif
51 use() const;
52
53 [[nodiscard]] int getAttribLocation(const std::string& name) const;
55 [[nodiscard]] int getUniformLocation(const std::string& name) const;
56
57private:
59};
60
61void setUniform(int location, float v0, float v1);
62
63} // namespace jngl
Contains jngl::Finally class.
Linked vertex and fragment shaders.
int getUniformLocation(const std::string &name) const
Fragment or vertex GLSL shader.
Definition: Shader.hpp:12
JNGL's main namespace.
Definition: Achievement.hpp:10
Lifetime object when the ShaderProgram is in use.
static void setUniform(int location, int v0)
Sets the Context's associated ShaderProgram's uniform.