glviewvol

view src/main.cc @ 4:04330eb80b36

lots of stuff
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 29 Dec 2014 05:41:36 +0200
parents 32c4a7160350
children f22be47a3572
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;
25 int main(int argc, char **argv)
26 {
27 glutInit(&argc, argv);
29 if(parse_args(argc, argv) == -1) {
30 return 1;
31 }
33 glutInitWindowSize(1280, 800);
34 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
35 glutCreateWindow("dicom viewer");
37 glutDisplayFunc(display);
38 glutReshapeFunc(reshape);
39 glutKeyboardFunc(key_down);
40 glutKeyboardUpFunc(key_up);
41 glutMouseFunc(mouse);
42 glutMotionFunc(motion);
44 glewInit();
46 if(init() == -1) {
47 return 1;
48 }
50 glutMainLoop();
51 return 0;
52 }
54 void swap_buffers()
55 {
56 glutSwapBuffers();
57 }
59 void redisplay()
60 {
61 glutPostRedisplay();
62 }
64 void quit()
65 {
66 cleanup();
67 exit(0);
68 }
70 void get_window_size(int *xsz, int *ysz)
71 {
72 *xsz = win_width;
73 *ysz = win_height;
74 }
76 static void display()
77 {
78 ev_display();
79 }
81 static void reshape(int x, int y)
82 {
83 win_width = x;
84 win_height = y;
85 ev_reshape(x, y);
86 }
88 static void key_down(unsigned char key, int x, int y)
89 {
90 ev_keyboard(key, 1, x, y);
91 }
93 static void key_up(unsigned char key, int x, int y)
94 {
95 ev_keyboard(key, 0, x, y);
96 }
98 static void mouse(int bn, int state, int x, int y)
99 {
100 ev_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y);
101 }
103 static void motion(int x, int y)
104 {
105 ev_mouse_motion(x, y);
106 }
108 #endif // USE_GLUT