-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhongShader.h
executable file
·89 lines (79 loc) · 2.17 KB
/
PhongShader.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
//
// PhongShader.hpp
// ogl4
//
// Created by Philipp Lensing on 16.09.16.
// Copyright © 2016 Philipp Lensing. All rights reserved.
//
#ifndef PhongShader_hpp
#define PhongShader_hpp
#include <stdio.h>
#ifdef WIN32
#include <GL/glew.h>
#include <glfw/glfw3.h>
#else
#define GLFW_INCLUDE_GLCOREARB
#define GLFW_INCLUDE_GLEXT
#include <glfw/glfw3.h>
#endif
#include <iostream>
#include <assert.h>
#include "color.h"
#include "vector.h"
#include "matrix.h"
#include "camera.h"
#include "baseshader.h"
#include "texture.h"
class PhongShader : public BaseShader
{
public:
PhongShader();
// setter
void diffuseColor( const Color& c);
void ambientColor( const Color& c);
void specularColor( const Color& c);
void specularExp( float exp);
void diffuseTexture(const Texture* pTex);
void lightPos( const Vector& pos);
void lightColor(const Color& c);
//getter
const Color& diffuseColor() const { return DiffuseColor; }
const Color& ambientColor() const { return AmbientColor; }
const Color& specularColor() const { return SpecularColor; }
float specularExp() const { return SpecularExp; }
const Texture* diffuseTexture() const { return DiffuseTexture; }
const Vector& lightPos() const { return LightPos; }
const Color& lightColor() const { return LightColor; }
virtual void activate(const BaseCamera& Cam) const;
private:
void assignLocations();
Color DiffuseColor;
Color SpecularColor;
Color AmbientColor;
float SpecularExp;
Vector LightPos;
Color LightColor;
const Texture* DiffuseTexture;
GLint DiffuseColorLoc;
GLint SpecularColorLoc;
GLint AmbientColorLoc;
GLint SpecularExpLoc;
GLint LightPosLoc;
GLint LightColorLoc;
GLint ModelMatLoc;
GLint ModelViewProjLoc;
GLint EyePosLoc;
GLint DiffuseTexLoc;
mutable unsigned int UpdateState;
enum UPDATESTATES
{
DIFF_COLOR_CHANGED = 1<<0,
AMB_COLOR_CHANGED = 1<<1,
SPEC_COLOR_CHANGED = 1<<2,
SPEC_EXP_CHANGED = 1<<3,
LIGHT_POS_CHANGED = 1<<4,
LIGHT_COLOR_CHANGED = 1<<5,
DIFF_TEX_CHANGED = 1<<6
};
};
#endif /* PhongShader_hpp */