PGR Copakond OpenGL Engine - Bowling
Loading...
Searching...
No Matches
shader.h
Go to the documentation of this file.
1#ifndef PGR_SEM_COPAKOND_SHADER_H
2#define PGR_SEM_COPAKOND_SHADER_H
3
4#define WORLD_AMBIENT glm::vec3(0.25f, 0.25f, 0.25f)
5
6#include "../pgr-portable.h"
7#include "../meshes/mesh.h"
9#include "../light/light.h"
10
11namespace copakond {
13 class Shader {
14 private:
15 float _totalTime = 0.0f;
16 protected:
17 GLuint _shaderProgram = 0;
18
19 GLuint _worldAmbientUID = 0;
20
21 GLint _modelUID = 0; // model matrix uniform index;
22 GLint _viewUID = 0; // view matrix uniform index;
23 GLint _projectionUID = 0; // projection matrix uniform index;
24 GLint _pvmUID = 0; // PVM matrix uniform index;
25 GLint _camPos = 0; // position of camera eye position uniform index;
26 GLint _normalMatrix = 0; // correct matrix for non-rigid transform uniform index;
27
28 GLint _fogEnabled = 0;
29 GLint _fogStart = 0;
30 GLint _fogEnd = 0;
31 GLint _fogColor = 0;
32
33 GLint _ambient = 0;
34 GLint _diffuse = 0;
35 GLint _specular = 0;
36 GLint _shininess = 0;
37 GLint _alpha = 0;
38
39 GLuint _diffuseMapUID = 0;
40 GLuint _specularMapUID = 0;
41 GLuint _shininessMapUID = 0;
42 GLuint _alphaMapUID = 0;
43 GLuint _normalMapUID = 0;
44
48 GLuint _useAlphaMapUID = 0;
49 GLuint _useNormalMapUID = 0;
50
51 GLuint _isTextLabelUID = 0;
52 GLuint _isVertexWaveUID = 0;
53 GLuint _timeUID = 0;
54
55 GLint _numLights = 0; // uniform id
56 size_t totalNumLights = 0; // actual counter
57
58 glm::mat4 _viewM; // camera view matrix
59 glm::mat4 _projectionM; // perspective projection matrix
60 glm::vec3 _position;
61
62 public:
63 Shader();
64
65 static glm::vec3 getWorldAmbient() { return WORLD_AMBIENT; }
66
68 void applyMaterialUniforms(std::shared_ptr<Material> mat);
69 void setLight(Light *light, int lightIndex);
70 void updateLight(Light* light);
71
76 GLuint init(std::string vertShaderLocation, std::string fragShaderLocation);
77
79 void update(Camera &camera, int winWidth, int winHeight, float deltaTime);
80
86 void draw(Mesh &mesh, bool drawTransparent, float deltaTime);
87 };
88}
89
90
91#endif //PGR_SEM_COPAKOND_SHADER_H
Camera for generating view and projection matrices.
Definition camera.h:20
Base class for scene lighting calculations.
Definition light.h:23
Base drawable 3D object containing geometry and material data.
Definition mesh.h:19
GLuint _useSpecularMapUID
Definition shader.h:46
GLuint _normalMapUID
Definition shader.h:43
GLint _fogStart
Definition shader.h:29
GLuint _diffuseMapUID
Definition shader.h:39
glm::mat4 _viewM
Definition shader.h:58
GLint _fogEnabled
Definition shader.h:28
GLint _fogEnd
Definition shader.h:30
void setLight(Light *light, int lightIndex)
Definition shader.cpp:64
GLuint _useNormalMapUID
Definition shader.h:49
glm::vec3 _position
Definition shader.h:60
GLint _numLights
Definition shader.h:55
static glm::vec3 getWorldAmbient()
Definition shader.h:65
GLuint _isTextLabelUID
Definition shader.h:51
GLint _alpha
Definition shader.h:37
void applyMaterialUniforms(std::shared_ptr< Material > mat)
Binds material properties and active textures to the shader pipeline.
Definition shader.cpp:126
GLuint _isVertexWaveUID
Definition shader.h:52
size_t totalNumLights
Definition shader.h:56
GLint _viewUID
Definition shader.h:22
GLint _specular
Definition shader.h:35
glm::mat4 _projectionM
Definition shader.h:59
GLuint _shininessMapUID
Definition shader.h:41
GLint _shininess
Definition shader.h:36
GLuint _specularMapUID
Definition shader.h:40
GLuint _useShininessMapUID
Definition shader.h:47
GLint _normalMatrix
Definition shader.h:26
void update(Camera &camera, int winWidth, int winHeight, float deltaTime)
Updates global shader uniforms (Camera, Fog, Time).
Definition shader.cpp:103
GLuint _useDiffuseMapUID
Definition shader.h:45
GLint _camPos
Definition shader.h:25
GLint _modelUID
Definition shader.h:21
GLuint _worldAmbientUID
Definition shader.h:19
GLuint _shaderProgram
Definition shader.h:17
GLint _pvmUID
Definition shader.h:24
GLint _projectionUID
Definition shader.h:23
GLuint _timeUID
Definition shader.h:53
GLint _fogColor
Definition shader.h:31
void updateLight(Light *light)
Definition shader.cpp:86
Shader()
Definition shader.cpp:7
GLint _ambient
Definition shader.h:33
GLuint _useAlphaMapUID
Definition shader.h:48
GLuint _alphaMapUID
Definition shader.h:42
GLint _diffuse
Definition shader.h:34
PGR Semestral work with sample scenes and bowling. doxygen was generated with a help of LLM.
Definition bezier.cpp:3
int winHeight
Definition main.cpp:35
int winWidth
Definition main.cpp:34
void init()
Initializes OpenGL context, scene data, and sets up GLUT callbacks.
Definition main.cpp:42
void draw()
Main render loop. Handles updates, physics, and rendering of all scene elements.
Definition main.cpp:97
#define WORLD_AMBIENT
Definition shader.h:4