I'm not sure what your problem exactly is,

a.) OpenGL?

b.) Calculations?

From your question I see you recognized how to come from 3D- XYZ Space to xy(Y) space.

Anyway:

Here you will find a set of formulas from convert from Spectrum to XYZ on from there to xyY, sRGB, etc. and vice versa (of course excl. 3D back to spectrum):

www.brucelindbloom.com[^]

Here a good article on CP with also a lot of background info:

Color Topics for Programmers[^]

I hope it helps.

[Edit]

Explaining how to calculate(show) the "horse Shoe" in the xy- plane is too much to explain it here ;)

15,749,352 members

Btw: This for the math, but I assume you know this allready:www.brucelindbloom[^]