I am writing a visualization program that shows scalar data. Since simple coloring methods were not good for me, with a little googling, I found this article. Article it self suggests these steps:
Imagine a set of 50 data values to map colors onto:
- Create a 1D 64 entry texture map (you're limited to creating textures whose dimensions are powers-of-2)
- Load the first 50 entries of the texture with the color values corresponding to the first 50 data values.
- Choose a texture transformation matrix that maps the data values to the S values that index the corresponding texels. This will work if the data values can be mapped with a linear or perspective transformation to the appropriate texture coordinates. If your implementation supports a lookup table associated with texture filtering, such as GL_TEXTURE_COLOR_TABLE_SGI, you can use the glColorTableSGI() command to create an arbitrary non-linear mapping between data value and texture coordinate. If you don't have this support, you can create a lookup table in the application.
- If you don't want to interpolate between data values, use GL_NEAREST for GL_TEXTURE_MIN_FILTER, and GL_TEXTURE_MAG_FILTER, and use the same texture coordinates over all the vertices of the primitive you want to color. Remember that OpenGL indexs a texel by truncating the texture coordinate scaled by the texture size. This is written into the specification, so you can always look up the exact texel you want.
- If you do want to interpolate colors between data values, use GL_LINEAR for GL_TEXTURE_MIN_FILTER and GL_TEXTURE_MAG_FILTER, and choose the correct data values at the sample points, letting texture filtering do the color interpolation for you. Since OpenGL texture mapping is perspective correct, you don't have to worry about perspective projection coloring artifacts.
While I am not so expert in openGL/TK, can any one give me some clues which functions should I use to implement these steps?
Thank you in advance.