-
Notifications
You must be signed in to change notification settings - Fork 2
/
Skybox.h
65 lines (55 loc) · 1.4 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
#ifndef _SKYBOX_H_
#define _SKYBOX_H_
#define GLFW_INCLUDE_GLEXT
#ifdef __APPLE__
#define GLFW_INCLUDE_GLCOREARB
#else
#include <GL/glew.h>
#endif
#include <GLFW/glfw3.h>
// Use of degrees is deprecated. Use radians instead.
#ifndef GLM_FORCE_RADIANS
#define GLM_FORCE_RADIANS
#endif
#include <glm/mat4x4.hpp>
#include <glm/gtc/matrix_transform.hpp>
class Skybox
{
public:
Skybox();
Skybox(float mult);
~Skybox();
glm::mat4 toWorld;
void initialize();
void draw(GLuint);
void sendLight(GLuint shaderProgram);
// Cubemap
GLuint loadCubemap();
GLuint textureID;
// These variables are needed for the shader program
GLuint VBO, VAO, EBO;
GLuint uProjection, uModelview, uModel, uView;
GLfloat vertices[8][3] = {
// "Front" vertices
{ -2.0, -2.0, 2.0 },{ 2.0, -2.0, 2.0 },{ 2.0, 2.0, 2.0 },{ -2.0, 2.0, 2.0 },
// "Back" vertices
{ -2.0, -2.0, -2.0 },{ 2.0, -2.0, -2.0 },{ 2.0, 2.0, -2.0 },{ -2.0, 2.0, -2.0 }
};
};
// Note that GL_QUADS is deprecated in modern OpenGL (and removed from OSX systems).
// This is why we need to draw each face as 2 triangles instead of 1 quadrilateral
const GLuint indices[6][6] = {
// Front face
{0, 1, 2, 2, 3, 0},
// Top face
{1, 5, 6, 6, 2, 1},
// Back face
{7, 6, 5, 5, 4, 7},
// Bottom face
{4, 0, 3, 3, 7, 4},
// Left face
{4, 5, 1, 1, 0, 4},
// Right face
{3, 2, 6, 6, 7, 3}
};
#endif