intersection

hello
I have designed one sphere and a cube with the functions GlutwriteCube and to glutWriteShpere or to glutSolidSphere and glutSolidCube. Now I would have to calculate and to visualize the result of their intersection. who can help to make this me?
thanks and sorry for my English

Are you looking for an image based intersection? OpenCSG might be just the ticket for that.

Or, for hand-rolled boolean operations on simple geometric primitives, especially convex polytopes like cubes and spheres, you may want to try some simple operations with b-reps. If you represent your cube and sphere as a collection of planes defining the boundary, the intersection, for example, can be found by clipping one of the primitives to the “inside” of the other. For instance, split all the polygons of the sphere on each of the 6 planes of the cube, keeping the fragments of the sphere that are on the “back” side of each plane (assuming the normals of the cube’s planes point outside the cube).