# HG changeset patch # User Eleni Maria Stea # Date 1398612340 -10800 # Node ID 5ee081af59b8b4b834787c6a07bfcace4c9c4328 # Parent 4b6c952a83bd420aa9710fb96accd092f7adc76c volume rendering diff -r 4b6c952a83bd -r 5ee081af59b8 src/main.cc --- a/src/main.cc Sun Apr 27 18:13:44 2014 +0300 +++ b/src/main.cc Sun Apr 27 18:25:40 2014 +0300 @@ -53,6 +53,7 @@ static int use_orig_vol_res = 1; static int vol_res[3]; // volume sampling resolution x/y/z +static float bound_scale = 1.42; static GLUI *ui; @@ -124,6 +125,8 @@ vol_res[1] = vol->get_slice(0)->get_height(); vol_res[2] = vol->get_slice_count(); + num_poly = std::max(vol_res[0], std::max(vol_res[1], vol_res[2])) * bound_scale; + if(!(ui = create_ui())) { return false; } @@ -296,13 +299,9 @@ if(tmax_loc != -1) glUniform1f(tmax_loc, std::max(thres, thres2)); - const Image *img = vol->get_slice(0); - int res_x = img->get_width(); - int res_y = img->get_height(); - int res_z = vol->get_slice_count(); int res_loc = glGetUniformLocation(sprog_vol, "res"); if(res_loc != -1) - glUniform3f(res_loc, (float)res_x, (float)res_y, (float)res_z); + glUniform3f(res_loc, (float)vol_res[0], (float)vol_res[1], (float)vol_res[2]); glDisable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_3D, vol->get_texture()); @@ -314,10 +313,10 @@ float tex_z = (float)i / (float)num_poly; float z = 2 * tex_z - 1; - glTexCoord3f(0, 0, tex_z); glVertex3f(-2, -2, z * 2); - glTexCoord3f(0, 1, tex_z); glVertex3f(-2, 2, z * 2); - glTexCoord3f(1, 1, tex_z); glVertex3f(2, 2, z * 2); - glTexCoord3f(1, 0, tex_z); glVertex3f(2, -2, z * 2); + glTexCoord3f(0, 0, tex_z); glVertex3f(-bound_scale, -bound_scale, z * bound_scale); + glTexCoord3f(0, 1, tex_z); glVertex3f(-bound_scale, bound_scale, z * bound_scale); + glTexCoord3f(1, 1, tex_z); glVertex3f(bound_scale, bound_scale, z * bound_scale); + glTexCoord3f(1, 0, tex_z); glVertex3f(bound_scale, -bound_scale, z * bound_scale); } glEnd(); glDisable(GL_BLEND);