JNGL
Easy to use cross-platform 2D game library
Loading...
Searching...
No Matches
jngl
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
12
namespace
jngl
{
13
14
class
Shader;
15
17
class
ShaderProgram
{
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
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
50
Context
51
use()
const
;
52
53
[[nodiscard]]
int
getAttribLocation(
const
std::string
& name)
const
;
55
[[nodiscard]]
int
getUniformLocation
(
const
std::string
& name)
const
;
56
57
private
:
58
std::unique_ptr<Impl>
impl;
59
};
60
61
void
setUniform(
int
location,
float
v0,
float
v1);
62
63
}
// namespace jngl
Finally.hpp
Contains jngl::Finally class.
std::string
jngl::ShaderProgram
Linked vertex and fragment shaders.
Definition
ShaderProgram.hpp:17
jngl::ShaderProgram::getUniformLocation
int getUniformLocation(const std::string &name) const
jngl::Shader
Fragment or vertex GLSL shader.
Definition
Shader.hpp:12
std::function
memory
jngl
JNGL's main namespace.
Definition
Achievement.hpp:10
string
jngl::ShaderProgram::Context
Lifetime object when the ShaderProgram is in use.
Definition
ShaderProgram.hpp:28
jngl::ShaderProgram::Context::setUniform
static void setUniform(int location, int v0)
Sets the Context's associated ShaderProgram's uniform.