-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShader.h
97 lines (83 loc) · 3.11 KB
/
Shader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#pragma once
#include "GL/glew.h"
#include <iostream>
#include <string>
#include <fstream>
#include "DirectionalLight.h"
class Shader
{
public:
//Constructor
Shader();
//Destructor
~Shader();
//Creates Shader from string
void CreateShadersFromText(const char* vShaderCode, const char* fShaderCode);
//Creates shaders from files
void CreateShadersFromFiles(const char* vShaderPath, const char* fShaderPath);
//Reads the shader file and returns cpp string
std::string ReadFile(const char* FilePath);
//Enables the shader during rendering
void EnableShader();
//Disables the shader.THIS MUST BE CALLED AT THE END OF EACH RENDER LOOP.
void DisableShader();
//Completely clears the shader
void ClearShaders();
//Attaches a directional light to the shader to pass information
void SetDirectionalLight(DirectionalLight* TheLight);
//Enables the information in the directional light to be passed on to shader during rendering
void EnableDirectionalLight();
//Returns Uniform variable Model location ID
GLuint GetUniformModel();
//Returns uniform variable projection location ID
GLuint GetUniformProjection();
//Returns uniform variable view location ID
GLuint GetUniformView();
//Returns uniform variable ambient light colour ID
GLuint GetUniformAmbientLightColour();
//Returns uniform variable ambient light intensity ID
GLuint GetUniformAmbientLightIntensity();
//Returns uniform variable diffuse light direction ID
GLuint GetUniformDiffuseDirection();
//Returns uniform variable diffuse light intensity ID
GLuint GetUniformDiffuseIntensity();
//Returns uniform variable specular intensity ID
GLuint GetUniformSpecularIntensity();
//Returns uniform variable specular shininess intensity ID
GLuint GetUniformSpecularShininess();
//Returns uniform variable camera view ID
GLuint GetUniformCameraPosition();
GLuint GetUniformMaxHeight();
private:
//Actually the program id to which the shaders are linked to
GLuint ShaderId;
//Uniform variable Model location ID
GLuint UniformModel;
//Uniform variable projection location ID.Used to set whether projection is orthographic or perspective projection.
GLuint UniformProjection;
//User's perspective (not the projection,this is their POV) uniform location ID
GLuint UniformView;
//Specular intensity uniform location ID
GLuint UniformSpecularIntensity;
//Specular shininess uniform location ID
GLuint UniformSpecularShininess;
//User's camera position uniform location ID
GLuint UniformCameraPosition;
//Number of point lights uniform location ID
GLuint UniformPointLightCount;
//Number of spot lights uniform location ID
GLuint UniformSpotLightCount;
GLuint UniformMaxTerrainHeight;
struct DirectionalLightUniformVars {
GLuint UniformAmbientLightColour;
GLuint UniformAmbientLightIntensity;
GLuint UniformDiffuseDirection;
GLuint UniformDiffuseIntensity;
} DirectionalLightUniformContainer;
//Pointer to directional light
DirectionalLight* dLight;
//Adds the shader to the program
GLuint AddShader(GLuint TheProgram, const char* ShaderCode, GLenum ShaderType);
//Compiles the shader
void CompileShaders(const char* vShaderCode, const char* fShaderCode);
};