开发者

Colored sphere in OpenGL

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 sph开发者_运维问答ere 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 :)


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜