glviewvol
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/main.cc Sat Dec 27 02:35:58 2014 +0200 1.3 @@ -0,0 +1,93 @@ 1.4 +// GLUT frontend 1.5 +#ifdef USE_GLUT 1.6 + 1.7 +#include <stdlib.h> 1.8 +#include "opengl.h" 1.9 + 1.10 +#ifdef __APPLE__ 1.11 +#include <GLUT/glut.h> 1.12 +#else 1.13 +#include <GL/glut.h> 1.14 +#endif 1.15 + 1.16 +#include "dicomview.h" 1.17 + 1.18 +static void display(); 1.19 +static void reshape(int x, int y); 1.20 +static void key_down(unsigned char key, int x, int y); 1.21 +static void key_up(unsigned char key, int x, int y); 1.22 +static void mouse(int bn, int state, int x, int y); 1.23 +static void motion(int x, int y); 1.24 + 1.25 +static float cam_theta, cam_phi, cam_dist = 6; 1.26 + 1.27 +int main(int argc, char **argv) 1.28 +{ 1.29 + glutInit(&argc, argv); 1.30 + glutInitWindowSize(1280, 800); 1.31 + glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 1.32 + glutCreateWindow("dicom viewer"); 1.33 + 1.34 + glutDisplayFunc(display); 1.35 + glutReshapeFunc(reshape); 1.36 + glutKeyboardFunc(keyb); 1.37 + glutMouseFunc(mouse); 1.38 + glutMotionFunc(motion); 1.39 + 1.40 + glewInit(); 1.41 + 1.42 + if(init() == -1) { 1.43 + return 1; 1.44 + } 1.45 + 1.46 + glutMainLoop(); 1.47 + return 0; 1.48 +} 1.49 + 1.50 +void swap_buffers() 1.51 +{ 1.52 + glutSwapBuffers(); 1.53 +} 1.54 + 1.55 +void redisplay() 1.56 +{ 1.57 + glutPostRedisplay(); 1.58 +} 1.59 + 1.60 +void quit() 1.61 +{ 1.62 + cleanup(); 1.63 + exit(0); 1.64 +} 1.65 + 1.66 +static void display() 1.67 +{ 1.68 + ev_display(); 1.69 +} 1.70 + 1.71 +static void reshape(int x, int y) 1.72 +{ 1.73 + ev_reshape(x, y); 1.74 +} 1.75 + 1.76 +static void key_down(unsigned char key, int x, int y) 1.77 +{ 1.78 + ev_keyboard(key, 1, x, y); 1.79 +} 1.80 + 1.81 +static void key_up(unsigned char key, int x, int y) 1.82 +{ 1.83 + ev_keyboard(key, 0, x, y); 1.84 +} 1.85 + 1.86 +static void mouse(int bn, int state, int x, int y) 1.87 +{ 1.88 + ev_mouse_button(bn - GLUT_LEFT_BUTTON, state == GLUT_DOWN ? 1 : 0, x, y); 1.89 +} 1.90 + 1.91 +static void motion(int x, int y) 1.92 +{ 1.93 + ev_mouse_motion(x, y); 1.94 +} 1.95 + 1.96 +#endif // USE_GLUT