first git commit: scene, object, mesh, texture, shader, material etc
[demo] / src / opengl / opengl.cc
1 #include <GL/glew.h>
2 #include <stdio.h>
3
4 #include "opengl/opengl.h"
5 #include "common-ui.h"
6
7 extern GLFWwindow *win;
8 bool init_opengl()
9 {
10         if(!glfwInit()) {
11                 fprintf(stderr, "Failed to initialize GLFW.\n");
12                 return false;
13         }
14
15         glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
16         glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 5);
17
18         if(!(win = glfwCreateWindow(win_w, win_h, "glcow", 0, 0))) {
19                 fprintf(stderr, "Failed to create window.\n");
20                 return false;
21         }
22         glfwMakeContextCurrent(win);
23
24         glewInit();
25         return true;
26 }
27
28 void cleanup_opengl()
29 {
30         if(win) {
31                 glfwDestroyWindow(win);
32         }
33         glfwTerminate();
34 }
35
36 void display_opengl()
37 {
38         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
39         glClearColor(0.5, 0.5, 0.5, 1.0);
40 }