Color Sphere in OpenGL

So, here is the link to the code in C ++ http://pastebin.com/nfPmd0um (with Polish comments;) I would like to make a sphere divided into four planes. Each part of the sphere must have a different color. At the moment, it displays only 2 colored parts. I know that something is wrong with this part of the code in the Display () function:

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

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

Does anyone know what I have to change? Thanks in advance:)

+3
source share
2 answers

Why are you using + i in your glEnable / Disable call. This means that after I increase to 1, you modify the planes above the index (GL_CLIP_PLANE3), and you do not have the planes defined there.

, "i" glEnable/Disable - (mod (i, 4) == i% 4).

+1

. , :

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); 

, (1 + 4-i)% 4 1 0 3 2, 0 1 2 3. 3 2 1 0.

0

Source: https://habr.com/ru/post/1747274/


All Articles