# HG changeset patch # User Eleni Maria Stea # Date 1398364348 -10800 # Node ID 930c063ae3462c3ae80daf9ab11345e71d4026e5 # Parent 4e120dcd55ec124a11566326d76681c5df54502f preview works - transfer function on sdr diff -r 4e120dcd55ec -r 930c063ae346 src/main.cc --- a/src/main.cc Thu Apr 24 20:47:48 2014 +0300 +++ b/src/main.cc Thu Apr 24 21:32:28 2014 +0300 @@ -95,13 +95,6 @@ fprintf(stderr, "Failed to create shader program!\n"); return false; } - glUseProgram(sprog); - float t1 = glGetUniformLocation(sprog, "thres1"); - if(t1 != -1) - glUniform1f(t1, 0); - float t2 = glGetUniformLocation(sprog, "thres2"); - glUniform1f(t2, 1); - glUseProgram(0); vol = new Volume; if(!vol->load(vol_fname)) { @@ -141,14 +134,16 @@ if(prev_thres != thres || prev_thres2 != thres2) { prev_thres = thres; prev_thres2 = thres2; + mesh->clear(); + + glutSetWindow(xferwin_id); + glutPostRedisplay(); + glutSetWindow(mainwin_id); + glutPostRedisplay(); } +} - glutSetWindow(xferwin_id); - glutPostRedisplay(); - glutSetWindow(mainwin_id); - glutPostRedisplay(); -} static void res_change(int id) { static float prev_resx = vol_res[0]; @@ -204,6 +199,12 @@ glDisable(GL_DEPTH_TEST); glUseProgram(sprog); + int tmin_loc = glGetUniformLocation(sprog, "tmin"); + if(tmin_loc != -1) + glUniform1f(tmin_loc, std::min(thres, thres2)); + int tmax_loc = glGetUniformLocation(sprog, "tmax"); + if(tmax_loc != -1) + glUniform1f(tmax_loc, std::max(thres, thres2)); glMatrixMode(GL_MODELVIEW); glPushMatrix(); @@ -268,13 +269,14 @@ glDisable(GL_TEXTURE_3D); */ - if(mesh->is_empty()) { +/* if(mesh->is_empty()) { printf("recalculating isosurface ... "); fflush(stdout); vol->create_mesh(mesh, thres, thres2, vol_res[0], vol_res[1], vol_res[2]); printf("done.\n"); } mesh->draw(); +*/ volume_preview(); glutSwapBuffers(); @@ -510,6 +512,7 @@ float xpos = (float)x / (float)width; *select_thres = xpos; + thres_change(0); glutPostRedisplay(); glutSetWindow(mainwin_id);