Commit 8b30eb84e3bec987dd1da9f5c285598e2a1291c2
1 parent
86a4e373
add SPACE keyboard to render the transparant T close to GT
Showing
1 changed file
with
38 additions
and
3 deletions
Show diff stats
main.cu
... | ... | @@ -77,6 +77,7 @@ GLuint cmap_tex = 0; //texture name for the color map |
77 | 77 | float delta; |
78 | 78 | float sigma = 3; //default sigma |
79 | 79 | float radius = 3; //equals to radius |
80 | +int transparancy_fac = 0; | |
80 | 81 | |
81 | 82 | //sets an OpenGL viewport taking up the entire window |
82 | 83 | void glut_render_single_projection(){ |
... | ... | @@ -149,6 +150,15 @@ void glut_render(void) { |
149 | 150 | glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map |
150 | 151 | |
151 | 152 | GT.glCylinder(sigma, radius); //render the GT network |
153 | + if (transparancy_fac == 1) { | |
154 | + glEnable(GL_BLEND); //enable color blend | |
155 | + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function | |
156 | + glDisable(GL_DEPTH_TEST); //should disable depth | |
157 | + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); | |
158 | + T.glCylinder(sigma, radius); | |
159 | + glDisable(GL_BLEND); | |
160 | + glEnable(GL_DEPTH_TEST); | |
161 | + } | |
152 | 162 | |
153 | 163 | glut_render_right_projection(); //set up a projection for the right half of the window |
154 | 164 | glut_render_modelview(); //set up the modelview matrix using camera details |
... | ... | @@ -175,6 +185,15 @@ void glut_render(void) { |
175 | 185 | glBindTexture(GL_TEXTURE_1D, cmap_tex); //bind the Brewer texture map |
176 | 186 | |
177 | 187 | _GT.glCylinder(sigma, radius); //render the GT network |
188 | + if (transparancy_fac == 1) { | |
189 | + glEnable(GL_BLEND); //enable color blend | |
190 | + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function | |
191 | + glDisable(GL_DEPTH_TEST); //should disable depth | |
192 | + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); | |
193 | + _T.glCylinder(sigma, radius); | |
194 | + glDisable(GL_BLEND); | |
195 | + glEnable(GL_DEPTH_TEST); | |
196 | + } | |
178 | 197 | |
179 | 198 | glut_render_right_projection(); //set up a projection for the right half of the window |
180 | 199 | glut_render_modelview(); //set up the modelview matrix using camera details |
... | ... | @@ -186,13 +205,21 @@ void glut_render(void) { |
186 | 205 | glut_render_left_projection(); //set up a projection for the left half of the window |
187 | 206 | glut_render_modelview(); //set up the modelview matrix using camera details |
188 | 207 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the screen |
189 | - | |
190 | - //_GT.glRandColorCenterlineGT(dlist1, _gt_t, colormap); | |
208 | + | |
191 | 209 | _GT.glRandColorCylinder1(dlist1, _gt_t, colormap, sigma, radius); |
210 | + if (transparancy_fac == 1) { | |
211 | + glEnable(GL_BLEND); //enable color blend | |
212 | + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //set blend function | |
213 | + glDisable(GL_DEPTH_TEST); //should disable depth | |
214 | + glColor4f(1.0f, 1.0f, 1.0f, 0.2f); | |
215 | + _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius); | |
216 | + glDisable(GL_BLEND); | |
217 | + glEnable(GL_DEPTH_TEST); | |
218 | + } | |
192 | 219 | |
193 | 220 | glut_render_right_projection(); //set up a projection for the right half of the window |
194 | 221 | glut_render_modelview(); //set up the modelview matrix using camera details |
195 | - //_T.glRandColorCenterlineT(dlist2, _t_gt, colormap); | |
222 | + | |
196 | 223 | _T.glRandColorCylinder2(dlist2, _t_gt, colormap, sigma, radius); |
197 | 224 | sigma = radius; //set sigma equal to radius |
198 | 225 | } |
... | ... | @@ -362,6 +389,14 @@ void glut_keyboard(unsigned char key, int x, int y){ |
362 | 389 | if (radius < 0.001f) |
363 | 390 | radius = 0.2; |
364 | 391 | break; |
392 | + | |
393 | + // render a transparant T very close to GT | |
394 | + case 32: // if keyboard 'SPACE' is pressed, then change the transparancy_fac | |
395 | + if (compareMode && !mappingMode && !transparancy_fac) | |
396 | + transparancy_fac = 1; | |
397 | + else | |
398 | + transparancy_fac = 0; | |
399 | + break; | |
365 | 400 | |
366 | 401 | // close window and exit application |
367 | 402 | case 27: // if keyboard 'ESC' is pressed, then exit | ... | ... |