quick backup of changes:
[demo] / src / opengl / opengl.cc
1 #include <GL/glew.h>
2 #include <stdio.h>
3
4 #include "opengl/opengl.h"
5
6 extern GLFWwindow *win;
7 extern int win_h;
8 extern int win_w;
9
10 /* static test_* functions are going to be removed: just to test the shaders */
11 static void test_draw();
12 static void test_torus();
13
14 bool init_opengl()
15 {
16         if(!glfwInit()) {
17                 fprintf(stderr, "Failed to initialize GLFW.\n");
18                 return false;
19         }
20
21         glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
22         glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
23
24         if(!(win = glfwCreateWindow(win_w, win_h, "glcow", 0, 0))) {
25                 fprintf(stderr, "Failed to create window.\n");
26                 return false;
27         }
28         glfwMakeContextCurrent(win);
29
30         glewInit();
31         return true;
32 }
33
34 void cleanup_opengl()
35 {
36         if(win) {
37                 glfwDestroyWindow(win);
38         }
39         glfwTerminate();
40 }
41
42 void display_opengl()
43 {
44         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
45         glClearColor(0.5, 0.5, 0.5, 1.0);
46
47 }
48
49 static void test_draw()
50 {
51         /* this function is going to be removed, it's here only to test the shaders */
52
53 }