From 8b30eb84e3bec987dd1da9f5c285598e2a1291c2 Mon Sep 17 00:00:00 2001 From: Jiaming Guo Date: Wed, 18 Jan 2017 17:12:17 -0600 Subject: [PATCH] add SPACE keyboard to render the transparant T close to GT --- main.cu | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/main.cu b/main.cu index 4183c19..1f7eb6c 100644 --- a/main.cu +++ b/main.cu @@ -77,6 +77,7 @@ GLuint cmap_tex = 0; //texture name for the color map float delta; float sigma = 3; //default sigma float radius = 3; //equals to radius +int transparancy_fac = 0; //sets an OpenGL viewport taking up the entire window void glut_render_single_projection(){ @@ -149,6 +150,15 @@ void glut_render(void) { glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map GT.glCylinder(sigma, radius); //render the GT network + if (transparancy_fac == 1) { + glEnable(GL_BLEND); //enable color blend + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function + glDisable(GL_DEPTH_TEST); //should disable depth + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); + T.glCylinder(sigma, radius); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + } glut_render_right_projection(); //set up a projection for the right half of the window glut_render_modelview(); //set up the modelview matrix using camera details @@ -175,6 +185,15 @@ void glut_render(void) { glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map _GT.glCylinder(sigma, radius); //render the GT network + if (transparancy_fac == 1) { + glEnable(GL_BLEND); //enable color blend + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function + glDisable(GL_DEPTH_TEST); //should disable depth + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); + _T.glCylinder(sigma, radius); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + } glut_render_right_projection(); //set up a projection for the right half of the window glut_render_modelview(); //set up the modelview matrix using camera details @@ -186,13 +205,21 @@ void glut_render(void) { glut_render_left_projection(); //set up a projection for the left half of the window glut_render_modelview(); //set up the modelview matrix using camera details glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen - - //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap); + _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma, radius); + if (transparancy_fac == 1) { + glEnable(GL_BLEND); //enable color blend + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function + glDisable(GL_DEPTH_TEST); //should disable depth + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); + _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius); + glDisable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + } glut_render_right_projection(); //set up a projection for the right half of the window glut_render_modelview(); //set up the modelview matrix using camera details - //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap); + _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius); sigma = radius; //set sigma equal to radius } @@ -362,6 +389,14 @@ void glut_keyboard(unsigned char key, int x, int y){ if (radius < 0.001f) radius = 0.2; break; + + // render a transparant T very close to GT + case 32: // if keyboard 'SPACE' is pressed, then change the transparancy_fac + if (compareMode && !mappingMode && !transparancy_fac) + transparancy_fac = 1; + else + transparancy_fac = 0; + break; // close window and exit application case 27: // if keyboard 'ESC' is pressed, then exit -- libgit2 0.21.4