3535#include "ws.h"
3636#include "private/wsglP.h"
3737
38- extern GLint clipping_ind , num_clip_planes , plane0 , point0 ;
38+ extern GLint clipping_ind , num_clip_planes ;
39+ extern GLint plane0 , point0 ;
40+ extern GLint plane1 , point1 ;
3941extern GLint shading_mode ;
4042extern GLint ModelViewMatrix , ProjectionMatrix ;
4143extern GLint alpha_channel ;
@@ -242,8 +244,13 @@ void wsgl_set_clip_ind(
242244 glUniform1i (clipping_ind , ind );
243245 if (ind == 1 ) {
244246 glEnable (GL_CLIP_PLANE0 );
247+ glDisable (GL_CLIP_PLANE1 );
248+ } else if (ind == 2 ) {
249+ glEnable (GL_CLIP_PLANE0 );
250+ glEnable (GL_CLIP_PLANE1 );
245251 } else {
246252 glDisable (GL_CLIP_PLANE0 );
253+ glDisable (GL_CLIP_PLANE1 );
247254 }
248255 }
249256}
@@ -283,8 +290,10 @@ void wsgl_set_clip_vol3(
283290 int op , num ;
284291 int * int_data = (int * ) el_data ;
285292 Phalf_space3 * list ;
286- Phalf_space3 volume0 ;
287- Ppoint3 tmp1 , tmp2 , vol3 , point3 , pwc ;
293+ Phalf_space3 volume0 , volume1 ;
294+ Ppoint3 nn0 , pt0 ; /* first plane */
295+ Ppoint3 nn1 , pt1 ; /* second plane if any */
296+ Ppoint3 vol3 , point3 , pwc ;
288297 Pmatrix3 vrc2wc , unity ;
289298
290299#ifdef GLEW
@@ -297,21 +306,43 @@ void wsgl_set_clip_vol3(
297306 op = int_data [0 ];
298307 num = int_data [1 ];
299308 list = (Phalf_space3 * )(& int_data [2 ]);
300- volume0 = list [0 ];
301- /* take a local copy of the data */
302- tmp1 .x = volume0 .norm .delta_x ;
303- tmp1 .y = volume0 .norm .delta_y ;
304- tmp1 .z = volume0 .norm .delta_z ;
305-
306- tmp2 .x = volume0 .point .x ;
307- tmp2 .y = volume0 .point .y ;
308- tmp2 .z = volume0 .point .z ;
309-
310- glUniform1i (num_clip_planes , num );
311- glUniform4f (plane0 , tmp1 .x , tmp1 .y , tmp1 .z , 0. );
312- GLdouble eqn0 [4 ] = {tmp1 .x , tmp1 .y , tmp1 .z , 0. };
313- glClipPlane (GL_CLIP_PLANE0 , eqn0 );
314- glUniform4f (point0 , tmp2 .x , tmp2 .y , tmp2 .z , 0. );
309+ if (1 == num || 2 == num ){
310+ glUniform1i (num_clip_planes , num );
311+ /* first plane */
312+ volume0 = list [0 ];
313+ /* take a local copy of the data */
314+ nn0 .x = volume0 .norm .delta_x ;
315+ nn0 .y = volume0 .norm .delta_y ;
316+ nn0 .z = volume0 .norm .delta_z ;
317+
318+ pt0 .x = volume0 .point .x ;
319+ pt0 .y = volume0 .point .y ;
320+ pt0 .z = volume0 .point .z ;
321+
322+ glUniform4f (plane0 , nn0 .x , nn0 .y , nn0 .z , 0. );
323+ GLdouble eqn0 [4 ] = {nn0 .x , nn0 .y , nn0 .z , 0. };
324+ glClipPlane (GL_CLIP_PLANE0 , eqn0 );
325+ glUniform4f (point0 , pt0 .x , pt0 .y , pt0 .z , 0. );
326+ if (2 == num ){
327+ /* first plane */
328+ volume1 = list [1 ];
329+ /* take a local copy of the data */
330+ nn1 .x = volume1 .norm .delta_x ;
331+ nn1 .y = volume1 .norm .delta_y ;
332+ nn1 .z = volume1 .norm .delta_z ;
333+
334+ pt1 .x = volume1 .point .x ;
335+ pt1 .y = volume1 .point .y ;
336+ pt1 .z = volume1 .point .z ;
337+
338+ glUniform4f (plane1 , nn1 .x , nn1 .y , nn1 .z , 0. );
339+ GLdouble eqn1 [4 ] = {nn1 .x , nn1 .y , nn1 .z , 0. };
340+ glClipPlane (GL_CLIP_PLANE1 , eqn1 );
341+ glUniform4f (point1 , pt1 .x , pt1 .y , pt1 .z , 0. );
342+ }
343+ } else {
344+ glUniform1i (num_clip_planes , 0 ); /* ignore the call */
345+ }
315346 }
316347}
317348
0 commit comments