-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmaterial.h
60 lines (42 loc) · 1.14 KB
/
material.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
//
// Created by kskun on 2022/5/14.
//
#ifndef MESH_VIEWER_MATERIAL_H
#define MESH_VIEWER_MATERIAL_H
#include "shader.h"
class Texture2D;
class Material;
class Texture2D {
friend Material;
public:
Texture2D() {}
explicit Texture2D(const std::string &path);
virtual ~Texture2D();
virtual void use(int unit) const;
protected:
const unsigned char *data = nullptr;
GLuint glTexture;
int width, height;
};
class Material {
public:
Material() {}
Material(ShaderProgram *program, std::vector<Texture2D *> textures);
virtual void use() const;
protected:
// don't delete them in dtor
// Material is just a combination of program, textures and parameters
// manage program & textures in models
ShaderProgram *program = nullptr;
std::vector<Texture2D *> textures;
};
class PhongMaterial : public Material {
public:
PhongMaterial() {}
PhongMaterial(ShaderProgram *program, std::vector<Texture2D *> textures, int texDiffuse, int texSpecular, float shininess);
void use() const override;
protected:
int texDiffuse, texSpecular;
float shininess;
};
#endif //MESH_VIEWER_MATERIAL_H