volmetrics

view src/main.cc @ 0:88d390af583f

Image loader
author Eleni Maria Stea <eleni@mutantstargoat.com>
date Sat, 11 Jan 2014 17:22:36 +0200
parents
children cca2e05dbabe
line source
1 #include <GL/glew.h>
2 #include <GL/glut.h>
4 #include <stdio.h>
5 #include <assert.h>
7 //static void init(void);
8 static void display(void);
9 static void reshape(int x, int y);
10 static void keyboard(unsigned char key, int x, int y);
11 static void mouse(int button, int state, int x, int y);
12 static void motion(int x, int y);
14 static int win_xsz, win_ysz;
16 int main(int argc, char **argv)
17 {
18 glutInit(&argc, argv);
19 glutInitWindowSize(1280, 720);
20 glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
22 //TODO parse arguments
24 glutCreateWindow("My Colonoscopie OEO!");
26 glutDisplayFunc(display);
27 glutReshapeFunc(reshape);
28 glutKeyboardFunc(keyboard);
29 glutMouseFunc(mouse);
30 glutMotionFunc(motion);
32 glewInit();
34 //call init
36 glutMainLoop();
37 return 0;
38 }
40 int init(void)
41 {
42 //TODO
43 return 0;
44 }
46 void display(void)
47 {
48 //render
50 glutSwapBuffers();
51 assert(glGetError() == GL_NO_ERROR);
52 }
54 void reshape(int x, int y)
55 {
56 glViewport(0, 0, x, y);
57 if(x != win_xsz || y != win_ysz) {
58 //TODO raytex_needs_recalc = 1;
59 win_xsz = x;
60 win_ysz = y;
61 }
62 }
64 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 }
74 static int prev_x, prev_y;
75 void mouse(int bn, int state, int x, int y)
76 {
77 prev_x = x;
78 prev_y = y;
79 }
81 void motion(int x, int y)
82 {
83 int dx = x - prev_x;
84 int dy = y - prev_y;
85 prev_x = x;
86 prev_y = y;
87 }