Kale
Loading...
Searching...
No Matches
Shader.hpp
Go to the documentation of this file.
1/*
2 Copyright 2022 Rishi Challa
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17#pragma once
18
19#ifdef KALE_OPENGL
20
21#include <Kale/Math/Math.hpp>
22
23namespace Kale::OpenGL {
24
28 class Shader {
29 private:
30
34 unsigned int program;
35
43 unsigned int createShader(unsigned int type, const char* filePath);
44
45 public:
46
53 Shader(const char* vertShaderFile, const char* fragShaderFile);
54
58 Shader(const Shader& other) = delete;
59
63 void operator=(const Shader& other) = delete;
64
68 ~Shader();
69
73 void useProgram() const;
74
80 int getAttributeLocation(const char* name) const;
81
87 int getUniformLocation(const char* name) const;
88
94 void uniform(unsigned int location, const Vector2f& value) const;
95
101 void uniform(unsigned int location, const Vector3f& value) const;
102
108 void uniform(unsigned int location, const Vector4f& value) const;
109
115 void uniform(unsigned int location, const Matrix2f& value) const;
116
122 void uniform(unsigned int location, const Matrix3f& value) const;
123
129 void uniform(unsigned int location, const Matrix4f& value) const;
130
136 void uniform(unsigned int location, const Transform& value) const;
137
143 void uniform(unsigned int location, float value) const;
144
150 void uniform(unsigned int location, int value) const;
151
157 void uniform(unsigned int location, const std::vector<Vector2f>& value) const;
158
164 void uniform(unsigned int location, const std::vector<Vector3f>& value) const;
165
171 void uniform(unsigned int location, const std::vector<Vector4f>& value) const;
172
178 void uniform(unsigned int location, const std::vector<Matrix2f>& value) const;
179
185 void uniform(unsigned int location, const std::vector<Matrix3f>& value) const;
186
192 void uniform(unsigned int location, const std::vector<Matrix4f>& value) const;
193
199 void uniform(unsigned int location, const std::vector<Transform>& value) const;
200
206 void uniform(unsigned int location, const std::vector<float>& value) const;
207
214 void uniform(unsigned int location, const Vector2f* ptr, size_t size) const;
215
222 void uniform(unsigned int location, const Vector3f* ptr, size_t size) const;
223
230 void uniform(unsigned int location, const Vector4f* ptr, size_t size) const;
231
238 void uniform(unsigned int location, const Matrix2f* ptr, size_t size) const;
239
246 void uniform(unsigned int location, const Matrix3f* ptr, size_t size) const;
247
254 void uniform(unsigned int location, const Matrix4f* ptr, size_t size) const;
255
262 void uniform(unsigned int location, const Transform* ptr, size_t size) const;
263
270 void uniform(unsigned int location, const float* ptr, size_t size) const;
271
272 };
273}
274
275#endif
Shader(const Shader &other)=delete
void uniform(unsigned int location, const Vector2f &value) const
Definition Shader.cpp:155
int getAttributeLocation(const char *name) const
Definition Shader.cpp:137
Shader(const char *vertShaderFile, const char *fragShaderFile)
Definition Shader.cpp:83
unsigned int program
Definition Shader.hpp:34
void operator=(const Shader &other)=delete
int getUniformLocation(const char *name) const
Definition Shader.cpp:146
void useProgram() const
Definition Shader.cpp:128
unsigned int createShader(unsigned int type, const char *filePath)
Definition Shader.cpp:39