-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
45 lines (35 loc) · 1.13 KB
/
main.cpp
File metadata and controls
45 lines (35 loc) · 1.13 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
#include <glew.h> // Include GLEW for easy OpenGL function loading
#include <glfw3.h> // Include GLFW for window handling
int main() {
// Initialize GLFW
glfwInit();
// Set OpenGL version and profile (core in this case)
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello OpenGL", NULL, NULL);
if (!window) {
glfwTerminate();
return -1;
}
// Make the window's context current
glfwMakeContextCurrent(window);
// Initialize GLEW
glewExperimental = true;
if (glewInit() != GLEW_OK) {
glfwTerminate();
return -1;
}
// Render loop
while (!glfwWindowShouldClose(window)) {
// Clear the screen to a color
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// show what we've drawn
glfwSwapBuffers(window);
// Process events (input, window resize, etc.)
glfwPollEvents();
}
glfwTerminate();
return 0;
}