-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (40 loc) · 1.32 KB
/
Copy pathmain.cpp
File metadata and controls
54 lines (40 loc) · 1.32 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
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
using std::cout, std::cerr, std::endl;
void glfwErrorCallback(int error, const char* description) {
cerr << "GLFW Error (" << error << "): " << description << endl;
}
int main() {
glfwSetErrorCallback(glfwErrorCallback);
if (!glfwInit()) {
cerr << "Failed to initialize GLFW" << endl;
return -1;
}
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
GLFWwindow* window = glfwCreateWindow(800, 600, "Hello GLEW and GLFW", NULL, NULL);
if (!window) {
cerr << "Failed to create GLFW window" << endl;
glfwTerminate();
return -1;
}
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE;
if (glewInit() != GLEW_OK) {
cerr << "Failed to initialize GLEW" << endl;
return -1;
}
cout << "OpenGL version: " << glGetString(GL_VERSION) << endl;
while (!glfwWindowShouldClose(window)) {
glfwPollEvents();
glClearColor(3.0f, 0.8f, 0.5f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}