glviewvol

view src/main.cc @ 7:71b479ffb9f7

curve manipulation works
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 30 Dec 2014 17:28:38 +0200
parents f22be47a3572
children fb6d93471352
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 static int win_width, win_height;
24 static unsigned int mod;
26 int main(int argc, char **argv)
27 {
28 glutInit(&argc, argv);
30 if(parse_args(argc, argv) == -1) {
31 return 1;
32 }
34 glutInitWindowSize(opt.xsz, opt.ysz);
35 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
36 glutCreateWindow("dicom viewer");
38 glutDisplayFunc(display);
39 glutReshapeFunc(reshape);
40 glutKeyboardFunc(key_down);
41 glutKeyboardUpFunc(key_up);
42 glutMouseFunc(mouse);
43 glutMotionFunc(motion);
44 glutPassiveMotionFunc(motion);
46 glewInit();
48 if(init() == -1) {
49 return 1;
50 }
52 glutMainLoop();
53 return 0;
54 }
56 void swap_buffers()
57 {
58 glutSwapBuffers();
59 }
61 void redisplay()
62 {
63 glutPostRedisplay();
64 }
66 void quit()
67 {
68 cleanup();
69 exit(0);
70 }
72 void get_window_size(int *xsz, int *ysz)
73 {
74 *xsz = win_width;
75 *ysz = win_height;
76 }
78 unsigned int get_modifiers()
79 {
80 return mod;
81 }
83 static void display()
84 {
85 ev_display();
86 }
88 static void reshape(int x, int y)
89 {
90 win_width = x;
91 win_height = y;
92 ev_reshape(x, y);
93 }
95 static void key_down(unsigned char key, int x, int y)
96 {
97 mod = glutGetModifiers();
98 ev_keyboard(key, 1, x, y);
99 }
101 static void key_up(unsigned char key, int x, int y)
102 {
103 mod = glutGetModifiers();
104 ev_keyboard(key, 0, x, y);
105 }
107 static void mouse(int bn, int state, int x, int y)
108 {
109 mod = glutGetModifiers();
110 ev_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y);
111 }
113 static void motion(int x, int y)
114 {
115 ev_mouse_motion(x, y);
116 }
118 #endif // USE_GLUT