glviewvol

view src/main.cc @ 1:cc9e0d8590e2

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 27 Dec 2014 06:32:28 +0200
parents 7bdf40403b9c
children 32c4a7160350
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 int main(int argc, char **argv)
23 {
24 glutInit(&argc, argv);
25 glutInitWindowSize(1280, 800);
26 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
27 glutCreateWindow("dicom viewer");
29 glutDisplayFunc(display);
30 glutReshapeFunc(reshape);
31 glutKeyboardFunc(key_down);
32 glutKeyboardUpFunc(key_up);
33 glutMouseFunc(mouse);
34 glutMotionFunc(motion);
36 glewInit();
38 if(init() == -1) {
39 return 1;
40 }
42 glutMainLoop();
43 return 0;
44 }
46 void swap_buffers()
47 {
48 glutSwapBuffers();
49 }
51 void redisplay()
52 {
53 glutPostRedisplay();
54 }
56 void quit()
57 {
58 cleanup();
59 exit(0);
60 }
62 static void display()
63 {
64 ev_display();
65 }
67 static void reshape(int x, int y)
68 {
69 ev_reshape(x, y);
70 }
72 static void key_down(unsigned char key, int x, int y)
73 {
74 ev_keyboard(key, 1, x, y);
75 }
77 static void key_up(unsigned char key, int x, int y)
78 {
79 ev_keyboard(key, 0, x, y);
80 }
82 static void mouse(int bn, int state, int x, int y)
83 {
84 ev_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y);
85 }
87 static void motion(int x, int y)
88 {
89 ev_mouse_motion(x, y);
90 }
92 #endif // USE_GLUT