-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshaders.h
38 lines (31 loc) · 917 Bytes
/
shaders.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
#ifndef __SHADERS_H__
#define __SHADERS_H__
#include "geometry.h"
#include "tgaimage.h"
class IShader {
protected:
Matrix* viewport;
Matrix* projection;
Matrix* modelView;
public:
IShader(Matrix& viewport, Matrix& projection, Matrix& modelView) {
this->viewport = &viewport;
this->projection = &projection;
this->modelView = &modelView;
}
virtual ~IShader() {
// needs testing for children classes
}
virtual Vec4f vertex(int iface, int nthvert) = 0;
virtual bool fragment(Vec3f bar, TGAColor &color) = 0;
};
class GouraudShader : public IShader {
private:
Vec3f varying_intensity; // written by vertex shader, read by fragment shader
public:
GouraudShader(Matrix& viewport, Matrix& projection, Matrix& modelView) : IShader(viewport, projection, modelView) {
}
Vec4f vertex(int iface, int nthvert) override;
bool fragment(Vec3f bar, TGAColor &color) override;
};
#endif //__SHADERS_H__