galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Sampler.cpp
Go to the documentation of this file.
1
7
8#include <glad/glad.h>
9
10#include "Sampler.hpp"
11
12namespace galaxy
13{
15 : m_id {0}
16 {
17 glCreateSamplers(1, &m_id);
18 }
19
21 {
22 if (this->m_id != 0)
23 {
24 glDeleteSamplers(1, &m_id);
25 }
26
27 this->m_id = s.m_id;
28 s.m_id = 0;
29 }
30
32 {
33 if (this != &s)
34 {
35 if (this->m_id != 0)
36 {
37 glDeleteSamplers(1, &m_id);
38 }
39
40 this->m_id = s.m_id;
41 s.m_id = 0;
42 }
43
44 return *this;
45 }
46
48 {
49 glDeleteSamplers(1, &m_id);
50 }
51
52 void Sampler::set(const unsigned int param, const int value) const
53 {
54 glSamplerParameteri(m_id, param, value);
55 }
56
57 void Sampler::setf(const unsigned int param, const float value) const
58 {
59 glSamplerParameterf(m_id, param, value);
60 }
61
62 void Sampler::bind(const unsigned int texture_unit) const
63 {
64 glBindSampler(texture_unit, m_id);
65 }
66
67 void Sampler::unbind(const unsigned int texture_unit) const
68 {
69 glBindSampler(texture_unit, 0);
70 }
71
72 unsigned int Sampler::id() const noexcept
73 {
74 return m_id;
75 }
76} // namespace galaxy
Texture sampler definitions.
Definition Sampler.hpp:17
void set(const unsigned int param, const int value) const
Set a sampler field.
Definition Sampler.cpp:52
Sampler & operator=(Sampler &&) noexcept
Move assignment operator.
Definition Sampler.cpp:31
unsigned int id() const noexcept
Get program id.
Definition Sampler.cpp:72
void bind(const unsigned int texture_unit) const
Bind sampler.
Definition Sampler.cpp:62
void setf(const unsigned int param, const float value) const
Set a float sampler field.
Definition Sampler.cpp:57
void unbind(const unsigned int texture_unit) const
Unbind sampler.
Definition Sampler.cpp:67
Sampler() noexcept
Constructor.
Definition Sampler.cpp:14
~Sampler() noexcept
Destructor.
Definition Sampler.cpp:47
unsigned int m_id
OpenGL handle.
Definition Sampler.hpp:96
Animated.cpp galaxy.
Definition Animated.cpp:16