volmetrics

diff src/main.cc @ 23:930c063ae346

preview works - transfer function on sdr
author Eleni Maria Stea <elene.mst@gmail.com>
date Thu, 24 Apr 2014 21:32:28 +0300
parents 4e120dcd55ec
children 4b6c952a83bd
line diff
     1.1 --- a/src/main.cc	Thu Apr 24 20:47:48 2014 +0300
     1.2 +++ b/src/main.cc	Thu Apr 24 21:32:28 2014 +0300
     1.3 @@ -95,13 +95,6 @@
     1.4  		fprintf(stderr, "Failed to create shader program!\n");
     1.5  		return false;
     1.6  	}
     1.7 -	glUseProgram(sprog);
     1.8 -	float t1 = glGetUniformLocation(sprog, "thres1");
     1.9 -	if(t1 != -1)
    1.10 -		glUniform1f(t1, 0);
    1.11 -	float t2 = glGetUniformLocation(sprog, "thres2");
    1.12 -		glUniform1f(t2, 1);
    1.13 -	glUseProgram(0);
    1.14  
    1.15  	vol = new Volume;
    1.16  	if(!vol->load(vol_fname)) {
    1.17 @@ -141,14 +134,16 @@
    1.18  	if(prev_thres != thres || prev_thres2 != thres2) {
    1.19  		prev_thres = thres;
    1.20  		prev_thres2 = thres2;
    1.21 +
    1.22  		mesh->clear();
    1.23 +
    1.24 +		glutSetWindow(xferwin_id);
    1.25 +		glutPostRedisplay();
    1.26 +		glutSetWindow(mainwin_id);
    1.27 +		glutPostRedisplay();
    1.28  	}
    1.29 +}
    1.30  
    1.31 -	glutSetWindow(xferwin_id);
    1.32 -	glutPostRedisplay();
    1.33 -	glutSetWindow(mainwin_id);
    1.34 -	glutPostRedisplay();
    1.35 -}
    1.36  static void res_change(int id)
    1.37  {
    1.38  	static float prev_resx = vol_res[0];
    1.39 @@ -204,6 +199,12 @@
    1.40  	glDisable(GL_DEPTH_TEST);
    1.41  
    1.42  	glUseProgram(sprog);
    1.43 +	int tmin_loc = glGetUniformLocation(sprog, "tmin");
    1.44 +	if(tmin_loc != -1)
    1.45 +		glUniform1f(tmin_loc, std::min(thres, thres2));
    1.46 +	int tmax_loc = glGetUniformLocation(sprog, "tmax");
    1.47 +	if(tmax_loc != -1)
    1.48 +		glUniform1f(tmax_loc, std::max(thres, thres2));
    1.49  
    1.50  	glMatrixMode(GL_MODELVIEW);
    1.51  	glPushMatrix();
    1.52 @@ -268,13 +269,14 @@
    1.53  	glDisable(GL_TEXTURE_3D);
    1.54  */
    1.55  
    1.56 -	if(mesh->is_empty()) {
    1.57 +/*	if(mesh->is_empty()) {
    1.58  		printf("recalculating isosurface ... ");
    1.59  		fflush(stdout);
    1.60  		vol->create_mesh(mesh, thres, thres2, vol_res[0], vol_res[1], vol_res[2]);
    1.61  		printf("done.\n");
    1.62  	}
    1.63  	mesh->draw();
    1.64 +*/
    1.65  
    1.66  	volume_preview();
    1.67  	glutSwapBuffers();
    1.68 @@ -510,6 +512,7 @@
    1.69  	float xpos = (float)x / (float)width;
    1.70  
    1.71  	*select_thres = xpos;
    1.72 +	thres_change(0);
    1.73  
    1.74  	glutPostRedisplay();
    1.75  	glutSetWindow(mainwin_id);