YourGameLib
Loading...
Searching...
No Matches
shader.h
Go to the documentation of this file.
1/*
2Copyright (c) 2019-2024 Alexander Scholz
3
4This software is provided 'as-is', without any express or implied
5warranty. In no event will the authors be held liable for any damages
6arising from the use of this software.
7
8Permission is granted to anyone to use this software for any purpose,
9including commercial applications, and to alter it and redistribute it
10freely, subject to the following restrictions:
11
121. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
162. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
183. This notice may not be removed or altered from any source distribution.
19*/
20#ifndef YOURGAME_GLSHADER_H
21#define YOURGAME_GLSHADER_H
22
23#include <string>
24#include <vector>
25#include <map>
26#include "yourgame/gl_include.h"
29
30namespace yourgame
31{
32 namespace gl
33 {
34 class Shader
35 {
36 public:
37 static Shader *make(const std::vector<std::pair<GLenum, std::string>> &shaderCodes,
38 const std::vector<std::pair<GLuint, std::string>> &attrLocs,
39 const std::vector<std::pair<GLuint, std::string>> &fragDataLocs,
40 std::string &errorLog);
41 ~Shader();
42 void useProgram(Lightsource *lightsource = nullptr, yourgame::math::Camera *camera = nullptr);
43 GLint getUniformLocation(const GLchar *name);
44
45 /* deleting the copy constructor and the copy assignment operator
46 prevents copying (and moving) of the object. */
47 Shader(Shader const &) = delete;
48 Shader &operator=(Shader const &) = delete;
49
50 private:
51 Shader() {}
52 GLuint m_programHandle;
53 std::map<std::string, GLint> m_uniformLocations;
54 };
55 } // namespace gl
56} // namespace yourgame
57
58#endif
Definition lightsource.h:30
Definition shader.h:35
GLint getUniformLocation(const GLchar *name)
Definition shader.cpp:216
Shader(Shader const &)=delete
Shader & operator=(Shader const &)=delete
void useProgram(Lightsource *lightsource=nullptr, yourgame::math::Camera *camera=nullptr)
Definition shader.cpp:168
static Shader * make(const std::vector< std::pair< GLenum, std::string > > &shaderCodes, const std::vector< std::pair< GLuint, std::string > > &attrLocs, const std::vector< std::pair< GLuint, std::string > > &fragDataLocs, std::string &errorLog)
Definition shader.cpp:52
~Shader()
Definition shader.cpp:163
Definition camera.h:34
Definition audio.h:27