summaryrefslogtreecommitdiff
path: root/src/main.c
blob: f5941bb5a1376f480732a6c51510a14a7b278a81 (plain) (blame)
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 <stdlib.h>
#include <stdio.h>

#include <GL/glew.h>
#include <GLFW/glfw3.h>

int main(int argc, char** argv) {
   glewExperimental = 1;

   if (!glfwInit()) {
      fprintf(stderr, "bad\n");
      return 1;
   }

   // Window hints.
   glfwWindowHint(GLFW_SAMPLES, 4); // 4x antialiasing.
   glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);  // Version 3.3.
   glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
   glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
   glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

   // Create the window.
   GLFWwindow* window;
   window = glfwCreateWindow( 1024, 768, "Hi", NULL, NULL);

   if (!window) {
      fprintf(stderr, "no window\n");
      glfwTerminate();
      return 1;
   }

   // Glue.
   glfwMakeContextCurrent(window);
   glewExperimental = 1;

   // Is the glue OK?
   if (glewInit() != GLEW_OK) {
      fprintf(stderr, "glewless\n");
      return 1;
   }

   glfwSetInputMode(window, GLFW_STICKY_KEYS, 1);

   do {
      glfwSwapBuffers(window);
      glfwPollEvents();
   } while (
      glfwGetKey(window, GLFW_KEY_ESCAPE) != GLFW_PRESS
      && !glfwWindowShouldClose(window)
   );


   return 0;
}