glviewvol

view src/dicomview.cc @ 3:32c4a7160350

den kanei kryo stin ellada
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 28 Dec 2014 21:48:15 +0200
parents cc9e0d8590e2
children 04330eb80b36
line source
1 #include <stdio.h>
2 #include "opengl.h"
3 #include "dicomview.h"
4 #include "rend_fast.h"
5 #include "opt.h"
6 #include "volume.h"
8 static int win_width, win_height;
9 static float cam_theta, cam_phi, cam_dist = 6;
11 static Renderer *rend;
12 static Volume *vol;
14 extern "C" {
16 int init()
17 {
18 if(!opt.fname) {
19 fprintf(stderr, "you must specify the volume data filename\n");
20 return -1;
21 }
23 switch(opt.rend_type) {
24 case REND_FAST:
25 rend = new RendererFast;
26 break;
27 default:
28 return -1;
29 }
31 if(!rend->init()) {
32 fprintf(stderr, "renderer initialization failed\n");
33 return -1;
34 }
36 VoxelVolume *voxvol = new VoxelVolume;
37 if(!voxvol->load(opt.fname)) {
38 fprintf(stderr, "failed to load volume data from: %s\n", opt.fname);
39 return -1;
40 }
41 vol = voxvol;
42 rend->set_volume(vol);
44 return 0;
45 }
47 void cleanup()
48 {
49 rend->destroy();
50 delete rend;
51 delete vol;
52 }
54 void ev_display()
55 {
56 glClear(GL_COLOR_BUFFER_BIT);
58 rend->update(0);
59 rend->render();
60 }
62 void ev_reshape(int x, int y)
63 {
64 win_width = x;
65 win_height = y;
67 glViewport(0, 0, x, y);
68 }
70 void ev_keyboard(int key, int press, int x, int y)
71 {
72 if(press) {
73 switch(key) {
74 case 27:
75 quit();
76 }
77 }
78 }
80 void ev_mouse_button(int bn, int press, int x, int y)
81 {
82 }
84 void ev_mouse_motion(int x, int y)
85 {
86 }
88 } // extern "C"