initial commit: a line and 5 points
[ludumice] / src / main.cc
1 #include <GL/glew.h>
2 #include <GL/glut.h>
3 #include <stdio.h>
4
5 #include "tentacle.h"
6
7 static bool init();
8 static void cleanup();
9
10 static void display();
11 static void keyboard(unsigned char key, int x, int y);
12
13 /* XXX FIXME */
14 static Tentacle tentacle;
15
16 int main(int argc, char **argv)
17 {
18         glutInit(&argc, argv);
19         glutInitWindowSize(800, 600);
20         glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);
21
22         glutCreateWindow("ludu mice");
23         glutDisplayFunc(display);
24         glutKeyboardFunc(keyboard);
25
26         if (!init())
27                 exit(1);
28
29         atexit(cleanup);
30
31         glutMainLoop();
32 }
33
34 static bool init()
35 {
36         glewInit();
37         glClearColor(1.0, 1.0, 0.0, 1.0);
38
39         if (!tentacle.init()) {
40                 fprintf(stderr, "Failed to initialize tentacle control points.\n");
41                 return false;
42         }
43
44         return true;
45 }
46
47 static void cleanup()
48 {
49 }
50
51 static void display()
52 {
53         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
54
55         //XXX FIXME
56         glMatrixMode(GL_MODELVIEW);
57         glLoadIdentity();
58
59         tentacle.draw();
60
61         glutSwapBuffers();
62 }
63
64 static void keyboard(unsigned char key, int x, int y)
65 {
66         switch(key) {
67         case 27:
68                 exit(0);
69         default:
70                 break;
71         }
72 }