metasurf
diff examples/volume/src/volume.c @ 11:430d8dde62aa
random changes
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 23 Aug 2015 07:17:56 +0300 |
parents | c1a60ab45bf7 |
children |
line diff
1.1 --- a/examples/volume/src/volume.c Thu Apr 17 13:51:10 2014 +0300 1.2 +++ b/examples/volume/src/volume.c Sun Aug 23 07:17:56 2015 +0300 1.3 @@ -25,6 +25,7 @@ 1.4 void disp(void); 1.5 void reshape(int x, int y); 1.6 void keyb(unsigned char key, int x, int y); 1.7 +void keyb_up(unsigned char key, int x, int y); 1.8 void mouse(int bn, int state, int x, int y); 1.9 void motion(int x, int y); 1.10 int parse_args(int argc, char **argv); 1.11 @@ -38,6 +39,8 @@ 1.12 unsigned int sdr; 1.13 #endif 1.14 1.15 +float yscale = 1.0; 1.16 + 1.17 struct img_pixmap *volume; 1.18 int xres, yres, num_slices; 1.19 1.20 @@ -67,6 +70,7 @@ 1.21 glutDisplayFunc(disp); 1.22 glutReshapeFunc(reshape); 1.23 glutKeyboardFunc(keyb); 1.24 + glutKeyboardUpFunc(keyb_up); 1.25 glutMouseFunc(mouse); 1.26 glutMotionFunc(motion); 1.27 1.28 @@ -158,6 +162,7 @@ 1.29 1.30 glMatrixMode(GL_MODELVIEW); 1.31 glPushMatrix(); 1.32 + glScalef(1.0, yscale, 1.0); 1.33 glRotatef(90, 1, 0, 0); 1.34 1.35 if(need_update) { 1.36 @@ -219,6 +224,8 @@ 1.37 cam_aspect((float)x / (float)y); 1.38 } 1.39 1.40 +int mode_scale; 1.41 + 1.42 void keyb(unsigned char key, int x, int y) 1.43 { 1.44 static int wire; 1.45 @@ -263,11 +270,24 @@ 1.46 need_update = 1; 1.47 break; 1.48 1.49 + case 'y': 1.50 + mode_scale = 1; 1.51 + break; 1.52 + 1.53 default: 1.54 break; 1.55 } 1.56 } 1.57 1.58 +void keyb_up(unsigned char key, int x, int y) 1.59 +{ 1.60 + switch(key) { 1.61 + case 'y': 1.62 + mode_scale = 0; 1.63 + break; 1.64 + } 1.65 +} 1.66 + 1.67 int bnstate[32]; 1.68 int prev_x, prev_y; 1.69 1.70 @@ -287,11 +307,15 @@ 1.71 prev_x = x; 1.72 prev_y = y; 1.73 1.74 - if(bnstate[GLUT_LEFT_BUTTON]) { 1.75 - cam_inp_rotate(dx, dy); 1.76 - } 1.77 - if(bnstate[GLUT_RIGHT_BUTTON]) { 1.78 - cam_inp_zoom(dy); 1.79 + if(mode_scale) { 1.80 + yscale += dy * 0.001; 1.81 + } else { 1.82 + if(bnstate[GLUT_LEFT_BUTTON]) { 1.83 + cam_inp_rotate(dx, dy); 1.84 + } 1.85 + if(bnstate[GLUT_RIGHT_BUTTON]) { 1.86 + cam_inp_zoom(dy); 1.87 + } 1.88 } 1.89 glutPostRedisplay(); 1.90 }