-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
83 lines (64 loc) · 1.56 KB
/
main.cpp
File metadata and controls
83 lines (64 loc) · 1.56 KB
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
78
79
80
81
82
83
#include <stdio.h>
#include <vector>
#include <GLEW/GL/glew.h>
#include <GLFW/glfw3.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "shader.h"
#include "objloader.hpp"
#include "Scene.h"
GLFWwindow* InitWindow()
{
if (!glfwInit())
{
fprintf(stderr, "GLFW Error.");
return NULL;
}
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window;
window = glfwCreateWindow(
512, 512,
"Half Life 3 confirmed!",
NULL, NULL
);
if (window == NULL)
{
fprintf(stderr, "Window creation failed.");
glfwTerminate();
}
glfwMakeContextCurrent(window);
glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
GLenum err = glewInit();
if (err != GLEW_OK) {
fprintf(stderr, "GLEW failed.\n");
fprintf(stderr, "%s\n", glewGetErrorString(err));
glfwTerminate();
}
return window;
}
int main(void)
{
GLFWwindow* window = InitWindow();
if (window == NULL)
{
return -1;
}
glClearColor(0.0f, 0.0f, 0.4f, 1.0f);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
Scene scene;
scene.LoadScene("data/scene.scn");
do
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
scene.DrawScene();
glfwSwapBuffers(window);
glfwPollEvents();
} while (glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS && glfwWindowShouldClose(window) == 0);
scene.Clear();
glfwTerminate();
}