-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
74 lines (57 loc) · 1.92 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* CS 5610
* Project 7 - Shadow Mapping
* Luis Tadeo Sanchez
* March 12, 2024
*/
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "utils.h"
#include "application.h"
GLFWwindow *window;
int main(int argc, char **argv)
{
if (argc < 2)
Utils::Error(1, "Missing required arguments. Correct usage: Project7 <obj_path>");
if (!glfwInit())
Utils::Error(1, "Unable to initialize GLFW");
/* Create GLFW window */
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
#ifdef __APPLE__
glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GLFW_TRUE);
#endif
window = glfwCreateWindow(800, 600, "Project 7", nullptr, nullptr);
if (!window)
Utils::Error(1, "Unable to create window");
glfwMakeContextCurrent(window);
//glfwSwapInterval(0);
/* Initialize GLEW */
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
Utils::Error(1, "Failed to initialize GLEW");
/* Setup OpenGL */
glClearColor(0, 0, 0, 1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_MULTISAMPLE);
int width, height;
glfwGetFramebufferSize(window, &width, &height);
Application app(width, height, argv[1]);
glfwSetWindowUserPointer(window, &app);
glfwSetKeyCallback(window, Application::KeyCallback);
glfwSetFramebufferSizeCallback(window, Application::ResizeCallback);
glfwSetCursorPosCallback(window, Application::CursorPosCallback);
glfwSetMouseButtonCallback(window, Application::MouseButtonCallback);
Application::ResizeCallback(window, width, height);
while(!glfwWindowShouldClose(window))
{
app.Update();
app.Draw();
glfwPollEvents();
glfwSwapBuffers(window);
}
glfwDestroyWindow(window);
glfwTerminate();
}