glviewvol

view src/main.cc @ 3:32c4a7160350

den kanei kryo stin ellada
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 28 Dec 2014 21:48:15 +0200
parents cc9e0d8590e2
children 04330eb80b36
line source
1 // GLUT frontend
2 #ifdef USE_GLUT
4 #include <stdlib.h>
5 #include "opengl.h"
7 #ifdef __APPLE__
8 #include <GLUT/glut.h>
9 #else
10 #include <GL/glut.h>
11 #endif
13 #include "dicomview.h"
14 #include "opt.h"
16 static void display();
17 static void reshape(int x, int y);
18 static void key_down(unsigned char key, int x, int y);
19 static void key_up(unsigned char key, int x, int y);
20 static void mouse(int bn, int state, int x, int y);
21 static void motion(int x, int y);
23 int main(int argc, char **argv)
24 {
25 glutInit(&argc, argv);
27 if(parse_args(argc, argv) == -1) {
28 return 1;
29 }
31 glutInitWindowSize(1280, 800);
32 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
33 glutCreateWindow("dicom viewer");
35 glutDisplayFunc(display);
36 glutReshapeFunc(reshape);
37 glutKeyboardFunc(key_down);
38 glutKeyboardUpFunc(key_up);
39 glutMouseFunc(mouse);
40 glutMotionFunc(motion);
42 glewInit();
44 if(init() == -1) {
45 return 1;
46 }
48 glutMainLoop();
49 return 0;
50 }
52 void swap_buffers()
53 {
54 glutSwapBuffers();
55 }
57 void redisplay()
58 {
59 glutPostRedisplay();
60 }
62 void quit()
63 {
64 cleanup();
65 exit(0);
66 }
68 static void display()
69 {
70 ev_display();
71 }
73 static void reshape(int x, int y)
74 {
75 ev_reshape(x, y);
76 }
78 static void key_down(unsigned char key, int x, int y)
79 {
80 ev_keyboard(key, 1, x, y);
81 }
83 static void key_up(unsigned char key, int x, int y)
84 {
85 ev_keyboard(key, 0, x, y);
86 }
88 static void mouse(int bn, int state, int x, int y)
89 {
90 ev_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y);
91 }
93 static void motion(int x, int y)
94 {
95 ev_mouse_motion(x, y);
96 }
98 #endif // USE_GLUT