indexed colors (jogl)

Hi,
I would like to view raster maps/charts in a JOGL application. The raster maps has different color tables for different modes (day, night, dusk, dawn etc).
It will be the same for vector maps/charts but then I can at least get the wanted RGB value from an array, which would not be very effective for raster charts.

I can not see how to load a color indexed raster and the change the color table according to the surrounding environment. Does anyone have an solution for
this or do I have to create 6 versions of the raster map/chart and reload them each time the operator changes the night-, day-…mode? The last doesn´t seem
very attractive.

Kind regards,
Paul

I have a few thoughts:

  1. You could use a custom glsl shader that draws the raster map, looks up the color value in the active table and uses that as the final color drawn to the screen. This requires knowing glsl. Also, int based textures are only newly supported, so a float hack might get ugly.

  2. You don’t need to “reload” each raster map every time you want to change. Textures in opengl have an id that refers to them. The process is: get an id, bind the texture id, send the pixel data, unbind the texture. Then every time you need it later, just bind the id and you’re good to go. So, you could just load the 5 phases on startup and just switch which texture id you use.

  3. Encode the index as an alpha value from 0 to 1. Then, for each index in the color map, setup an alpha test so that only pixels with an alpha matching the normalized index are drawn. Then draw a rectangle where the image would be with a solid color for the current index. Just make sure you don’t have blending enabled so that the drawn colors still appear opaque.

I like 2 the best since its simplest. If you don’t like loading 5 entire textures (which isn’t a big of a deal if you do it once), I would choose option 3 since it should work anywhere.