
Coloring Problem GL.Color3
Posted Friday, 20 August, 2010 - 02:40 by adityatan inHi there:
I have a problem in coloring my mesh. Here's a piece of my code. The OpenTK setup has been done successfully.
List<double> red1 = new List<double>(); List<double> green1 = new List<double>(); for (int i = 0; i < a.Mesh.ElementConnectivityList.Count(); i++) { GL.Color3(red1.ElementAt(i), green1.ElementAt(i), 0.0f); GL.Begin(BeginMode.TriangleFan); GL.Vertex3(elementConnectivity0.ElementAt(i)); GL.Vertex3(tempSideTriangleA.ElementAt(i)); GL.Vertex3(tempMidTriangleP.ElementAt(i)); GL.Vertex3(tempSideTriangleB.ElementAt(i)); GL.Vertex3(tempMidTriangleR.ElementAt(i)); GL.Vertex3(tempSideTriangleD.ElementAt(i)); GL.Vertex3(tempMidTriangleQ.ElementAt(i)); GL.Vertex3(tempSideTriangleA.ElementAt(i)); GL.End(); }
Here's the first three values of red1: [0] = 103.41385656142761, [1] = 110.80128724674469, [2] = 29.120187397654238
Here's the first three values of green1: [0] = 151.58614343857238, [1] = 144.19871275325531, [2] = 225.87981260234577
It's weird how my triangle strips are all yellow. It's not supposed to be yellow--those R-G-B values does not indicate 255, 255, 0 !
Please help. Thank you.
Regards,
Aditya Tan


Comments
Re: Coloring Problem GL.Color3
The OpenGL specs are quite explicit about the floating point ranges for glColor,
see http://www.opengl.org/sdk/docs/man/xhtml/glColor.xml
Re: Coloring Problem GL.Color3
Colors defined as floats (or doubles in your case) should be in the range of [0, 1]. Unless you would be using HDR, all of your colors should be within that range.