-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab2_main.cpp
More file actions
69 lines (52 loc) · 1.41 KB
/
Lab2_main.cpp
File metadata and controls
69 lines (52 loc) · 1.41 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
#define GLEW_STATIC
#include <iostream>
#include "OpenGL dev libs/include/GL/glew.h"
#include "OpenGL dev libs/include/GLFW/glfw3.h"
int glWindowWidth = 640;
int glWindowHeight = 480;
GLFWwindow* glWindow = NULL;
bool initOpenGLWindow()
{
if (!glfwInit()) {
fprintf(stderr, "ERROR: could not start GLFW3\n");
return false;
}
glWindow = glfwCreateWindow(glWindowWidth, glWindowHeight, "Hello Window", NULL, NULL);
if (!glWindow) {
fprintf(stderr, "ERROR: could not open window with GLFW3\n");
glfwTerminate();
return false;
}
glfwMakeContextCurrent(glWindow);
// start GLEW extension handler
glewExperimental = GL_TRUE;
glewInit();
// get version info
const GLubyte* renderer = glGetString(GL_RENDERER); // get renderer string
const GLubyte* version = glGetString(GL_VERSION); // version as a string
printf("Renderer: %s\n", renderer);
printf("OpenGL version supported %s\n", version);
return true;
}
void processEvents(){
if (glfwGetKey(glWindow, GLFW_KEY_A)) {
//TODO
std::cout << "PRESSED KEY A" << "\n";
}
}
void renderScene(){
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearColor(0, 0, 1, 1.0);
}
int main(int argc, const char * argv[]) {
initOpenGLWindow();
while (!glfwWindowShouldClose(glWindow)) {
renderScene();
processEvents();
glfwPollEvents();
glfwSwapBuffers(glWindow);
}
//close GL context and any other GLFW resources
glfwTerminate();
return 0;
}