metasurf

changeset 11:430d8dde62aa tip

random changes
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 23 Aug 2015 07:17:56 +0300
parents dab7d6a158e2
children
files .hgignore examples/volume/Makefile examples/volume/src/volume.c src/metasurf.c
diffstat 4 files changed, 32 insertions(+), 7 deletions(-) [+]
line diff
     1.1 --- a/.hgignore	Thu Apr 17 13:51:10 2014 +0300
     1.2 +++ b/.hgignore	Sun Aug 23 07:17:56 2015 +0300
     1.3 @@ -6,3 +6,4 @@
     1.4  ^metasurf\.dylib
     1.5  ^Makefile$
     1.6  \.png$
     1.7 +\.jpg$
     2.1 --- a/examples/volume/Makefile	Thu Apr 17 13:51:10 2014 +0300
     2.2 +++ b/examples/volume/Makefile	Sun Aug 23 07:17:56 2015 +0300
     2.3 @@ -9,6 +9,7 @@
     2.4  CC = gcc
     2.5  CFLAGS = -pedantic -Wall -g -I../../src $(inc) $(nosdr)
     2.6  LDFLAGS = -L../.. -lmetasurf $(libgl) -limago -lm
     2.7 +#-lgomp
     2.8  
     2.9  ifeq ($(shell uname -s), Darwin)
    2.10  	inc = -I/opt/local/include
     3.1 --- a/examples/volume/src/volume.c	Thu Apr 17 13:51:10 2014 +0300
     3.2 +++ b/examples/volume/src/volume.c	Sun Aug 23 07:17:56 2015 +0300
     3.3 @@ -25,6 +25,7 @@
     3.4  void disp(void);
     3.5  void reshape(int x, int y);
     3.6  void keyb(unsigned char key, int x, int y);
     3.7 +void keyb_up(unsigned char key, int x, int y);
     3.8  void mouse(int bn, int state, int x, int y);
     3.9  void motion(int x, int y);
    3.10  int parse_args(int argc, char **argv);
    3.11 @@ -38,6 +39,8 @@
    3.12  unsigned int sdr;
    3.13  #endif
    3.14  
    3.15 +float yscale = 1.0;
    3.16 +
    3.17  struct img_pixmap *volume;
    3.18  int xres, yres, num_slices;
    3.19  
    3.20 @@ -67,6 +70,7 @@
    3.21  	glutDisplayFunc(disp);
    3.22  	glutReshapeFunc(reshape);
    3.23  	glutKeyboardFunc(keyb);
    3.24 +	glutKeyboardUpFunc(keyb_up);
    3.25  	glutMouseFunc(mouse);
    3.26  	glutMotionFunc(motion);
    3.27  
    3.28 @@ -158,6 +162,7 @@
    3.29  
    3.30  	glMatrixMode(GL_MODELVIEW);
    3.31  	glPushMatrix();
    3.32 +	glScalef(1.0, yscale, 1.0);
    3.33  	glRotatef(90, 1, 0, 0);
    3.34  
    3.35  	if(need_update) {
    3.36 @@ -219,6 +224,8 @@
    3.37  	cam_aspect((float)x / (float)y);
    3.38  }
    3.39  
    3.40 +int mode_scale;
    3.41 +
    3.42  void keyb(unsigned char key, int x, int y)
    3.43  {
    3.44  	static int wire;
    3.45 @@ -263,11 +270,24 @@
    3.46  		need_update = 1;
    3.47  		break;
    3.48  
    3.49 +	case 'y':
    3.50 +		mode_scale = 1;
    3.51 +		break;
    3.52 +
    3.53  	default:
    3.54  		break;
    3.55  	}
    3.56  }
    3.57  
    3.58 +void keyb_up(unsigned char key, int x, int y)
    3.59 +{
    3.60 +	switch(key) {
    3.61 +	case 'y':
    3.62 +		mode_scale = 0;
    3.63 +		break;
    3.64 +	}
    3.65 +}
    3.66 +
    3.67  int bnstate[32];
    3.68  int prev_x, prev_y;
    3.69  
    3.70 @@ -287,11 +307,15 @@
    3.71  	prev_x = x;
    3.72  	prev_y = y;
    3.73  
    3.74 -	if(bnstate[GLUT_LEFT_BUTTON]) {
    3.75 -		cam_inp_rotate(dx, dy);
    3.76 -	}
    3.77 -	if(bnstate[GLUT_RIGHT_BUTTON]) {
    3.78 -		cam_inp_zoom(dy);
    3.79 +	if(mode_scale) {
    3.80 +		yscale += dy * 0.001;
    3.81 +	} else {
    3.82 +		if(bnstate[GLUT_LEFT_BUTTON]) {
    3.83 +			cam_inp_rotate(dx, dy);
    3.84 +		}
    3.85 +		if(bnstate[GLUT_RIGHT_BUTTON]) {
    3.86 +			cam_inp_zoom(dy);
    3.87 +		}
    3.88  	}
    3.89  	glutPostRedisplay();
    3.90  }
     4.1 --- a/src/metasurf.c	Thu Apr 17 13:51:10 2014 +0300
     4.2 +++ b/src/metasurf.c	Sun Aug 23 07:17:56 2015 +0300
     4.3 @@ -160,7 +160,6 @@
     4.4  
     4.5  	pos[0] = ms->min[0];
     4.6  	for(i=0; i<ms->res[0] - 1; i++) {
     4.7 -
     4.8  		pos[1] = ms->min[1];
     4.9  		for(j=0; j<ms->res[1] - 1; j++) {
    4.10  
    4.11 @@ -279,6 +278,7 @@
    4.12  				ms->normal(dfdx, dfdy, dfdz);
    4.13  			}
    4.14  
    4.15 +			/* TODO multithreadied polygon emmit */
    4.16  			ms->vertex(v[0], v[1], v[2]);
    4.17  		}
    4.18  	}
    4.19 @@ -409,5 +409,4 @@
    4.20  		}
    4.21  	}*/
    4.22  }
    4.23 -
    4.24  #endif	/* USE_MTETRA */