tags:

views:

70

answers:

2

Ok so here's link to code in c++ http://pastebin.com/nfPmd0um (with polish comments ;) I would like to make a sphere divided by four planes. Each part of sphere should have a different color. At the moment it displays only 2 colored parts. I know that something's wrong with that part of code in Display() function:

glEnable (GL_CLIP_PLANE0 +i);
glDisable (GL_CLIP_PLANE1 -i);

glEnable (GL_CLIP_PLANE2 +i);
glDisable (GL_CLIP_PLANE3 -i); 

Anyone know what should i change? Thanks in advance :)

+1  A: 

Why are you using + i in your glEnable/Disable call. Which implies that after i increments to 1 you are modifying planes above index (GL_CLIP_PLANE3) and you don't have any planes defined there.

So, remove "i" from your glEnable/Disable code and use something like (mod(i,4) == i%4).

Ketan

Ketan
A: 

I agree with Ketan. You may be looking for this:

glEnable (GL_CLIP_PLANE0 +i );
glDisable (GL_CLIP_PLANE0 + (1+4-i)%4);

glEnable (GL_CLIP_PLANE0 +(2+i)%4);
glDisable (GL_CLIP_PLANE0 +(3+4-i)%4); 

For example, the (1+4-i)%4 part gives you the sequence 1 0 3 2 as i goes from 0 1 2 3. Similarly the last clip plane iterates 3 2 1 0.

Rich