-
Notifications
You must be signed in to change notification settings - Fork 0
/
Skybox.h
77 lines (51 loc) · 1.92 KB
/
Skybox.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
#ifndef _SKYBOX_H_
#define _SKYBOX_H_
class Skybox {
public:
Skybox();
void draw();
void initAll();
//-----------------------------------------------------
// Getter + Setter
void setGViewMatrix(const glm::mat4 &gViewMatrix);
void setGProjectionMatrix(const glm::mat4 &gProjectionMatrix);
private:
glm::mat4 g_viewMatrix, g_projectionMatrix, g_modelMatrix;
//-----------------------------------------------------
GLuint g_ShaderProgram;
GLuint g_Texture;
GLuint g_uniformMVP;
GLuint g_vaoSkybox;
//-----------------------------------------------------
void initVAO();
void initShader();
void initTexture();
// Our Vertex-Struct (pos and color)
struct VertexXYZColor {
glm::vec3 m_Pos;
glm::vec3 m_Color;
};
// Define the 8 vertices of a unit cube
VertexXYZColor g_Vertices[8] = {
{ glm::vec3( 1, 1, 1 ), glm::vec3( 1, 1, 1 ) }, // 0
{ glm::vec3( -1, 1, 1 ), glm::vec3( 0, 1, 1 ) }, // 1
{ glm::vec3( -1, -1, 1 ), glm::vec3( 0, 0, 1 ) }, // 2
{ glm::vec3( 1, -1, 1 ), glm::vec3( 1, 0, 1 ) }, // 3
{ glm::vec3( 1, -1, -1 ), glm::vec3( 1, 0, 0 ) }, // 4
{ glm::vec3( -1, -1, -1 ), glm::vec3( 0, 0, 0 ) }, // 5
{ glm::vec3( -1, 1, -1 ), glm::vec3( 0, 1, 0 ) }, // 6
{ glm::vec3( 1, 1, -1 ), glm::vec3( 1, 1, 0 ) }, // 7
};
// Define the vertex indices for the cube.
// Each set of 6 vertices represents a set of triangles in
// counter-clockwise winding order.
GLuint g_Indices[36] = {
0, 1, 2, 2, 3, 0, // Front face
7, 4, 5, 5, 6, 7, // Back face
6, 5, 2, 2, 1, 6, // Left face
7, 0, 3, 3, 4, 7, // Right face
7, 6, 1, 1, 0, 7, // Top face
3, 2, 5, 5, 4, 3 // Bottom face
};
};
#endif //_SKYBOX_H_