glviewvol

view src/main.cc @ 0:7bdf40403b9c

dicom viewer project underway
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 27 Dec 2014 02:35:58 +0200
parents
children cc9e0d8590e2
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"
15 static void display();
16 static void reshape(int x, int y);
17 static void key_down(unsigned char key, int x, int y);
18 static void key_up(unsigned char key, int x, int y);
19 static void mouse(int bn, int state, int x, int y);
20 static void motion(int x, int y);
22 static float cam_theta, cam_phi, cam_dist = 6;
24 int main(int argc, char **argv)
25 {
26 glutInit(&argc, argv);
27 glutInitWindowSize(1280, 800);
28 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
29 glutCreateWindow("dicom viewer");
31 glutDisplayFunc(display);
32 glutReshapeFunc(reshape);
33 glutKeyboardFunc(keyb);
34 glutMouseFunc(mouse);
35 glutMotionFunc(motion);
37 glewInit();
39 if(init() == -1) {
40 return 1;
41 }
43 glutMainLoop();
44 return 0;
45 }
47 void swap_buffers()
48 {
49 glutSwapBuffers();
50 }
52 void redisplay()
53 {
54 glutPostRedisplay();
55 }
57 void quit()
58 {
59 cleanup();
60 exit(0);
61 }
63 static void display()
64 {
65 ev_display();
66 }
68 static void reshape(int x, int y)
69 {
70 ev_reshape(x, y);
71 }
73 static void key_down(unsigned char key, int x, int y)
74 {
75 ev_keyboard(key, 1, x, y);
76 }
78 static void key_up(unsigned char key, int x, int y)
79 {
80 ev_keyboard(key, 0, x, y);
81 }
83 static void mouse(int bn, int state, int x, int y)
84 {
85 ev_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y);
86 }
88 static void motion(int x, int y)
89 {
90 ev_mouse_motion(x, y);
91 }
93 #endif // USE_GLUT