-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.cpp
51 lines (40 loc) · 1.25 KB
/
main.cpp
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
#include "../common/util.h"
#include "../common/shader.h"
#include "skybox.h"
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
int main(void)
{
GLFWwindow* window;
window = init("Cubemaps", 640, 480);
if(!window)
{
return -1;
}
glm::mat4 proj = glm::perspective(glm::radians(45.0f), (float)640/(float)480, 0.1f, 1000.0f);
glm::mat4 view;
// We will need to enable depth testing, so that OpenGL draws further
// vertices first
glEnable(GL_DEPTH_TEST);
GLuint cubemap = loadCubeMap("cm_xp.png", "cm_xn.png", "cm_yp.png", "cm_yn.png", "cm_zp.png", "cm_zn.png");
if(!cubemap)
{
std::cerr << "Could not load cubemap" << std::endl;
return -1;
}
Skybox skybox(cubemap);
glClearColor(0.75f, 0.75f, 0.75f, 1.0f);
while(!glfwWindowShouldClose(window))
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Rotate the view to show the 3D skybox effect
view = glm::rotate(view, glm::radians(15.0f) * (float)glfwGetTime(), glm::vec3(0.0f, 1.0f, 0.0f));
glfwSetTime(0.0);
skybox.render(view, proj);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
return 0;
}