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-2026 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 "
Rgb.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
&&)
noexcept
;
23
ShaderProgram
& operator=(
const
ShaderProgram
&) =
delete
;
24
ShaderProgram
& operator=(
ShaderProgram
&&)
noexcept
;
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
43
static
void
setUniform
(
int
location,
Rgb
);
44
45
private
:
46
static
int
referenceCount;
47
static
const
Impl* activeImpl;
48
};
49
50
#if __cplusplus >= 201703L
51
[[nodiscard]]
52
#endif
53
Context
54
use()
const
;
55
56
[[nodiscard]]
int
getAttribLocation(
const
std::string
& name)
const
;
57
69
[[nodiscard]]
int
getUniformLocation
(
const
std::string
& name)
const
;
70
71
private
:
72
std::unique_ptr<Impl>
impl;
73
};
74
75
void
setUniform(
int
location,
float
v0,
float
v1);
76
77
}
// namespace jngl
Rgb.hpp
Contains jngl::Rgb class.
std::string
jngl::Rgb
Object representing a RGB color, new version of jngl::Color (which will be deprecated in the future)
Definition
Rgb.hpp:21
jngl::ShaderProgram
Linked vertex and fragment shaders.
Definition
ShaderProgram.hpp:17
jngl::ShaderProgram::getUniformLocation
int getUniformLocation(const std::string &name) const
Returns the location of a uniform variable for use with Context::setUniform.
jngl::Shader
Fragment or vertex GLSL shader.
Definition
Shader.hpp:13
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, Rgb)
sets a vec3 to the color of the Rgb object
jngl::ShaderProgram::Context::setUniform
static void setUniform(int location, int v0)
Sets the Context's associated ShaderProgram's uniform.
std::unique_ptr